-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for invitations in invite request status.
- Loading branch information
1 parent
53fc408
commit 0812a2a
Showing
10 changed files
with
133 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!--Descriptive page name, messages and instructions--> | ||
<h2 class="heading"> | ||
<%= t(".title", email: invitation.invitee_email) %> | ||
</h2> | ||
<!--/descriptions--> | ||
|
||
<!--main content--> | ||
<p> | ||
<%= t(".date", date: l(invitation.sent_at.to_date)) %> | ||
<% if invitation.sent_at < ArchiveConfig.HOURS_BEFORE_RESEND_INVITATION.hours.ago %> | ||
<%= t(".resend", count: ArchiveConfig.HOURS_BEFORE_RESEND_INVITATION) %> | ||
<%= button_to t(".resend_button"), resend_invite_requests_path(email: invitation.invitee_email) %> | ||
<% end %> | ||
</p> | ||
<!--/content--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<% if @invite_request %> | ||
$j("#invite-status").html("<%= escape_javascript(render "invite_requests/invite_request", invite_request: @invite_request) %>"); | ||
<% elsif @invitation %> | ||
$j("#invite-status").html("<%= escape_javascript(render "invitation", invitation: @invitation) %>"); | ||
<% else %> | ||
$j("#invite-status").html("<p>Sorry, we can't find the email address you entered. If you had used it to join our invitation queue, it's possible that your invitation may have already been emailed to you; please check your spam folder, as your spam filters may have placed it there.</p>"); | ||
$j("#invite-status").html("<p>Sorry, we can't find the email address you entered.</p>"); | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
collection do | ||
get :manage | ||
get :status | ||
post :resend | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ Feature: Invite queue management | |
# check your place in the queue - invalid address | ||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, your invitation may have already been emailed to that address; please check your email spam folder as your spam filters may have placed it there." | ||
And I should see "Sorry, we can't find the email address you entered." | ||
And I should not see "You are currently number" | ||
|
||
# check your place in the queue - correct address | ||
|
@@ -98,7 +98,7 @@ Feature: Invite queue management | |
Then 1 email should be delivered to test@archiveofourown.org | ||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, your invitation may have already been emailed to that address;" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
|
||
# invite can be used | ||
When I am logged in as an admin | ||
|
@@ -155,3 +155,29 @@ Feature: Invite queue management | |
And I fill in "invite_request_email" with "[email protected]" | ||
And I press "Add me to the list" | ||
Then I should see "Email is already being used by an account holder." | ||
|
||
Scenario: Users can resend their invitation after enough time has passed | ||
Given account creation is enabled | ||
And the invitation queue is enabled | ||
And account creation requires an invitation | ||
And the invite_from_queue_at is yesterday | ||
And an invitation request for "[email protected]" | ||
When the scheduled check_invite_queue job is run | ||
Then 1 email should be delivered to invitee@example.org | ||
|
||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
And I should not see "Because your invitation was sent more than 24 hours ago, you can have your invitation resent." | ||
And I should not see a "Resend Invitation" button | ||
|
||
When all emails have been delivered | ||
And it is currently 25 hours from now | ||
And I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
And I should see "Because your invitation was sent more than 24 hours ago, you can have your invitation resent." | ||
And I should see a "Resend Invitation" button | ||
|
||
When I press "Resend Invitation" | ||
Then 1 email should be delivered to invitee@example.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,21 +17,14 @@ | |
|
||
describe "GET #show" do | ||
context "when given invalid emails" do | ||
it "redirects to index with error" do | ||
message = "You can search for the email address you signed up with below. If you can't find it, your invitation may have already been emailed to that address; please check your email spam folder as your spam filters may have placed it there." | ||
get :show, params: { id: 0 } | ||
it_redirects_to_with_error(status_invite_requests_path, message) | ||
expect(assigns(:invite_request)).to be_nil | ||
get :show, params: { id: 0, email: "[email protected]" } | ||
it_redirects_to_with_error(status_invite_requests_path, message) | ||
it "renders" do | ||
get :show, params: { email: "[email protected]" } | ||
expect(response).to render_template("show") | ||
expect(assigns(:invite_request)).to be_nil | ||
end | ||
|
||
it "renders for an ajax call" do | ||
get :show, params: { id: 0 }, xhr: true | ||
expect(response).to render_template("show") | ||
expect(assigns(:invite_request)).to be_nil | ||
get :show, params: { id: 0, email: "[email protected]" }, xhr: true | ||
get :show, params: { email: "[email protected]" }, xhr: true | ||
expect(response).to render_template("show") | ||
expect(assigns(:invite_request)).to be_nil | ||
end | ||
|
@@ -41,19 +34,39 @@ | |
let(:invite_request) { create(:invite_request) } | ||
|
||
it "renders" do | ||
get :show, params: { id: 0, email: invite_request.email } | ||
get :show, params: { email: invite_request.email } | ||
expect(response).to render_template("show") | ||
expect(assigns(:invite_request)).to eq(invite_request) | ||
end | ||
|
||
it "renders for an ajax call" do | ||
get :show, params: { id: 0, email: invite_request.email }, xhr: true | ||
get :show, params: { email: invite_request.email }, xhr: true | ||
expect(response).to render_template("show") | ||
expect(assigns(:invite_request)).to eq(invite_request) | ||
end | ||
end | ||
end | ||
|
||
describe "POST #resend" do | ||
context "when the email doesn't match any invitations" do | ||
it "redirects with an error" do | ||
post :resend, params: { email: "[email protected]" } | ||
it_redirects_to_with_error(status_invite_requests_path, | ||
"Could not find an invitation associated with that email.") | ||
end | ||
end | ||
|
||
context "when the invitation is too recent" do | ||
let(:invitation) { create(:invitation) } | ||
|
||
it "redirects with an error" do | ||
post :resend, params: { email: invitation.invitee_email } | ||
it_redirects_to_with_error(status_invite_requests_path, | ||
"You cannot resend an invitation that was sent in the last 24 hours.") | ||
end | ||
end | ||
end | ||
|
||
describe "POST #create" do | ||
it "redirects to index with error given invalid emails" do | ||
post :create, params: { invite_request: { email: "wat" } } | ||
|