Move ApplicationController specs to application_controllers_spec
This commit is contained in:
parent
92e4cd34ae
commit
78953fe2bf
3 changed files with 34 additions and 45 deletions
|
|
@ -6,19 +6,15 @@ require 'spec_helper'
|
|||
|
||||
describe ApplicationController do
|
||||
controller do
|
||||
def user_signed_in?
|
||||
nil
|
||||
end
|
||||
|
||||
def current_user
|
||||
nil
|
||||
end
|
||||
|
||||
def index
|
||||
render :nothing => true
|
||||
head :ok
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
sign_in alice
|
||||
end
|
||||
|
||||
describe '#set_diaspora_headers' do
|
||||
it 'sets the version header' do
|
||||
get :index
|
||||
|
|
@ -66,4 +62,33 @@ describe ApplicationController do
|
|||
request.format.xml?.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe '#tags' do
|
||||
before do
|
||||
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
|
||||
TagFollowing.create!(:tag => @tag, :user => alice)
|
||||
end
|
||||
|
||||
it 'queries current_users tag if there are tag_followings' do
|
||||
@controller.send(:tags).should == [@tag]
|
||||
end
|
||||
|
||||
it 'does not query twice' do
|
||||
User.any_instance.should_receive(:followed_tags).once.and_return([@tag])
|
||||
@controller.send(:tags)
|
||||
@controller.send(:tags)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#after_sign_in_path_for" do
|
||||
context 'getting started true on user' do
|
||||
before do
|
||||
alice.update_attribute(:getting_started, true)
|
||||
end
|
||||
|
||||
it "redirects to getting started if the user has getting started set to true" do
|
||||
@controller.send(:after_sign_in_path_for, alice).should == getting_started_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -174,23 +174,4 @@ describe AspectsController do
|
|||
@alices_aspect_1.reload.contacts_visible.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
context 'helper methods' do
|
||||
before do
|
||||
@tag = ActsAsTaggableOn::Tag.create!(:name => "partytimeexcellent")
|
||||
TagFollowing.create!(:tag => @tag, :user => alice)
|
||||
alice.should_receive(:followed_tags).once.and_return([42])
|
||||
end
|
||||
|
||||
describe 'tags' do
|
||||
it 'queries current_users tag if there are tag_followings' do
|
||||
@controller.tags.should == [42]
|
||||
end
|
||||
|
||||
it 'does not query twice' do
|
||||
@controller.tags.should == [42]
|
||||
@controller.tags.should == [42]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -251,22 +251,5 @@ describe UsersController do
|
|||
response.should be_success
|
||||
end
|
||||
end
|
||||
|
||||
# This logic lives in application controller
|
||||
describe "#after_sign_in_path_for" do
|
||||
before do
|
||||
@controller.stub(:current_user).and_return(eve)
|
||||
end
|
||||
|
||||
context 'getting started true on user' do
|
||||
before do
|
||||
eve.update_attribute(:getting_started, true)
|
||||
end
|
||||
|
||||
it "redirects to getting started if the user has getting started set to true" do
|
||||
@controller.after_sign_in_path_for(eve).should == getting_started_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue