Skip to content
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

Updated Zoonou Accessibility Testing Environment #5118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/controllers/admin/suppliers/lead_providers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module Admin
module Suppliers
class LeadProvidersController < Admin::BaseController
before_action :set_lead_provider, only: %i[show]
skip_after_action :verify_policy_scoped

def show; end

private

def set_lead_provider
@lead_provider = LeadProvider.find(params[:id])
authorize @lead_provider
end
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module AdminHelper
def admin_edit_user_path(user)
if user.lead_provider?
edit_admin_lead_provider_user_path(user)
edit_admin_lead_provider_lead_provider_user_path(user.lead_provider, user)
elsif user.induction_coordinator?
edit_admin_induction_coordinator_path(user)
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/supplier_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module SupplierHelper
def supplier_link(supplier)
supplier.is_a?(LeadProvider) ? supplier.name : govuk_link_to(supplier.name, edit_admin_delivery_partner_path(supplier))
govuk_link_to(supplier.name, supplier.is_a?(LeadProvider) ? admin_lead_provider_path(supplier) : edit_admin_delivery_partner_path(supplier))
end
end
4 changes: 2 additions & 2 deletions app/views/admin/suppliers/lead_provider_users/delete.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% content_for :title, "Delete user" %>
<h1>Do you want to delete this user?</h1>
<p class="govuk-!-font-weight-bold">Supplier user: <span class="govuk-!-font-weight-regular"><%= @lead_provider_user.full_name %></span></p>
<%= form_for :confirmation, url: admin_lead_provider_user_path(@lead_provider_user), method: :delete do |f| %>
<%= form_for :confirmation, url: admin_lead_provider_lead_provider_user_path(@lead_provider_user), method: :delete do |f| %>
<div class="govuk-button-group">
<%= f.govuk_submit "Delete", classes: "govuk-button--warning", "data-test": "delete-button" %>
<%= govuk_button_link_to "Back", edit_admin_lead_provider_user_path(@lead_provider_user), class: "govuk-button--secondary" %>
<%= govuk_button_link_to "Back", edit_admin_lead_provider_lead_provider_user_path(@lead_provider_user), class: "govuk-button--secondary" %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/admin/suppliers/lead_provider_users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-l">Edit user details</h1>
<%= form_for(@lead_provider_user, url: admin_lead_provider_user_path(@lead_provider_user)) do |f| %>
<%= form_for(@lead_provider_user, url: admin_lead_provider_lead_provider_user_path(@lead_provider_user)) do |f| %>
<%= f.govuk_error_summary %>
<%= f.govuk_text_field(
:full_name,
Expand All @@ -16,7 +16,7 @@
%>
<div class="govuk-button-group">
<%= f.govuk_submit "Save" %>
<%= govuk_button_link_to "Delete", delete_admin_lead_provider_user_path(@lead_provider_user), class: "govuk-button--warning", "data-test"=> "delete-button" %>
<%= govuk_button_link_to "Delete", delete_admin_lead_provider_lead_provider_user_path(@lead_provider_user), class: "govuk-button--warning", "data-test"=> "delete-button" %>
</div>
<% end %>
</div>
Expand Down
53 changes: 53 additions & 0 deletions app/views/admin/suppliers/lead_providers/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<% content_for :title, "Lead Provider: overview" %>
<% content_for :before_content, govuk_back_link(text: "Back", href: admin_suppliers_path) %>

<h1 class="govuk-heading-l"><%= @lead_provider.name %></h1>

<div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters">

<h2 class="govuk-heading-m">ECF Lead Provider Details</h2>
<%=
govuk_summary_list do |sl|
sl.with_row do |row|
row.with_key(text: "ID")
row.with_value(text: @lead_provider.id)
end

sl.with_row do |row|
row.with_key(text: "VAT Chargable")
row.with_value(text: @lead_provider.vat_chargeable ? "Yes" : "No")
end

@lead_provider.users.each do |user|
sl.with_row do |row|
row.with_key(text: "User email")
row.with_value(text: user.email)
end
end
end
%>

<h3 class="govuk-heading-m">Delivery partners</h3>
<% if @lead_provider.delivery_partners %>
<table class="govuk-table">
<thead>
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header">Supplier</th>
<th scope="col" class="govuk-table__header">Supplier type</th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @lead_provider.delivery_partners.each do |supplier| %>
<tr class="govuk-table__row">
<td class="govuk-table__cell" data-test="supplier-name"><%= supplier_link(supplier) %></td>
<td class="govuk-table__cell"><%= supplier.model_name.human %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="govuk-body">No Delivery partners associated with this Lead Provider</p>
<% end %>
</div>
</div>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@
end
end

scope path: "lead-providers" do
resources :lead_providers, only: :show, path: "lead-providers" do
resources :lead_provider_users, only: %i[edit update destroy], path: "users" do
member do
get "delete", action: :delete
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/admin_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
describe "#admin_edit_user_path" do
context "when the user is a lead provider" do
let(:profile) { create(:lead_provider_profile) }
let(:result) { "/admin/suppliers/lead-providers/users/#{user.id}/edit" }
let(:result) { "/admin/suppliers/lead-providers/#{user.lead_provider.id}/users/#{user.id}/edit" }

it "returns the admin edit url for the user" do
expect(helper.admin_edit_user_path(user)).to eq(result)
Expand Down
6 changes: 4 additions & 2 deletions spec/helpers/supplier_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

describe "#supplier_link" do
context "when the supplier is a lead provider" do
it "returns nil" do
expect(helper.supplier_link(lead_provider)).to eq(CGI.escapeHTML(lead_provider.name))
let(:result) { "/admin/suppliers/lead-providers/#{lead_provider.id}" }

it "returns the admin show url for the lead provider" do
expect(helper.supplier_link(lead_provider)).to include(result, CGI.escapeHTML(lead_provider.name))
end
end

Expand Down
16 changes: 8 additions & 8 deletions spec/requests/admin/lead_providers/lead_provider_users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
lead_provider_user_two
end

describe "GET /admin/suppliers/lead_providers/users/:id/edit" do
describe "GET /admin/suppliers/lead_providers/:lead_provider_id/users/:id/edit" do
it "renders the index template" do
get "/admin/suppliers/lead-providers/users/#{lead_provider_user.id}/edit"
get "/admin/suppliers/lead-providers/#{lead_provider_user.lead_provider.id}/users/#{lead_provider_user.id}/edit"

expect(response.body).to include("Edit user details")
expect(response).to render_template("admin/suppliers/lead_provider_users/edit")
end
end

describe "PATCH /admin/suppliers/lead_providers/users/:id" do
describe "PATCH /admin/suppliers/lead_providers/:lead_provider_id/users/:id" do
let(:email) { "[email protected]" }

it "updates the user and redirects to users page" do
patch "/admin/suppliers/lead-providers/users/#{lead_provider_user.id}", params: {
patch "/admin/suppliers/lead-providers/#{lead_provider_user.lead_provider.id}/users/#{lead_provider_user.id}", params: {
user: { email: },
}

Expand All @@ -39,7 +39,7 @@

context "when the user params are invalid" do
it "renders error messages" do
patch "/admin/suppliers/lead-providers/users/#{lead_provider_user.id}", params: {
patch "/admin/suppliers/lead-providers/#{lead_provider_user.lead_provider.id}/users/#{lead_provider_user.id}", params: {
user: { email: nil },
}

Expand All @@ -52,7 +52,7 @@
let(:current_admin) { admin_user }

before do
patch "/admin/suppliers/lead-providers/users/#{lead_provider_user.id}", params: {
patch "/admin/suppliers/lead-providers/#{lead_provider_user.lead_provider.id}/users/#{lead_provider_user.id}", params: {
user: { email: },
}
end
Expand All @@ -61,9 +61,9 @@
end
end

describe "DELETE /admin/suppliers/lead_providers/users/:id/", versioning: true do
describe "DELETE /admin/suppliers/lead_providers/:lead_provider_id/users/:id/", versioning: true do
before do
delete "/admin/suppliers/lead-providers/users/#{lead_provider_user_two.id}"
delete "/admin/suppliers/lead-providers/#{lead_provider_user.lead_provider.id}/users/#{lead_provider_user_two.id}"
end

it "deletes the lead_provider" do
Expand Down
Loading