Skip to content

Commit

Permalink
Merge pull request #3068 from h-kataria/policy_assignment_fix
Browse files Browse the repository at this point in the history
Passing in `@in_a_form` to report_data call
  • Loading branch information
martinpovolny authored Dec 15, 2017
2 parents d4e9e12 + 924efc3 commit d4f2be2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ApplicationController
:embedded,
:showlinks,
:policy_sim,
:in_a_form,
:lastaction,
:display
) do
Expand All @@ -41,6 +42,7 @@ def with_quadicon_options(options)
self.showlinks = options[:showlinks]
self.policy_sim = options[:policy_sim]
self.lastaction = options[:lastaction]
self.in_a_form = options[:in_a_form]
self.display = options[:display]
end

Expand Down
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,7 @@ def process_show_list_options(options, curr_model = nil)
:showlinks => @showlinks,
:policy_sim => @policy_sim,
:lastaction => @lastaction,
:in_a_form => @in_a_form,
:display => @display
)
@report_data_additional_options.with_row_button(@row_button) if @row_button
Expand Down Expand Up @@ -1674,6 +1675,10 @@ def restore_quadicon_options(quadicon_options)
# we also need to pass the @display because @display passed throught the
# session does not persist the null value
@display = quadicon_options[:display]

# need to pass @in_a_form so get_view does not set advanced search options
# in the forms that render gtl that mess up @edit
@in_a_form = quadicon_options[:in_a_form]
end

# Wrapper around jquery-rjs' remote_function which adds an extra .html_safe()
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/vm_infra_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -588,4 +588,26 @@
controller.send(:disable_check?, wf)
expect(response.status).to eq(200)
end

it "should not add search variables in @edit[:new] when rendering Policy assignment form" do
controller.instance_variable_set(:@_response, ActionDispatch::TestResponse.new)
controller.instance_variable_set(:@_params,
:pressed => "vm_protect",
"check_#{vm_vmware.id}" => "1",
:active_tree => "vandt_tree",
:model_name => "VmOrTemplate",
:model => "VmOrTemplate",
:explorer => true,
:additional_options => {:in_a_form => true}
)
edit = {:new => {}, :current => {}}
controller.instance_variable_set(:@sb, {})
controller.instance_variable_set(:@edit, edit)
session[:edit] = edit
allow(controller).to receive(:assign_policies)
allow(controller).to receive(:replace_right_cell)
controller.send(:x_button)
controller.report_data
expect(assigns(:edit)[:new]).to_not include(:expression)
end
end

0 comments on commit d4f2be2

Please sign in to comment.