Skip to content

Commit

Permalink
Merge pull request ManageIQ#346 from jntullo/add_enterprise
Browse files Browse the repository at this point in the history
Add enterprise collection
  • Loading branch information
abellotti authored Mar 19, 2018
2 parents 7a39df0 + 20bf05a commit 697e407
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/controllers/api/enterprises_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Api
class EnterprisesController < BaseController
end
end
12 changes: 12 additions & 0 deletions config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,18 @@
:identifier: storage_tag
- :name: unassign
:identifier: storage_tag
:enterprises:
:description: Enterprises
:options:
- :collection
:verbs: *g
:klass: MiqEnterprise
:collection_actions:
:get:
- :name: read
:resource_actions:
:get:
- :name: read
:event_streams:
:description: Event Streams
:options:
Expand Down
33 changes: 33 additions & 0 deletions spec/requests/enterprises_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
describe "Enterprises API" do
context "GET /api/enterprises" do
it "returns the enterprises" do
enterprise = FactoryGirl.create(:miq_enterprise)
api_basic_authorize

get(api_enterprises_url)

expected = {
"name" => "enterprises",
"resources" => [{"href" => api_enterprise_url(nil, enterprise)}]
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end
end

context "GET /api/enterprises/:id" do
it "returns the enterprise" do
enterprise = FactoryGirl.create(:miq_enterprise)
api_basic_authorize

get(api_enterprise_url(nil, enterprise))

expected = {
"name" => enterprise.name,
"href" => api_enterprise_url(nil, enterprise)
}
expect(response).to have_http_status(:ok)
expect(response.parsed_body).to include(expected)
end
end
end

0 comments on commit 697e407

Please sign in to comment.