Move normalize_for_artist_finder! into model.
Move the call to normalize_for_artist_finder! from the artist controller into Artist#find_all_by_url. This makes testing easier. It also makes it so that URLs are normalized when using the search form on the artist listing page.
This commit is contained in:
@@ -118,9 +118,7 @@ class ArtistsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def finder
|
def finder
|
||||||
url = Sources::Site.new(params[:url]).normalize_for_artist_finder!
|
@artists = Artist.url_matches(params[:url]).order("id desc").limit(20)
|
||||||
|
|
||||||
@artists = Artist.url_matches(url).order("id desc").limit(20)
|
|
||||||
respond_with(@artists) do |format|
|
respond_with(@artists) do |format|
|
||||||
format.xml do
|
format.xml do
|
||||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Artist < ActiveRecord::Base
|
|||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
def find_all_by_url(url)
|
def find_all_by_url(url)
|
||||||
|
url = Sources::Site.new(url).normalize_for_artist_finder!
|
||||||
url = ArtistUrl.normalize(url)
|
url = ArtistUrl.normalize(url)
|
||||||
artists = []
|
artists = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user