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 export button in widget export screen #2921

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/controllers/report_controller.rb
Expand Up @@ -555,14 +555,13 @@ def get_export_reports
def set_form_locals
locals = {}
if x_active_tree == :export_tree
locals[:no_reset] = locals[:no_cancel] = locals[:multi_record] = true
if x_node == "xx-exportwidgets"
action_url = nil
record_id = nil
locals[:export_button] = false
else
action_url = "download_report"
locals[:no_reset] = true
locals[:no_cancel] = true
locals[:multi_record] = true
locals[:export_button] = true
end
elsif x_active_tree == :schedules_tree || params[:pressed] == "miq_report_schedule_add"
Expand Down Expand Up @@ -857,7 +856,7 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
presenter[:right_cell_text] = @right_cell_text

# Handle bottom cell
if ((@in_a_form || @pages) || (@sb[:pages] && @html)) && params[:id] != 'xx-exportwidgets'
if (@in_a_form || @pages) || (@sb[:pages] && @html)
if @pages
presenter.hide(:form_buttons_div, :rpb_div_1).show(:pc_div_1)
elsif @in_a_form
Expand All @@ -871,7 +870,7 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr
else
presenter.hide(:paging_div)
end
if @sb[:active_tab] == 'report_info' && x_node.split('-').length == 5 && !@in_a_form
if (@sb[:active_tab] == 'report_info' && x_node.split('-').length == 5 && !@in_a_form) || %w(xx-exportwidgets xx-exportcustomreports).include?(x_node)
presenter.hide(:paging_div)
end
presenter.set_visibility(!@in_a_form, :toolbar)
Expand Down
39 changes: 39 additions & 0 deletions spec/controllers/report_controller_spec.rb
Expand Up @@ -824,6 +824,45 @@
end
end

describe "import/export accordion" do
include_context "valid session"
render_views

before :each do
login_as(FactoryGirl.create(:user))
allow(controller).to receive(:x_active_tree) { :export_tree }
end

context "accordion root" do
it "correctly renders the screen for accordion root" do
allow(controller).to receive(:x_node) { 'root' }
post :tree_select, :params => {'id' => 'root'}
expect(response.status).to eq(200)
expect(response.body).to include('Choose a Import/Export type from the menus on the left.')
end
end

context "widgets import/export node" do
it "correctly renders the widget import/export screen" do
allow(controller).to receive(:x_node) { 'xx-exportwidgets' }
post :tree_select, :params => {'id' => 'xx-exportwidgets'}
expect(response.status).to eq(200)
expect(response.body).to include('Widgets')
expect(response.body).to match(/input.+type=.+submit.+value=.+Export.+/)
end
end

context "custom reports import/export node" do
it "correctly renders the custom reports import/export screen" do
allow(controller).to receive(:x_node) { 'xx-exportcustomreports' }
post :tree_select, :params => {'id' => 'xx-exportcustomreports'}
expect(response.body).to include('Custom Reports')
expect(response.status).to eq(200)
expect(response.body).to match(/input.+type=.+submit.+value=.+Export.+/)
end
end
end

describe "#export_widgets" do
include_context "valid session"

Expand Down