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
|
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
|
protect_from_forgery :except => :receive
|
||||||
layout 'application'
|
layout 'application'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class BlogsController < ApplicationController
|
class BlogsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class BookmarksController < ApplicationController
|
class BookmarksController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bookmarks = Bookmark.criteria.all.order_by( [:created_at, :desc] )
|
@bookmarks = Bookmark.criteria.all.order_by( [:created_at, :desc] )
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class FriendsController < ApplicationController
|
class FriendsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@friends = Friend.criteria.all.order_by( [:created_at, :desc] )
|
@friends = Friend.criteria.all.order_by( [:created_at, :desc] )
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
class StatusMessagesController < ApplicationController
|
class StatusMessagesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@status_message = StatusMessage.new
|
@status_message = StatusMessage.new
|
||||||
|
|
@ -15,11 +14,11 @@ class StatusMessagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@status_message = StatusMessage.new(params[:status_message])
|
if current_user.post :status_message, params[:status_message]
|
||||||
if @status_message.save
|
|
||||||
flash[:notice] = "Successfully created status message."
|
flash[:notice] = "Successfully created status message."
|
||||||
redirect_to status_messages_url
|
redirect_to status_messages_url
|
||||||
else
|
else
|
||||||
|
flash[:notics] = "You have failed to update your status."
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_user!
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@users = User.criteria.all.order_by( [:created_at, :desc] )
|
@users = User.criteria.all.order_by( [:created_at, :desc] )
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ class Post
|
||||||
belongs_to_related :person
|
belongs_to_related :person
|
||||||
|
|
||||||
|
|
||||||
before_create :set_defaults
|
|
||||||
|
|
||||||
after_save :send_to_view
|
after_save :send_to_view
|
||||||
|
|
||||||
|
|
@ -53,8 +52,5 @@ class Post
|
||||||
WebSocket.update_clients(self)
|
WebSocket.update_clients(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_defaults
|
|
||||||
self.person ||= User.first
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,12 @@ class User < Person
|
||||||
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
# :token_authenticatable, :confirmable, :lockable and :timeoutable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
: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
|
end
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ describe StatusMessage do
|
||||||
it "should have a message" do
|
it "should have a message" do
|
||||||
n = Factory.build(:status_message, :message => nil)
|
n = Factory.build(:status_message, :message => nil)
|
||||||
n.valid?.should be false
|
n.valid?.should be false
|
||||||
|
n.message = ""
|
||||||
|
n.valid?.should be false
|
||||||
n.message = "wales"
|
n.message = "wales"
|
||||||
n.valid?.should be true
|
n.valid?.should be true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
require 'spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe User do
|
describe User do
|
||||||
it "should require a real name" do
|
it "should require a real name" do
|
||||||
|
|
@ -16,5 +16,16 @@ describe User do
|
||||||
Factory.create(:user)
|
Factory.create(:user)
|
||||||
Person.count.should == n+1
|
Person.count.should == n+1
|
||||||
end
|
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
|
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
|
# 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
|
# examples within a transaction, comment the following line or assign false
|
||||||
# instead of true.
|
# instead of true.
|
||||||
# config.use_transactional_fixtures = true
|
config.use_transactional_fixtures = true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue