-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-931 Show placeholder for deleted invitee #5000
Open
brianjaustin
wants to merge
2
commits into
otwcode:master
Choose a base branch
from
brianjaustin:AO3-931
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+91
−25
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
module InvitationsHelper | ||
|
||
def creator_link(invitation) | ||
if invitation.creator.is_a?(User) | ||
case invitation.creator | ||
when User | ||
link_to(invitation.creator.login, invitation.creator) | ||
elsif invitation.creator.is_a?(Admin) | ||
when Admin | ||
invitation.creator.login | ||
else | ||
"queue" | ||
t("invitations.invitation.queue") | ||
end | ||
end | ||
|
||
def invitee_link(invitation) | ||
if invitation.invitee && invitation.invitee.is_a?(User) | ||
link_to(invitation.invitee.login, invitation.invitee) | ||
end | ||
return unless invitation.invitee_type == "User" | ||
return link_to(invitation.invitee.login, invitation.invitee) if invitation.invitee.present? | ||
return t("invitations.invitation.deleted_user_with_id", user_id: invitation.invitee_id) if User.current_user.is_a?(Admin) | ||
|
||
t("invitations.invitation.deleted_user") | ||
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 |
---|---|---|
@@ -1,29 +1,33 @@ | ||
<dl> | ||
<dt>Sender</dt> | ||
<dd><%= creator_link(invitation) %></dd> | ||
<dt>Invitation token</dt> | ||
<dd><%= invitation.token %></dd> | ||
<dt>Copy link</dt> | ||
<dd><% unless invitation.redeemed_at %><%= link_to "copy and use", signup_path(:invitation_token => invitation.token) %><% end %></dd> | ||
<dt>Sent to</dt> | ||
<dt><%= t(".sender") %></dt> | ||
<dd><%= creator_link(invitation) %></dd> | ||
<dt><%= t(".invitation_token") %></dt> | ||
<dd><%= invitation.token %></dd> | ||
<dt><%= t(".copy_link") %></dt> | ||
<dd> | ||
<% unless invitation.redeemed_at %> | ||
<%= link_to t(".copy_and_use"), signup_path(invitation_token: invitation.token) %> | ||
<% end %> | ||
</dd> | ||
<dt><%= t(".sent_to") %></dt> | ||
<dd> | ||
<% if invitation.redeemed_at %> | ||
<dd><%= invitation.invitee_email %></dd> | ||
<%= invitation.invitee_email %> | ||
<% else %> | ||
<dd> | ||
<%= form_for(invitation) do |f| %> | ||
<%= error_messages_for invitation %> | ||
<p><%= f.label :invitee_email, t(".email_address_label") %> <%= f.text_field :invitee_email %></p> | ||
<p><%= hidden_field_tag :user_id, @user.try(:login) %></p> | ||
<p class="submit actions"><%= f.submit %></p> | ||
<% end %> | ||
</dd> | ||
<% end %> | ||
<dt>Redeemed by</dt> | ||
<dd><%= invitee_link(invitation) %></dd> | ||
<dt>Created at</dt> | ||
<dd><%= invitation.created_at %></dd> | ||
<dt>Sent at</dt> | ||
<dd><%= invitation.sent_at %></dd> | ||
<dt>Redeemed at</dt> | ||
<dd><%= invitation.redeemed_at %></dd> | ||
</dd> | ||
<dt><%= t(".redeemed_by") %></dt> | ||
<dd><%= invitee_link(invitation) %></dd> | ||
<dt><%= t(".created_at") %></dt> | ||
<dd><%= invitation.created_at %></dd> | ||
<dt><%= t(".sent_at") %></dt> | ||
<dd><%= invitation.sent_at %></dd> | ||
<dt><%= t(".redeemed_at") %></dt> | ||
<dd><%= invitation.redeemed_at %></dd> | ||
</dl> |
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 |
---|---|---|
|
@@ -1358,7 +1358,19 @@ en: | |
what_you_cant_do: What you can't do | ||
invitations: | ||
invitation: | ||
copy_and_use: copy and use | ||
copy_link: Copy link | ||
created_at: Created at | ||
deleted_user: deleted user | ||
deleted_user_with_id: deleted user (%{user_id}) | ||
Comment on lines
+1364
to
+1365
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you fix the capitalization here? shakes fist at lowercase |
||
email_address_label: Enter an email address | ||
invitation_token: Invitation token | ||
queue: queue | ||
redeemed_at: Redeemed at | ||
redeemed_by: Redeemed by | ||
sender: Sender | ||
sent_at: Sent at | ||
sent_to: Sent to | ||
invite_requests: | ||
index_open: | ||
add_to_list: Add me to the list | ||
|
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,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe InvitationsHelper do | ||
describe "#invitee_link" do | ||
let(:invitation) { create(:invitation) } | ||
|
||
context "when the invitee is an existing user" do | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
invitation.update!(invitee: user) | ||
end | ||
|
||
it "returns a link to the user" do | ||
expect(helper.invitee_link(invitation)).to eq(link_to(user.login, user_path(user))) | ||
end | ||
end | ||
|
||
context "when the invitee is a deleted user" do | ||
let(:user) { create(:user) } | ||
|
||
before do | ||
invitation.update!(invitee: user) | ||
user.destroy! | ||
invitation.reload | ||
end | ||
|
||
it "returns a placeholder with the user ID" do | ||
expect(helper.invitee_link(invitation)).to eq("deleted user") | ||
end | ||
|
||
context "when logged in as an admin" do | ||
let(:admin) { build(:admin) } | ||
let!(:user_id) { user.id } | ||
|
||
before do | ||
User.current_user = admin | ||
end | ||
|
||
it "returns a placeholder with the user ID" do | ||
expect(helper.invitee_link(invitation)).to eq("deleted user (#{user_id})") | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be wandering out of scope here, but while I was updating AO3-6095, I noticed it specifies using
Deleted admin
when the admin is deleted. We don't cover that case here, so is it possible this page would either 500 or incorrectly specify the queue if the admin who issued an invitation was now deleted?