fixes #3724
This commit is contained in:
@@ -2,7 +2,7 @@ class ArtistUrl < ApplicationRecord
|
|||||||
before_validation :parse_prefix
|
before_validation :parse_prefix
|
||||||
before_save :initialize_normalized_url, on: [ :create ]
|
before_save :initialize_normalized_url, on: [ :create ]
|
||||||
before_save :normalize
|
before_save :normalize
|
||||||
validates_presence_of :url
|
validates :url, presence: true, uniqueness: true
|
||||||
validate :validate_url_format
|
validate :validate_url_format
|
||||||
belongs_to :artist, :touch => true
|
belongs_to :artist, :touch => true
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
refute(@artist.urls[0].is_active?)
|
refute(@artist.urls[0].is_active?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "not allow duplicate active+inactive urls" do
|
||||||
|
@artist = Artist.create(name: "blah", url_string: "-http://monet.com\nhttp://monet.com")
|
||||||
|
assert_equal(1, @artist.urls.count)
|
||||||
|
assert_equal(["-http://monet.com"], @artist.urls.map(&:to_s))
|
||||||
|
refute(@artist.urls[0].is_active?)
|
||||||
|
end
|
||||||
|
|
||||||
should "should have a valid name" do
|
should "should have a valid name" do
|
||||||
@artist = Artist.new(:name => "-blah")
|
@artist = Artist.new(:name => "-blah")
|
||||||
@artist.save
|
@artist.save
|
||||||
|
|||||||
Reference in New Issue
Block a user