Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jamie Cobbett jamiecobbett authored
2  app/controllers/artefacts_controller.rb
@@ -10,7 +10,7 @@ class ArtefactsController < ApplicationController
10 10 ITEMS_PER_PAGE = 100
11 11
12 12 def index
13   - @section = params[:section] || "all"
  13 + @section = params[:section].present? ? params[:section] : "all"
14 14 if @section != "all"
15 15 tags = Tag.where(tag_type: "section", parent_id: @section)
16 16 tag_ids = tags.collect {|t| t.tag_id}
8 test/functional/artefacts_controller_test.rb
@@ -29,6 +29,14 @@ class ArtefactsControllerTest < ActionController::TestCase
29 29 assert_select "tbody tr td", artefact1.name
30 30 end
31 31
  32 + should "treat a blank section parameter as 'All'" do
  33 + artefact1 = FactoryGirl.create(:artefact, name: "Cheese")
  34 +
  35 + get :index, filter: "cheese", section: ""
  36 + assert_select "tbody tr", count: 1
  37 + assert_select "tbody tr td", artefact1.name
  38 + end
  39 +
32 40 should "filter by 'filter' parameter" do
33 41 artefact1 = FactoryGirl.create(:artefact, name: "Cheese")
34 42 artefact2 = FactoryGirl.create(:artefact, name: "Chalk")

0 comments on commit 320feb4

Please sign in to comment.
Something went wrong with that request. Please try again.