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

Fixed Schedules accordion swapping logic. #4621

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
3 changes: 1 addition & 2 deletions app/assets/javascripts/miq_explorer.js
Expand Up @@ -183,8 +183,7 @@ ManageIQ.explorer.processReplaceRightCell = function(data) {
ManageIQ.explorer.miqButtons(data);

if (_.isString(data.clearTreeCookies)) { miqDeleteTreeCookies(data.clearTreeCookies); }

if (_.isString(data.accordionSwap) && ! data.activateNode.activeTree.includes(data.accordionSwap)) {
if (_.isString(data.accordionSwap)) {
miqAccordionSwap('#accordion .panel-collapse.collapse.in', '#' + data.accordionSwap + '_accord');
}

Expand Down
1 change: 1 addition & 0 deletions app/controllers/report_controller.rb
Expand Up @@ -847,6 +847,7 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tre
end
presenter.show(:paging_div)
else
presenter.hide(:form_buttons_div)
presenter.hide(:paging_div)
end
if (@sb[:active_tab] == 'report_info' && x_node.split('-').length == 5 && !@in_a_form) || %w(xx-exportwidgets xx-exportcustomreports).include?(x_node)
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/report_controller/schedules.rb
Expand Up @@ -223,11 +223,10 @@ def schedule_edit
# ensure we land in the right accordion with the right tree and
# with the listing opened even when entering 'add' from the reports
# menu

@_params[:accord] = "schedules" unless x_active_accord == :schedules
self.x_active_tree = "schedules_tree"
self.x_active_accord = "schedules"
self.x_node = "msc-#{schedule.id}"
@_params[:accord] = "schedules"
replace_right_cell(:replace_trees => [:schedules])
else
schedule.errors.each do |field, msg|
Expand Down
31 changes: 31 additions & 0 deletions spec/controllers/report_controller/schedules_spec.rb
Expand Up @@ -3,6 +3,7 @@
let(:admin_user) { FactoryGirl.create(:user, :role => "super_administrator") }

let(:schedule) { FactoryGirl.create(:miq_schedule, :name => "tester1") }
let(:report) { FactoryGirl.create(:miq_report, :name => "report1") }

before do
EvmSpecHelper.create_guid_miq_server_zone
Expand All @@ -14,6 +15,15 @@
allow(controller).to receive(:assert_privileges)
allow(controller).to receive(:checked_or_params).and_return(MiqSchedule.all.ids)
allow(controller).to receive(:replace_right_cell).and_return(true)

timer = ReportHelper::Timer.new('hourly', 1, 1, 1, 1, Time.now.utc, '00', '00')
edit = {:key => "schedule_edit__#{schedule.id}",
:sched_id => schedule.id,
:new => {:name => "foo", :description => "Foo", :repfilter => report.id, :timer => timer}}
controller.instance_variable_set(:@edit, edit)
controller.instance_variable_set(:@sb, {})
session[:edit] = edit
allow(controller).to receive(:drop_breadcrumb)
end

it "reset rbac testing" do
Expand All @@ -22,5 +32,26 @@
expected_id = controller.instance_variable_get(:@schedule).id
expect(expected_id).to eq(schedule.id)
end

it "sets params accord only when schedule is added from Reports accordion" do
allow(controller).to receive(:x_active_accord).and_return(:reports)
post :schedule_edit, :params => { :button => "add", :id => schedule.id }
params = ActionController::Parameters.new('button' => 'add',
'id' => schedule.id.to_s,
'controller' => 'report',
'action' => 'schedule_edit',
'accord' => 'schedules')
expect(controller.params).to eq(params)
end

it "does not set params accord when adding/editing schedule from Schedules accordion" do
allow(controller).to receive(:x_active_accord).and_return(:schedules)
post :schedule_edit, :params => { :button => "add", :id => schedule.id }
params = ActionController::Parameters.new('button' => 'add',
'id' => schedule.id.to_s,
'controller' => 'report',
'action' => 'schedule_edit')
expect(controller.params).to eq(params)
end
end
end