|
|
|
@ -246,19 +246,42 @@ RSpec.describe SchemesController, type: :request do |
|
|
|
context "when looking at scheme details" do |
|
|
|
context "when looking at scheme details" do |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
|
|
|
|
let(:add_deactivations) { scheme.scheme_deactivation_periods << scheme_deactivation_period } |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
|
|
|
|
add_deactivations |
|
|
|
|
|
|
|
scheme.save! |
|
|
|
get "/schemes/#{scheme.id}" |
|
|
|
get "/schemes/#{scheme.id}" |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "with active scheme" do |
|
|
|
context "with active scheme" do |
|
|
|
|
|
|
|
let(:add_deactivations) {} |
|
|
|
|
|
|
|
|
|
|
|
it "renders deactivate this scheme" do |
|
|
|
it "renders deactivate this scheme" do |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(page).to have_link("Deactivate this scheme", href: "/schemes/#{scheme.id}/new-deactivation") |
|
|
|
expect(page).to have_link("Deactivate this scheme", href: "/schemes/#{scheme.id}/new-deactivation") |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with deactivated scheme" do |
|
|
|
|
|
|
|
let(:scheme_deactivation_period) { FactoryBot.create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 9)) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders reactivate this scheme" do |
|
|
|
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
|
|
|
expect(page).to have_link("Reactivate this scheme", href: "/schemes/#{scheme.id}/reactivate") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "with scheme that's deactivating soon" do |
|
|
|
|
|
|
|
let(:scheme_deactivation_period) { FactoryBot.create(:scheme_deactivation_period, deactivation_date: Time.zone.local(2022, 10, 12)) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "renders reactivate this scheme" do |
|
|
|
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
|
|
|
expect(page).to have_link("Reactivate this scheme", href: "/schemes/#{scheme.id}/reactivate") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -1743,7 +1766,6 @@ RSpec.describe SchemesController, type: :request do |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
let(:startdate) { Time.utc(2021, 1, 2) } |
|
|
|
|
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 10) } |
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 10) } |
|
|
|
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location:, scheme:, startdate:, owning_organisation: user.organisation) } |
|
|
|
let!(:lettings_log) { FactoryBot.create(:lettings_log, :sh, location:, scheme:, startdate:, owning_organisation: user.organisation) } |
|
|
|
let(:startdate) { Time.utc(2022, 10, 11) } |
|
|
|
let(:startdate) { Time.utc(2022, 10, 11) } |
|
|
|
@ -1787,6 +1809,7 @@ RSpec.describe SchemesController, type: :request do |
|
|
|
follow_redirect! |
|
|
|
follow_redirect! |
|
|
|
follow_redirect! |
|
|
|
follow_redirect! |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
|
|
|
expect(page).to have_css(".govuk-notification-banner.govuk-notification-banner--success") |
|
|
|
scheme.reload |
|
|
|
scheme.reload |
|
|
|
expect(scheme.scheme_deactivation_periods.count).to eq(1) |
|
|
|
expect(scheme.scheme_deactivation_periods.count).to eq(1) |
|
|
|
expect(scheme.scheme_deactivation_periods.first.deactivation_date).to eq(deactivation_date) |
|
|
|
expect(scheme.scheme_deactivation_periods.first.deactivation_date).to eq(deactivation_date) |
|
|
|
|