Skip to content

Commit fc2e0b1

Browse files
committed
fix failing spec
1 parent 4cecea4 commit fc2e0b1

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Users::InvitationsController < Devise::InvitationsController
2+
# Override the edit action to ensure the invitation_token is properly set in the form
3+
def edit
4+
self.resource = resource_class.new
5+
set_minimum_password_length if respond_to?(:set_minimum_password_length, true)
6+
resource.invitation_token = params[:invitation_token]
7+
render :edit
8+
end
9+
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
mount Rswag::Api::Engine => "/api-docs"
66

77
devise_for :all_casa_admins, path: "all_casa_admins", controllers: {sessions: "all_casa_admins/sessions"}
8-
devise_for :users, controllers: {sessions: "users/sessions", passwords: "users/passwords"}
8+
devise_for :users, controllers: {sessions: "users/sessions", passwords: "users/passwords", invitations: "users/invitations"}
99
authenticate :all_casa_admins do
1010
mount PgHero::Engine, at: "pg_dashboard", constraints: lambda { |request|
1111
admin = request.env["warden"].user(:all_casa_admin)

spec/system/volunteers/invite_spec.rb

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@
5555
end
5656
end
5757

58-
# Note: The acceptance tests below are currently failing due to issues with
59-
# the invitation token not being properly preserved in the Devise form.
60-
# This appears to be a limitation of the current Devise invitable setup
61-
# and would require further investigation into the form submission flow.
6258
describe "accepting invitation" do
6359
let(:volunteer) { create(:volunteer, casa_org: organization, phone_number: nil) }
6460
let!(:invitation_token) do
@@ -79,8 +75,7 @@
7975
expect(page).to have_button("Set my password")
8076
end
8177

82-
# These tests are skipped due to form submission issues with the invitation token
83-
xit "allows volunteer to set password and accept invitation" do
78+
it "allows volunteer to set password and accept invitation" do
8479
visit accept_user_invitation_path(invitation_token: invitation_token)
8580

8681
expect(page).to have_text "Set my password"
@@ -93,11 +88,11 @@
9388
volunteer.reload
9489
expect(volunteer.invitation_accepted_at).not_to be_nil
9590

96-
# Should be redirected to the home page or dashboard after accepting
97-
expect(page).to have_current_path(root_path, ignore_query: true)
91+
# Should be redirected to dashboard after accepting invitation
92+
expect(page).to have_text("My Cases")
9893
end
9994

100-
xit "shows error when passwords don't match" do
95+
it "shows error when passwords don't match" do
10196
visit accept_user_invitation_path(invitation_token: invitation_token)
10297

10398
fill_in "Password", with: "SecurePassword123!"
@@ -111,7 +106,7 @@
111106
expect(volunteer.invitation_accepted_at).to be_nil
112107
end
113108

114-
xit "shows error when password is too short" do
109+
it "shows error when password is too short" do
115110
visit accept_user_invitation_path(invitation_token: invitation_token)
116111

117112
fill_in "Password", with: "short"
@@ -125,7 +120,7 @@
125120
expect(volunteer.invitation_accepted_at).to be_nil
126121
end
127122

128-
xit "shows error when password is blank" do
123+
it "shows error when password is blank" do
129124
visit accept_user_invitation_path(invitation_token: invitation_token)
130125

131126
fill_in "Password", with: ""

0 commit comments

Comments
 (0)