Browse Source

providers cannot see add a location button

pull/1642/head
Phil Lee 3 years ago
parent
commit
e89fdc4466
  1. 4
      app/views/locations/index.html.erb
  2. 42
      spec/views/locations/index.html.erb_spec.rb

4
app/views/locations/index.html.erb

@ -64,12 +64,12 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<% if user_can_edit_scheme?(current_user, @scheme) %>
<% if LocationPolicy.new(current_user, Location).create? %>
<%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %> <%= govuk_button_to "Add a location", scheme_locations_path(@scheme), method: "post", secondary: true %>
<% end %> <% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
<%= govuk_table do |table| %> <%= govuk_table do |table| %>
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>

42
spec/views/locations/index.html.erb_spec.rb

@ -0,0 +1,42 @@
require "rails_helper"
RSpec.describe "locations/index.html.erb" do
context "when a data provider" do
let(:user) { create(:user) }
let(:scheme) do
instance_double(
Scheme,
owning_organisation: user.organisation,
id: 1,
service_name: "some name",
id_to_display: "S1",
sensitive: false,
scheme_type: "some type",
registered_under_care_act: false,
arrangement_type: "some other type",
primary_client_group: false,
has_other_client_group: false,
secondary_client_group: false,
support_type: "some support type",
intended_stay: "some intended stay",
available_from: 1.week.ago,
scheme_deactivation_periods: [],
status: :active,
)
end
it "does not see add a location button" do
assign(:pagy, Pagy.new(count: 0, page: 1))
assign(:scheme, scheme)
assign(:locations, [])
allow(view).to receive(:current_user).and_return(user)
allow(SearchComponent).to receive(:new).and_return(inline: "")
render
expect(rendered).not_to have_content("Add a location")
end
end
end
Loading…
Cancel
Save