Commit 7e15d0cbfaede6b348793e8a7024f8f3bb9ccf38

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 5085f5d6

Fixed crash when searching for unexistent tag

(ActionItem1701)
app/controllers/public/search_controller.rb
@@ -223,10 +223,10 @@ class SearchController < PublicController @@ -223,10 +223,10 @@ class SearchController < PublicController
223 end 223 end
224 224
225 def tag 225 def tag
226 - @tag = environment.tags.find_by_name(params[:tag]) 226 + @tag = params[:tag]
227 @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_env_#{environment.id.to_s}_page_#{params[:npage]}" 227 @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_env_#{environment.id.to_s}_page_#{params[:npage]}"
228 if is_cache_expired?(@tag_cache_key, true) 228 if is_cache_expired?(@tag_cache_key, true)
229 - @tagged = environment.articles.find_tagged_with(@tag.name).paginate(:per_page => 10, :page => params[:npage]) 229 + @tagged = environment.articles.find_tagged_with(@tag).paginate(:per_page => 10, :page => params[:npage])
230 end 230 end
231 end 231 end
232 232
features/tags.feature
@@ -40,3 +40,7 @@ Feature: tags @@ -40,3 +40,7 @@ Feature: tags
40 Scenario: viewing profile's content tagged 40 Scenario: viewing profile's content tagged
41 When I go to /profile/joaoaraujo/tags/amazon 41 When I go to /profile/joaoaraujo/tags/amazon
42 Then I should see "the Amazon is being destroyed" 42 Then I should see "the Amazon is being destroyed"
  43 +
  44 + Scenario: trying to view a tag not used
  45 + When I go to /tag/shark
  46 + Then I should see /Tagged with "shark"/