Skip to content

Commit

Permalink
Merge pull request #13681 from abellotti/api_options_subcollections
Browse files Browse the repository at this point in the history
Api collection OPTIONS Enhancement to expose list of supported subcollections
  • Loading branch information
gtanzillo authored Jan 27, 2017
2 parents 2bec755 + 2395855 commit 479460f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/base_controller/renderer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ def render_options(resource, data = {})
collection.virtual_reflections.keys.collect(&:to_s)).sort
}
end
options[:subcollections] = Array(collection_config[resource].subcollections).sort
options[:data] = data
render :json => options
end
Expand Down
2 changes: 2 additions & 0 deletions spec/requests/api/arbitration_rule_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@

attributes = (ArbitrationRule.attribute_names - ArbitrationRule.virtual_attribute_names).sort.as_json
reflections = (ArbitrationRule.reflections.keys | ArbitrationRule.virtual_reflections.keys.collect(&:to_s)).sort
subcollections = Array(Api::ApiConfig.collections[:arbitration_rules].subcollections).collect(&:to_s).sort
expected = {
'attributes' => attributes,
'virtual_attributes' => ArbitrationRule.virtual_attribute_names.sort.as_json,
'relationships' => reflections,
'subcollections' => subcollections,
'data' => {
'field_values' => ArbitrationRule.field_values
}
Expand Down
1 change: 1 addition & 0 deletions spec/requests/api/querying_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,7 @@ def create_vms_by_name(names)
'attributes' => (Vm.attribute_names - Vm.virtual_attribute_names).sort.as_json,
'virtual_attributes' => Vm.virtual_attribute_names.sort.as_json,
'relationships' => (Vm.reflections.keys | Vm.virtual_reflections.keys.collect(&:to_s)).sort,
'subcollections' => Array(Api::ApiConfig.collections[:vms].subcollections).collect(&:to_s).sort,
'data' => {}
}
run_options(vms_url)
Expand Down

0 comments on commit 479460f

Please sign in to comment.