-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from jntullo/container_nodes_api
Container Nodes Collection
- quinteros-2.2
- quinteros-2.1
- quinteros-2
- quinteros-1
- petrosian-1
- oparin-1.1
- oparin-1
- najdorf-1.3
- najdorf-1.2
- najdorf-1.1
- najdorf-1
- morphy-1
- morphy-1-beta1
- lasker-1
- lasker-1-beta1
- kasparov-2
- kasparov-1
- kasparov-1-beta1.1
- kasparov-1-beta1
- kasparov-1-alpha1
- jansa-4
- jansa-3
- jansa-2
- jansa-1
- jansa-1-rc2
- jansa-1-rc1
- jansa-1-beta1
- jansa-1-alpha1
- ivanchuk-8
- ivanchuk-7
- ivanchuk-6
- ivanchuk-5
- ivanchuk-4
- ivanchuk-3
- ivanchuk-2
- ivanchuk-1
- ivanchuk-1-rc1
- ivanchuk-1-beta2
- ivanchuk-1-beta1
- hammer-11
- hammer-10
- hammer-9
- hammer-8
- hammer-7
- hammer-6
- hammer-5.1
- hammer-5
- hammer-4
- hammer-3
- hammer-2
- hammer-1
- hammer-1-rc2
- hammer-1-rc1
- hammer-1-beta2
- hammer-1-beta1.1
- hammer-1-beta1
- gaprindashvili-7
- gaprindashvili-6
- gaprindashvili-5
- gaprindashvili-4
- gaprindashvili-3
- gaprindashvili-2
- gaprindashvili-1
- gaprindashvili-1-rc1
- gaprindashvili-1-beta2
- gaprindashvili-1-beta1
Showing
4 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module Api | ||
class ContainerNodesController < BaseController | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
RSpec.describe 'Container Nodes API' do | ||
describe 'GET /api/container_nodes' do | ||
it 'will not list container nodes without an appropriate role' do | ||
api_basic_authorize | ||
|
||
get(api_container_nodes_url) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
|
||
it 'lists all container nodes with an appropriate role' do | ||
node1, node2 = FactoryGirl.create_list(:container_node, 2) | ||
api_basic_authorize collection_action_identifier(:container_nodes, :read, :get) | ||
|
||
get(api_container_nodes_url) | ||
|
||
expected = { | ||
'count' => 2, | ||
'name' => 'container_nodes', | ||
'resources' => a_collection_including( | ||
{'href' => api_container_node_url(nil, node1)}, {'href' => api_container_node_url(nil, node2)} | ||
) | ||
} | ||
expect(response).to have_http_status(:ok) | ||
expect(response.parsed_body).to include(expected) | ||
end | ||
end | ||
|
||
describe 'GET /api/container_nodes/:id' do | ||
it 'will not show a container node without an appropriate role' do | ||
api_basic_authorize | ||
node = FactoryGirl.create(:container_node) | ||
|
||
get(api_container_node_url(nil, node)) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
|
||
it 'will show a container node with an appropriate role' do | ||
node = FactoryGirl.create(:container_node) | ||
api_basic_authorize action_identifier(:container_nodes, :read, :resource_actions, :get) | ||
|
||
get(api_container_node_url(nil, node)) | ||
|
||
expect(response.parsed_body).to include('id' => node.id.to_s, 'href' => api_container_node_url(nil, node)) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
end | ||
end |