Skip to content

Commit

Permalink
Merge pull request #1216 from Autosde/storage_service_update
Browse files Browse the repository at this point in the history
storage service edit
  • Loading branch information
kbrock committed Apr 30, 2023
2 parents 4142288 + 004d17c commit 29a826f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
6 changes: 6 additions & 0 deletions app/controllers/api/storage_services_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@ def delete_resource_action(type, id = nil, _data = nil)
{:task_id => storage_service.delete_storage_service_queue(User.current_userid)}
end
end

def edit_resource(type, id, data = {})
api_resource(type, id, "Updating", :supports => :update) do |storage_service|
{:task_id => storage_service.update_storage_service_queue(User.current_userid, data)}
end
end
end
end
4 changes: 3 additions & 1 deletion config/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4237,7 +4237,7 @@
:identifier: storage_service
:options:
- :collection
:verbs: *gpd
:verbs: *gpppd
:klass: StorageService
:subcollections:
:collection_actions:
Expand All @@ -4247,6 +4247,8 @@
:post:
- :name: create
:identifier: storage_service_new
- :name: edit
:identifier: storage_service_edit
- :name: delete
:identifier: storage_service_delete
- :name: refresh
Expand Down
26 changes: 20 additions & 6 deletions spec/requests/storage_services_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
describe "Storage Services API" do
include Spec::Support::SupportsHelper

let(:provider) { FactoryBot.create(:ems_autosde) }

context "GET /api/storage_services" do
it "returns all storage_services" do
storage_service = FactoryBot.create(:storage_service)
Expand Down Expand Up @@ -35,7 +38,6 @@
context "POST /api/storage_services" do
it "creates new Storage Service" do
api_basic_authorize(collection_action_identifier(:storage_services, :create))
provider = FactoryBot.create(:ems_autosde)
request = {
"action" => "create",
"resource" => {
Expand All @@ -51,8 +53,7 @@
end

it "deletes a single Storage Service" do
provider = FactoryBot.create(:ems_autosde, :name => 'Autosde')
service = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service', :ext_management_system => provider)
service = FactoryBot.create(:storage_service, :name => 'test_service', :ext_management_system => provider)
api_basic_authorize('storage_service_delete')

stub_supports(StorageService, :delete)
Expand All @@ -62,9 +63,8 @@
end

it "deletes multiple Storage Services" do
provider = FactoryBot.create(:ems_autosde, :name => 'Autosde')
service1 = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service1', :ext_management_system => provider)
service2 = FactoryBot.create("ManageIQ::Providers::Autosde::StorageManager::StorageService", :name => 'test_service2', :ext_management_system => provider)
service1 = FactoryBot.create(:storage_service, :name => 'test_service1', :ext_management_system => provider)
service2 = FactoryBot.create(:storage_service, :name => 'test_service2', :ext_management_system => provider)
api_basic_authorize('storage_service_delete')

stub_supports(StorageService, :delete)
Expand All @@ -79,4 +79,18 @@

expect(response).to have_http_status(:ok)
end

context 'Storage Services edit action' do
it "PUT /api/storage_services/:id'" do
storage_service = FactoryBot.create(:storage_service, :ext_management_system => provider)

api_basic_authorize('storage_service_edit')

stub_supports(StorageService, :update)
put(api_storage_service_url(nil, storage_service))

expect(response.parsed_body["message"]).to include("Updating")
expect(response).to have_http_status(:ok)
end
end
end

0 comments on commit 29a826f

Please sign in to comment.