Merge pull request #3247 from evazion/fix-2346
Fix #2346: Artist URLs: auto add 'http', remove non-links
This commit is contained in:
@@ -134,6 +134,13 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
assert_equal(["http://aaa.com", "http://rembrandt.com/test.jpg"], artist.urls.map(&:to_s).sort)
|
||||
end
|
||||
|
||||
should "not allow invalid urls" do
|
||||
artist = FactoryGirl.build(:artist, :url_string => "blah")
|
||||
|
||||
assert_equal(false, artist.valid?)
|
||||
assert_equal(["'blah' must begin with http:// or https://"], artist.errors[:url])
|
||||
end
|
||||
|
||||
should "make sure old urls are deleted" do
|
||||
artist = FactoryGirl.create(:artist, :name => "rembrandt", :url_string => "http://rembrandt.com/test.jpg")
|
||||
artist.url_string = "http://not.rembrandt.com/test.jpg"
|
||||
@@ -168,11 +175,16 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
assert_equal(["minko"], Artist.find_all_by_url("http://minko.com/x/test.jpg").map(&:name))
|
||||
end
|
||||
|
||||
should "not allow duplicates" do
|
||||
should "not find duplicates" do
|
||||
FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/x/a/image.jpg\nhttp://warhol.com/x/b/image.jpg")
|
||||
assert_equal(["warhol"], Artist.find_all_by_url("http://warhol.com/x/test.jpg").map(&:name))
|
||||
end
|
||||
|
||||
should "not include duplicate urls" do
|
||||
artist = FactoryGirl.create(:artist, :url_string => "http://foo.com http://foo.com")
|
||||
assert_equal(["http://foo.com"], artist.url_array)
|
||||
end
|
||||
|
||||
should "hide deleted artists" do
|
||||
FactoryGirl.create(:artist, :name => "warhol", :url_string => "http://warhol.com/a/image.jpg", :is_active => false)
|
||||
assert_equal([], Artist.find_all_by_url("http://warhol.com/a/image.jpg").map(&:name))
|
||||
@@ -407,5 +419,18 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
tag.reload
|
||||
assert_equal(Tag.categories.artist, tag.category)
|
||||
end
|
||||
|
||||
context "when updated" do
|
||||
setup do
|
||||
@artist = FactoryGirl.create(:artist)
|
||||
@artist.stubs(:merge_version?).returns(false)
|
||||
end
|
||||
|
||||
should "create a new version" do
|
||||
assert_difference("@artist.versions.count") do
|
||||
@artist.update(:url_string => "http://foo.com")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user