diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 39003b0ab..a23af3610 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -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 diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 9a7f85aae..1e68047e3 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -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 diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 9b23b82de..cc67471f7 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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