improved artist test
This commit is contained in:
@@ -6,6 +6,10 @@ class ArtistVersion < ActiveRecord::Base
|
||||
q = scoped
|
||||
return q if params.blank?
|
||||
|
||||
if params[:name]
|
||||
q = q.where("name like ? escape E'\\\\'", params[:name].to_escaped_for_sql_like)
|
||||
end
|
||||
|
||||
if params[:artist_id]
|
||||
q = q.where("artist_id = ?", params[:artist_id].to_i)
|
||||
end
|
||||
|
||||
@@ -19,10 +19,18 @@ class Ban < ActiveRecord::Base
|
||||
q = q.where("banner_id = (select _.id from users _ where lower(_.name) = ?)", params[:banner_name].downcase)
|
||||
end
|
||||
|
||||
if params[:banner_id]
|
||||
q = q.where("banner_id = ?", params[:banner_id].to_i)
|
||||
end
|
||||
|
||||
if params[:user_name]
|
||||
q = q.where("user_id = (select _.id from users _ where lower(_.name) = ?)", params[:user_name].downcase)
|
||||
end
|
||||
|
||||
if params[:user_id]
|
||||
q = q.where("user_id = ?", params[:user_id].to_i)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class CommentVote < ActiveRecord::Base
|
||||
validates_inclusion_of :score, :in => [-1, 1], :message => "must be 1 or -1"
|
||||
|
||||
def self.prune!
|
||||
destroy_all(["created_at < ?", 14.days.ago])
|
||||
destroy_all("created_at < ?", 14.days.ago)
|
||||
end
|
||||
|
||||
def validate_user_can_vote
|
||||
|
||||
@@ -115,11 +115,18 @@ class ArtistTest < ActiveSupport::TestCase
|
||||
assert_equal("aaa bbb ccc_ddd", artist.other_names)
|
||||
end
|
||||
|
||||
should "search on its name should return results" do
|
||||
artist = FactoryGirl.create(:artist, :name => "artist")
|
||||
assert_not_nil(Artist.search(:name => "artist").first)
|
||||
end
|
||||
|
||||
should "search on other names should return matches" do
|
||||
artist = FactoryGirl.create(:artist, :name => "artist", :other_names => "aaa, ccc ddd")
|
||||
assert_nil(Artist.other_names_match("artist").first)
|
||||
assert_not_nil(Artist.other_names_match("aaa").first)
|
||||
assert_not_nil(Artist.other_names_match("ccc_ddd").first)
|
||||
assert_not_nil(Artist.search(:name => "other:aaa").first)
|
||||
assert_not_nil(Artist.search(:name => "aaa").first)
|
||||
end
|
||||
|
||||
should "search on group name and return matches" do
|
||||
|
||||
Reference in New Issue
Block a user