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
Fix the return of the OneDrive::Queries::FileInfoQuery
Marcello Rochaff43a6ad6902
diff --git a/modules/storages/app/common/storages/adapters/providers/one_drive/queries/file_info_query.rb b/modules/storages/app/common/storages/adapters/providers/one_drive/queries/file_info_query.rbindex 780ebe70c6a..c2f9b1ad184 100644--- a/modules/storages/app/common/storages/adapters/providers/one_drive/queries/file_info_query.rb+++ b/modules/storages/app/common/storages/adapters/providers/one_drive/queries/file_info_query.rb@@ -55,7 +55,7 @@ module Storagesdef admin_query(file_id)Authentication[userless_strategy].call(storage: @storage) do |http|drive_item_query.call(http:, drive_item_id: file_id, fields: FIELDS)- .bind { |json| storage_file_info(json, status: "forbidden", status_code: 403) }+ .fmap { |json| storage_file_info(json, status: "forbidden", status_code: 403) }endenddiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 12b682841e8..820d6cac991 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -123,6 +123,7 @@ en:messages:error: An unexpected error occurred. Please check OpenProject logs for more information or contact an administratorunauthorized: OpenProject could not authenticate with the Storage Provider. Please ensure that you have access to it.+ not_found: OpenProject could not find the file on the Storage Provider. Please check if it wasn't deleted.models:copy_project_folders_service:conflict: The folder %{destination_path} already exists. Interrupting process to avoid overwrites.diff --git a/modules/storages/spec/services/storages/storage_file_service_spec.rb b/modules/storages/spec/services/storages/storage_file_service_spec.rbnew file mode 100644index 00000000000..7d899c0a2db--- /dev/null+++ b/modules/storages/spec/services/storages/storage_file_service_spec.rb@@ -0,0 +1,92 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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"+require_module_spec_helper++module Storages+ RSpec.describe StorageFileService, :webmock do+ shared_examples "storage file service: successful response" do+ it "returns a success with a Adapters::Results::StorageFileInfo" do+ service_result = described_class.call(storage:, user:, file_id:)++ expect(service_result).to be_success+ file_info = service_result.result+ expect(file_info).to be_a(Adapters::Results::StorageFileInfo)+ expect(file_info.id).to eq(file_id)+ end+ end++ shared_examples "storage file service: not found" do+ it "returns a failure with code :not_found" do+ result = described_class.call(storage:, user:, file_id:)++ expect(result).to be_failure+ expect(result.errors[:base]).to eq([I18n.t("services.errors.messages.not_found")])+ end+ end++ describe "Nextcloud Storage" do+ shared_let(:user) { create(:user) }+ shared_let(:storage) do+ create(:nextcloud_storage_with_local_connection, :as_not_automatically_managed, oauth_client_token_user: user)+ end++ context "when the file exists", vcr: "nextcloud/file_info_query_success_file" do+ let(:file_id) { "267" }++ it_behaves_like "storage file service: successful response"+ end++ context "when the file does not exists", vcr: "nextcloud/file_info_query_not_found" do+ let(:file_id) { "not_existent" }++ it_behaves_like "storage file service: not found"+ end+ end++ describe "OneDriveStorage" do+ shared_let(:user) { create(:user) }+ shared_let(:storage) { create(:one_drive_sandbox_storage, oauth_client_token_user: user) }++ context "when the file exists", vcr: "one_drive/file_info_query_success_file" do+ let(:file_id) { "01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA" }++ it_behaves_like "storage file service: successful response"+ end++ context "when the file does not exists", vcr: "one_drive/file_info_query_not_found" do+ let(:file_id) { "not_existent" }++ it_behaves_like "storage file service: not found"+ end+ end+ end+end