diff --git a/lib/api/v3/root.rb b/lib/api/v3/root.rb index 883f51c7d6..3edce98d60 100644 --- a/lib/api/v3/root.rb +++ b/lib/api/v3/root.rb @@ -69,6 +69,7 @@ module API mount ::API::V3::Repositories::RevisionsAPI mount ::API::V3::Roles::RolesAPI mount ::API::V3::Statuses::StatusesAPI + mount ::API::V3::Storages::StoragesAPI mount ::API::V3::StringObjects::StringObjectsAPI mount ::API::V3::Types::TypesAPI mount ::API::V3::Users::UsersAPI diff --git a/modules/storages/spec/features/create_file_links_spec.rb b/modules/storages/lib/api/v3/storages/storages_api.rb similarity index 75% rename from modules/storages/spec/features/create_file_links_spec.rb rename to modules/storages/lib/api/v3/storages/storages_api.rb index aed444cf90..d2235b8f33 100644 --- a/modules/storages/spec/features/create_file_links_spec.rb +++ b/modules/storages/lib/api/v3/storages/storages_api.rb @@ -1,6 +1,6 @@ #-- copyright # OpenProject is an open source project management software. -# Copyright (C) 2012-2021 the OpenProject GmbH +# Copyright (C) 2012-2022 the OpenProject GmbH # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 3. @@ -26,6 +26,18 @@ # See COPYRIGHT and LICENSE files for more details. #++ -describe 'Create file links on a work package' do - +module API + module V3 + module Storages + class StoragesAPI < ::API::OpenProjectAPI + resources :storages do + route_param :storage_id, type: Integer, desc: 'Storage id' do + get do + raise ::API::Errors::NotImplemented + end + end + end + end + end + end end diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb index 26af907715..49defd9446 100644 --- a/modules/storages/lib/open_project/storages/engine.rb +++ b/modules/storages/lib/open_project/storages/engine.rb @@ -64,20 +64,8 @@ module OpenProject::Storages parent: :settings end - add_api_path :file_links do |work_package_id| - "#{work_package(work_package_id)}/file_links" - end - - add_api_path :file_link do |work_package_id, file_link_id| - "#{work_package(work_package_id)}/file_links/#{file_link_id}" - end - - add_api_path :file_link_download do |work_package_id, file_link_id| - "#{work_package(work_package_id)}/file_links/#{file_link_id}/download" - end - - add_api_path :file_link_open do |work_package_id, file_link_id| - "#{work_package(work_package_id)}/file_links/#{file_link_id}/open" + add_api_path :storages do |storage_id| + "#{root}/storages/#{storage_id}" end add_api_path :file_links do |work_package_id| diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb index e720393211..f82507de67 100644 --- a/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb +++ b/modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb @@ -90,7 +90,8 @@ describe 'API v3 file links resource', type: :request do let(:path) { api_v3_paths.file_link(work_package.id, 1337) } before do - post path + header 'Content-Type', 'application/json' + delete path end it 'returns not implemented' do diff --git a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb new file mode 100644 index 0000000000..379dc75079 --- /dev/null +++ b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb @@ -0,0 +1,59 @@ +#-- copyright +# OpenProject is an open source project management software. +# Copyright (C) 2012-2022 the OpenProject GmbH +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See COPYRIGHT and LICENSE files for more details. +#++ + +require 'spec_helper' + +describe 'API v3 storages resource', type: :request do + include API::V3::Utilities::PathHelper + + let(:permissions) { %i(view_file_links) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + + let(:current_user) do + FactoryBot.create(:user, member_in_project: project, member_through_role: role) + end + + subject(:response) { last_response } + + before do + login_as current_user + end + + describe 'GET /api/v3/storages/:storage_id' do + let(:path) { api_v3_paths.storages(1337) } + + before do + get path + end + + it 'returns not implemented' do + expect(subject.status).to eql 501 + end + end +end