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. 62
      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" %>
<% 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>
<div class="govuk-grid-row">
<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| %>
<%= f.govuk_error_summary %>
@ -35,7 +35,10 @@
<% 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 %>
<%= govuk_button_link_to "Continue", merge_organisations_organisation_path, button: true %>
<%= govuk_button_link_to "Continue", "#", button: true %>
</div>

62
spec/requests/organisations_controller_spec.rb

@ -443,20 +443,62 @@ RSpec.describe OrganisationsController, type: :request do
describe "#merge" do
context "with an organisation that the user belongs to" do
before do
get "/organisations/#{organisation.id}/merge/start", headers:, params: {}
end
context "when on the start merge page" do
before do
get "/organisations/#{organisation.id}/merge/start", headers:, params: {}
end
it "shows the correct content" do
expect(page).to have_content("Tell us if your organisation is merging")
end
it "shows the correct content" do
expect(page).to have_content("Tell us if your organisation is merging")
end
it "has a correct back link" do
expect(page).to have_link("Back", href: "/organisations/#{organisation.id}")
it "has a correct back link" do
expect(page).to have_link("Back", href: "/organisations/#{organisation.id}")
end
it "has a correct start now button" do
expect(page).to have_link("Start now", href: "/organisations/#{organisation.id}/merge/organisations")
end
end
it "has a correct start now button" do
expect(page).to have_link("Start now", href: "/organisations/#{organisation.id}/merge/organisations")
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

Loading…
Cancel
Save