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
[#50987] updated unit tests for files query
Eric Schubert6a6bc3f07578
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_query_spec.rbindex 7fcfd9480c0..fc45148bcba 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/files_query_spec.rb@@ -33,6 +33,7 @@ require_module_spec_helperRSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery, :webmock dolet(:storage) { create(:nextcloud_storage, :with_oauth_client) }+ let(:folder) { Storages::Peripherals::ParentFolder.new('/') }let(:user) { create(:user) }let(:token) docreate(:oauth_client_token, user:, oauth_client: storage.oauth_client, origin_user_id: 'darth@vader with spaces')@@ -57,7 +58,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,endit 'returns a list of files and folders' do- storage_files = files_query.call(storage:, folder: nil, user:).result+ storage_files = files_query.call(storage:, folder:, user:).resultexpect(storage_files).to be_a(Storages::StorageFiles)expect(storage_files.files.size).to eq(4)@@ -71,7 +72,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,endit 'returns permissions for each' do- storage_files = files_query.call(storage:, folder: nil, user:).result+ storage_files = files_query.call(storage:, folder:, user:).resultwriteable_folder = storage_files.files.find { |file| file.mime_type == 'application/x-op-directory' }expect(writeable_folder.permissions).to match_array(%i[readable writeable])@@ -81,15 +82,15 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,endcontext 'when requesting a sub-folder' do- let(:parent) { '/Photos/Birds' }- let(:webdav_subfolder_success_response) { create(:webdav_data, parent_path: parent, root_path: '', origin_user_id:) }+ let(:folder) { Storages::Peripherals::ParentFolder.new('/Photos/Birds') }+ let(:webdav_subfolder_success_response) { create(:webdav_data, parent_path: folder.path, root_path: '', origin_user_id:) }before do- uri = "#{storage.host}/remote.php/dav/files/darth@vader%20with%20spaces#{parent}"+ uri = "#{storage.host}/remote.php/dav/files/darth@vader%20with%20spaces#{folder.path}"stub_request(:propfind, uri).to_return(status: 207, body: webdav_subfolder_success_response, headers: {})end- subject(:query_result) { files_query.call(user:, storage:, folder: parent).result }+ subject(:query_result) { files_query.call(user:, storage:, folder:).result }it 'returns 2 ancestors' doancestors = query_result.ancestors@@ -118,7 +119,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,let(:storage) { create(:nextcloud_storage, :with_oauth_client, host: 'https://example.com/death_star_blueprints') }it 'just works' do- storage_files = files_query.call(storage:, user:, folder: '')+ storage_files = files_query.call(storage:, user:, folder:)expect(storage_files).to be_successend@@ -128,12 +129,12 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,before doallow(Storages::Peripherals::StorageInteraction::Nextcloud::Util).to receive(:token)- .and_return(ServiceResult.failure(result: :unauthorized,- errors: Storages::StorageError.new(code: :unauthorized)))+ .and_return(ServiceResult.failure(result: :unauthorized,+ errors: Storages::StorageError.new(code: :unauthorized)))endit 'returns an ":unauthorized" ServiceResult' do- result = files_query.call(folder: '', user:, storage:)+ result = files_query.call(folder:, user:, storage:)expect(result).to be_failureexpect(result.errors.code).to be(:unauthorized)end@@ -147,7 +148,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,endit "must return :#{symbol} ServiceResult" do- result = files_query.call(folder: '', user:, storage:)+ result = files_query.call(folder:, user:, storage:)expect(result).to be_failureexpect(result.errors.code).to be(symbol)end@@ -158,9 +159,3 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,include_examples 'outbound is failing', 401, :unauthorizedinclude_examples 'outbound is failing', 500, :errorend--# describe 'with storage running on a sub path' do-# let(:root_path) { '/storage' }-# #-# end-# enddiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rbindex cfeee14c24d..c2008e4f4e7 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb@@ -36,6 +36,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,let(:user) { create(:user) }let(:storage) { create(:sharepoint_dev_drive_storage, oauth_client_token_user: user) }+ let(:folder) { Storages::Peripherals::ParentFolder.new('/') }describe '#call' doit 'responds with correct parameters' do@@ -49,7 +50,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,context 'with parent folder being nil', vcr: 'one_drive/files_query_root' do# rubocop:disable RSpec/ExampleLengthit 'returns a StorageFiles object for root' do- storage_files = described_class.call(storage:, user:, folder: nil).result+ storage_files = described_class.call(storage:, user:, folder:).resultexpect(storage_files).to be_a(Storages::StorageFiles)expect(storage_files.ancestors).to be_empty@@ -86,8 +87,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,endcontext 'with a given parent folder', vcr: 'one_drive/files_query_parent_folder' do+ let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder/Subfolder') }+subject do- described_class.call(storage:, user:, folder: '/Folder/Subfolder').result+ described_class.call(storage:, user:, folder:).resultend# rubocop:disable RSpec/ExampleLength@@ -144,8 +147,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,endcontext 'with parent folder being empty', vcr: 'one_drive/files_query_empty_folder' do+ let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder with spaces/very empty folder') }+it 'returns an empty StorageFiles object with parent and ancestors' do- storage_files = described_class.call(storage:, user:, folder: '/Folder with spaces/very empty folder').result+ storage_files = described_class.call(storage:, user:, folder:).resultexpect(storage_files).to be_a(Storages::StorageFiles)expect(storage_files.files).to be_empty@@ -156,8 +161,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,endcontext 'with a path full of umlauts', vcr: 'one_drive/files_query_umlauts' do+ let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder/Ümlæûts') }+it 'returns the correct StorageFiles object' do- storage_files = described_class.call(storage:, user:, folder: '/Folder/Ümlæûts').result+ storage_files = described_class.call(storage:, user:, folder:).resultexpect(storage_files).to be_a(Storages::StorageFiles)expect(storage_files.parent.id).to eq('01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB')@@ -183,8 +190,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,endcontext 'with not existent parent folder', vcr: 'one_drive/files_query_invalid_parent' do+ let(:folder) { Storages::Peripherals::ParentFolder.new('/I/just/made/that/up') }+it 'must return unauthorized' do- result = described_class.call(storage:, user:, folder: '/I/just/made/that/up')+ result = described_class.call(storage:, user:, folder:)expect(result).to be_failureexpect(result.error_source).to be_a(described_class)@@ -204,7 +213,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,endit 'must return unauthorized' do- result = described_class.call(storage:, user:, folder: nil)+ result = described_class.call(storage:, user:, folder:)expect(result).to be_failureexpect(result.error_source).to be_a(described_class)@@ -219,7 +228,7 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,let(:user_without_token) { create(:user) }it 'must return unauthorized' do- result = described_class.call(storage:, user: user_without_token, folder: nil)+ result = described_class.call(storage:, user: user_without_token, folder:)expect(result).to be_failureexpect(result.error_source).to be_a(OAuthClients::ConnectionManager)