Browse Source

testing primary client group update via check answers page

pull/671/head
JG 3 years ago
parent
commit
eca7d38cbe
  1. 20
      spec/requests/schemes_controller_spec.rb

20
spec/requests/schemes_controller_spec.rb

@ -625,6 +625,8 @@ RSpec.describe SchemesController, type: :request do
context "when signed in as a data coordinator" do context "when signed in as a data coordinator" do
let(:user) { FactoryBot.create(:user, :data_coordinator) } let(:user) { FactoryBot.create(:user, :data_coordinator) }
let(:scheme_to_update) { FactoryBot.create(:scheme, :organisation => user.organisation) } let(:scheme_to_update) { FactoryBot.create(:scheme, :organisation => user.organisation) }
context "when updating primary client group" do
let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group" } } } let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group" } } }
before do before do
@ -632,7 +634,7 @@ RSpec.describe SchemesController, type: :request do
patch "/schemes/#{scheme_to_update.id}", params: patch "/schemes/#{scheme_to_update.id}", params:
end end
it "renders the primary client group after successful update" do it "renders confirm secondary group after successful update" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("Does this scheme provide for another client group?") expect(page).to have_content("Does this scheme provide for another client group?")
@ -642,6 +644,22 @@ RSpec.describe SchemesController, type: :request do
follow_redirect! follow_redirect!
expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs") expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs")
end end
context "when updating from check answers page" do
let(:params) { { scheme: { primary_client_group: "Homeless families with support needs", page: "primary-client-group", check_answers: "true" } } }
it "renders check answers page after successful update" do
follow_redirect!
expect(response).to have_http_status(:ok)
expect(page).to have_content("Check your changes before updating this scheme")
end
it "updates a scheme with valid params" do
follow_redirect!
expect(scheme_to_update.reload.primary_client_group).to eq("Homeless families with support needs")
end
end
end
end end
end end
end end

Loading…
Cancel
Save