-
Notifications
You must be signed in to change notification settings - Fork 897
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 #13626 from jntullo/enhancement/get_ansible_reposi…
…tories Configuration Script Sources API
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
app/controllers/api/configuration_script_sources_controller.rb
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 ConfigurationScriptSourcesController < 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
RSpec.describe 'Configuration Script Sources API' do | ||
describe 'GET /api/configuration_script_sources' do | ||
it 'lists all the configuration script sources with an appropriate role' do | ||
repository = FactoryGirl.create(:configuration_script_source) | ||
api_basic_authorize collection_action_identifier(:configuration_script_sources, :read, :get) | ||
|
||
run_get(configuration_script_sources_url) | ||
|
||
expected = { | ||
'count' => 1, | ||
'subcount' => 1, | ||
'name' => 'configuration_script_sources', | ||
'resources' => [hash_including('href' => a_string_matching(configuration_script_sources_url(repository.id)))] | ||
} | ||
expect(response.parsed_body).to include(expected) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'forbids access to configuration script sources without an appropriate role' do | ||
api_basic_authorize | ||
|
||
run_get(configuration_script_sources_url) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
|
||
describe 'GET /api/configuration_script_sources/:id' do | ||
it 'will show a configuration script source with an appropriate role' do | ||
repository = FactoryGirl.create(:configuration_script_source) | ||
api_basic_authorize collection_action_identifier(:configuration_script_sources, :read, :get) | ||
|
||
run_get(configuration_script_sources_url(repository.id)) | ||
|
||
expected = { | ||
'href' => a_string_matching(configuration_script_sources_url(repository.id)) | ||
} | ||
expect(response.parsed_body).to include(expected) | ||
expect(response).to have_http_status(:ok) | ||
end | ||
|
||
it 'forbids access to a configuration script source without an appropriate role' do | ||
repository = FactoryGirl.create(:configuration_script_source) | ||
api_basic_authorize | ||
|
||
run_get(configuration_script_sources_url(repository.id)) | ||
|
||
expect(response).to have_http_status(:forbidden) | ||
end | ||
end | ||
end |