Skip to content

LG-8399: IPP PO Search: Mock ArcGIS service generates fake but unique addresses#7698

Merged
allthesignals merged 9 commits intomainfrom
wmg/mock-bug
Jan 30, 2023
Merged

LG-8399: IPP PO Search: Mock ArcGIS service generates fake but unique addresses#7698
allthesignals merged 9 commits intomainfrom
wmg/mock-bug

Conversation

@allthesignals
Copy link
Contributor

🎫 Ticket

Link to the relevant ticket.

🛠 Summary of changes

Leverages Faker to get the ArcGIS mock service to return unique responses across requests. This reduces the severity of this bug as for as "DX" goes.

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

  • A developer running the app locally can search multiple times when the mock service is enabled (arcgis_mock_fallback: true)

@allthesignals allthesignals requested review from a team and NavaTim January 25, 2023 17:10
gem 'devise', '~> 4.8'
gem 'dotiw', '>= 4.0.1'
gem 'faraday', '~> 2'
gem 'faker'
Copy link
Contributor Author

@allthesignals allthesignals Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixtures class, which are used for the development environment mock service, now leverages this gem, and so is moved out of the :test block.

Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Rails.root.join('spec', 'fixtures', 'arcgis_responses', filename).read
end

private_class_method def self.generate_suggestions(count = 5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be cleaner to move all the methods into class << self ?

i.e.

module ArcgisApi
  module Mock
    module Fixtures
      class << self
        def request_suggestions_response
          # ...
        end

        # ...

        private

        def generate_suggestions(count = 5)
          # ...
        end
      end
    end
  end
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, add a newline?

Suggested change
private_class_method def self.generate_suggestions(count = 5)
private_class_method
def self.generate_suggestions(count = 5)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm there is a mix of styles to doing this in the source code. I opted for:

private_class_method :generate_suggestions, :generate_address_candidates

🤷 not particularly sold on any one style.

@allthesignals
Copy link
Contributor Author

allthesignals commented Jan 26, 2023

Some updates about this:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish I could move this above the methods (similar to Rails hooks), but it doesn't seem to know about the methods then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants