37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
feature "Admin masquerading as an user" do
|
|
let!(:current_user) { create(:user, admin: true, email: "me@test.com") }
|
|
let!(:another_user) { create(:user, admin: false, email: "them@test.com") }
|
|
let(:project) { create(:project, account: current_user.primary_account) }
|
|
|
|
scenario "masquerades as user and stops" do
|
|
my_project = create(:project, name: "My Project", account: current_user.primary_account)
|
|
another_project = create(:project, name: "Their Project", account: another_user.primary_account)
|
|
sign_in current_user
|
|
visit admin_users_path
|
|
|
|
click_link "Masquerade"
|
|
|
|
expect(page).not_to have_content("me@test.com")
|
|
expect(page).to have_content("them@test.com")
|
|
expect(page).to have_content("Their Project")
|
|
expect(page).not_to have_content("My Project")
|
|
expect(page).to have_content "Stop Masquerading"
|
|
|
|
click_link "Stop Masquerading"
|
|
|
|
expect(page).to have_content("me@test.com")
|
|
expect(page).to have_content("them@test.com")
|
|
expect(page).to have_content("Masquerade")
|
|
|
|
visit projects_path
|
|
|
|
expect(page).to have_content("me@test.com")
|
|
expect(page).not_to have_content("them@test.com")
|
|
expect(page).to have_content("My Project")
|
|
expect(page).not_to have_content("Their Project")
|
|
expect(page).not_to have_content "Stop Masquerading"
|
|
end
|
|
end
|