Skip to content

Commit

Permalink
Fix regression in perpage_key for GTL types
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Dec 4, 2018
1 parent 189dfe3 commit da5d869
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ def perpage_key(dbname)
when "job", "miqtask"
:job_task
else
PERPAGE_TYPES[dbname]
PERPAGE_TYPES[@gtl_type]
end
end

Expand Down
29 changes: 29 additions & 0 deletions spec/controllers/application_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,35 @@
end
end

describe '#perpage_key' do
{
'miqreportresult' => :reports,
'job' => :job_task,
'miqtask' => :job_task
}.each do |dbname, response|
context "key is #{dbname}" do
it "returns with #{response}" do
expect(controller.send(:perpage_key, dbname)).to eq(response)
end
end
end

{
'grid' => :grid,
'list' => :list,
'tile' => :tile,
'foobar' => nil
}.each do |gtl_type, response|
context "gtl_type is #{gtl_type}" do
before { controller.instance_variable_set(:@gtl_type, gtl_type) }

it "returns with #{response}" do
expect(controller.send(:perpage_key, 'foobar')).to eq(response)
end
end
end
end

describe "#replace_trees_by_presenter" do
let(:tree_1) { double(:name => 'tree_1', :type => 'tree_1') }
let(:tree_2) { double(:name => 'tree_2', :type => 'tree_2') }
Expand Down

0 comments on commit da5d869

Please sign in to comment.