From 63ab637419baea1a3e6f59125676e1d9e3967c06 Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Fri, 25 May 2018 10:16:52 -0700 Subject: [PATCH] potential fix for #3727 --- app/models/artist_url.rb | 2 +- test/functional/artists_controller_test.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/models/artist_url.rb b/app/models/artist_url.rb index 8c0cac456..f6755f7b1 100644 --- a/app/models/artist_url.rb +++ b/app/models/artist_url.rb @@ -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 diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index 7a9bf1aea..f1203b8ac 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -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