Skip to content

Commit

Permalink
Merge pull request #351 from abellotti/add_enterprise_href_to_entrypoint
Browse files Browse the repository at this point in the history
Added the enterprise_href in the server_info section of the entrypoint
  • Loading branch information
Jillian Tullo authored Mar 20, 2018
2 parents 48c8adb + 324bfab commit e254402
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
15 changes: 8 additions & 7 deletions app/controllers/api/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ def entrypoint_collections

def server_info
{
:version => Vmdb::Appliance.VERSION,
:build => Vmdb::Appliance.BUILD,
:appliance => MiqServer.my_server.name,
:time => Time.now.utc.iso8601,
:server_href => "#{@req.api_prefix}/servers/#{MiqServer.my_server.id}",
:zone_href => "#{@req.api_prefix}/zones/#{MiqServer.my_server.zone.id}",
:region_href => "#{@req.api_prefix}/regions/#{MiqRegion.my_region.id}"
:version => Vmdb::Appliance.VERSION,
:build => Vmdb::Appliance.BUILD,
:appliance => MiqServer.my_server.name,
:time => Time.now.utc.iso8601,
:server_href => "#{@req.api_prefix}/servers/#{MiqServer.my_server.id}",
:zone_href => "#{@req.api_prefix}/zones/#{MiqServer.my_server.zone.id}",
:region_href => "#{@req.api_prefix}/regions/#{MiqRegion.my_region.id}",
:enterprise_href => "#{@req.api_prefix}/enterprises/#{MiqEnterprise.my_enterprise.id}"
}
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/enterprises_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe "Enterprises API" do
context "GET /api/enterprises" do
it "returns the enterprises" do
enterprise = FactoryGirl.create(:miq_enterprise)
enterprise = MiqEnterprise.first
api_basic_authorize

get(api_enterprises_url)
Expand Down
15 changes: 8 additions & 7 deletions spec/requests/entrypoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@

expect(response.parsed_body).to include(
"server_info" => a_hash_including(
"version" => Vmdb::Appliance.VERSION,
"build" => Vmdb::Appliance.BUILD,
"appliance" => MiqServer.my_server.name,
"time" => "2018-01-01T00:00:00Z",
"server_href" => api_server_url(nil, MiqServer.my_server),
"zone_href" => api_zone_url(nil, MiqServer.my_server.zone),
"region_href" => api_region_url(nil, MiqRegion.my_region)
"version" => Vmdb::Appliance.VERSION,
"build" => Vmdb::Appliance.BUILD,
"appliance" => MiqServer.my_server.name,
"time" => "2018-01-01T00:00:00Z",
"server_href" => api_server_url(nil, MiqServer.my_server),
"zone_href" => api_zone_url(nil, MiqServer.my_server.zone),
"region_href" => api_region_url(nil, MiqRegion.my_region),
"enterprise_href" => api_enterprise_url(nil, MiqEnterprise.my_enterprise)
)
)
end
Expand Down
1 change: 1 addition & 0 deletions spec/support/api/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Support
module Api
module Helpers
def init_api_spec_env
@enterprise = FactoryGirl.create(:miq_enterprise)
@guid, @server, @zone = EvmSpecHelper.create_guid_miq_server_zone
@region = FactoryGirl.create(:miq_region, :region => ApplicationRecord.my_region_number)
@role = FactoryGirl.create(:miq_user_role, :name => "Api User Role")
Expand Down

0 comments on commit e254402

Please sign in to comment.