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

[#54553] fixed test setup and query usage

Eric Schubertc076d8b8186d
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
index ef604efcff0..fcf1a4d1c74 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
@@ -57,9 +57,10 @@ module Storages
private
def upload_data_failure
- Util.failure(code: :error,
- data: StorageErrorData.new(source: self.class),
- log_message: "Invalid upload data!")
+ ServiceResult.failure(result: :error,
+ errors: StorageError.new(code: :error,
+ data: StorageErrorData.new(source: self.class),
+ log_message: "Invalid upload data!"))
end
def invalid?(upload_data:)
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb
index a05ec40e2b4..fe18cd81966 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/copy_template_folder_command_spec.rb
@@ -95,7 +95,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::CopyTemplate
command_result = described_class.call(storage:, source_path:, destination_path: "My New Folder")
expect(command_result).to be_success
- expect(command_result.result.requires_polling?).to be_truthy
+ expect(command_result.result).to be_requires_polling
expect(command_result.result.polling_url).to match %r</drives/#{storage.drive_id}/items/.+\?.+$>
ensure
delete_copied_folder(command_result.result.polling_url)
@@ -161,11 +161,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::CopyTemplate
subfolder = command.call(auth_strategy:, folder_name: "Subfolder with File", parent_location:).result
file_name = "files_query_root.yml"
- token = OAuthClientToken.last
-
+ upload_data = Storages::UploadData.new(folder_id: subfolder.id, file_name:)
upload_link = Storages::Peripherals::Registry
.resolve("one_drive.queries.upload_link")
- .call(storage:, user: token.user, data: { "parent" => subfolder.id, "file_name" => file_name })
+ .call(storage:, auth_strategy:, upload_data:)
.result
path = Rails.root.join("modules/storages/spec/support/fixtures/vcr_cassettes/one_drive", file_name)
diff --git a/modules/storages/spec/lib/api/v3/storage_files/storage_upload_link_representer_spec.rb b/modules/storages/spec/lib/api/v3/storage_files/storage_upload_link_representer_spec.rb
index faee87adc67..7f8613bcdc0 100644
--- a/modules/storages/spec/lib/api/v3/storage_files/storage_upload_link_representer_spec.rb
+++ b/modules/storages/spec/lib/api/v3/storage_files/storage_upload_link_representer_spec.rb
@@ -38,7 +38,7 @@ RSpec.describe API::V3::StorageFiles::StorageUploadLinkRepresenter, "rendering"
let(:token) { "xyz123" }
let(:destination) { "https://example.com/upload/#{token}" }
let(:upload_link) do
- Storages::UploadLink.new("https://example.com/upload/#{token}")
+ Storages::UploadLink.new("https://example.com/upload/#{token}", :post)
end
let(:representer) { described_class.new(upload_link, current_user: user) }
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 afe0bd2febe..325d43367fb 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
@@ -31,6 +31,7 @@
require "spec_helper"
require_module_spec_helper
+# rubocop:disable RSpecRails/HaveHttpStatus
RSpec.describe "API v3 storage files", :webmock, content_type: :json do
include API::V3::Utilities::PathHelper
include StorageServerHelpers
@@ -249,7 +250,7 @@ RSpec.describe "API v3 storage files", :webmock, content_type: :json do
describe "POST /api/v3/storages/:storage_id/files/prepare_upload" do
let(:permissions) { %i(view_work_packages view_file_links manage_file_links) }
let(:path) { api_v3_paths.prepare_upload(storage.id) }
- let(:upload_link) { Storages::UploadLink.new("https://example.com/upload/xyz123") }
+ let(:upload_link) { Storages::UploadLink.new("https://example.com/upload/xyz123", :post) }
let(:body) { { fileName: "ape.png", parent: "/Pictures", projectId: project.id }.to_json }
subject(:last_response) do
@@ -323,3 +324,5 @@ RSpec.describe "API v3 storage files", :webmock, content_type: :json do
end
end
end
+
+# rubocop:enable RSpecRails/HaveHttpStatus