Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to RouteStopPattern show #393

Merged
merged 2 commits into from
Feb 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/controllers/api/v1/route_stop_patterns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class Api::V1::RouteStopPatternsController < Api::V1::BaseApiController
include JsonCollectionPagination
include DownloadableCsv

before_action :set_route_stop_pattern, only: [:show]

def index
@rsps = RouteStopPattern.where('')

Expand Down Expand Up @@ -57,7 +59,13 @@ def index

def show
respond_to do |format|
format.json { render json: @route }
format.json { render json: @route_stop_pattern }
end
end

private

def set_route_stop_pattern
@route_stop_pattern = RouteStopPattern.find_by_onestop_id!(params[:id])
end
end
23 changes: 23 additions & 0 deletions spec/controllers/api/v1/route_stop_patterns_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,29 @@
}})
end
end
end

describe 'GET show' do
it 'returns route stop patterns by OnestopID' do
get :show, id: 'r-9q9j-bullet-c2e44f-8c801d'
expect_json_types({
onestop_id: :string,
route_onestop_id: :string,
geometry: :object,
stop_pattern: :array,
trips: :array,
identifiers: :array,
created_at: :date,
updated_at: :date
})
expect_json({ onestop_id: -> (onestop_id) {
expect(onestop_id).to eq 'r-9q9j-bullet-c2e44f-8c801d'
}})
end

it 'returns a 404 when not found' do
get :show, id: 'r-9q9j-bullet-test12-test12'
expect(response.status).to eq 404
end
end
end