diff --git a/app/helpers/log_list_helper.rb b/app/helpers/log_list_helper.rb index b3e967358..02152105d 100644 --- a/app/helpers/log_list_helper.rb +++ b/app/helpers/log_list_helper.rb @@ -1,7 +1,7 @@ module LogListHelper def display_delete_logs?(current_user, search_term, filter_type) if current_user.data_provider? - filter_selected?("user", "yours", filter_type) + filter_selected?("assigned_to", "you", filter_type) else any_filter_selected?(filter_type) || search_term.present? end diff --git a/spec/features/lettings_log_spec.rb b/spec/features/lettings_log_spec.rb index df881d824..cf96c8dc9 100644 --- a/spec/features/lettings_log_spec.rb +++ b/spec/features/lettings_log_spec.rb @@ -253,7 +253,7 @@ RSpec.describe "Lettings Log Features" do expect(page).not_to have_link "Delete logs" within ".app-filter" do check "status-in-progress-field" - choose "user-yours-field" + choose "assigned-to-you-field" click_button end expect(page).to have_selector "article.app-log-summary", count: 2 diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index e7c853ac2..e5a9e322a 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -194,7 +194,7 @@ RSpec.describe "User Features" do end check("years-2021-field") click_button("Apply filters") - expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?years[]=&years[]=2021&status[]=&assigned_to=all") + expect(page).to have_current_path("/organisations/#{org_id}/lettings-logs?years[]=&years[]=2021&status[]=&assigned_to=all&user=") expect(page).not_to have_link first_log.id.to_s, href: "/lettings-logs/#{first_log.id}" end end @@ -227,7 +227,7 @@ RSpec.describe "User Features" do end check("years-2021-field") click_button("Apply filters") - expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?years[]=&years[]=2021&status[]=&assigned_to=all") + expect(page).to have_current_path("/organisations/#{org_id}/sales-logs?years[]=&years[]=2021&status[]=&assigned_to=all&user=") expect(page).not_to have_link first_log.id.to_s, href: "/sales-logs/#{first_log.id}" end end diff --git a/spec/features/sales_log_spec.rb b/spec/features/sales_log_spec.rb index d39df431b..d6ff88076 100644 --- a/spec/features/sales_log_spec.rb +++ b/spec/features/sales_log_spec.rb @@ -58,7 +58,7 @@ RSpec.describe "Sales Log Features" do expect(page).not_to have_link "Delete logs" within ".app-filter" do - choose "user-yours-field" + choose "assigned-to-you-field" click_button end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index 62e185b2e..cc314e8dd 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -724,10 +724,10 @@ RSpec.describe "User Features" do expect(page).to have_field("organisation-field", with: "") find("#organisation-field").click.native.send_keys("F", "i", "l", "t", :down, :enter) click_button("Apply filters") - expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&user=all&organisation_select=specific_org&organisation=#{organisation.id}") + expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&organisation_select=specific_org&organisation=#{organisation.id}") choose("organisation-select-all-field", allow_label_click: true) click_button("Apply filters") - expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&user=all&organisation_select=all") + expect(page).to have_current_path("/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&assigned_to=all&organisation_select=all") end end end diff --git a/spec/helpers/filters_helper_spec.rb b/spec/helpers/filters_helper_spec.rb index 65d0c2c6b..ab837bed6 100644 --- a/spec/helpers/filters_helper_spec.rb +++ b/spec/helpers/filters_helper_spec.rb @@ -16,8 +16,9 @@ RSpec.describe FiltersHelper do context "when looking at the all value" do it "returns true if no filters have been set yet" do - expect(filter_selected?("user", :all, "lettings_logs")).to be true - expect(filter_selected?("user", :yours, "lettings_logs")).to be false + expect(filter_selected?("assigned_to", :all, "lettings_logs")).to be true + expect(filter_selected?("assigned_to", :you, "lettings_logs")).to be false + expect(filter_selected?("assigned_to", :specific_user, "lettings_logs")).to be false end end end @@ -60,7 +61,7 @@ RSpec.describe FiltersHelper do context "when the specific organisation filter is not set" do before do - session[:lettings_logs_filters] = { "status" => [""], "years" => [""], "user" => "all" }.to_json + session[:lettings_logs_filters] = { "status" => [""], "years" => [""], "assigned_to" => "all" }.to_json end it "marks the all options as checked" do @@ -85,15 +86,15 @@ RSpec.describe FiltersHelper do end context "when organisation and user are set to all" do - let(:filters) { { "organisation_select" => "all", "user" => "all" } } + let(:filters) { { "organisation_select" => "all", "assigned_to" => "all" } } it "returns false" do expect(result).to be_falsey end end - context "when user is set to 'yours'" do - let(:filters) { { "user" => "yours" } } + context "when user is set to 'you'" do + let(:filters) { { "user" => "you" } } it "returns true" do expect(result).to be true @@ -135,7 +136,7 @@ RSpec.describe FiltersHelper do context "when a range of filters is applied" do let(:filters) do { - "user" => "all", + "assigned_to" => "all", "status" => %w[in_progress completed], "years" => [""], "organisation" => 2, @@ -218,7 +219,7 @@ RSpec.describe FiltersHelper do context "when no filters are applied" do let(:filters) do { - "user" => "all", + "assigned_to" => "all", "status" => [""], "years" => [""], "organisation" => "all", @@ -233,7 +234,7 @@ RSpec.describe FiltersHelper do context "when a range of filters is applied" do let(:filters) do { - "user" => "all", + "assigned_to" => "all", "status" => %w[in_progress completed], "years" => [""], "organisation" => 2, diff --git a/spec/jobs/email_csv_job_spec.rb b/spec/jobs/email_csv_job_spec.rb index f8677e493..61d5dca74 100644 --- a/spec/jobs/email_csv_job_spec.rb +++ b/spec/jobs/email_csv_job_spec.rb @@ -12,7 +12,7 @@ describe EmailCsvJob do let(:sales_log_csv_service) { instance_double(Csv::SalesLogCsvService) } let(:lettings_log_csv_service) { instance_double(Csv::LettingsLogCsvService) } let(:search_term) { "meaning" } - let(:filters) { { "user" => "yours", "status" => %w[in_progress] } } + let(:filters) { { "user" => "you", "status" => %w[in_progress] } } let(:all_orgs) { false } let(:organisation) { build(:organisation) } let(:codes_only_export) { true } diff --git a/spec/models/forms/delete_logs_form_spec.rb b/spec/models/forms/delete_logs_form_spec.rb index adad36d90..092566ee0 100644 --- a/spec/models/forms/delete_logs_form_spec.rb +++ b/spec/models/forms/delete_logs_form_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Forms::DeleteLogsForm do { "years" => [""], "status" => ["", "completed"], - "user" => "yours", + "user" => "you", } end let(:selected_ids) { [visible_logs.first.id] } diff --git a/spec/models/lettings_log_spec.rb b/spec/models/lettings_log_spec.rb index 6a965f1d5..ef09643fb 100644 --- a/spec/models/lettings_log_spec.rb +++ b/spec/models/lettings_log_spec.rb @@ -2786,15 +2786,11 @@ RSpec.describe LettingsLog do end it "allows filtering on current user" do - expect(described_class.filter_by_user(%w[you]).count).to eq(2) + expect(described_class.filter_by_user(created_by_user.id.to_s).count).to eq(2) end it "returns all logs when all logs selected" do - expect(described_class.filter_by_user(%w[all]).count).to eq(3) - end - - it "returns all logs when all and your users selected" do - expect(described_class.filter_by_user(%w[all you]).count).to eq(3) + expect(described_class.filter_by_user(nil).count).to eq(3) end end diff --git a/spec/requests/delete_logs_controller_spec.rb b/spec/requests/delete_logs_controller_spec.rb index 9a90a9d87..9f94ebe1c 100644 --- a/spec/requests/delete_logs_controller_spec.rb +++ b/spec/requests/delete_logs_controller_spec.rb @@ -22,7 +22,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get lettings_logs_path(logs_filters) # adds the filters to the session @@ -71,7 +71,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get lettings_logs_path(logs_filters) # adds the filters to the session @@ -262,7 +262,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get sales_logs_path(logs_filters) # adds the filters to the session @@ -311,7 +311,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get sales_logs_path(logs_filters) # adds the filters to the session @@ -506,7 +506,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get lettings_logs_path(logs_filters) # adds the filters to the session @@ -555,7 +555,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get lettings_logs_path(logs_filters) # adds the filters to the session @@ -731,7 +731,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get sales_logs_path(logs_filters) # adds the filters to the session @@ -780,7 +780,7 @@ RSpec.describe "DeleteLogs", type: :request do logs_filters = { "years" => [""], "status" => ["", "in_progress"], - "user" => "all", + "assigned_to" => "all", } get sales_logs_path(logs_filters) # adds the filters to the session diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb index 46f4027a9..9f86a9836 100644 --- a/spec/requests/lettings_logs_controller_spec.rb +++ b/spec/requests/lettings_logs_controller_spec.rb @@ -801,7 +801,7 @@ RSpec.describe LettingsLogsController, type: :request do context "when the support user has filtered by organisation, then switches back to all organisations" do it "shows all organisations" do - get "http://localhost:3000/lettings-logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&user=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: {} expect(page).to have_content(tenant_code_1) expect(page).to have_content(tenant_code_2) end