@@ -69,6 +69,8 @@ class Api::V1::Shopkeeper::Accounts::AccountsInvitationsControllerTest < ActionD
6969 end
7070
7171 assert_response :unprocessable_entity
72+ assert_equal 422 , response . parsed_body [ "code" ]
73+ assert response . parsed_body [ "error_message" ] . present?
7274 end
7375
7476 test "create requires admin role" do
@@ -118,6 +120,8 @@ class Api::V1::Shopkeeper::Accounts::AccountsInvitationsControllerTest < ActionD
118120 headers : @shopkeeper . create_new_auth_token
119121
120122 assert_response :unprocessable_entity
123+ assert_equal 422 , response . parsed_body [ "code" ]
124+ assert response . parsed_body [ "error_message" ] . present?
121125 end
122126
123127 test "update requires admin role" do
@@ -158,16 +162,23 @@ class Api::V1::Shopkeeper::Accounts::AccountsInvitationsControllerTest < ActionD
158162 assert_response :unauthorized
159163 end
160164
161- test "resend sends invitation email again and touches created_at" do
162- original_created_at = @invitation . created_at
165+ test "resend sends invitation email again" do
166+ post resend_api_v1_shopkeeper_account_accounts_invitation_path ( @account , @invitation . token ) ,
167+ headers : @shopkeeper . create_new_auth_token
163168
164- travel_to ( 1 . hour . from_now ) do
165- post resend_api_v1_shopkeeper_account_accounts_invitation_path ( @account , @invitation . token ) ,
166- headers : @shopkeeper . create_new_auth_token
169+ assert_response :success
170+ assert_enqueued_emails 1
171+ end
167172
168- assert_response :success
169- assert @invitation . reload . created_at > original_created_at
170- end
173+ test "resend resets expiration for expired invitation" do
174+ @invitation . update_column ( :created_at , ( AccountsInvitation ::EXPIRES_IN + 1 . minute ) . ago )
175+ assert @invitation . expired?
176+
177+ post resend_api_v1_shopkeeper_account_accounts_invitation_path ( @account , @invitation . token ) ,
178+ headers : @shopkeeper . create_new_auth_token
179+
180+ assert_response :success
181+ assert_not @invitation . reload . expired?
171182 end
172183
173184 test "resend requires admin role" do
0 commit comments