Skip to content

Commit

Permalink
[WIP] Force mounted endpoints to inherit params and validations from …
Browse files Browse the repository at this point in the history
…the mounting API.
  • Loading branch information
rnubel committed Jul 2, 2015
1 parent 62fe025 commit 8ad4e3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/grape/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def inherited(subclass)

def inherit_settings(other_settings)
top_level_setting.inherit_from other_settings.point_in_time_copy
endpoints.each { |e|
e.inheritable_setting.route[:saved_declared_params] << top_level_setting.route[:declared_params]
e.inheritable_setting.route[:saved_validations] += top_level_setting.namespace_stackable[:validations]
}

endpoints.each(&:reset_routes!)

Expand Down
4 changes: 2 additions & 2 deletions spec/grape/endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,11 @@ def app
end

it 'can access parent attributes' do
get '/something/123/mount_space/456'
get '/something/123/another/456'
expect(last_response.status).to eq 200
json = JSON.parse(last_response.body, symbolize_names: true)
expect(json[:declared_params][:id]).to eq 123
expect(json[:declared_params][:mount_space]).to eq 456
expect(json[:declared_params][:id]).to eq 123
end
end

Expand Down

0 comments on commit 8ad4e3b

Please sign in to comment.