added additional artist test
This commit is contained in:
@@ -20,6 +20,8 @@ class Artist < ActiveRecord::Base
|
||||
search_methods :url_match, :other_names_match
|
||||
|
||||
module UrlMethods
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def find_all_by_url(url)
|
||||
url = ArtistUrl.normalize(url)
|
||||
@@ -35,10 +37,6 @@ class Artist < ActiveRecord::Base
|
||||
artists.uniq_by {|x| x.name}.slice(0, 20)
|
||||
end
|
||||
end
|
||||
|
||||
def self.included(m)
|
||||
m.extend(ClassMethods)
|
||||
end
|
||||
|
||||
def save_url_string
|
||||
if @url_string
|
||||
@@ -60,15 +58,13 @@ class Artist < ActiveRecord::Base
|
||||
end
|
||||
|
||||
module NameMethods
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
def normalize_name(name)
|
||||
name.to_s.downcase.strip.gsub(/ /, '_')
|
||||
end
|
||||
end
|
||||
|
||||
def self.included(m)
|
||||
m.extend(ClassMethods)
|
||||
end
|
||||
|
||||
def normalize_name
|
||||
self.name = Artist.normalize_name(name)
|
||||
|
||||
@@ -14,6 +14,21 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "with a matching tag alias" do
|
||||
setup do
|
||||
@tag_alias = Factory.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||
@artist = Factory.create(:artist, :name => "aaa")
|
||||
end
|
||||
|
||||
should "know it has an alias" do
|
||||
assert_equal(true, @artist.has_tag_alias?)
|
||||
end
|
||||
|
||||
should "know its alias" do
|
||||
assert_equal("bbb", @artist.tag_alias_name)
|
||||
end
|
||||
end
|
||||
|
||||
context "that has been banned" do
|
||||
setup do
|
||||
@post = Factory.create(:post, :tag_string => "aaa")
|
||||
|
||||
Reference in New Issue
Block a user