Fixed issue #2380 : No more 500 error when following an unnormalized version of an existing tag.
e.g. if "test" exists and you try to follow "Test".
This commit is contained in:
parent
6526e2f305
commit
05b1e2fc19
2 changed files with 22 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ class ActsAsTaggableOn::Tag
|
|||
# Special case for love, because the world needs more love.
|
||||
'<3'
|
||||
elsif name
|
||||
name.gsub(/[^#{self.tag_text_regexp}]/, '')
|
||||
name.gsub(/[^#{self.tag_text_regexp}]/, '').downcase
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,17 +33,20 @@ describe TagFollowingsController do
|
|||
it "creates a new TagFollowing" do
|
||||
expect {
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
}.to change(TagFollowing, :count).by(1)
|
||||
end
|
||||
|
||||
it "associates the tag following with the currently-signed-in user" do
|
||||
expect {
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
}.to change(bob.tag_followings, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created tag_following as @tag_following" do
|
||||
post :create, valid_attributes
|
||||
response.should be_redirect
|
||||
assigns(:tag_following).should be_a(TagFollowing)
|
||||
assigns(:tag_following).should be_persisted
|
||||
end
|
||||
|
|
@ -67,32 +70,48 @@ describe TagFollowingsController do
|
|||
end
|
||||
|
||||
it 'squashes the tag' do
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should be_nil
|
||||
post :create, :name => "some stuff"
|
||||
assigns[:tag].name.should == "somestuff"
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should_not be_nil
|
||||
end
|
||||
|
||||
it 'downcases the tag name' do
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should be_nil
|
||||
post :create, :name => "SOMESTUFF"
|
||||
response.should be_redirect
|
||||
assigns[:tag].name.should == "somestuff"
|
||||
ActsAsTaggableOn::Tag.find_by_name('somestuff').should_not be_nil
|
||||
end
|
||||
|
||||
it "normalizes the tag name" do
|
||||
ActsAsTaggableOn::Tag.find_by_name('foobar').should be_nil
|
||||
post :create, :name => "foo:bar"
|
||||
assigns[:tag].name.should == "foobar"
|
||||
ActsAsTaggableOn::Tag.find_by_name('foobar').should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fails to' do
|
||||
it "create the tag IFF already exists" do
|
||||
it "create the tag if it already exists" do
|
||||
ActsAsTaggableOn::Tag.find_by_name('tomcruisecontrol').should be_nil
|
||||
expect {
|
||||
post :create, :name => "tomcruisecontrol"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(1)
|
||||
|
||||
ActsAsTaggableOn::Tag.find_by_name('tomcruisecontrol').should_not be_nil
|
||||
|
||||
expect {
|
||||
post :create, :name => "tomcruisecontrol"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "tom cruise control"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "TomCruiseControl"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
expect {
|
||||
post :create, :name => "tom:cruise:control"
|
||||
}.to change(ActsAsTaggableOn::Tag, :count).by(0)
|
||||
end
|
||||
|
||||
it "create a tag following for a user other than the currently signed in user" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue