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

[#53370] fixed files query unit test

Eric Schubert8c720c9eadaf
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.rb
index a6e426cc6cf..427180aba28 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
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery, :vcr, :webmock do
@@ -38,13 +38,13 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,
let(:storage) do
create(:nextcloud_storage_with_local_connection, :as_not_automatically_managed, oauth_client_token_user: user)
end
- let(:folder) { Storages::Peripherals::ParentFolder.new('/') }
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/") }
let(:auth_strategy) do
Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken.strategy.with_user(user)
end
- describe '#call' do
- it 'responds with correct parameters' do
+ describe "#call" do
+ it "responds with correct parameters" do
expect(described_class).to respond_to(:call)
method = described_class.method(:call)
@@ -53,10 +53,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,
%i[keyreq folder])
end
- context 'with outbound requests successful' do
- context 'with parent folder being root', vcr: 'nextcloud/files_query_root' do
+ context "with outbound requests successful" do
+ context "with parent folder being root", vcr: "nextcloud/files_query_root" do
# rubocop:disable RSpec/ExampleLength
- it 'returns a StorageFiles object for root' do
+ it "returns a StorageFiles object for root" do
storage_files = described_class.call(storage:, auth_strategy:, folder:).result
expect(storage_files).to be_a(Storages::StorageFiles)
@@ -67,48 +67,48 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,
expect(storage_files.files.map(&:to_h))
.to eq([
{
- id: '172',
- name: 'Folder',
+ id: "172",
+ name: "Folder",
size: 982713473,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2023-11-29T15:31:30Z',
+ created_by_name: "admin",
+ last_modified_at: "2023-11-29T15:31:30Z",
last_modified_by_name: nil,
- location: '/Folder',
- mime_type: 'application/x-op-directory',
+ location: "/Folder",
+ mime_type: "application/x-op-directory",
permissions: %i[readable writeable]
}, {
- id: '173',
- name: 'Folder with spaces',
+ id: "173",
+ name: "Folder with spaces",
size: 74,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2023-11-29T15:42:21Z',
+ created_by_name: "admin",
+ last_modified_at: "2023-11-29T15:42:21Z",
last_modified_by_name: nil,
- location: '/Folder%20with%20spaces',
- mime_type: 'application/x-op-directory',
+ location: "/Folder%20with%20spaces",
+ mime_type: "application/x-op-directory",
permissions: %i[readable writeable]
}, {
- id: '211',
- name: 'Practical_guide_to_BAGGM_Digital.pdf',
+ id: "211",
+ name: "Practical_guide_to_BAGGM_Digital.pdf",
size: 154592937,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2022-08-09T06:53:12Z',
+ created_by_name: "admin",
+ last_modified_at: "2022-08-09T06:53:12Z",
last_modified_by_name: nil,
- location: '/Practical_guide_to_BAGGM_Digital.pdf',
- mime_type: 'application/pdf',
+ location: "/Practical_guide_to_BAGGM_Digital.pdf",
+ mime_type: "application/pdf",
permissions: %i[readable writeable]
}, {
- id: '178',
- name: 'Readme.md',
+ id: "178",
+ name: "Readme.md",
size: 31,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2023-11-29T15:29:16Z',
+ created_by_name: "admin",
+ last_modified_at: "2023-11-29T15:29:16Z",
last_modified_by_name: nil,
- location: '/Readme.md',
- mime_type: 'text/markdown',
+ location: "/Readme.md",
+ mime_type: "text/markdown",
permissions: %i[readable writeable]
}
])
@@ -116,88 +116,88 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::FilesQuery,
# rubocop:enable RSpec/ExampleLength
end
- context 'with a given parent folder', vcr: 'nextcloud/files_query_parent_folder' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder with spaces/New Requests') }
+ context "with a given parent folder", vcr: "nextcloud/files_query_parent_folder" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/Folder with spaces/New Requests") }
subject do
described_class.call(storage:, auth_strategy:, folder:).result
end
# rubocop:disable RSpec/ExampleLength
- it 'returns the files content' do
+ it "returns the files content" do
expect(subject.files.size).to eq(2)
expect(subject.files.map(&:to_h))
.to eq([
{
- id: '181',
- name: 'request_001.md',
+ id: "181",
+ name: "request_001.md",
size: 48,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2023-11-29T15:35:25Z',
+ created_by_name: "admin",
+ last_modified_at: "2023-11-29T15:35:25Z",
last_modified_by_name: nil,
- location: '/Folder%20with%20spaces/New%20Requests/request_001.md',
- mime_type: 'text/markdown',
+ location: "/Folder%20with%20spaces/New%20Requests/request_001.md",
+ mime_type: "text/markdown",
permissions: %i[readable writeable]
}, {
- id: '182',
- name: 'request_002.md',
+ id: "182",
+ name: "request_002.md",
size: 26,
created_at: nil,
- created_by_name: 'admin',
- last_modified_at: '2023-11-29T15:35:34Z',
+ created_by_name: "admin",
+ last_modified_at: "2023-11-29T15:35:34Z",
last_modified_by_name: nil,
- location: '/Folder%20with%20spaces/New%20Requests/request_002.md',
- mime_type: 'text/markdown',
+ location: "/Folder%20with%20spaces/New%20Requests/request_002.md",
+ mime_type: "text/markdown",
permissions: %i[readable writeable]
}
])
end
# rubocop:enable RSpec/ExampleLength
- it 'returns ancestors with a forged id' do
+ it "returns ancestors with a forged id" do
expect(subject.ancestors.map { |a| { id: a.id, name: a.name, location: a.location } })
.to eq([
{
- id: '8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1',
- name: 'Root',
- location: '/'
+ id: "8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1",
+ name: "Root",
+ location: "/"
}, {
- id: 'c8776f1f6dd36c023c6615d39f01a71d68dd1707b232115b7a4f58bc6da94e2e',
- name: 'Folder with spaces',
- location: '/Folder%20with%20spaces'
+ id: "c8776f1f6dd36c023c6615d39f01a71d68dd1707b232115b7a4f58bc6da94e2e",
+ name: "Folder with spaces",
+ location: "/Folder%20with%20spaces"
}
])
end
- it 'returns the parent itself' do
- expect(subject.parent.id).to eq('180')
- expect(subject.parent.name).to eq('New Requests')
- expect(subject.parent.location).to eq('/Folder%20with%20spaces/New%20Requests')
+ it "returns the parent itself" do
+ expect(subject.parent.id).to eq("180")
+ expect(subject.parent.name).to eq("New Requests")
+ expect(subject.parent.location).to eq("/Folder%20with%20spaces/New%20Requests")
end
end
- context 'with parent folder being empty', vcr: 'nextcloud/files_query_empty_folder' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder/empty') }
+ context "with parent folder being empty", vcr: "nextcloud/files_query_empty_folder" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/Folder/empty") }
- it 'returns an empty StorageFiles object with parent and ancestors' do
+ it "returns an empty StorageFiles object with parent and ancestors" do
storage_files = described_class.call(storage:, auth_strategy:, folder:).result
expect(storage_files).to be_a(Storages::StorageFiles)
expect(storage_files.files).to be_empty
- expect(storage_files.parent.id).to eq('174')
+ expect(storage_files.parent.id).to eq("174")
expect(storage_files.ancestors.map(&:name)).to eq(%w[Root Folder])
end
end
end
- context 'with not existent parent folder', vcr: 'nextcloud/files_query_invalid_parent' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/I/just/made/that/up') }
+ context "with not existent parent folder", vcr: "nextcloud/files_query_invalid_parent" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/I/just/made/that/up") }
- it 'must return not found' do
+ it "must return not found" do
result = described_class.call(storage:, auth_strategy:, folder:)
expect(result).to be_failure
- expect(result.error_source).to be_a(described_class)
+ expect(result.error_source).to be(described_class)
result.match(
on_failure: ->(error) { expect(error.code).to eq(:not_found) },