Skip to content

Commit

Permalink
Add Back button to policy simulation page for non-explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilda Stastna committed Aug 26, 2019
1 parent 4e569d5 commit c76b7ed
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller/policy_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def policy_sim(records = [])
@refresh_partial = "layouts/policy_sim"
replace_right_cell(:refresh_breadcrumbs => false)
end
else
session[:edit] = @edit
end
end

Expand Down
9 changes: 9 additions & 0 deletions app/views/vm_common/_policies.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,12 @@

= _('* Items in <font color="red"><i>red italics</i></font> do not change the outcome of the scope or expression.').html_safe

- unless @explorer
#buttons{:align => 'right'}
-# Go back to policy simulation screen
= link_to(_('Back'),
{:action => 'policy_sim', :continue => true, :controller => 'vm'},
:class => 'btn btn-default',
:alt => t = _('Back'),
:title => t,
:method => :post)
13 changes: 13 additions & 0 deletions spec/views/vm_common/_policies.html.haml_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe 'vm_common/_policies.html.haml' do
before do
assign(:policy_options, :out_of_scope => true, :passed => true, :failed => true)
assign(:policy_simulation_tree, TreeBuilderPolicySimulation.new(:policy_simulation_tree, {}, true))
assign(:record, FactoryBot.create(:vm_infra))
set_controller_for_view('vm_or_template')
end

it 'renders Back button for non explorer screens' do
render :partial => 'vm_common/policies'
expect(response).to include('<a class="btn btn-default" alt="Back" title="Back" rel="nofollow" data-method="post" href="/vm/policy_sim?continue=true">Back</a>')
end
end

0 comments on commit c76b7ed

Please sign in to comment.