Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only use the section parameter if it's non-blank

This fixes a bug with filtering when you haven't selected a section, but
because it tries to preserve a section choice, it sets a blank section.
  • Loading branch information...
commit 320feb4097a98bfe77ee8399a8c5cc37b209e5de 1 parent 34844d2
@jamiecobbett jamiecobbett authored
View
2  app/controllers/artefacts_controller.rb
@@ -10,7 +10,7 @@ class ArtefactsController < ApplicationController
ITEMS_PER_PAGE = 100
def index
- @section = params[:section] || "all"
+ @section = params[:section].present? ? params[:section] : "all"
if @section != "all"
tags = Tag.where(tag_type: "section", parent_id: @section)
tag_ids = tags.collect {|t| t.tag_id}
View
8 test/functional/artefacts_controller_test.rb
@@ -29,6 +29,14 @@ class ArtefactsControllerTest < ActionController::TestCase
assert_select "tbody tr td", artefact1.name
end
+ should "treat a blank section parameter as 'All'" do
+ artefact1 = FactoryGirl.create(:artefact, name: "Cheese")
+
+ get :index, filter: "cheese", section: ""
+ assert_select "tbody tr", count: 1
+ assert_select "tbody tr td", artefact1.name
+ end
+
should "filter by 'filter' parameter" do
artefact1 = FactoryGirl.create(:artefact, name: "Cheese")
artefact2 = FactoryGirl.create(:artefact, name: "Chalk")
Please sign in to comment.
Something went wrong with that request. Please try again.