Skip to content

Commit

Permalink
Merge pull request rubyforgood#5802 from rubyforgood/pc-impersonate
Browse files Browse the repository at this point in the history
Moved impersonate message to top of the page, put it in a red box
  • Loading branch information
freestylebit authored Jun 12, 2024
2 parents 0ab26de + 736f7a7 commit 73ffd95
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 23 deletions.
7 changes: 7 additions & 0 deletions app/views/layouts/_header.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<header class="header pt-0">
<%= render 'layouts/banner' %>

<% if current_user != true_user %>
<%= link_to stop_impersonating_volunteers_path, method: :post, class: "pt-4 pb-4 bg-danger", style: "padding-left: 15px; display: block;" do %>
You (<%= true_user.display_name %>) are signed in as <%= current_user.display_name %>.
Click here to stop impersonating.
<% end %>
<% end %>

<div class="container-fluid pt-30">
<div class="row">
<div class="col-lg-5 col-md-5 col-6">
Expand Down
8 changes: 0 additions & 8 deletions app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@
{ title: "Edit Organization", icon: "cogs", path: edit_casa_org_path(current_organization), render_check: policy(:application).modify_organization? }
]) %>
<% end %>
<li>
<% if current_user != true_user %>
<%= link_to stop_impersonating_volunteers_path, method: :post, class: "mr-10 ml-10" do %>
You (<%= true_user.display_name %>) are signed in as <%= current_user.display_name %>.
Click here to stop impersonating.
<% end %>
<% end %>
</li>
</ul>
</nav>
</nav>
Expand Down
4 changes: 2 additions & 2 deletions spec/system/volunteers/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@

click_on "Impersonate"

within(".sidebar-nav-wrapper") do
within(".header") do
expect(page).to have_text(
"You (#{admin.display_name}) are signed in as John Doe. " \
"Click here to stop impersonating."
Expand All @@ -579,7 +579,7 @@

click_on "Impersonate"

within(".sidebar-nav-wrapper") do
within(".header") do
expect(page).to have_text(
"You (#{supervisor.display_name}) are signed in as John Doe. " \
"Click here to stop impersonating."
Expand Down
8 changes: 8 additions & 0 deletions spec/views/layouts/header.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,13 @@ def true_user

expect(rendered).to match "<strong>Role: Volunteer</strong>"
end

it "renders a stop impersonating link when impersonating" do
allow(view).to receive(:true_user).and_return(true_user)

render partial: "layouts/header"

expect(rendered).to have_link(href: "/volunteers/stop_impersonating")
end
end
end
13 changes: 0 additions & 13 deletions spec/views/layouts/sidebar.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,4 @@ def true_user
expect(rendered).to_not have_link("Emancipation Checklist", href: "/emancipation_checklists")
end
end

context "impersonation" do
let(:user) { build_stubbed :volunteer }
let(:true_user) { build_stubbed :casa_admin }

it "renders a stop impersonating link when impersonating" do
allow(view).to receive(:true_user).and_return(true_user)

render partial: "layouts/sidebar"

expect(rendered).to have_link(href: "/volunteers/stop_impersonating")
end
end
end

0 comments on commit 73ffd95

Please sign in to comment.