Files
grecia/spec/system/admin/users_spec.rb
Javi Martín 5c7d87f763 Open admin links in the same window
In the admin section, when clicking on a link that leads to a page in
the public area, sometimes the page was opened in the same window and
sometimes it would open in a new window, with no clear criteria
regarding when either scenario would take place.

This was really confusing, so now we're more consistent and open
(almost) every link in the same window. The main reason behind it is
simple: if we add `target: _blank`, people who want to open those links
in the same window can no longer do so, so we're taking control away
from them. However, if we don't add this attribute, people can choose
whether to open the link on the same tab or to open it on a new one,
since all browsers implement a method to do so.

More reasons behind this decision can be found in "Opening Links in New
Browser Windows and Tabs" [1].

We're keeping some exceptions, though:

* Opening the link to edit an investment on the same tab would result in
  losing all the investment filters already applied when searching for
  investments, so until we implement a way to keep these filters, we're
  also opening the link to edit an investment in a new tab
* For now, we're also opening links to download files in a new window;
  we'll deal with this case in the future

[1] https://www.nngroup.com/articles/new-browser-windows-and-tabs/
2023-10-24 16:31:39 +02:00

79 lines
2.1 KiB
Ruby

require "rails_helper"
describe "Admin users" do
let(:admin) { create(:administrator) }
let!(:user) { create(:user, username: "Jose Luis Balbin") }
before { login_as(admin.user) }
scenario "Index" do
visit admin_users_path
expect(page).to have_link user.name
expect(page).to have_content user.email
expect(page).to have_content admin.name
expect(page).to have_content admin.email
end
scenario "The username links to their public profile" do
visit admin_users_path
click_link user.name
expect(page).to have_current_path(user_path(user))
end
scenario "Show active or erased users using filters" do
erased_user = create(:user, username: "Erased")
erased_user.erase("I don't like this site.")
visit admin_users_path
expect(page).not_to have_link(erased_user.id.to_s, href: user_path(erased_user))
expect(page).to have_link("Erased")
click_link "Erased"
expect(page).to have_link("Active")
expect(page).to have_link(erased_user.id.to_s, href: user_path(erased_user))
expect(page).to have_content "I don't like this site."
expect(page).to have_content("Erased")
fill_in :search, with: "Erased"
click_button "Search"
expect(page).to have_content "There are no users."
end
scenario "Search" do
visit admin_users_path
fill_in :search, with: "Luis"
click_button "Search"
expect(page).to have_content user.name
expect(page).to have_content user.email
expect(page).not_to have_content admin.name
expect(page).not_to have_content admin.email
end
describe "Show account activation status" do
scenario "when user account is confimed" do
visit admin_users_path
expect(page).to have_content "Activation Status"
expect(page).to have_content "Account activated"
expect(page).not_to have_content "Account not activated"
end
scenario "when user account is not confimed" do
user.update!(confirmed_at: nil)
visit admin_users_path
expect(page).to have_content "Activation Status"
expect(page).to have_content "Account not activated"
end
end
end