|
|
|
@ -321,31 +321,56 @@ RSpec.describe CaseLogsController, type: :request do
|
|
|
|
|
|
|
|
|
|
context "when using a search query" do |
|
|
|
|
let(:logs) { FactoryBot.create_list(:case_log, 3, :completed, owning_organisation: user.organisation) } |
|
|
|
|
let(:log_to_search) { FactoryBot.create(:case_log, :completed, owning_organisation: user.organisation) } |
|
|
|
|
|
|
|
|
|
it "has search results in the title" do |
|
|
|
|
get "/logs?search=#{log_to_search.id}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content("Logs (search results for ‘#{log_to_search.id}’) - Submit social housing and sales data (CORE) - GOV.UK") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows case logs matching the id" do |
|
|
|
|
get "/logs?search=#{logs[0].id}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(logs[0].id) |
|
|
|
|
expect(page).not_to have_content(logs[1].id) |
|
|
|
|
expect(page).not_to have_content(logs[2].id) |
|
|
|
|
get "/logs?search=#{log_to_search.id}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(log_to_search.id) |
|
|
|
|
logs.each do |log| |
|
|
|
|
expect(page).not_to have_content(log.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows case logs matching the tenancy code" do |
|
|
|
|
get "/logs?search=#{logs[0].tenancy_code}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(logs[0].id) |
|
|
|
|
expect(page).not_to have_content(logs[1].id) |
|
|
|
|
expect(page).not_to have_content(logs[2].id) |
|
|
|
|
get "/logs?search=#{log_to_search.tenancy_code}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(log_to_search.id) |
|
|
|
|
logs.each do |log| |
|
|
|
|
expect(page).not_to have_content(log.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "shows case logs matching the property reference" do |
|
|
|
|
get "/logs?search=#{logs[0].propcode}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(logs[0].id) |
|
|
|
|
expect(page).not_to have_content(logs[1].id) |
|
|
|
|
expect(page).not_to have_content(logs[2].id) |
|
|
|
|
get "/logs?search=#{log_to_search.propcode}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(log_to_search.id) |
|
|
|
|
logs.each do |log| |
|
|
|
|
expect(page).not_to have_content(log.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "has search results in the title" do |
|
|
|
|
get "/logs?search=#{logs[0].id}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content("Logs (search results for ‘#{logs[0].id}’) - Submit social housing and sales data (CORE) - GOV.UK") |
|
|
|
|
it "shows case logs matching the property postcode" do |
|
|
|
|
get "/logs?search=#{log_to_search.postcode_full}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(log_to_search.id) |
|
|
|
|
logs.each do |log| |
|
|
|
|
expect(page).not_to have_content(log.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when more than one results with matching postcode" do |
|
|
|
|
let!(:matching_postcode_log) { FactoryBot.create(:case_log, :completed, owning_organisation: user.organisation, postcode_full: log_to_search.postcode_full) } |
|
|
|
|
|
|
|
|
|
it "displays all matching logs" do |
|
|
|
|
get "/logs?search=#{log_to_search.postcode_full}", headers: headers, params: {} |
|
|
|
|
expect(page).to have_content(log_to_search.id) |
|
|
|
|
expect(page).to have_content(matching_postcode_log.id) |
|
|
|
|
logs.each do |log| |
|
|
|
|
expect(page).not_to have_content(log.id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when there are more than 1 page of search results" do |
|
|
|
@ -362,15 +387,6 @@ RSpec.describe CaseLogsController, type: :request do
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when matching postcode" do |
|
|
|
|
it "shows case logs matching the post code" do |
|
|
|
|
get "/logs?search=#{logs[1].postcode_full}", headers: headers, params: {} |
|
|
|
|
expect(page).not_to have_content(logs[0].id) |
|
|
|
|
expect(page).to have_content(logs[1].id) |
|
|
|
|
expect(page).not_to have_content(logs[2].id) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "when search query doesn't match any logs" do |
|
|
|
|
it "doesn't display any logs" do |
|
|
|
|
get "/logs?search=foobar", headers:, params: {} |
|
|
|
|