IMHO opening new windows is a usability issue which has been known for twenty years since it takes control away from the user and breaks the "back button", but for now we're keeping the same behavior as we already had, while slightly increasing the complexity of the tests (which is a good indicator of a usability issue).
57 lines
1.6 KiB
Ruby
57 lines
1.6 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Admin users" do
|
|
let(:admin) { create(:administrator) }
|
|
let!(:user) { create(:user, username: "Jose Luis Balbin") }
|
|
|
|
before do
|
|
login_as(admin.user)
|
|
visit admin_users_path
|
|
end
|
|
|
|
scenario "Index" do
|
|
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", :js do
|
|
within_window(window_opened_by { click_link user.name }) do
|
|
expect(page).to have_current_path(user_path(user))
|
|
end
|
|
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}", 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}", 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
|
|
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
|
|
end
|