Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression in perpage_key for GTL types #5036

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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