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.
965 lines
37 KiB
965 lines
37 KiB
3 years ago
|
require "rails_helper"
|
||
|
|
||
2 years ago
|
RSpec.describe LettingsLogsController, type: :request do
|
||
3 years ago
|
let(:user) { FactoryBot.create(:user) }
|
||
3 years ago
|
let(:owning_organisation) { user.organisation }
|
||
|
let(:managing_organisation) { owning_organisation }
|
||
3 years ago
|
let(:api_username) { "test_user" }
|
||
|
let(:api_password) { "test_password" }
|
||
|
let(:basic_credentials) do
|
||
|
ActionController::HttpAuthentication::Basic
|
||
3 years ago
|
.encode_credentials(api_username, api_password)
|
||
3 years ago
|
end
|
||
|
|
||
|
let(:headers) do
|
||
|
{
|
||
|
"Content-Type" => "application/json",
|
||
|
"Accept" => "application/json",
|
||
|
"Authorization" => basic_credentials,
|
||
|
}
|
||
|
end
|
||
|
|
||
|
before do
|
||
|
allow(ENV).to receive(:[])
|
||
|
allow(ENV).to receive(:[]).with("API_USER").and_return(api_username)
|
||
|
allow(ENV).to receive(:[]).with("API_KEY").and_return(api_password)
|
||
|
end
|
||
|
|
||
3 years ago
|
describe "POST #create" do
|
||
|
let(:tenant_code) { "T365" }
|
||
3 years ago
|
let(:age1) { 35 }
|
||
|
let(:offered) { 12 }
|
||
3 years ago
|
let(:period) { 2 }
|
||
2 years ago
|
let(:postcode_full) { "SE11 6TY" }
|
||
3 years ago
|
let(:in_progress) { "in_progress" }
|
||
|
let(:completed) { "completed" }
|
||
3 years ago
|
|
||
3 years ago
|
context "when API" do
|
||
|
let(:params) do
|
||
|
{
|
||
|
"owning_organisation_id": owning_organisation.id,
|
||
|
"managing_organisation_id": managing_organisation.id,
|
||
3 years ago
|
"created_by_id": user.id,
|
||
3 years ago
|
"tenancycode": tenant_code,
|
||
3 years ago
|
"age1": age1,
|
||
3 years ago
|
"postcode_full": postcode_full,
|
||
3 years ago
|
"offered": offered,
|
||
3 years ago
|
"period": period,
|
||
3 years ago
|
}
|
||
|
end
|
||
3 years ago
|
|
||
3 years ago
|
before do
|
||
3 years ago
|
post "/logs", headers:, params: params.to_json
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it "returns http success" do
|
||
|
expect(response).to have_http_status(:success)
|
||
|
end
|
||
3 years ago
|
|
||
2 years ago
|
it "returns a serialized lettings log" do
|
||
3 years ago
|
json_response = JSON.parse(response.body)
|
||
2 years ago
|
expect(json_response.keys).to match_array(LettingsLog.new.attributes.keys)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "creates a lettings log with the values passed" do
|
||
3 years ago
|
json_response = JSON.parse(response.body)
|
||
3 years ago
|
expect(json_response["tenancycode"]).to eq(tenant_code)
|
||
3 years ago
|
expect(json_response["age1"]).to eq(age1)
|
||
3 years ago
|
expect(json_response["postcode_full"]).to eq(postcode_full)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "with invalid json parameters" do
|
||
|
let(:age1) { 2000 }
|
||
|
let(:offered) { 21 }
|
||
|
|
||
2 years ago
|
it "validates lettings log parameters" do
|
||
3 years ago
|
json_response = JSON.parse(response.body)
|
||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||
3 years ago
|
expect(json_response["errors"]).to match_array([["offered", [I18n.t("validations.property.offered.relet_number")]], ["age1", [I18n.t("validations.numeric.valid", field: "Lead tenant’s age", min: 16, max: 120)]]])
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
context "with a partial lettings log submission" do
|
||
3 years ago
|
it "marks the record as in_progress" do
|
||
|
json_response = JSON.parse(response.body)
|
||
|
expect(json_response["status"]).to eq(in_progress)
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "with a complete lettings log submission" do
|
||
3 years ago
|
let(:org_params) do
|
||
|
{
|
||
2 years ago
|
"lettings_log" => {
|
||
3 years ago
|
"owning_organisation_id" => owning_organisation.id,
|
||
|
"managing_organisation_id" => managing_organisation.id,
|
||
3 years ago
|
"created_by_id" => user.id,
|
||
3 years ago
|
},
|
||
|
}
|
||
|
end
|
||
2 years ago
|
let(:lettings_log_params) { JSON.parse(File.open("spec/fixtures/complete_lettings_log.json").read) }
|
||
3 years ago
|
let(:params) do
|
||
2 years ago
|
lettings_log_params.merge(org_params) { |_k, a_val, b_val| a_val.merge(b_val) }
|
||
3 years ago
|
end
|
||
|
|
||
|
it "marks the record as completed" do
|
||
|
json_response = JSON.parse(response.body)
|
||
|
|
||
|
expect(json_response).not_to have_key("errors")
|
||
|
expect(json_response["status"]).to eq(completed)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "with a request containing invalid credentials" do
|
||
|
let(:basic_credentials) do
|
||
|
ActionController::HttpAuthentication::Basic.encode_credentials(api_username, "Oops")
|
||
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it "returns 401" do
|
||
|
expect(response).to have_http_status(:unauthorized)
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "when UI" do
|
||
|
let(:user) { FactoryBot.create(:user) }
|
||
|
let(:headers) { { "Accept" => "text/html" } }
|
||
|
|
||
|
before do
|
||
|
RequestHelper.stub_http_requests
|
||
|
sign_in user
|
||
3 years ago
|
post "/logs", headers:
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "tracks who created the record" do
|
||
|
created_id = response.location.match(/[0-9]+/)[0]
|
||
2 years ago
|
whodunnit_actor = LettingsLog.find_by(id: created_id).versions.last.actor
|
||
3 years ago
|
expect(whodunnit_actor).to be_a(User)
|
||
|
expect(whodunnit_actor.id).to eq(user.id)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
describe "GET" do
|
||
3 years ago
|
let(:page) { Capybara::Node::Simple.new(response.body) }
|
||
3 years ago
|
let(:user) { FactoryBot.create(:user) }
|
||
|
let(:organisation) { user.organisation }
|
||
|
let(:other_organisation) { FactoryBot.create(:organisation) }
|
||
2 years ago
|
let!(:lettings_log) do
|
||
3 years ago
|
FactoryBot.create(
|
||
2 years ago
|
:lettings_log,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
managing_organisation: organisation,
|
||
3 years ago
|
tenancycode: "LC783",
|
||
3 years ago
|
)
|
||
3 years ago
|
end
|
||
2 years ago
|
let!(:unauthorized_lettings_log) do
|
||
3 years ago
|
FactoryBot.create(
|
||
2 years ago
|
:lettings_log,
|
||
3 years ago
|
owning_organisation: other_organisation,
|
||
|
managing_organisation: other_organisation,
|
||
3 years ago
|
tenancycode: "UA984",
|
||
3 years ago
|
)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "when displaying a collection of logs" do
|
||
3 years ago
|
let(:headers) { { "Accept" => "text/html" } }
|
||
|
|
||
3 years ago
|
context "when the user is a customer support user" do
|
||
|
let(:user) { FactoryBot.create(:user, :support) }
|
||
3 years ago
|
|
||
3 years ago
|
before do
|
||
3 years ago
|
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
|
||
|
sign_in user
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
it "does have organisation values" do
|
||
3 years ago
|
get "/logs", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_content("Owned by")
|
||
|
expect(page).to have_content("Managed by")
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
it "shows lettings logs for all organisations" do
|
||
3 years ago
|
get "/logs", headers: headers, params: {}
|
||
|
expect(page).to have_content("LC783")
|
||
|
expect(page).to have_content("UA984")
|
||
|
end
|
||
|
|
||
3 years ago
|
context "when there are no logs in the database" do
|
||
|
before do
|
||
2 years ago
|
LettingsLog.destroy_all
|
||
3 years ago
|
end
|
||
|
|
||
|
it "page has correct title" do
|
||
|
get "/logs", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_title("Logs - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "when filtering" do
|
||
3 years ago
|
context "with status filter" do
|
||
3 years ago
|
let(:organisation_2) { FactoryBot.create(:organisation) }
|
||
3 years ago
|
let(:user_2) { FactoryBot.create(:user, organisation: organisation_2) }
|
||
2 years ago
|
let!(:in_progress_lettings_log) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
3 years ago
|
managing_organisation: organisation,
|
||
|
created_by: user)
|
||
3 years ago
|
end
|
||
2 years ago
|
let!(:completed_lettings_log) do
|
||
|
FactoryBot.create(:lettings_log, :completed,
|
||
3 years ago
|
owning_organisation: organisation_2,
|
||
3 years ago
|
managing_organisation: organisation,
|
||
|
created_by: user_2)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for multiple selected statuses" do
|
||
3 years ago
|
get "/logs?status[]=in_progress&status[]=completed", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(in_progress_lettings_log.id.to_s)
|
||
|
expect(page).to have_link(completed_lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for one selected status" do
|
||
3 years ago
|
get "/logs?status[]=in_progress", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(in_progress_lettings_log.id.to_s)
|
||
|
expect(page).not_to have_link(completed_lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "filters on organisation" do
|
||
|
get "/logs?organisation[]=#{organisation_2.id}", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(completed_lettings_log.id.to_s)
|
||
|
expect(page).not_to have_link(in_progress_lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "does not reset the filters" do
|
||
|
get "/logs?status[]=in_progress", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(in_progress_lettings_log.id.to_s)
|
||
|
expect(page).not_to have_link(completed_lettings_log.id.to_s)
|
||
3 years ago
|
|
||
|
get "/logs", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(in_progress_lettings_log.id.to_s)
|
||
|
expect(page).not_to have_link(completed_lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "with year filter" do
|
||
2 years ago
|
let!(:lettings_log_2021) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
startdate: Time.zone.local(2022, 3, 1),
|
||
|
managing_organisation: organisation)
|
||
|
end
|
||
2 years ago
|
let!(:lettings_log_2022) do
|
||
|
lettings_log = FactoryBot.build(:lettings_log, :completed,
|
||
|
owning_organisation: organisation,
|
||
|
mrcdate: Time.zone.local(2022, 2, 1),
|
||
|
startdate: Time.zone.local(2022, 12, 1),
|
||
|
tenancy: 6,
|
||
|
managing_organisation: organisation)
|
||
|
lettings_log.save!(validate: false)
|
||
|
lettings_log
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for multiple selected years" do
|
||
3 years ago
|
get "/logs?years[]=2021&years[]=2022", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(lettings_log_2021.id.to_s)
|
||
|
expect(page).to have_link(lettings_log_2022.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for one selected year" do
|
||
3 years ago
|
get "/logs?years[]=2021", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(lettings_log_2021.id.to_s)
|
||
|
expect(page).not_to have_link(lettings_log_2022.id.to_s)
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "with year and status filter" do
|
||
3 years ago
|
before do
|
||
|
Timecop.freeze(Time.zone.local(2022, 12, 1))
|
||
|
end
|
||
|
|
||
|
after do
|
||
|
Timecop.unfreeze
|
||
|
end
|
||
|
|
||
2 years ago
|
let!(:lettings_log_2021) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
startdate: Time.zone.local(2022, 3, 1),
|
||
3 years ago
|
managing_organisation: organisation,
|
||
|
created_by: user)
|
||
3 years ago
|
end
|
||
2 years ago
|
let!(:lettings_log_2022) do
|
||
|
FactoryBot.create(:lettings_log, :completed,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
mrcdate: Time.zone.local(2022, 2, 1),
|
||
|
startdate: Time.zone.local(2022, 12, 1),
|
||
3 years ago
|
tenancy: 6,
|
||
3 years ago
|
managing_organisation: organisation,
|
||
|
created_by: user)
|
||
3 years ago
|
end
|
||
2 years ago
|
let!(:lettings_log_2022_in_progress) do
|
||
|
FactoryBot.build(:lettings_log, :in_progress,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
mrcdate: Time.zone.local(2022, 2, 1),
|
||
|
startdate: Time.zone.local(2022, 12, 1),
|
||
|
tenancy: 6,
|
||
|
managing_organisation: organisation,
|
||
|
tenancycode: nil,
|
||
|
created_by: user)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for multiple selected statuses and years" do
|
||
3 years ago
|
get "/logs?years[]=2021&years[]=2022&status[]=in_progress&status[]=completed", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(lettings_log_2021.id.to_s)
|
||
|
expect(page).to have_link(lettings_log_2022.id.to_s)
|
||
|
expect(page).to have_link(lettings_log_2022_in_progress.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs for one selected status" do
|
||
3 years ago
|
get "/logs?years[]=2022&status[]=in_progress", headers: headers, params: {}
|
||
2 years ago
|
expect(page).to have_link(lettings_log_2022_in_progress.id.to_s)
|
||
|
expect(page).not_to have_link(lettings_log_2021.id.to_s)
|
||
|
expect(page).not_to have_link(lettings_log_2022.id.to_s)
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "when the user is not a customer support user" do
|
||
3 years ago
|
before do
|
||
3 years ago
|
sign_in user
|
||
|
end
|
||
|
|
||
|
it "does not have organisation columns" do
|
||
|
get "/logs", headers: headers, params: {}
|
||
|
expect(page).not_to have_content("Owning organisation")
|
||
|
expect(page).not_to have_content("Managing organisation")
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "when using a search query" do
|
||
2 years ago
|
let(:logs) { FactoryBot.create_list(:lettings_log, 3, :completed, owning_organisation: user.organisation, created_by: user) }
|
||
|
let(:log_to_search) { FactoryBot.create(:lettings_log, :completed, owning_organisation: user.organisation, created_by: user) }
|
||
|
let(:log_total_count) { LettingsLog.where(owning_organisation: user.organisation).count }
|
||
3 years ago
|
|
||
|
it "has search results in the title" do
|
||
|
get "/logs?search=#{log_to_search.id}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_title("Logs (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs matching the id" do
|
||
3 years ago
|
get "/logs?search=#{log_to_search.id}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs matching the tenant code" do
|
||
3 years ago
|
get "/logs?search=#{log_to_search.tenancycode}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs matching the property reference" do
|
||
3 years ago
|
get "/logs?search=#{log_to_search.propcode}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
it "shows lettings logs matching the property postcode" do
|
||
3 years ago
|
get "/logs?search=#{log_to_search.postcode_full}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
|
context "when more than one results with matching postcode" do
|
||
2 years ago
|
let!(:matching_postcode_log) { FactoryBot.create(:lettings_log, :completed, owning_organisation: user.organisation, postcode_full: log_to_search.postcode_full) }
|
||
3 years ago
|
|
||
|
it "displays all matching logs" do
|
||
|
get "/logs?search=#{log_to_search.postcode_full}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
expect(page).to have_link(matching_postcode_log.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "when there are more than 1 page of search results" do
|
||
3 years ago
|
let(:postcode) { "XX11YY" }
|
||
2 years ago
|
let(:logs) { FactoryBot.create_list(:lettings_log, 30, :completed, owning_organisation: user.organisation, postcode_full: postcode, created_by: user) }
|
||
|
let(:log_total_count) { LettingsLog.where(owning_organisation: user.organisation).count }
|
||
3 years ago
|
|
||
|
it "has title with pagination details for page 1" do
|
||
|
get "/logs?search=#{logs[0].postcode_full}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_title("Logs (#{logs.count} logs matching ‘#{postcode}’) (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
|
|
||
|
it "has title with pagination details for page 2" do
|
||
|
get "/logs?search=#{logs[0].postcode_full}&page=2", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_title("Logs (#{logs.count} logs matching ‘#{postcode}’) (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
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: {}
|
||
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
3 years ago
|
expect(page).not_to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
|
context "when search query is empty" do
|
||
|
it "doesn't display any logs" do
|
||
|
get "/logs?search=", headers:, params: {}
|
||
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
3 years ago
|
expect(page).not_to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
|
context "when search and filter is present" do
|
||
|
let(:matching_postcode) { log_to_search.postcode_full }
|
||
|
let(:matching_status) { "in_progress" }
|
||
2 years ago
|
let!(:log_matching_filter_and_search) { FactoryBot.create(:lettings_log, :in_progress, owning_organisation: user.organisation, postcode_full: matching_postcode, created_by: user) }
|
||
3 years ago
|
|
||
|
it "shows only logs matching both search and filters" do
|
||
|
get "/logs?search=#{matching_postcode}&status[]=#{matching_status}", headers: headers, params: {}
|
||
3 years ago
|
expect(page).to have_link(log_matching_filter_and_search.id.to_s)
|
||
|
expect(page).not_to have_link(log_to_search.id.to_s)
|
||
3 years ago
|
logs.each do |log|
|
||
3 years ago
|
expect(page).not_to have_link(log.id.to_s)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "when there are less than 20 logs" do
|
||
3 years ago
|
before do
|
||
3 years ago
|
get "/logs", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "shows a table of logs" do
|
||
2 years ago
|
expect(CGI.unescape_html(response.body)).to match(/<article class="app-log-summary">/)
|
||
3 years ago
|
expect(CGI.unescape_html(response.body)).to match(/logs/)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "only shows lettings logs for your organisation" do
|
||
|
expected_case_row_log = "<span class=\"govuk-visually-hidden\">Log </span>#{lettings_log.id}"
|
||
|
unauthorized_case_row_log = "<span class=\"govuk-visually-hidden\">Log </span>#{unauthorized_lettings_log.id}"
|
||
3 years ago
|
expect(CGI.unescape_html(response.body)).to include(expected_case_row_log)
|
||
|
expect(CGI.unescape_html(response.body)).not_to include(unauthorized_case_row_log)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "shows the formatted created at date for each log" do
|
||
2 years ago
|
formatted_date = lettings_log.created_at.to_formatted_s(:govuk_date)
|
||
3 years ago
|
expect(CGI.unescape_html(response.body)).to include(formatted_date)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "shows the log's status" do
|
||
2 years ago
|
expect(CGI.unescape_html(response.body)).to include(lettings_log.status.humanize)
|
||
3 years ago
|
end
|
||
|
|
||
|
it "shows the total log count" do
|
||
3 years ago
|
expect(CGI.unescape_html(response.body)).to match("<strong>1</strong> total logs")
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "does not show the pagination links" do
|
||
|
expect(page).not_to have_link("Previous")
|
||
3 years ago
|
expect(page).not_to have_link("Next")
|
||
|
end
|
||
|
|
||
3 years ago
|
it "does not show the pagination result line" do
|
||
|
expect(CGI.unescape_html(response.body)).not_to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs")
|
||
|
end
|
||
|
|
||
|
it "does not have pagination in the title" do
|
||
3 years ago
|
expect(page).to have_title("Logs - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
|
|
||
|
it "shows the download csv link" do
|
||
|
expect(page).to have_link("Download (CSV)", href: "/logs.csv")
|
||
|
end
|
||
3 years ago
|
|
||
|
it "does not show the organisation filter" do
|
||
|
expect(page).not_to have_field("organisation-field")
|
||
|
end
|
||
|
end
|
||
|
|
||
|
context "when the user is a customer support user" do
|
||
|
let(:user) { FactoryBot.create(:user, :support) }
|
||
|
let(:org_1) { FactoryBot.create(:organisation) }
|
||
|
let(:org_2) { FactoryBot.create(:organisation) }
|
||
|
let(:tenant_code_1) { "TC5638" }
|
||
|
let(:tenant_code_2) { "TC8745" }
|
||
|
|
||
|
before do
|
||
2 years ago
|
FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_1, tenancycode: tenant_code_1)
|
||
|
FactoryBot.create(:lettings_log, :in_progress, owning_organisation: org_2, tenancycode: tenant_code_2)
|
||
3 years ago
|
allow(user).to receive(:need_two_factor_authentication?).and_return(false)
|
||
|
sign_in user
|
||
|
end
|
||
|
|
||
|
it "does show the organisation filter" do
|
||
|
get "/logs", headers:, params: {}
|
||
|
expect(page).to have_field("organisation-field")
|
||
|
end
|
||
|
|
||
|
it "shows all logs by default" do
|
||
|
get "/logs", headers:, params: {}
|
||
|
expect(page).to have_content(tenant_code_1)
|
||
|
expect(page).to have_content(tenant_code_2)
|
||
|
end
|
||
|
|
||
|
context "when filtering by organisation" do
|
||
|
it "only show the selected organisations logs" do
|
||
|
get "/logs?organisation_select=specific_org&organisation=#{org_1.id}", headers:, params: {}
|
||
|
expect(page).to have_content(tenant_code_1)
|
||
|
expect(page).not_to have_content(tenant_code_2)
|
||
|
end
|
||
|
end
|
||
3 years ago
|
|
||
|
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/logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&user=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
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
|
context "when there are more than 20 logs" do
|
||
|
before do
|
||
2 years ago
|
FactoryBot.create_list(:lettings_log, 25, owning_organisation: organisation, managing_organisation: organisation)
|
||
3 years ago
|
end
|
||
|
|
||
|
context "when on the first page" do
|
||
|
before do
|
||
3 years ago
|
get "/logs", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
|
it "has pagination links" do
|
||
3 years ago
|
expect(page).not_to have_content("Previous")
|
||
3 years ago
|
expect(page).not_to have_link("Previous")
|
||
|
expect(page).to have_content("Next")
|
||
|
expect(page).to have_link("Next")
|
||
|
end
|
||
|
|
||
|
it "shows which logs are being shown on the current page" do
|
||
|
expect(CGI.unescape_html(response.body)).to match("Showing <b>1</b> to <b>20</b> of <b>26</b> logs")
|
||
|
end
|
||
|
|
||
|
it "has pagination in the title" do
|
||
3 years ago
|
expect(page).to have_title("Logs (page 1 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "when on the second page" do
|
||
|
before do
|
||
3 years ago
|
get "/logs?page=2", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
|
it "shows the total log count" do
|
||
|
expect(CGI.unescape_html(response.body)).to match("<strong>26</strong> total logs")
|
||
|
end
|
||
|
|
||
|
it "has pagination links" do
|
||
|
expect(page).to have_content("Previous")
|
||
|
expect(page).to have_link("Previous")
|
||
3 years ago
|
expect(page).not_to have_content("Next")
|
||
3 years ago
|
expect(page).not_to have_link("Next")
|
||
|
end
|
||
|
|
||
|
it "shows which logs are being shown on the current page" do
|
||
|
expect(CGI.unescape_html(response.body)).to match("Showing <b>21</b> to <b>26</b> of <b>26</b> logs")
|
||
|
end
|
||
|
|
||
|
it "has pagination in the title" do
|
||
3 years ago
|
expect(page).to have_title("Logs (page 2 of 2) - Submit social housing lettings and sales data (CORE) - GOV.UK")
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
context "when requesting a specific lettings log" do
|
||
|
let(:completed_lettings_log) { FactoryBot.create(:lettings_log, :completed) }
|
||
|
let(:id) { completed_lettings_log.id }
|
||
3 years ago
|
|
||
3 years ago
|
before do
|
||
3 years ago
|
get "/logs/#{id}", headers:
|
||
3 years ago
|
end
|
||
|
|
||
|
it "returns http success" do
|
||
|
expect(response).to have_http_status(:success)
|
||
|
end
|
||
|
|
||
2 years ago
|
it "returns a serialized lettings log" do
|
||
3 years ago
|
json_response = JSON.parse(response.body)
|
||
2 years ago
|
expect(json_response["status"]).to eq(completed_lettings_log.status)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "when requesting an invalid lettings log id" do
|
||
|
let(:id) { (LettingsLog.order(:id).last&.id || 0) + 1 }
|
||
3 years ago
|
|
||
|
it "returns 404" do
|
||
|
expect(response).to have_http_status(:not_found)
|
||
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
context "when editing a lettings log" do
|
||
3 years ago
|
let(:headers) { { "Accept" => "text/html" } }
|
||
|
|
||
3 years ago
|
context "with a user that is not signed in" do
|
||
2 years ago
|
it "does not let the user get lettings log tasklist pages they don't have access to" do
|
||
|
get "/logs/#{lettings_log.id}", headers: headers, params: {}
|
||
3 years ago
|
expect(response).to redirect_to("/account/sign-in")
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
|
||
3 years ago
|
context "with a signed in user" do
|
||
2 years ago
|
context "with lettings logs that are owned or managed by your organisation" do
|
||
3 years ago
|
before do
|
||
|
sign_in user
|
||
2 years ago
|
get "/logs/#{lettings_log.id}", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "shows the tasklist for lettings logs you have access to" do
|
||
3 years ago
|
expect(response.body).to match("Log")
|
||
2 years ago
|
expect(response.body).to match(lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "displays a section status for a lettings log" do
|
||
3 years ago
|
assert_select ".govuk-tag", text: /Not started/, count: 6
|
||
3 years ago
|
assert_select ".govuk-tag", text: /In progress/, count: 2
|
||
3 years ago
|
assert_select ".govuk-tag", text: /Completed/, count: 0
|
||
|
assert_select ".govuk-tag", text: /Cannot start yet/, count: 1
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "with a lettings log with a single section complete" do
|
||
|
let(:section_completed_lettings_log) do
|
||
3 years ago
|
FactoryBot.create(
|
||
2 years ago
|
:lettings_log,
|
||
3 years ago
|
:conditional_section_complete,
|
||
|
owning_organisation: organisation,
|
||
|
managing_organisation: organisation,
|
||
|
)
|
||
|
end
|
||
|
|
||
|
before do
|
||
|
sign_in user
|
||
2 years ago
|
get "/logs/#{section_completed_lettings_log.id}", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
it "displays a section status for a lettings log" do
|
||
3 years ago
|
assert_select ".govuk-tag", text: /Not started/, count: 6
|
||
3 years ago
|
assert_select ".govuk-tag", text: /Completed/, count: 1
|
||
|
assert_select ".govuk-tag", text: /Cannot start yet/, count: 1
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "with lettings logs that are not owned or managed by your organisation" do
|
||
3 years ago
|
before do
|
||
|
sign_in user
|
||
2 years ago
|
get "/logs/#{unauthorized_lettings_log.id}", headers:, params: {}
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
it "does not show the tasklist for lettings logs you don't have access to" do
|
||
3 years ago
|
expect(response).to have_http_status(:not_found)
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
3 years ago
|
|
||
3 years ago
|
context "when accessing the check answers page" do
|
||
2 years ago
|
let(:postcode_lettings_log) do
|
||
|
FactoryBot.create(:lettings_log,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
managing_organisation: organisation,
|
||
|
postcode_known: "No")
|
||
|
end
|
||
2 years ago
|
let(:id) { postcode_lettings_log.id }
|
||
3 years ago
|
|
||
|
before do
|
||
|
stub_request(:get, /api.postcodes.io/)
|
||
3 years ago
|
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
|
||
3 years ago
|
sign_in user
|
||
|
end
|
||
|
|
||
3 years ago
|
it "shows the inferred la" do
|
||
2 years ago
|
lettings_log = FactoryBot.create(:lettings_log,
|
||
|
owning_organisation: organisation,
|
||
|
managing_organisation: organisation,
|
||
|
postcode_known: 1,
|
||
|
postcode_full: "PO5 3TE")
|
||
|
id = lettings_log.id
|
||
3 years ago
|
get "/logs/#{id}/property-information/check-answers"
|
||
|
expected_inferred_answer = "<span class=\"govuk-!-font-weight-regular app-!-colour-muted\">Manchester</span>"
|
||
|
expect(CGI.unescape_html(response.body)).to include(expected_inferred_answer)
|
||
|
end
|
||
|
|
||
|
it "does not show do you know the property postcode question" do
|
||
|
get "/logs/#{id}/property-information/check-answers"
|
||
|
expect(CGI.unescape_html(response.body)).not_to include("Do you know the property postcode?")
|
||
|
end
|
||
|
|
||
|
it "shows if the postcode is not known" do
|
||
|
get "/logs/#{id}/property-information/check-answers"
|
||
|
expect(CGI.unescape_html(response.body)).to include("Not known")
|
||
|
end
|
||
3 years ago
|
|
||
|
it "shows `you haven't answered this question` if the question wasn't answered" do
|
||
|
get "/logs/#{id}/income-and-benefits/check-answers"
|
||
|
expect(CGI.unescape_html(response.body)).to include("You didn’t answer this question")
|
||
|
end
|
||
3 years ago
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
describe "CSV download" do
|
||
|
let(:headers) { { "Accept" => "text/csv" } }
|
||
|
let(:user) { FactoryBot.create(:user) }
|
||
|
let(:organisation) { user.organisation }
|
||
|
let(:other_organisation) { FactoryBot.create(:organisation) }
|
||
|
|
||
3 years ago
|
context "when a log exists" do
|
||
2 years ago
|
let!(:lettings_log) do
|
||
3 years ago
|
FactoryBot.create(
|
||
2 years ago
|
:lettings_log,
|
||
3 years ago
|
owning_organisation: organisation,
|
||
|
managing_organisation: organisation,
|
||
|
ecstat1: 1,
|
||
|
)
|
||
|
end
|
||
3 years ago
|
|
||
3 years ago
|
before do
|
||
|
sign_in user
|
||
2 years ago
|
FactoryBot.create(:lettings_log)
|
||
|
FactoryBot.create(:lettings_log,
|
||
3 years ago
|
:completed,
|
||
|
owning_organisation: organisation,
|
||
3 years ago
|
managing_organisation: organisation,
|
||
|
created_by: user)
|
||
3 years ago
|
get "/logs", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
|
it "downloads a CSV file with headers" do
|
||
|
csv = CSV.parse(response.body)
|
||
2 years ago
|
expect(csv.first.first).to eq("\uFEFFid")
|
||
2 years ago
|
expect(csv.second.first).to eq(lettings_log.id.to_s)
|
||
3 years ago
|
end
|
||
|
|
||
|
it "does not download other orgs logs" do
|
||
|
csv = CSV.parse(response.body)
|
||
3 years ago
|
expect(csv.count).to eq(3)
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it "downloads answer labels rather than values" do
|
||
|
csv = CSV.parse(response.body)
|
||
2 years ago
|
expect(csv.second[15]).to eq("Full-time – 30 hours or more")
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it "downloads filtered logs" do
|
||
3 years ago
|
get "/logs?status[]=completed", headers:, params: {}
|
||
|
csv = CSV.parse(response.body)
|
||
|
expect(csv.count).to eq(2)
|
||
|
end
|
||
3 years ago
|
|
||
|
it "dowloads searched logs" do
|
||
2 years ago
|
get "/logs?search=#{lettings_log.id}", headers:, params: {}
|
||
3 years ago
|
csv = CSV.parse(response.body)
|
||
2 years ago
|
expect(csv.count).to eq(LettingsLog.search_by(lettings_log.id.to_s).count + 1)
|
||
3 years ago
|
end
|
||
|
|
||
|
context "when both filter and search applied" do
|
||
|
let(:postcode) { "XX1 1TG" }
|
||
|
|
||
|
before do
|
||
2 years ago
|
FactoryBot.create(:lettings_log, :in_progress, postcode_full: postcode, owning_organisation: organisation, created_by: user)
|
||
|
FactoryBot.create(:lettings_log, :completed, postcode_full: postcode, owning_organisation: organisation, created_by: user)
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "downloads logs matching both csv and filter logs" do
|
||
3 years ago
|
get "/logs?status[]=completed&search=#{postcode}", headers:, params: {}
|
||
|
csv = CSV.parse(response.body)
|
||
|
expect(csv.count).to eq(2)
|
||
|
end
|
||
|
end
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
context "when there are more than 20 logs" do
|
||
|
before do
|
||
|
sign_in user
|
||
2 years ago
|
FactoryBot.create_list(:lettings_log, 26, owning_organisation: organisation)
|
||
3 years ago
|
get "/logs", headers:, params: {}
|
||
3 years ago
|
end
|
||
|
|
||
|
it "does not paginate, it downloads all the user's logs" do
|
||
|
csv = CSV.parse(response.body)
|
||
|
expect(csv.count).to eq(27)
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
describe "PATCH" do
|
||
2 years ago
|
let(:lettings_log) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress, tenancycode: "Old Value", postcode_full: "M1 1AE")
|
||
3 years ago
|
end
|
||
|
let(:params) do
|
||
3 years ago
|
{ tenancycode: "New Value" }
|
||
3 years ago
|
end
|
||
2 years ago
|
let(:id) { lettings_log.id }
|
||
3 years ago
|
|
||
|
before do
|
||
3 years ago
|
patch "/logs/#{id}", headers:, params: params.to_json
|
||
3 years ago
|
end
|
||
|
|
||
|
it "returns http success" do
|
||
|
expect(response).to have_http_status(:success)
|
||
|
end
|
||
|
|
||
2 years ago
|
it "updates the lettings log with the given fields and keeps original values where none are passed" do
|
||
|
lettings_log.reload
|
||
|
expect(lettings_log.tenancycode).to eq("New Value")
|
||
|
expect(lettings_log.postcode_full).to eq("M1 1AE")
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "with an invalid lettings log id" do
|
||
|
let(:id) { (LettingsLog.order(:id).last&.id || 0) + 1 }
|
||
3 years ago
|
|
||
|
it "returns 404" do
|
||
|
expect(response).to have_http_status(:not_found)
|
||
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
context "with an invalid lettings log params" do
|
||
3 years ago
|
let(:params) { { age1: 200 } }
|
||
3 years ago
|
|
||
|
it "returns 422" do
|
||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||
|
end
|
||
|
|
||
|
it "returns an error message" do
|
||
|
json_response = JSON.parse(response.body)
|
||
3 years ago
|
expect(json_response["errors"]).to eq({ "age1" => ["Lead tenant’s age must be between 16 and 120"] })
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "with a request containing invalid credentials" do
|
||
3 years ago
|
let(:basic_credentials) do
|
||
|
ActionController::HttpAuthentication::Basic.encode_credentials(api_username, "Oops")
|
||
|
end
|
||
|
|
||
|
it "returns 401" do
|
||
|
expect(response).to have_http_status(:unauthorized)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
# We don't really have any meaningful distinction between PUT and PATCH here since you can update some or all
|
||
|
# fields in both cases, and both route to #Update. Rails generally recommends PATCH as it more closely matches
|
||
|
# what actually happens to an ActiveRecord object and what we're doing here, but either is allowed.
|
||
|
describe "PUT" do
|
||
2 years ago
|
let(:lettings_log) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress, tenancycode: "Old Value", postcode_full: "SW1A 2AA")
|
||
3 years ago
|
end
|
||
|
let(:params) do
|
||
3 years ago
|
{ tenancycode: "New Value" }
|
||
3 years ago
|
end
|
||
2 years ago
|
let(:id) { lettings_log.id }
|
||
3 years ago
|
|
||
|
before do
|
||
3 years ago
|
put "/logs/#{id}", headers:, params: params.to_json
|
||
3 years ago
|
end
|
||
|
|
||
|
it "returns http success" do
|
||
|
expect(response).to have_http_status(:success)
|
||
|
end
|
||
|
|
||
2 years ago
|
it "updates the lettings log with the given fields and keeps original values where none are passed" do
|
||
|
lettings_log.reload
|
||
|
expect(lettings_log.tenancycode).to eq("New Value")
|
||
|
expect(lettings_log.postcode_full).to eq("SW1A 2AA")
|
||
3 years ago
|
end
|
||
|
|
||
2 years ago
|
context "with an invalid lettings log id" do
|
||
|
let(:id) { (LettingsLog.order(:id).last&.id || 0) + 1 }
|
||
3 years ago
|
|
||
|
it "returns 404" do
|
||
|
expect(response).to have_http_status(:not_found)
|
||
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "with a request containing invalid credentials" do
|
||
3 years ago
|
let(:basic_credentials) do
|
||
|
ActionController::HttpAuthentication::Basic.encode_credentials(api_username, "Oops")
|
||
|
end
|
||
|
|
||
|
it "returns 401" do
|
||
|
expect(response).to have_http_status(:unauthorized)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
describe "DELETE" do
|
||
2 years ago
|
let!(:lettings_log) do
|
||
|
FactoryBot.create(:lettings_log, :in_progress)
|
||
3 years ago
|
end
|
||
2 years ago
|
let(:id) { lettings_log.id }
|
||
3 years ago
|
|
||
2 years ago
|
context "when deleting a lettings log" do
|
||
3 years ago
|
before do
|
||
3 years ago
|
delete "/logs/#{id}", headers:
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
3 years ago
|
it "returns http success" do
|
||
|
expect(response).to have_http_status(:success)
|
||
|
end
|
||
3 years ago
|
|
||
2 years ago
|
it "deletes the lettings log" do
|
||
|
expect { LettingsLog.find(id) }.to raise_error(ActiveRecord::RecordNotFound)
|
||
3 years ago
|
end
|
||
3 years ago
|
|
||
2 years ago
|
context "with an invalid lettings log id" do
|
||
|
let(:id) { (LettingsLog.order(:id).last&.id || 0) + 1 }
|
||
3 years ago
|
|
||
3 years ago
|
it "returns 404" do
|
||
|
expect(response).to have_http_status(:not_found)
|
||
|
end
|
||
|
end
|
||
|
|
||
3 years ago
|
context "with a request containing invalid credentials" do
|
||
3 years ago
|
let(:basic_credentials) do
|
||
|
ActionController::HttpAuthentication::Basic.encode_credentials(api_username, "Oops")
|
||
|
end
|
||
|
|
||
|
it "returns 401" do
|
||
|
expect(response).to have_http_status(:unauthorized)
|
||
|
end
|
||
3 years ago
|
end
|
||
|
end
|
||
|
|
||
2 years ago
|
context "when a lettings log deletion fails" do
|
||
3 years ago
|
before do
|
||
2 years ago
|
allow(LettingsLog).to receive(:find_by).and_return(lettings_log)
|
||
|
allow(lettings_log).to receive(:delete).and_return(false)
|
||
3 years ago
|
delete "/logs/#{id}", headers:
|
||
3 years ago
|
end
|
||
|
|
||
3 years ago
|
it "returns an unprocessable entity 422" do
|
||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||
3 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|