In the management section, `current_user` is the user impersonated by the manager. We were deciding whether to show the admin menu depending on the privileges of the current user, but this menu should be shown according to the privileges of the manager who is impersonating the user. We're doing a similar (very subtle) change in the login items. We were rendering the `login_items` partial passing `current_user: user`. However, inside this method, we were using `user_signed_in`, which ignored the `current_user` we were passing. The result was always the same expect in tests where we manually sign in users, but we're changing it anyway in order to reduce confusion.
23 lines
757 B
Ruby
23 lines
757 B
Ruby
require "rails_helper"
|
|
|
|
describe "Management" do
|
|
let(:user) { create(:user) }
|
|
|
|
scenario "Does not show the admin menu when managing users having the admin menu" do
|
|
create(:manager, user: user)
|
|
create(:moderator, user: create(:user, :in_census, document_number: "12345678M"))
|
|
|
|
login_as(user)
|
|
visit management_sign_in_path
|
|
click_link "Select user"
|
|
fill_in "Document number", with: "12345678M"
|
|
click_button "Check document"
|
|
|
|
expect(page).to have_content "This user account is already verified"
|
|
expect(page).not_to have_content "You don't have new notifications"
|
|
expect(page).not_to have_content "My content"
|
|
expect(page).not_to have_content "My account"
|
|
expect(page).not_to have_content "Sign out"
|
|
end
|
|
end
|