Browse Source

feat: add new test

pull/1775/head
natdeanlewissoftwire 3 years ago
parent
commit
a49dadd28d
  1. 10
      spec/requests/lettings_logs_controller_spec.rb

10
spec/requests/lettings_logs_controller_spec.rb

@ -774,7 +774,7 @@ RSpec.describe LettingsLogsController, type: :request do
let(:tenant_code_2) { "TC8745" } let(:tenant_code_2) { "TC8745" }
before do before do
FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_1, tenancycode: tenant_code_1) FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_1, tenancycode: tenant_code_1, created_by: user)
FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_2, tenancycode: tenant_code_2) FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_2, tenancycode: tenant_code_2)
allow(user).to receive(:need_two_factor_authentication?).and_return(false) allow(user).to receive(:need_two_factor_authentication?).and_return(false)
sign_in user sign_in user
@ -799,6 +799,14 @@ RSpec.describe LettingsLogsController, type: :request do
end end
end end
context "when filtering by a specific user" do
it "only show the selected user's logs" do
get "/lettings-logs?assigned_to=you&user=#{user.id}", headers:, params: {}
expect(page).to have_content(tenant_code_1)
expect(page).not_to have_content(tenant_code_2)
end
end
context "when the support user has filtered by organisation, then switches back to all organisations" do context "when the support user has filtered by organisation, then switches back to all organisations" do
it "shows all organisations" do it "shows all organisations" do
get "http://localhost:3000/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&organisation_select=all&organisation=#{org_1.id}", headers:, params: {} get "http://localhost:3000/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&organisation_select=all&organisation=#{org_1.id}", headers:, params: {}

Loading…
Cancel
Save