|
|
@ -4,6 +4,7 @@ RSpec.describe CaseLogsController, type: :request do |
|
|
|
describe "POST #create" do |
|
|
|
describe "POST #create" do |
|
|
|
let(:tenant_code) { "T365" } |
|
|
|
let(:tenant_code) { "T365" } |
|
|
|
let(:tenant_age) { 35 } |
|
|
|
let(:tenant_age) { 35 } |
|
|
|
|
|
|
|
let(:property_number_of_times_relet) { 12 } |
|
|
|
let(:property_postcode) { "SE11 6TY" } |
|
|
|
let(:property_postcode) { "SE11 6TY" } |
|
|
|
let(:api_username) { "test_user" } |
|
|
|
let(:api_username) { "test_user" } |
|
|
|
let(:api_password) { "test_password" } |
|
|
|
let(:api_password) { "test_password" } |
|
|
@ -27,6 +28,7 @@ RSpec.describe CaseLogsController, type: :request do |
|
|
|
"tenant_code": tenant_code, |
|
|
|
"tenant_code": tenant_code, |
|
|
|
"tenant_age": tenant_age, |
|
|
|
"tenant_age": tenant_age, |
|
|
|
"property_postcode": property_postcode, |
|
|
|
"property_postcode": property_postcode, |
|
|
|
|
|
|
|
"property_number_of_times_relet": property_number_of_times_relet |
|
|
|
} |
|
|
|
} |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
@ -55,11 +57,12 @@ RSpec.describe CaseLogsController, type: :request do |
|
|
|
|
|
|
|
|
|
|
|
context "invalid json params" do |
|
|
|
context "invalid json params" do |
|
|
|
let(:tenant_age) { 2000 } |
|
|
|
let(:tenant_age) { 2000 } |
|
|
|
|
|
|
|
let(:property_number_of_times_relet) { 21 } |
|
|
|
|
|
|
|
|
|
|
|
it "validates case log parameters" do |
|
|
|
it "validates case log parameters" do |
|
|
|
json_response = JSON.parse(response.body) |
|
|
|
json_response = JSON.parse(response.body) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(response).to have_http_status(:unprocessable_entity) |
|
|
|
expect(json_response["errors"]).to eq(["Tenant age must be between 0 and 120"]) |
|
|
|
expect(json_response["errors"]).to match_array(["Tenant age must be between 0 and 120", "Property number of times relet must be between 0 and 20"]) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|