[#40228] added storages endpoint

- fixed request test for DELETE
- added request test for storages endpoint
pull/10133/head
Eric Schubert 3 years ago committed by Wieland Lindenthal
parent cf99edc7f0
commit f890926a9d
No known key found for this signature in database
GPG Key ID: 7ACCABE64832A0C6
  1. 1
      lib/api/v3/root.rb
  2. 18
      modules/storages/lib/api/v3/storages/storages_api.rb
  3. 16
      modules/storages/lib/open_project/storages/engine.rb
  4. 3
      modules/storages/spec/requests/api/v3/file_links/file_links_spec.rb
  5. 59
      modules/storages/spec/requests/api/v3/storages/storages_spec.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

@ -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

@ -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|

@ -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

@ -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
Loading…
Cancel
Save