Browse Source

Show full list of logs for support users viewing organisation after merge (#2897)

pull/2905/head
Manny Dinssa 2 weeks ago committed by GitHub
parent
commit
e3b8a6fea4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/controllers/organisations_controller.rb
  2. 62
      spec/requests/organisations_controller_spec.rb

4
app/controllers/organisations_controller.rb

@ -176,7 +176,7 @@ class OrganisationsController < ApplicationController
end
def lettings_logs
organisation_logs = LettingsLog.visible.filter_by_organisation(@organisation).filter_by_years_or_nil(FormHandler.instance.years_of_available_lettings_forms)
organisation_logs = LettingsLog.visible.filter_by_organisation(@organisation.absorbed_organisations + [@organisation]).filter_by_years_or_nil(FormHandler.instance.years_of_available_lettings_forms)
unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters)
@search_term = search_term
@ -206,7 +206,7 @@ class OrganisationsController < ApplicationController
end
def sales_logs
organisation_logs = SalesLog.visible.filter_by_organisation(@organisation).filter_by_years_or_nil(FormHandler.instance.years_of_available_sales_forms)
organisation_logs = SalesLog.visible.filter_by_organisation(@organisation.absorbed_organisations + [@organisation]).filter_by_years_or_nil(FormHandler.instance.years_of_available_sales_forms)
unpaginated_filtered_logs = filter_manager.filtered_logs(organisation_logs, search_term, session_filters)
respond_to do |format|

62
spec/requests/organisations_controller_spec.rb

@ -1307,6 +1307,37 @@ RSpec.describe OrganisationsController, type: :request do
end
end
end
context "when the organisation has absorbed another organisation" do
let(:absorbed_organisation) { create(:organisation) }
let(:number_of_absorbed_org_lettings_logs) { 3 }
let(:lettings_log) { create(:lettings_log, owning_organisation: absorbed_organisation) }
before do
organisation.update!(absorbed_organisations: [absorbed_organisation])
create_list(:lettings_log, number_of_absorbed_org_lettings_logs, owning_organisation: absorbed_organisation)
end
context "without search query" do
before do
get "/organisations/#{organisation.id}/lettings-logs", headers:, params: {}
end
it "returns a count of all logs for both the merging and absorbed organisations" do
expect(page).to have_content("#{total_number_of_org1_logs + number_of_absorbed_org_lettings_logs} total logs")
end
end
context "when searching for an absorbing organisation by ID" do
before do
get "/organisations/#{organisation.id}/lettings-logs?search=#{lettings_log.id}", headers:, params: {}
end
it "displays the lettings log from the absorbed organisation" do
expect(page).to have_content(lettings_log.id)
end
end
end
end
context "when viewing a specific organisation's sales logs" do
@ -1398,6 +1429,37 @@ RSpec.describe OrganisationsController, type: :request do
end
end
end
context "when the organisation has absorbed another organisation" do
let(:absorbed_organisation) { create(:organisation) }
let(:number_of_absorbed_org_sales_logs) { 3 }
let(:sales_log) { create(:sales_log, owning_organisation: absorbed_organisation) }
before do
organisation.update!(absorbed_organisations: [absorbed_organisation])
create_list(:sales_log, number_of_absorbed_org_sales_logs, owning_organisation: absorbed_organisation)
end
context "without search query" do
before do
get "/organisations/#{organisation.id}/sales-logs", headers:, params: {}
end
it "returns a count of all logs for both the merging and absorbed organisations" do
expect(page).to have_content("#{number_of_org1_sales_logs + number_of_absorbed_org_sales_logs} total logs")
end
end
context "when searching for an absorbing organisation by ID" do
before do
get "/organisations/#{organisation.id}/sales-logs?search=#{sales_log.id}", headers:, params: {}
end
it "displays the sales log from the absorbed organisation" do
expect(page).to have_content(sales_log.id)
end
end
end
end
context "when viewing a specific organisation's users" do

Loading…
Cancel
Save