Browse Source

Add link to add locations from scheme page (#1979)

pull/1986/head
kosiakkatrina 1 year ago committed by GitHub
parent
commit
16f96895bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/views/schemes/show.html.erb
  2. 6
      spec/requests/schemes_controller_spec.rb

4
app/views/schemes/show.html.erb

@ -22,8 +22,8 @@
<% row.key { attr[:name] } %>
<% row.value do %>
<%= details_html(attr) %>
<% if attr[:name] == "Status" && @scheme.confirmed? && @scheme.locations.confirmed.none? %>
<span class="app-!-colour-muted">Add a location to complete this scheme</span>
<% if attr[:name] == "Status" && @scheme.confirmed? && @scheme.locations.confirmed.none? && LocationPolicy.new(current_user, @scheme.locations.new).create? %>
<span class="app-!-colour-muted">Complete this scheme by adding a location using the <%= govuk_link_to("‘locations’ tab", scheme_locations_path(@scheme)) %>.</span>
<% end %>
<% end %>
<% if SchemePolicy.new(current_user, @scheme).update? %>

6
spec/requests/schemes_controller_spec.rb

@ -603,7 +603,8 @@ RSpec.describe SchemesController, type: :request do
it "shows the scheme as incomplete with text to explain" do
get scheme_path(specific_scheme)
expect(page).to have_content "Incomplete"
expect(page).to have_content "Add a location to complete this scheme"
expect(page).to have_content "Complete this scheme by adding a location using the"
expect(page).to have_link "‘locations’ tab"
end
end
@ -612,7 +613,8 @@ RSpec.describe SchemesController, type: :request do
create(:location, scheme: specific_scheme)
get scheme_path(specific_scheme)
expect(page).to have_content "Active"
expect(page).not_to have_content "Add a location to complete this scheme"
expect(page).not_to have_content "Complete this scheme by adding a location using the"
expect(page).not_to have_link "‘locations’ tab"
end
end
end

Loading…
Cancel
Save