|
|
@ -235,6 +235,18 @@ RSpec.describe SalesLogsController, type: :request do |
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/sales-logs/csv-download?codes_only=true") |
|
|
|
expect(page).to have_link("Download (CSV, codes only)", href: "/sales-logs/csv-download?codes_only=true") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when there are duplicate logs for this user" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
FactoryBot.create_list(:sales_log, 2, :duplicate, owning_organisation: user.organisation, created_by: user) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not show a notification banner even if there are duplicate logs for this user" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).not_to have_content "duplicate logs" |
|
|
|
|
|
|
|
expect(page).not_to have_link "Review logs" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when there are no logs in the database" do |
|
|
|
context "when there are no logs in the database" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
SalesLog.destroy_all |
|
|
|
SalesLog.destroy_all |
|
|
@ -566,6 +578,12 @@ RSpec.describe SalesLogsController, type: :request do |
|
|
|
expect(page).not_to have_link("Download (CSV, codes only)") |
|
|
|
expect(page).not_to have_link("Download (CSV, codes only)") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not show a notification banner even if there are duplicate logs for this user" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).not_to have_content "duplicate logs" |
|
|
|
|
|
|
|
expect(page).not_to have_link "Review logs" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when using a search query" do |
|
|
|
context "when using a search query" do |
|
|
|
let(:logs) { FactoryBot.create_list(:sales_log, 3, :completed, owning_organisation: user.organisation, created_by: user) } |
|
|
|
let(:logs) { FactoryBot.create_list(:sales_log, 3, :completed, owning_organisation: user.organisation, created_by: user) } |
|
|
|
let(:log_to_search) { FactoryBot.create(:sales_log, :completed, owning_organisation: user.organisation, created_by: user) } |
|
|
|
let(:log_to_search) { FactoryBot.create(:sales_log, :completed, owning_organisation: user.organisation, created_by: user) } |
|
|
@ -727,6 +745,63 @@ RSpec.describe SalesLogsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "and there are duplicate logs for this user" do |
|
|
|
|
|
|
|
let!(:duplicate_logs) { FactoryBot.create_list(:lettings_log, 2, :duplicate, owning_organisation: user.organisation, created_by: user) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "displays a notification banner with a link to review logs" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).to have_content "duplicate logs" |
|
|
|
|
|
|
|
expect(page).to have_link "Review logs", href: "/duplicate-logs?referrer=duplicate_logs_banner" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when there is one set of duplicates" do |
|
|
|
|
|
|
|
it "displays the correct copy in the banner" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).to have_content "There is 1 set of duplicate logs" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when the set is not editable" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
duplicate_logs.each do |log| |
|
|
|
|
|
|
|
log.startdate = Time.zone.now - 3.years |
|
|
|
|
|
|
|
log.save!(validate: false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "does not display the banner" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).not_to have_content "duplicate logs" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when there are multiple sets of duplicates" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
FactoryBot.create_list(:sales_log, 2, :duplicate, owning_organisation: user.organisation, created_by: user) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "displays the correct copy in the banner" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).to have_content "There are 2 sets of duplicate logs" |
|
|
|
|
|
|
|
expect(page).to have_link "Review logs", href: "/duplicate-logs?referrer=duplicate_logs_banner" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context "when one set is not editable" do |
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
log = duplicate_logs.first |
|
|
|
|
|
|
|
log.startdate = Time.zone.now - 3.years |
|
|
|
|
|
|
|
log.save!(validate: false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "displays the correct copy in the banner" do |
|
|
|
|
|
|
|
get sales_logs_path |
|
|
|
|
|
|
|
expect(page).to have_content "There is 1 set of duplicate logs" |
|
|
|
|
|
|
|
expect(page).to have_link "Review logs", href: "/duplicate-logs?referrer=duplicate_logs_banner" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|