From dcbe06180948eb1475840165c4a9e354839746e5 Mon Sep 17 00:00:00 2001 From: evazion Date: Sun, 5 Oct 2014 12:08:09 -0500 Subject: [PATCH] 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. --- app/controllers/artists_controller.rb | 4 +--- app/models/artist.rb | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 86ce765db..f72be2ce1 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -118,9 +118,7 @@ class ArtistsController < ApplicationController end def finder - url = Sources::Site.new(params[:url]).normalize_for_artist_finder! - - @artists = Artist.url_matches(url).order("id desc").limit(20) + @artists = Artist.url_matches(params[:url]).order("id desc").limit(20) respond_with(@artists) do |format| format.xml do render :xml => @artists.to_xml(:include => [:urls], :root => "artists") diff --git a/app/models/artist.rb b/app/models/artist.rb index 9df4fc03d..f12dfa551 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -22,6 +22,7 @@ class Artist < ActiveRecord::Base module ClassMethods def find_all_by_url(url) + url = Sources::Site.new(url).normalize_for_artist_finder! url = ArtistUrl.normalize(url) artists = []