Refactor tag followings spec
This commit is contained in:
parent
8f0aa72e75
commit
0c818cf359
1 changed files with 19 additions and 12 deletions
|
|
@ -16,14 +16,14 @@ describe TagFollowingsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'index' do
|
describe 'index' do
|
||||||
it 'assings new TagStream' do
|
it 'succeeds' do
|
||||||
get :index
|
get :index
|
||||||
assigns[:stream].should be_a Stream::FollowedTag
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'renders a view' do
|
it 'assigns a stream' do
|
||||||
get :index
|
get :index
|
||||||
response.body.should_not be_blank
|
assigns[:stream].should be_a Stream::FollowedTag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -35,19 +35,29 @@ describe TagFollowingsController do
|
||||||
}.to change(TagFollowing, :count).by(1)
|
}.to change(TagFollowing, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "associates the tag following with the currently-signed-in user" do
|
||||||
|
expect {
|
||||||
|
post :create, valid_attributes
|
||||||
|
}.to change(bob.tag_followings, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
it "assigns a newly created tag_following as @tag_following" do
|
it "assigns a newly created tag_following as @tag_following" do
|
||||||
post :create, valid_attributes
|
post :create, valid_attributes
|
||||||
assigns(:tag_following).should be_a(TagFollowing)
|
assigns(:tag_following).should be_a(TagFollowing)
|
||||||
assigns(:tag_following).should be_persisted
|
assigns(:tag_following).should be_persisted
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates the tag if it does not already exist' do
|
it "creates the tag IFF it doesn't already exist" do
|
||||||
expect {
|
expect {
|
||||||
post :create, :name => "tomcruisecontrol"
|
post :create, :name => "tomcruisecontrol"
|
||||||
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
||||||
|
|
||||||
|
expect {
|
||||||
|
post :create, :name => "tomcruisecontrol"
|
||||||
|
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create the tag following for non signed in user' do
|
it "will only create a tag following for the currently-signed-in user" do
|
||||||
expect {
|
expect {
|
||||||
post :create, valid_attributes.merge(:user_id => alice.id)
|
post :create, valid_attributes.merge(:user_id => alice.id)
|
||||||
}.to_not change(alice.tag_followings, :count).by(1)
|
}.to_not change(alice.tag_followings, :count).by(1)
|
||||||
|
|
@ -55,14 +65,12 @@ describe TagFollowingsController do
|
||||||
|
|
||||||
it "flashes success to the tag page" do
|
it "flashes success to the tag page" do
|
||||||
post :create, valid_attributes
|
post :create, valid_attributes
|
||||||
|
|
||||||
flash[:notice].should include(valid_attributes[:name])
|
flash[:notice].should include(valid_attributes[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
it "flashes error if you already have a tag" do
|
it "flashes error if you already have a tag" do
|
||||||
TagFollowing.any_instance.stub(:save).and_return(false)
|
TagFollowing.any_instance.stub(:save).and_return(false)
|
||||||
post :create, valid_attributes
|
post :create, valid_attributes
|
||||||
|
|
||||||
flash[:error].should include(valid_attributes[:name])
|
flash[:error].should include(valid_attributes[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -72,9 +80,8 @@ describe TagFollowingsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'downcases the tag name' do
|
it 'downcases the tag name' do
|
||||||
pending "THIS CAUSES A 500 WE NEED TO FIX IT"
|
post :create, :name => "SOMESTUFF"
|
||||||
post "tags/#{valid_attributes[:name].upcase}/tag_followings"
|
assigns[:tag].name.should == "somestuff"
|
||||||
assigns[:tag].should == @tag
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue