OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Makes tests pass xD
Marcello Rochaee38a4be1f67
diff --git a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb b/modules/storages/lib/api/v3/file_links/file_links_download_api.rbindex 479e1e96a8a..d2760fb561c 100644--- a/modules/storages/lib/api/v3/file_links/file_links_download_api.rb+++ b/modules/storages/lib/api/v3/file_links/file_links_download_api.rb@@ -33,10 +33,11 @@ class API::V3::FileLinks::FileLinksDownloadAPI < API::OpenProjectAPIresources :download doget doStorages::Peripherals::StorageRequests- .new(storage: @file_link.storage)- .download_link_query- .call(user: User.current, file_link: @file_link)- .match(+ .call(+ storage: @file_link.storage,+ operation: :download_link_query,+ user: User.current, file_link: @file_link+ ).match(on_success: ->(url) doredirect(url, body: "The requested resource can be downloaded from #{url}")status(303)diff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rbindex cb9005dd95c..65844334f8b 100644--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb@@ -86,7 +86,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'must return a download link URL' doresult = subject.call(operation: :download_link_query, storage:, user:, file_link:)expect(result).to be_success- expect(result.result).to be_eql(uri)+ expect(result.result).to eql(uri)endcontext 'if Nextcloud is running on a sub path' do@@ -95,7 +95,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'must return a download link URL' doresult = subject.call(operation: :download_link_query, storage:, user:, file_link:)expect(result).to be_success- expect(result.result).to be_eql(uri)+ expect(result.result).to eql(uri)endendend@@ -145,7 +145,7 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit "must return :#{symbol} ServiceResult" doresult = subject.call(operation: :download_link_query, user:, file_link:, storage:)expect(result).to be_failure- expect(result.errors.code).to be(symbol)+ expect(result.errors.code).to eq(symbol)endendend@@ -310,9 +310,9 @@ RSpec.describe Storages::Peripherals::StorageRequests, webmock: true doit 'must return an upload link URL' dolink = subject.call(operation: :upload_link_query, storage:, user:, data: query_payload).result- expect(link.destination.path).to be_eql("/index.php/apps/integration_openproject/direct-upload/#{upload_token}")- expect(link.destination.host).to be_eql(URI(url).host)- expect(link.destination.scheme).to be_eql(URI(url).scheme)+ expect(link.destination.path).to eql("/index.php/apps/integration_openproject/direct-upload/#{upload_token}")+ expect(link.destination.host).to eql(URI(url).host)+ expect(link.destination.scheme).to eql(URI(url).scheme)expect(link.destination.user).to be_nilexpect(link.destination.password).to be_nilexpect(link.method).to eq(:post)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_api_spec.rbsimilarity index 97%rename from modules/storages/spec/requests/api/v3/file_links/file_links_spec.rbrename to modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rbindex ee9e2e76e2b..7857f548a7a 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_api_spec.rb@@ -558,10 +558,10 @@ RSpec.describe 'API v3 file links resource' dodescribe 'with successful response' dobefore do- clazz = Storages::Peripherals::StorageInteraction::Nextcloud::DownloadLinkQuery- instance = instance_double(clazz)- allow(clazz).to receive(:new).and_return(instance)- allow(instance).to receive(:call).and_return(ServiceResult.success(result: url))+ Storages::Peripherals::Registry.stub(+ 'queries.nextcloud.download_link_query',+ ->(_) { ServiceResult.success(result: url) }+ )endit 'responds successfully' do@@ -574,11 +574,9 @@ RSpec.describe 'API v3 file links resource' dodescribe 'with query failed' dobefore do- clazz = Storages::Peripherals::StorageInteraction::Nextcloud::DownloadLinkQuery- instance = instance_double(clazz)- allow(clazz).to receive(:new).and_return(instance)- allow(instance).to receive(:call).and_return(- ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error))+ Storages::Peripherals::Registry.stub(+ 'queries.nextcloud.download_link_query',+ ->(_) { ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error)) })get pathdiff --git a/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb b/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rbindex ba1f054a6f6..a1d46287d24 100644--- a/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb+++ b/modules/storages/spec/requests/api/v3/storages/storage_files_api_spec.rb@@ -28,14 +28,11 @@require 'spec_helper'require_module_spec_helper-require 'dry/container/stub'RSpec.describe 'API v3 storage files', content_type: :json, webmock: true doinclude API::V3::Utilities::PathHelperinclude StorageServerHelpers- Storages::Peripherals::Registry.enable_stubs!-let(:permissions) { %i(view_work_packages view_file_links) }let(:project) { create(:project) }@@ -61,8 +58,6 @@ RSpec.describe 'API v3 storage files', content_type: :json, webmock: true dologin_as current_userend- after { Storages::Peripherals::Registry.unstub }-describe 'GET /api/v3/storages/:storage_id/files' dolet(:path) { api_v3_paths.storage_files(storage.id) }@@ -292,10 +287,10 @@ RSpec.describe 'API v3 storage files', content_type: :json, webmock: true dodescribe 'with successful response' dobefore do- clazz = Storages::Peripherals::StorageInteraction::Nextcloud::UploadLinkQuery- instance = instance_double(clazz)- allow(clazz).to receive(:new).and_return(instance)- allow(instance).to receive(:call).and_return(ServiceResult.success(result: upload_link))+ Storages::Peripherals::Registry.stub(+ 'queries.nextcloud.upload_link_query',+ ->(_) { ServiceResult.success(result: upload_link) }+ )endsubject { last_response.body }diff --git a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rbindex 440ad7a4c02..60f3b7caf8c 100644--- a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb+++ b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb@@ -29,7 +29,6 @@#++require 'spec_helper'-require 'dry/container/stub'RSpec.describe Storages::FileLinkSyncService, type: :model dolet(:user) { create(:user) }@@ -47,9 +46,6 @@ RSpec.describe Storages::FileLinkSyncService, type: :model dosubject(:service) { described_class.new(user:).call(file_links) }- before { Storages::Peripherals::Registry.enable_stubs! }- after { Storages::Peripherals::Registry.unstub }-describe '#call' docontext 'with one file link' dolet(:file_info) { build(:storage_file_info) }diff --git a/modules/storages/spec/spec_helper.rb b/modules/storages/spec/spec_helper.rbindex 15d27f62fe6..8c8d772a756 100644--- a/modules/storages/spec/spec_helper.rb+++ b/modules/storages/spec/spec_helper.rb@@ -33,5 +33,11 @@# This will include any support file from OpenProject corerequire 'spec_helper'require 'dry/container/stub'+# Loads files from relative support/ directoryDir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }++RSpec.configure do |config|+ config.before(:suite) { Storages::Peripherals::Registry.enable_stubs! }+ config.append_after { Storages::Peripherals::Registry.unstub }+end