artists: add more invalid name tests (#3901).
This commit is contained in:
@@ -8,9 +8,8 @@ class Artist < ApplicationRecord
|
|||||||
after_save :categorize_tag
|
after_save :categorize_tag
|
||||||
after_save :update_wiki
|
after_save :update_wiki
|
||||||
after_save :save_urls
|
after_save :save_urls
|
||||||
validates_uniqueness_of :name
|
|
||||||
validates_associated :urls
|
validates_associated :urls
|
||||||
validates :name, tag_name: true
|
validates :name, tag_name: true, uniqueness: true
|
||||||
validate :validate_wiki, :on => :create
|
validate :validate_wiki, :on => :create
|
||||||
after_validation :merge_validation_errors
|
after_validation :merge_validation_errors
|
||||||
belongs_to_creator
|
belongs_to_creator
|
||||||
|
|||||||
@@ -56,10 +56,12 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
assert(@artist.urls[0].is_active?)
|
assert(@artist.urls[0].is_active?)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "should have a valid name" do
|
context "with an invalid name" do
|
||||||
@artist = Artist.new(:name => "-blah")
|
subject { FactoryBot.build(:artist) }
|
||||||
@artist.save
|
|
||||||
assert_equal(["Name '-blah' cannot begin with a dash ('-')"], @artist.errors.full_messages)
|
should_not allow_value("-blah").for(:name)
|
||||||
|
should_not allow_value("_").for(:name)
|
||||||
|
should_not allow_value("").for(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with a matching tag alias" do
|
context "with a matching tag alias" do
|
||||||
|
|||||||
Reference in New Issue
Block a user