Add api/v1/parks
This commit is contained in:
5
app/controllers/api/v1/parks_controller.rb
Normal file
5
app/controllers/api/v1/parks_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class Api::V1::ParksController < ApplicationController
|
||||||
|
def index
|
||||||
|
render json: Park.all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,9 @@
|
|||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
namespace :api do
|
||||||
|
namespace :v1 do
|
||||||
|
resources :parks, only: %i[index]
|
||||||
|
end
|
||||||
|
end
|
||||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||||
|
|
||||||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
||||||
|
|||||||
8
test/controllers/api/v1/parks_controller_test.rb
Normal file
8
test/controllers/api/v1/parks_controller_test.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class Api::V1::ParksControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
test "should get index" do
|
||||||
|
get api_v1_parks_url
|
||||||
|
assert_response :success
|
||||||
|
end
|
||||||
|
end
|
||||||
4
test/fixtures/parks.yml
vendored
4
test/fixtures/parks.yml
vendored
@@ -4,10 +4,10 @@ one:
|
|||||||
code: crla
|
code: crla
|
||||||
name: Crater Lake National Park
|
name: Crater Lake National Park
|
||||||
states: OR
|
states: OR
|
||||||
properties:
|
properties: {}
|
||||||
|
|
||||||
two:
|
two:
|
||||||
code: olym
|
code: olym
|
||||||
name: Olympic National Park
|
name: Olympic National Park
|
||||||
states: WA
|
states: WA
|
||||||
properties:
|
properties: {}
|
||||||
|
|||||||
Reference in New Issue
Block a user