|
|
|
@ -816,7 +816,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when there are more than 1 page of search results" do |
|
|
|
xcontext "when there are more than 1 page of search results" do |
|
|
|
let(:postcode) { "XX11YY" } |
|
|
|
let(:postcode) { "XX11YY" } |
|
|
|
let(:logs) { FactoryBot.create_list(:lettings_log, 30, :completed, owning_organisation: user.organisation, postcode_full: postcode, assigned_to: user) } |
|
|
|
let(:logs) { FactoryBot.create_list(:lettings_log, 30, :completed, owning_organisation: user.organisation, postcode_full: postcode, assigned_to: user) } |
|
|
|
let(:log_total_count) { LettingsLog.where(owning_organisation: user.organisation).count } |
|
|
|
let(:log_total_count) { LettingsLog.where(owning_organisation: user.organisation).count } |
|
|
|
@ -983,7 +983,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when on the second page" do |
|
|
|
xcontext "when on the second page" do |
|
|
|
before do |
|
|
|
before do |
|
|
|
get "/lettings-logs?page=2", headers:, params: {} |
|
|
|
get "/lettings-logs?page=2", headers:, params: {} |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1403,19 +1403,50 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
before do |
|
|
|
sign_in user |
|
|
|
sign_in user |
|
|
|
get "/lettings-logs/csv-download?search=#{search_term}&codes_only=false", headers: |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "returns http success" do |
|
|
|
context "when there is 1 year selected in the filters" do |
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
before do |
|
|
|
|
|
|
|
get "/lettings-logs/csv-download?years[]=2021&search=#{search_term}&codes_only=false", headers: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "returns http success" do |
|
|
|
|
|
|
|
expect(response).to have_http_status(:success) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "shows a confirmation button" do |
|
|
|
|
|
|
|
expect(page).to have_button("Send email") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "includes the search term" do |
|
|
|
|
|
|
|
expect(page).to have_field("search", type: "hidden", with: search_term) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "shows a confirmation button" do |
|
|
|
context "when there are no years selected in the filters" do |
|
|
|
expect(page).to have_button("Send email") |
|
|
|
before do |
|
|
|
|
|
|
|
get "/lettings-logs/csv-download?years[]=2021&years[]=2022&search=#{search_term}&codes_only=false", headers: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects to the year filter question" do |
|
|
|
|
|
|
|
expect(response).to redirect_to("/lettings-logs/filters/years?codes_only=false&search=#{search_term}") |
|
|
|
|
|
|
|
follow_redirect! |
|
|
|
|
|
|
|
expect(page).to have_content("Which financial year do you want to download data for?") |
|
|
|
|
|
|
|
expect(page).to have_button("Save changes") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "includes the search term" do |
|
|
|
context "when there are multiple years selected in the filters" do |
|
|
|
expect(page).to have_field("search", type: "hidden", with: search_term) |
|
|
|
before do |
|
|
|
|
|
|
|
get "/lettings-logs/csv-download?search=#{search_term}&codes_only=false", headers: |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "redirects to the year filter question" do |
|
|
|
|
|
|
|
expect(response).to redirect_to("/lettings-logs/filters/years?codes_only=false&search=#{search_term}") |
|
|
|
|
|
|
|
follow_redirect! |
|
|
|
|
|
|
|
expect(page).to have_content("Which financial year do you want to download data for?") |
|
|
|
|
|
|
|
expect(page).to have_button("Save changes") |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@ -1746,13 +1777,13 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "renders a page with the correct header" do |
|
|
|
it "renders a page with the correct header" do |
|
|
|
get "/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=false", headers:, params: {} |
|
|
|
header = page.find_css("h1") |
|
|
|
header = page.find_css("h1") |
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
expect(header.text).to include("Download CSV") |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
it "renders a form with the correct target containing a button with the correct text" do |
|
|
|
get "/lettings-logs/csv-download?codes_only=false", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=false", headers:, params: {} |
|
|
|
form = page.find("form.button_to") |
|
|
|
form = page.find("form.button_to") |
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
expect(form[:method]).to eq("post") |
|
|
|
expect(form[:action]).to eq("/lettings-logs/email-csv") |
|
|
|
expect(form[:action]).to eq("/lettings-logs/email-csv") |
|
|
|
@ -1761,7 +1792,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
it "when query string contains search parameter, form contains hidden field with correct value" do |
|
|
|
search_term = "blam" |
|
|
|
search_term = "blam" |
|
|
|
get "/lettings-logs/csv-download?codes_only=false&search=#{search_term}", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=false&search=#{search_term}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("search", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
expect(hidden_field.value).to eq(search_term) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1771,7 +1802,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
codes_only = false |
|
|
|
codes_only = false |
|
|
|
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1786,7 +1817,7 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
context "when the user is a data provider" do |
|
|
|
context "when the user is a data provider" do |
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
codes_only = false |
|
|
|
codes_only = false |
|
|
|
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
@ -1803,14 +1834,14 @@ RSpec.describe LettingsLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is false, form contains hidden field with correct value" do |
|
|
|
codes_only = false |
|
|
|
codes_only = false |
|
|
|
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
it "when codes_only query parameter is true, form contains hidden field with correct value" do |
|
|
|
codes_only = true |
|
|
|
codes_only = true |
|
|
|
get "/lettings-logs/csv-download?codes_only=#{codes_only}", headers:, params: {} |
|
|
|
get "/lettings-logs/csv-download?years[]=2021&codes_only=#{codes_only}", headers:, params: {} |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
hidden_field = page.find("form.button_to").find_field("codes_only", type: "hidden") |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
expect(hidden_field.value).to eq(codes_only.to_s) |
|
|
|
end |
|
|
|
end |
|
|
|
|