Fix current_user usage in management section

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.
This commit is contained in:
Javi Martín
2023-01-12 15:48:09 +01:00
parent 44e3a393a0
commit cb2aebe2c8
5 changed files with 27 additions and 31 deletions

View File

@@ -11,7 +11,6 @@ describe Layout::AdminHeaderComponent do
context "management section", controller: Management::BaseController do
it "shows the menu for administrators" do
create(:administrator, user: user)
sign_in(user)
render_inline Layout::AdminHeaderComponent.new(user)
@@ -24,7 +23,6 @@ describe Layout::AdminHeaderComponent do
it "does not show the menu managers" do
create(:manager, user: user)
sign_in(user)
render_inline Layout::AdminHeaderComponent.new(user)