Fixes "Invite Flow" 404s for Unregistered Users (#10743) [deploy]

* Add conditional to display "<username> is not registered" or Admin User profile in /admin/show.html.erb
  -Displays a "<username> is not registered" message for unregistered users
  -Displays all linked usernames and Admin User info for registered users

* Adds tests around unregistered users Admin User profiles

* Use predicate method in all conditionals in /admin/users/show.html.erb

* Adjusts message alerting admins that a user has not accepted the invite yet
  - Makes the message displayed on the Admin User prof more explicit
  - Makes GETS singular instead of plural in invitations_spec.rb
  - Updates users_spec.rb to test against updated message
This commit is contained in:
Julianna Tetreault 2020-10-13 07:53:29 -06:00 committed by GitHub
parent 54db91bb4b
commit cb93197d43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 10 deletions

View file

@ -1,10 +1,16 @@
<div class="grid gap-6">
<div class="crayons-card p-6">
<h2 class="d-inline">
<%= @user.name %><%= link_to "@#{@user.username}", @user.path, class: "ml-2", target: "_blank", rel: "noopener" %>
<% if @user.registered? %>
<%= @user.name %><%= link_to "@#{@user.username}", @user.path, class: "ml-2", target: "_blank", rel: "noopener" %>
<% else %>
@<%= @user.username %> has not accepted their invitation yet.
<% end %>
</h2>
<a href="<%= edit_admin_user_path(@user) %>" class="btn btn-primary float-right">Manage User</a>
<p class="font-italic">Member since <%= @user.created_at.strftime("%b %e '%y") %></p>
<% if @user.registered? %>
<a href="<%= edit_admin_user_path(@user) %>" class="btn btn-primary float-right">Manage User</a>
<p class="font-italic">Member since <%= @user.created_at.strftime("%b %e '%y") %></p>
<% end %>
<hr>
@ -35,8 +41,10 @@
</dl>
</div>
<%= render "activity" %>
<%= render "credits" %>
<%= render "notes" %>
<%= render "user_organizations" %>
<%= render "email_tools" %>
<% if @user.registered? %>
<%= render "activity" %>
<%= render "credits" %>
<%= render "notes" %>
<%= render "user_organizations" %>
<%= render "email_tools" %>
<% end %>

View file

@ -8,7 +8,7 @@ RSpec.describe "/admin/invitations", type: :request do
sign_in(admin)
end
describe "GETS /admin/invitations" do
describe "GET /admin/invitations" do
it "renders to appropriate page" do
user.update_column(:registered, false)
get "/admin/invitations"
@ -16,7 +16,7 @@ RSpec.describe "/admin/invitations", type: :request do
end
end
describe "GETS /admin/invitations/new" do
describe "GET /admin/invitations/new" do
it "renders to appropriate page" do
get "/admin/invitations/new"
expect(response.body).to include("Email:")

View file

@ -23,6 +23,27 @@ RSpec.describe "admin/users", type: :request do
get "/admin/users/#{user.id}"
expect(response.body).to include(user.username)
end
context "when a user is unregistered" do
it "renders a message stating that the user isn't registered" do
user.update_columns(registered: false)
get "/admin/users/#{user.id}"
expect(response.body).to include("@#{user.username} has not accepted their invitation yet.")
end
it "only displays limited information about the user" do
user.update_columns(registered: false)
get "/admin/users/#{user.id}"
expect(response.body).not_to include("Current Roles")
end
end
context "when a user is registered" do
it "renders the Admin User profile as expected" do
get "/admin/users/#{user.id}"
expect(response.body).to include("Current Roles")
end
end
end
describe "GET /admin/users/:id/edit" do