From a89243b99e78e6df5416de70867bd049497edcb5 Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Mon, 24 Apr 2023 20:54:42 +0900 Subject: [PATCH 1/2] Tests for resending invitations --- test/system/invitations_test.rb | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 11b19a1b1..4860f346f 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -95,15 +95,39 @@ def within_former_memberships_table within_membership_row(invited_membership) do assert page.has_content?("Invited") assert page.has_content?("Team Administrator") - click_on "Details" end end + # Resend the invite + assert page.has_content?("Resend") + assert_difference 'all_emails.count', 1 do + perform_enqueued_jobs do + click_on "Resend" + assert page.has_content?("Invitation was successfully resent.") + end + end + + # Prep a new window for making sure we can't resend invitations for tombstoned memberships. + new_window = open_new_window + within_window new_window do + visit account_team_memberships_path(hanakos_team) + end + + within_membership_row(invited_membership) do + click_on "Details" + end + assert page.has_content?("Invitation Details") accept_alert { click_on "Remove from Team" } assert page.has_content?("That user has been successfully removed from the team.") + # We shouldn't be able to resend invitations for memberships that aren't on the team anymore. + within_window new_window do + click_on "Resend" + assert page.has_content?("Sorry, we couldn't find an invitation to resend.") + end + # click the link in the email. # yes, this is a totally valid thing to do if you have access to the invitation email. # practically speaking this would almost never happen, but it's a legitimate way to test this functionality without @@ -136,6 +160,14 @@ def within_former_memberships_table assert page.has_content?("The user has been successfully re-invited. They will receive an email to rejoin the team.") end + # Make sure we can resend the invitation for memberships that come back to the team. + assert_difference 'all_emails.count', 1 do + perform_enqueued_jobs do + click_on "Resend" + assert page.has_content?("Invitation was successfully resent.") + end + end + # sign out. sign_out_for(display_details) From 1b860d84d8e9ad86d7e44455c7457db33a62e550 Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Mon, 24 Apr 2023 20:55:04 +0900 Subject: [PATCH 2/2] Fixing Standard Ruby --- test/system/invitations_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 4860f346f..970d23c3c 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -100,7 +100,7 @@ def within_former_memberships_table # Resend the invite assert page.has_content?("Resend") - assert_difference 'all_emails.count', 1 do + assert_difference "all_emails.count", 1 do perform_enqueued_jobs do click_on "Resend" assert page.has_content?("Invitation was successfully resent.") @@ -161,7 +161,7 @@ def within_former_memberships_table end # Make sure we can resend the invitation for memberships that come back to the team. - assert_difference 'all_emails.count', 1 do + assert_difference "all_emails.count", 1 do perform_enqueued_jobs do click_on "Resend" assert page.has_content?("Invitation was successfully resent.")