Skip to content

Commit

Permalink
Merge pull request #3235 from h-kataria/alert_profile_editor_fix
Browse files Browse the repository at this point in the history
Need to call alert_profile_edit_load_edit when cancel is pressed
(cherry picked from commit 6361567)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534060
  • Loading branch information
Dan Clarizio authored and simaishi committed Jan 12, 2018
1 parent f9f6ba2 commit 766616b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/miq_policy_controller/alert_profiles.rb
Expand Up @@ -6,7 +6,7 @@ def alert_profile_load
end

def alert_profile_edit_cancel
alert_profile_load
return unless alert_profile_edit_load_edit
@edit = nil
if @alert_profile && @alert_profile.id.blank?
add_flash(_("Add of new Alert Profile was cancelled by the user"))
Expand Down
21 changes: 21 additions & 0 deletions spec/controllers/miq_policy_controller/alert_profiles_spec.rb
Expand Up @@ -71,5 +71,26 @@
expect(controller.send(:flash_errors?)).not_to be_truthy
end
end

context "#alert_profile_edit" do
before :each do
controller.instance_variable_set(:@sb,
:trees => {
:alert_profile_tree => {:active_node => "xx-Vm"}},
:active_tree => :alert_profile_tree)
allow(controller).to receive(:replace_right_cell)
edit = {
:key => "alert_profile_edit__new"
}
session[:edit] = edit
end

it "Test cancel button" do
controller.instance_variable_set(:@_params, :id => 'new', :button => "cancel")
controller.alert_profile_edit
expect(assigns(:flash_array).first[:message]).to include("Add of new Alert Profile was cancelled by the user")
expect(controller.send(:flash_errors?)).not_to be_truthy
end
end
end
end

0 comments on commit 766616b

Please sign in to comment.