Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
3a26738446
11 changed files with 33 additions and 15 deletions
|
|
@ -1,4 +1,11 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
before_filter :authenticate_user!
|
||||
before_filter :set_user
|
||||
def set_user
|
||||
@user = current_user
|
||||
true
|
||||
end
|
||||
|
||||
protect_from_forgery :except => :receive
|
||||
layout 'application'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class BlogsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
|
||||
def index
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class BookmarksController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@bookmarks = Bookmark.criteria.all.order_by( [:created_at, :desc] )
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class FriendsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@friends = Friend.criteria.all.order_by( [:created_at, :desc] )
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
class StatusMessagesController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@status_message = StatusMessage.new
|
||||
|
|
@ -15,11 +14,11 @@ class StatusMessagesController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@status_message = StatusMessage.new(params[:status_message])
|
||||
if @status_message.save
|
||||
if current_user.post :status_message, params[:status_message]
|
||||
flash[:notice] = "Successfully created status message."
|
||||
redirect_to status_messages_url
|
||||
else
|
||||
flash[:notics] = "You have failed to update your status."
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
class UsersController < ApplicationController
|
||||
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@users = User.criteria.all.order_by( [:created_at, :desc] )
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ class Post
|
|||
belongs_to_related :person
|
||||
|
||||
|
||||
before_create :set_defaults
|
||||
|
||||
after_save :send_to_view
|
||||
|
||||
|
|
@ -53,8 +52,5 @@ class Post
|
|||
WebSocket.update_clients(self)
|
||||
end
|
||||
|
||||
def set_defaults
|
||||
self.person ||= User.first
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,12 @@ class User < Person
|
|||
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
def post(post_type, options)
|
||||
case post_type
|
||||
when :status_message
|
||||
StatusMessage.new(:person => self, :message => options[:message]).save
|
||||
else
|
||||
raise "Not a type I can post yet"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ describe StatusMessage do
|
|||
it "should have a message" do
|
||||
n = Factory.build(:status_message, :message => nil)
|
||||
n.valid?.should be false
|
||||
n.message = ""
|
||||
n.valid?.should be false
|
||||
n.message = "wales"
|
||||
n.valid?.should be true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
require 'spec_helper'
|
||||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe User do
|
||||
it "should require a real name" do
|
||||
|
|
@ -16,5 +16,16 @@ describe User do
|
|||
Factory.create(:user)
|
||||
Person.count.should == n+1
|
||||
end
|
||||
|
||||
describe 'when posting' do
|
||||
before do
|
||||
@user = Factory.create :user
|
||||
end
|
||||
it "should be able to set a status message" do
|
||||
@user.post :status_message, :text => "I feel good"
|
||||
StatusMessage.where(:person_id => @user.id).last.message.should == "I feel good"
|
||||
end
|
||||
it "should return nil from an invalid post" do
|
||||
@user.post(:status_message, :text => "").should be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -39,5 +39,5 @@ Rspec.configure do |config|
|
|||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, comment the following line or assign false
|
||||
# instead of true.
|
||||
# config.use_transactional_fixtures = true
|
||||
config.use_transactional_fixtures = true
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue