-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd69501
commit a162440
Showing
9 changed files
with
146 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
## | ||
# Realtime Controller | ||
class RetailLocationsController < ApplicationController | ||
before_action :set_retail_location, only: [:show] | ||
|
||
# GET /retail_locations | ||
def index | ||
render json: paginate_results(RetailLocation.all) | ||
end | ||
|
||
def show | ||
render json: @retail_location | ||
end | ||
|
||
# Use callbacks to share common setup or constraints between actions. | ||
def set_retail_location | ||
@retail_location = RetailLocation.find_by(location_code: params[:location_code]) | ||
raise ActionController::RoutingError, 'Not Found' if @retail_location.nil? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
## | ||
# Retail Location Model | ||
class RetailLocation < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
## | ||
# Create Retail Locations | ||
class CreateRetailLocations < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :retail_locations do |t| | ||
t.string 'location_code', unique: true, null: false | ||
t.string 'name' | ||
t.string 'address' | ||
t.string 'city' | ||
t.string 'state' | ||
t.string 'zip' | ||
t.boolean 'is_active', default: false, null: false | ||
t.boolean 'can_buy_media', default: false, null: false | ||
t.boolean 'can_reload_media', default: false, null: false | ||
t.decimal 'latitude', precision: 10, scale: 6, null: false | ||
t.decimal 'longitude', precision: 10, scale: 6, null: false | ||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class RetailLocationsControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@retail_location = retail_locations(:RetailLocation1).location_code | ||
end | ||
|
||
test 'should get index' do | ||
get retail_locations_url, as: :json | ||
assert_response :success | ||
json_response = response.parsed_body | ||
assert_equal 2, json_response['total'] | ||
assert_equal 2, json_response['data'].length | ||
assert_equal '170', json_response['data'][1]['location_code'] | ||
assert_equal 'CVS Pharmacy', json_response['data'][1]['name'] | ||
end | ||
|
||
test 'should show retail_location' do | ||
get retail_location_url(@retail_location), as: :json | ||
assert_response :success | ||
json_response = response.parsed_body | ||
assert_equal '170', json_response['location_code'] | ||
assert_equal 'CVS Pharmacy', json_response['name'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
RetailLocation1: | ||
location_code: 170 | ||
name: CVS Pharmacy | ||
address: 4201 Clarksville Highway | ||
city: Nashville | ||
state: TN | ||
zip: "37218" | ||
is_active: 1 | ||
can_buy_media: 1 | ||
can_reload_media: 1 | ||
latitude: 36.216513 | ||
longitude: -86.837775 | ||
|
||
RetailLocation2: | ||
location_code: 858 | ||
name: Dollar General | ||
address: 4201 CLARKSVILLE PIKE | ||
city: Nashville | ||
state: TN | ||
zip: "37218" | ||
is_active: 1 | ||
can_buy_media: 0 | ||
can_reload_media: 1 | ||
latitude: 36.21901 | ||
longitude: -86.837471 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class RetailLocationTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |