potential fix for #3727

This commit is contained in:
Albert Yi
2018-05-25 10:16:52 -07:00
parent c97b0245d6
commit 63ab637419
2 changed files with 3 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ class ArtistUrl < ApplicationRecord
before_validation :parse_prefix
before_save :initialize_normalized_url, on: [ :create ]
before_save :normalize
validates :url, presence: true, uniqueness: true
validates :url, presence: true, uniqueness: { scope: :artist_id }
validate :validate_url_format
belongs_to :artist, :touch => true

View File

@@ -4,7 +4,6 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
def assert_artist_found(expected_artist, source_url = nil)
if source_url
get_auth finder_artists_path(format: "json", url: source_url), @user
puts response.body
if response.body =~ /Net::OpenTimeout/
skip "Remote connection to #{source_url} failed"
return
@@ -134,7 +133,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
context "with an artist that has notes" do
setup do
as(@admin) do
@artist = create(:artist, name: "aaa", notes: "testing")
@artist = create(:artist, name: "aaa", notes: "testing", url_string: "htttp://example.com")
end
@wiki_page = @artist.wiki_page
@another_user = create(:user)
@@ -143,7 +142,7 @@ class ArtistsControllerTest < ActionDispatch::IntegrationTest
should "update an artist" do
old_timestamp = @wiki_page.updated_at
travel_to(1.minute.from_now) do
put_auth artist_path(@artist.id), @user, params: {artist: {notes: "rex"}}
put_auth artist_path(@artist.id), @user, params: {artist: {notes: "rex", url_string: "http://example.com\nhttp://monet.com"}}
end
@artist.reload
@wiki_page = @artist.wiki_page