Permalink
Browse files

artists: add more invalid name tests (#3901).

  • Loading branch information...
evazion committed Sep 14, 2018
1 parent bbb233b commit 761f2649afa2922e433f8de12bd06d7e37617eab
Showing with 7 additions and 6 deletions.
  1. +1 −2 app/models/artist.rb
  2. +6 −4 test/unit/artist_test.rb
View
@@ -8,9 +8,8 @@ class RevertError < Exception ; end
after_save :categorize_tag
after_save :update_wiki
after_save :save_urls
validates_uniqueness_of :name
validates_associated :urls
validates :name, tag_name: true
validates :name, tag_name: true, uniqueness: true
validate :validate_wiki, :on => :create
after_validation :merge_validation_errors
belongs_to_creator
View
@@ -56,10 +56,12 @@ def assert_artist_not_found(source_url)
assert(@artist.urls[0].is_active?)
end
should "should have a valid name" do
@artist = Artist.new(:name => "-blah")
@artist.save
assert_equal(["Name '-blah' cannot begin with a dash ('-')"], @artist.errors.full_messages)
context "with an invalid name" do
subject { FactoryBot.build(:artist) }
should_not allow_value("-blah").for(:name)
should_not allow_value("_").for(:name)
should_not allow_value("").for(:name)
end
context "with a matching tag alias" do

0 comments on commit 761f264

Please sign in to comment.