Skip to content

Commit

Permalink
adding tests for OPTOINS /api/providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Erez Freiberger committed Aug 8, 2017
1 parent 18248bc commit 9fb1dfc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/providers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def options
.select { |param| param.starts_with?("ems_type") } # 'parameters with "ems_type" name
.first.split('=').last # choosing only the first occuracne.
ems_class = ExtManagementSystem.descendants.select { |ems| ems.ems_type == req_class_name }.first
render :json => ems_class.respond_to?(:provider_settings) ? ems_class.provider_settings : {}
render_options(:providers, ems_class.respond_to?(:provider_settings) ? ems_class.provider_settings : {})
end

private
Expand Down
10 changes: 10 additions & 0 deletions spec/requests/api/providers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1116,4 +1116,14 @@ def gen_import_request
end
end
end

context "#options" do
it "returns options for queried provider class" do
api_basic_authorize
ExtManagementSystem.descendants.select { |ems| ems.respond_to?(:provider_settings) }.each do |ems_type|
run_options("#{providers_url}?ems_type=#{ems_type.ems_type}")
expect(response.parsed_body.to_json).to eq(ems_type.provider_settings.to_json)
end
end
end
end

0 comments on commit 9fb1dfc

Please sign in to comment.