Browse Source

Add tests to merging organisations

CLDC-2055-which-organisations-are-merging
Kat 2 years ago
parent
commit
6e610d0d36
  1. 9
      app/views/merge/organisations.html.erb
  2. 42
      spec/requests/organisations_controller_spec.rb

9
app/views/merge/organisations.html.erb

@ -1,12 +1,12 @@
<% title = "Tell us if your organisation is merging" %> <% title = "Tell us if your organisation is merging" %>
<% content_for :title, title %> <% content_for :title, title %>
<%= govuk_back_link href: organisation_path %> <%= govuk_back_link href: merge_start_organisation_path %>
<h2 class="govuk-heading-l">Tell us if your organisation is merging</h2> <h2 class="govuk-heading-l">Tell us if your organisation is merging</h2>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop"> <div class="govuk-grid-column-two-thirds-from-desktop">
<p class="govuk-body">Start typing to search for your managing agent</p> <p class="govuk-body">Which organisations are merging?</p>
<%= form_with model: @merge, url: merge_organisations_organisation_path, method: :patch do |f| %> <%= form_with model: @merge, url: merge_organisations_organisation_path, method: :patch do |f| %>
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
@ -35,7 +35,10 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<%= govuk_details(summary_text: "Can't find the managing agent you're looking for?") do %>
<p>List other organisations that are part of the merge but not registered on CORE.</li>
<% end %>
<% end %> <% end %>
<%= govuk_button_link_to "Continue", merge_organisations_organisation_path, button: true %> <%= govuk_button_link_to "Continue", "#", button: true %>
</div> </div>

42
spec/requests/organisations_controller_spec.rb

@ -443,6 +443,7 @@ RSpec.describe OrganisationsController, type: :request do
describe "#merge" do describe "#merge" do
context "with an organisation that the user belongs to" do context "with an organisation that the user belongs to" do
context "when on the start merge page" do
before do before do
get "/organisations/#{organisation.id}/merge/start", headers:, params: {} get "/organisations/#{organisation.id}/merge/start", headers:, params: {}
end end
@ -460,6 +461,47 @@ RSpec.describe OrganisationsController, type: :request do
end end
end end
context "when on the merging organisations page" do
let(:params) { {} }
before do
organisation.update!(name: "Name 1")
unauthorised_organisation.update!(name: "Name 2")
get "/organisations/#{organisation.id}/merge/organisations", headers:, params:
end
it "shows the correct content" do
expect(page).to have_content("Which organisations are merging?")
end
it "has a correct back link" do
expect(page).to have_link("Back", href: "/organisations/#{organisation.id}/merge/start")
end
it "has a correct Continue button" do
expect(page).to have_link("Continue", href: "#")
end
context "and the page is loaded for the first time" do
let(:params) { { merge: { merging_organisation: nil } } }
it "shows current organisation in the list of merging organisations" do
expect(page).to have_css("table tr", text: organisation.name)
expect(page).not_to have_css("table tr", text: unauthorised_organisation.name)
end
end
context "and the page is loaded after adding a new merging organisation" do
let(:params) { { merge: { merging_organisations: organisation.id, merging_organisation: unauthorised_organisation.id } } }
it "shows current organisation and added organisation in the list of merging organisations" do
expect(page).to have_css("table tr", text: organisation.name)
expect(page).to have_css("table tr", text: unauthorised_organisation.name)
end
end
end
end
context "with organisation that are not in scope for the user, i.e. that they do not belong to" do context "with organisation that are not in scope for the user, i.e. that they do not belong to" do
before do before do
get "/organisations/#{unauthorised_organisation.id}/merge/start", headers:, params: {} get "/organisations/#{unauthorised_organisation.id}/merge/start", headers:, params: {}

Loading…
Cancel
Save