Browse Source

feat: update tests to reflect sales logs shouldn't exist in new service before 2022

pull/1232/head
natdeanlewissoftwire 3 years ago
parent
commit
1d62ee5182
  1. 26
      spec/requests/sales_logs_controller_spec.rb

26
spec/requests/sales_logs_controller_spec.rb

@ -186,16 +186,16 @@ RSpec.describe SalesLogsController, type: :request do
end end
context "with year filter" do context "with year filter" do
let!(:sales_log_2021) do let!(:sales_log_2022) do
FactoryBot.create(:sales_log, :in_progress, FactoryBot.create(:sales_log, :in_progress,
owning_organisation: organisation, owning_organisation: organisation,
saledate: Time.zone.local(2022, 3, 1), saledate: Time.zone.local(2022, 4, 1),
managing_organisation: organisation) managing_organisation: organisation)
end end
let!(:sales_log_2022) do let!(:sales_log_2023) do
sales_log = FactoryBot.build(:sales_log, :completed, sales_log = FactoryBot.build(:sales_log, :completed,
owning_organisation: organisation, owning_organisation: organisation,
saledate: Time.zone.local(2022, 12, 1), saledate: Time.zone.local(2023, 1, 1),
managing_organisation: organisation) managing_organisation: organisation)
sales_log.save!(validate: false) sales_log.save!(validate: false)
sales_log sales_log
@ -203,14 +203,14 @@ RSpec.describe SalesLogsController, type: :request do
it "shows sales logs for multiple selected years" do it "shows sales logs for multiple selected years" do
get "/sales-logs?years[]=2021&years[]=2022", headers: headers, params: {} get "/sales-logs?years[]=2021&years[]=2022", headers: headers, params: {}
expect(page).to have_link(sales_log_2021.id.to_s)
expect(page).to have_link(sales_log_2022.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s)
expect(page).to have_link(sales_log_2023.id.to_s)
end end
it "shows sales logs for one selected year" do it "shows sales logs for one selected year" do
get "/sales-logs?years[]=2021", headers: headers, params: {} get "/sales-logs?years[]=2022", headers: headers, params: {}
expect(page).to have_link(sales_log_2021.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s)
expect(page).not_to have_link(sales_log_2022.id.to_s) expect(page).to have_link(sales_log_2023.id.to_s)
end end
end end
@ -223,24 +223,24 @@ RSpec.describe SalesLogsController, type: :request do
Timecop.unfreeze Timecop.unfreeze
end end
let!(:sales_log_2021) do let!(:sales_log_2022) do
FactoryBot.create(:sales_log, :completed, FactoryBot.create(:sales_log, :completed,
owning_organisation: organisation, owning_organisation: organisation,
saledate: Time.zone.local(2022, 3, 1), saledate: Time.zone.local(2022, 4, 1),
managing_organisation: organisation, managing_organisation: organisation,
created_by: user) created_by: user)
end end
let!(:sales_log_2022) do let!(:sales_log_2023) do
FactoryBot.create(:sales_log, FactoryBot.create(:sales_log,
owning_organisation: organisation, owning_organisation: organisation,
saledate: Time.zone.local(2022, 12, 1), saledate: Time.zone.local(2023, 1, 1),
managing_organisation: organisation, managing_organisation: organisation,
created_by: user) created_by: user)
end end
it "shows sales logs for multiple selected statuses and years" do it "shows sales logs for multiple selected statuses and years" do
get "/sales-logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {} get "/sales-logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {}
expect(page).to have_link(sales_log_2021.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s)
expect(page).to have_link(sales_log_2022.id.to_s) expect(page).to have_link(sales_log_2022.id.to_s)
end end
end end

Loading…
Cancel
Save