Browse Source

Add auth

pull/1752/head
Kat 3 years ago
parent
commit
260dcaa1d7
  1. 90
      spec/requests/duplicate_logs_controller_spec.rb

90
spec/requests/duplicate_logs_controller_spec.rb

@ -124,33 +124,85 @@ RSpec.describe DuplicateLogsController, type: :request do
end end
end end
context "with multiple duplicate sales logs" do context "when the user is from different organisation" do
let(:duplicate_logs) { create_list(:sales_log, 2, :completed) } let(:other_user) { create(:user) }
before do before do
allow(SalesLog).to receive(:duplicate_logs_for_organisation).and_return(duplicate_logs) allow(other_user).to receive(:need_two_factor_authentication?).and_return(false)
get "/sales-logs/#{sales_log.id}/duplicate-logs" sign_in other_user
end end
it "displays links to all the duplicate logs" do it "renders page not found" do
expect(page).to have_link("Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}") get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/sales-logs/#{duplicate_logs.first.id}") expect(response).to have_http_status(:not_found)
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/sales-logs/#{duplicate_logs.second.id}")
end end
end
it "displays check your answers for each log with correct questions" do context "when user is signed in" do
expect(page).to have_content("Owning organisation", count: 3) before do
expect(page).to have_content("Q1 - Sale completion date", count: 3) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
expect(page).to have_content("Q2 - Purchaser code", count: 3) sign_in user
expect(page).to have_content("Q20 - Lead buyer’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 21)
end end
it "displays buttons to delete" do context "with multiple duplicate lettings logs" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3) let(:duplicate_logs) { create_list(:lettings_log, 2, :completed) }
before do
allow(LettingsLog).to receive(:duplicate_logs_for_organisation).and_return(duplicate_logs)
get "/lettings-logs/#{lettings_log.id}/duplicate-logs"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{lettings_log.id}", href: "/lettings-logs/#{lettings_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/lettings-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/lettings-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Q1 - Stock owner", count: 3)
expect(page).to have_content("Q5 - Tenancy start date", count: 3)
expect(page).to have_content("Q7 - Tenant code", count: 3)
expect(page).to have_content("Q12 - Postcode", count: 3)
expect(page).to have_content("Q32 - Lead tenant’s age", count: 3)
expect(page).to have_content("Q33 - Lead tenant’s gender identity", count: 3)
expect(page).to have_content("Q37 - Lead tenant’s working situation", count: 3)
expect(page).to have_content("Household rent and charges", count: 3)
expect(page).to have_link("Change", count: 24)
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
end
end
context "with multiple duplicate sales logs" do
let(:duplicate_logs) { create_list(:sales_log, 2, :completed) }
before do
allow(SalesLog).to receive(:duplicate_logs_for_organisation).and_return(duplicate_logs)
get "/sales-logs/#{sales_log.id}/duplicate-logs"
end
it "displays links to all the duplicate logs" do
expect(page).to have_link("Log #{sales_log.id}", href: "/sales-logs/#{sales_log.id}")
expect(page).to have_link("Log #{duplicate_logs.first.id}", href: "/sales-logs/#{duplicate_logs.first.id}")
expect(page).to have_link("Log #{duplicate_logs.second.id}", href: "/sales-logs/#{duplicate_logs.second.id}")
end
it "displays check your answers for each log with correct questions" do
expect(page).to have_content("Owning organisation", count: 3)
expect(page).to have_content("Q1 - Sale completion date", count: 3)
expect(page).to have_content("Q2 - Purchaser code", count: 3)
expect(page).to have_content("Q20 - Lead buyer’s age", count: 3)
expect(page).to have_content("Q21 - Buyer 1’s gender identity", count: 3)
expect(page).to have_content("Q25 - Buyer 1's working situation", count: 3)
expect(page).to have_content("Q15 - Postcode", count: 3)
expect(page).to have_link("Change", count: 21)
end
it "displays buttons to delete" do
expect(page).to have_link("Keep this log and delete duplicates", count: 3)
end
end end
end end
end end

Loading…
Cancel
Save