|
|
|
@ -242,6 +242,46 @@ RSpec.describe SchemesController, type: :request do
|
|
|
|
|
expect(response).to have_http_status(:not_found) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when looking at scheme details" do |
|
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
|
sign_in user |
|
|
|
|
scheme.deactivation_date = deactivation_date |
|
|
|
|
scheme.save! |
|
|
|
|
get "/schemes/#{scheme.id}" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with active scheme" do |
|
|
|
|
let(:deactivation_date) { nil } |
|
|
|
|
|
|
|
|
|
it "renders deactivate this scheme" do |
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).to have_link("Deactivate this scheme", href: "/schemes/#{scheme.id}/deactivate") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with deactivated scheme" do |
|
|
|
|
let(:deactivation_date) { Time.utc(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(:deactivation_date) { Time.utc(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 |
|
|
|
|
|
|
|
|
|
context "when signed in as a support user" do |
|
|
|
@ -1724,7 +1764,6 @@ RSpec.describe SchemesController, type: :request do
|
|
|
|
|
context "when signed in as a data coordinator" do |
|
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
|
let(:startdate) { Time.utc(2021, 1, 2) } |
|
|
|
|
let(:deactivation_date) { Time.utc(2022, 10, 10) } |
|
|
|
|
|
|
|
|
@ -1820,68 +1859,4 @@ RSpec.describe SchemesController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "#show" do |
|
|
|
|
context "when not signed in" do |
|
|
|
|
it "redirects to the sign in page" do |
|
|
|
|
get "/schemes/1" |
|
|
|
|
expect(response).to redirect_to("/account/sign-in") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when signed in as a data provider" do |
|
|
|
|
let(:user) { FactoryBot.create(:user) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
sign_in user |
|
|
|
|
get "/schemes/1" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "returns 401 unauthorized" do |
|
|
|
|
request |
|
|
|
|
expect(response).to have_http_status(:unauthorized) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when signed in as a data coordinator" do |
|
|
|
|
let(:user) { FactoryBot.create(:user, :data_coordinator) } |
|
|
|
|
let!(:scheme) { FactoryBot.create(:scheme, owning_organisation: user.organisation) } |
|
|
|
|
let!(:location) { FactoryBot.create(:location, scheme:) } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
Timecop.freeze(Time.utc(2022, 10, 10)) |
|
|
|
|
sign_in user |
|
|
|
|
scheme.deactivation_date = deactivation_date |
|
|
|
|
scheme.save! |
|
|
|
|
get "/schemes/#{scheme.id}" |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with active scheme" do |
|
|
|
|
let(:deactivation_date) { nil } |
|
|
|
|
|
|
|
|
|
it "renders deactivate this scheme" do |
|
|
|
|
expect(response).to have_http_status(:ok) |
|
|
|
|
expect(page).to have_link("Deactivate this scheme", href: "/schemes/#{scheme.id}/deactivate") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "with deactivated scheme" do |
|
|
|
|
let(:deactivation_date) { Time.utc(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(:deactivation_date) { Time.utc(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 |
|
|
|
|