Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions spec/system/all_casa_admins/all_casa_admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
fill_in "Address", with: "123 Main St"
click_on "Create CASA Organization"
expect(page).to have_text "CASA Organization was successfully created."
organization = CasaOrg.find_by(name: "Cool Org Name")
expect(page).to have_current_path "/all_casa_admins/casa_orgs/#{organization.id}", ignore_query: true
expect(page).to have_text "Cool Org Name"
expect(page).to have_current_path(%r{/all_casa_admins/casa_orgs/\d+}, ignore_query: true)
expect(page).to have_content "Administrators"
expect(page).to have_content "Details"
expect(page).to have_content "Number of admins: 0"
Expand Down Expand Up @@ -131,9 +131,16 @@

it "admin invitations expire" do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way to create an all casa admin is via direct db access. Can you convert this test into a system test by having the user click on the invitation links?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converted to a system test that visits the invitation acceptance link via accept_all_casa_admin_invitation_path. It verifies that the "Set my password" form loads within 1 week, and
shows "The invitation token provided is not valid!" after expiry.

all_casa_admin = AllCasaAdmin.invite!(email: "valid@email.com")
raw_token = all_casa_admin.raw_invitation_token

# Invitation is valid within 1 week
travel 2.days
expect(all_casa_admin.valid_invitation?).to be true
visit accept_all_casa_admin_invitation_path(invitation_token: raw_token)
expect(page).to have_text "Set my password"

# Invitation expires after 1 week
travel 8.days
expect(all_casa_admin.valid_invitation?).to be false
visit accept_all_casa_admin_invitation_path(invitation_token: raw_token)
expect(page).to have_text "The invitation token provided is not valid!"
end
end
7 changes: 6 additions & 1 deletion spec/system/all_casa_admins/sessions/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
end

it "denies access to flipper" do
expect { visit "/flipper" }.to raise_error(ActionController::RoutingError)
original = Rails.application.env_config["action_dispatch.show_exceptions"]
Rails.application.env_config["action_dispatch.show_exceptions"] = :rescuable
visit "/flipper"
expect(page).to have_text "No route matches [GET] \"/flipper\""
ensure
Rails.application.env_config["action_dispatch.show_exceptions"] = original
end
end
end
Loading