Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.6 KiB

CLDC-2290 implement delete multiple logs story (#1657) * add a button to the logs list to delete multiple logs style and position of button helpers for displaying the button conditionally depending on user role and what filters and search are active * correct indentation from 4 spaces to 2 in view file * test appearance of delete logs button on index page for lettings logs * write a happy path feature test for the entire journey * create basic tests for the view component for listing logs to delete * create request tests for the GET delete-logs path * create request tests for the GET delete-logs-confirmation path * create request tests for the DELETE delete-logs path * comprehensive reworking after code review ensure that we are not passing lists of ids through params in the query string, risking overflowing the maximum URL length, adjust tests accordingly, do not attempt to reuse the same table for sales and lettings * alter config to allow creating controllers from the command line with associated spec files that matches how we test * extract controller methods and associated tests to do with the delete logs feature into their own controller, amend routes accordingly * implement same work for sales as for lettings * implement the story for lettings and sales logs under the organisation tab routing and controller methods testing for deleting sales logs, lettings or sales logs for an organisation move storage of relevant routes inside the form object as a comprehensive view model * merge the delete pages for lettings logs and sales logs, add to the tests for the lettings page to test sales specific content * minor refactor to delete logs controller: ensure session filters are only fetched from teh session when needed and extract discard logs method to private method * extract tables for lettings and sales to own partials * refactor delete logs controller after tech review improve the private method that builds the form object so that it has the flexibility to do so for all controller methods ensure that the search term is passed to the delete logs controller when navigating through the organisations tab ensure that noly logs for that organisation are displayed when navigating to delete logs through the organisations tab * remove unnecessary untested arguments * test new helper methods * implement dirty fiddle to get the checkboxes smaller and also not misaligned * ensure delete logs button is always visible on log lists when in the organisations tab * minor linting corrections * revert change, causing errors and outside the scope of this ticket * simplify tests for whether delete logs button appears on index page * replicate request specs from lettings for sales and organisations controllers * minor refactor of lettings log feature spec setup, replicate happy path for sales * minor refactors after rebasing onto Nat's work * temp * write tests for the delete logs form object * lint: add new line at end of file * respond to PO feedback the log id in the delte logs table should be a link to the log the delete logs button should be visible when the user is in a bulk upload journey updated associated tests
2 years ago
require "rails_helper"
RSpec.describe LogListHelper, type: :helper do
include FiltersHelper
describe "#display_delete_logs?" do
let(:search_term) { nil }
let(:filter_type) { "lettings_logs" }
context "when logged in as a data provider" do
let(:result) { display_delete_logs?(user, search_term, filter_type) }
let(:user) { create(:user) }
it "returns false if no filters or search are set" do
allow(self).to receive(:filter_selected?).and_return false
expect(result).to be false
end
it "returns true if the user filter is set to 'yours'" do
allow(self).to receive(:filter_selected?).with("user", "yours", filter_type).and_return true
expect(result).to be true
end
it "returns false if any filters other than the user filter are set" do
allow(self).to receive(:filter_selected?).and_return true
allow(self).to receive(:filter_selected?).with("user", "yours", filter_type).and_return false
expect(result).to be false
end
context "when there is a search term present" do
let(:search_term) { "word" }
it "still returns false as long as the user filter is not set to yours" do
allow(self).to receive(:filter_selected?).with("user", "yours", filter_type).and_return false
expect(result).to be false
end
end
end
context "when logged in as a support user or data coordinator" do
let(:support_user) { create(:user, :support) }
let(:data_coordinator) { create(:user, :data_coordinator) }
let(:support_result) { display_delete_logs?(support_user, search_term, filter_type) }
let(:coordinator_result) { display_delete_logs?(data_coordinator, search_term, filter_type) }
let(:results) { [support_result, coordinator_result] }
it "returns false if no filters or search are set" do
allow(self).to receive(:any_filter_selected?).and_return false
expect(results).to all be false
end
it "returns true if any filter is set" do
allow(self).to receive(:any_filter_selected?).and_return true
expect(results).to all be true
end
context "when there is a search term present" do
let(:search_term) { "word" }
it "returns true if no filter is selected" do
allow(self).to receive(:any_filter_selected?).and_return false
expect(results).to all be true
end
it "returns true if any filter is selected" do
allow(self).to receive(:any_filter_selected?).and_return true
expect(results).to all be true
end
end
end
end
end