Sha256: 11df44fe0e960a210d66970c7c489e3e3932eadbb198a577953e07d14864fc3b

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Fake
  module LocationsRoutes
    class << self
      def included(base)
        get_routes base
        post_routes base
        put_routes base
        delete_routes base

        super
      end

      def post_routes(base)
        base.post("/#{base.version}/locations") do
          status 204
        end
      end

      def delete_routes(base)
        base.delete("/#{base.version}/locations/:id") do
          return status(404) if params[:id] == 'not_found'

          status 204
        end
      end

      def put_routes(base)
        base.put("/#{base.version}/locations/:id") do
          return status(404) if params[:id] == 'not_found'

          status 204
        end
      end

      def get_routes(base)
        base.get("/#{base.version}/locations") do
          return status(400) if params[:filter] == 'invalid'

          json_response 200, 'locations/get_locations.json'
        end
        base.get("/#{base.version}/locations/:id") do
          return status(404) if params[:id] == 'not_found'

          json_response 200, 'locations/get_location.json'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
finapps-6.13.1 spec/support/routes/locations.rb
finapps-6.13.0 spec/support/routes/locations.rb
finapps-6.12.0 spec/support/routes/locations.rb
finapps-6.11.0 spec/support/routes/locations.rb
finapps-6.10.2 spec/support/routes/locations.rb
finapps-6.10.1 spec/support/routes/locations.rb