Browse Source

escape . in regex for API call stubs to satisfy codeQL

remove destroy_all call at the start of a test that was dealing with leftover modesl in the test db
pull/2389/head
Arthur Campbell 2 years ago
parent
commit
ad2d128cc3
  1. 2
      spec/features/form/page_routing_spec.rb
  2. 6
      spec/models/lettings_log_spec.rb
  3. 2
      spec/models/location_spec.rb
  4. 1
      spec/models/organisation_spec.rb
  5. 4
      spec/models/sales_log_spec.rb
  6. 2
      spec/request_helper.rb
  7. 2
      spec/requests/lettings_logs_controller_spec.rb
  8. 2
      spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb
  9. 2
      spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

2
spec/features/form/page_routing_spec.rb

@ -72,7 +72,7 @@ RSpec.describe "Form Page Routing" do
end
it "does not show question if the answer could be inferred" do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
visit("/lettings-logs/#{id}/property-postcode")

6
spec/models/lettings_log_spec.rb

@ -288,7 +288,7 @@ RSpec.describe LettingsLog do
context "when saving addresses" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end
@ -396,7 +396,7 @@ RSpec.describe LettingsLog do
context "when saving previous address" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end
@ -597,7 +597,7 @@ RSpec.describe LettingsLog do
end
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end

2
spec/models/location_spec.rb

@ -9,7 +9,7 @@ RSpec.describe Location, type: :model do
let(:location) { FactoryBot.build(:location) }
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
stub_request(:get, /api.postcodes.io\/postcodes\/CA101AA/)

1
spec/models/organisation_spec.rb

@ -243,7 +243,6 @@ RSpec.describe Organisation, type: :model do
describe "scopes" do
before do
described_class.destroy_all
create(:organisation, name: "Joe Bloggs", active: false)
create(:organisation, name: "Tom Smith", active: true)
end

4
spec/models/sales_log_spec.rb

@ -535,7 +535,7 @@ RSpec.describe SalesLog, type: :model do
context "when saving addresses" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\",\"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end
@ -820,7 +820,7 @@ RSpec.describe SalesLog, type: :model do
end
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
end

2
spec/request_helper.rb

@ -3,7 +3,7 @@ require "webmock/rspec"
module RequestHelper
def self.stub_http_requests
WebMock.disable_net_connect!(allow_localhost: true)
WebMock.stub_request(:get, /api.postcodes.io/)
WebMock.stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})
WebMock.stub_request(:get, "https://api.postcodes.io/postcodes/AA11AA")

2
spec/requests/lettings_logs_controller_spec.rb

@ -1319,7 +1319,7 @@ RSpec.describe LettingsLogsController, type: :request do
Singleton.__init__(FormHandler)
completed_lettings_log.update!(startdate: Time.zone.local(2021, 4, 1), voiddate: Time.zone.local(2021, 4, 1), mrcdate: Time.zone.local(2021, 4, 1))
Timecop.unfreeze
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
sign_in user
end

2
spec/services/bulk_upload/lettings/year2023/row_parser_spec.rb

@ -84,7 +84,7 @@ RSpec.describe BulkUpload::Lettings::Year2023::RowParser do
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
parser.valid?

2
spec/services/bulk_upload/sales/year2023/row_parser_spec.rb

@ -232,7 +232,7 @@ RSpec.describe BulkUpload::Sales::Year2023::RowParser do
describe "validations" do
before do
stub_request(:get, /api.postcodes.io/)
stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":200,\"result\":{\"admin_district\":\"Manchester\", \"codes\":{\"admin_district\": \"E08000003\"}}}", headers: {})
parser.valid?

Loading…
Cancel
Save