Skip to content

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

Update tests to rely on the registry

Marcello Rocha59c92f41aebf
diff --git a/modules/storages/app/services/storages/storage_file_service.rb b/modules/storages/app/services/storages/storage_file_service.rb
index 6a00ac7653c..6b664d92f1a 100644
--- a/modules/storages/app/services/storages/storage_file_service.rb
+++ b/modules/storages/app/services/storages/storage_file_service.rb
@@ -38,7 +38,7 @@ module Storages
auth_strategy = strategy(storage, user)
info "Requesting file #{file_id} information on #{storage.name}"
- Peripherals::Registry.resolve("#{storage}.queries.file_info").call(storage:, auth_strategy:, folder:)
+ Peripherals::Registry.resolve("#{storage}.queries.file_info").call(storage:, auth_strategy:, file_id:)
end
private
diff --git a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
index cf083a9351f..e5749975862 100644
--- a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
+++ b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
@@ -73,7 +73,7 @@ module API::V3::StorageFiles
route_param :file_id, type: String, desc: "Storage file id" do
get do
- Storages::StorageFilesService
+ Storages::StorageFileService
.call(storage: @storage, user: current_user, file_id: params[:file_id])
.map { |file_info| to_storage_file(file_info) }
.match(
diff --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.rb
index 4f5d4265c11..049ae17fb7d 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
@@ -43,14 +43,14 @@ RSpec.describe "API v3 storage files", :webmock, content_type: :json do
end
let(:oauth_application) { create(:oauth_application) }
- let(:storage) { create(:nextcloud_storage, creator: current_user, oauth_application:) }
+ let(:storage) { create(:nextcloud_storage_configured, creator: current_user, oauth_application:) }
+ let(:oauth_token) { create(:oauth_client_token, user: current_user, oauth_client: storage.oauth_client) }
let(:project_storage) { create(:project_storage, project:, storage:) }
- subject(:last_response) do
- get path
- end
+ subject(:last_response) { get path }
before do
+ oauth_application
project_storage
login_as current_user
end
@@ -205,12 +205,9 @@ RSpec.describe "API v3 storage files", :webmock, content_type: :json do
context "with query failed" do
before do
- clazz = Storages::Peripherals::StorageInteraction::Nextcloud::FileInfoQuery
- 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("#{storage}.queries.file_info",
+ ->(_) { ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error)) })
end
context "with authorization failure" do