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
[#45860] amend unit tests to test for location
Eric Schubert695fe185be7b
diff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rbindex 0ae259a0b15..2aabe027ec8 100644--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb@@ -184,8 +184,11 @@ describe Storages::Peripherals::StorageRequests, webmock: true doenddescribe '#files_query' do- let(:xml) { create(:webdav_data) }- let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}" }+ let(:parent) { '' }+ let(:root_path) { '' }+ let(:xml) { create(:webdav_data, parent_path: parent, root_path:) }+ let(:url) { "https://example.com#{root_path}" }+ let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}#{parent}" }before doallow(OAuthClients::ConnectionManager).to receive(:new).and_return(connection_manager)@@ -289,17 +292,15 @@ describe Storages::Peripherals::StorageRequests, webmock: true dodescribe 'with parent query parameter' dolet(:parent) { '/Photos/Birds' }- let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}#{parent}" }-- before do- stub_request(:propfind, request_url).to_return(status: 207, body: xml, headers: {})- endit dosubject.files_query(user:).match(- on_success: ->(query) { query.call(parent) },+ on_success: ->(query) {+ result = query.call(parent)+ expect(result.result[3].location).to eq('/Photos/Birds/README.md')+ },on_failure: ->(error) { raise "Files query could not be created: #{error}" })@@ -308,13 +309,16 @@ describe Storages::Peripherals::StorageRequests, webmock: true doenddescribe 'with storage running on a sub path' do- let(:url) { 'https://example.com/storage' }+ let(:root_path) { '/storage' }it dosubject.files_query(user:).match(- on_success: ->(query) { query.call(nil) },+ on_success: ->(query) {+ result = query.call(nil)+ expect(result.result[3].location).to eq('/README.md')+ },on_failure: ->(error) { raise "Files query could not be created: #{error}" })@@ -323,15 +327,17 @@ describe Storages::Peripherals::StorageRequests, webmock: true doenddescribe 'with storage running on a sub path and with parent parameter' do- let(:url) { 'https://example.com/storage' }+ let(:root_path) { '/storage' }let(:parent) { '/Photos/Birds' }- let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}#{parent}" }it dosubject.files_query(user:).match(- on_success: ->(query) { query.call(parent) },+ on_success: ->(query) {+ result = query.call(parent)+ expect(result.result[3].location).to eq('/Photos/Birds/README.md')+ },on_failure: ->(error) { raise "Files query could not be created: #{error}" })diff --git a/modules/storages/spec/factories/webdav_data_factory.rb b/modules/storages/spec/factories/webdav_data_factory.rbindex d1091b848d1..8a8d6d12fd0 100644--- a/modules/storages/spec/factories/webdav_data_factory.rb+++ b/modules/storages/spec/factories/webdav_data_factory.rb@@ -28,9 +28,16 @@FactoryBot.define dofactory :webdav_data, class: 'String' do+ transient do+ root_path { '' }+ parent_path { '' }+ end+skip_createinitialize_with do+ base_path = File.join(root_path, '/remote.php/dav/files/admin', parent_path)+Nokogiri::XML::Builder.new do |xml|xml['d'].multistatus('xmlns:d' => 'DAV:',@@ -39,7 +46,7 @@ FactoryBot.define do'xmlns:nc' => 'http://nextcloud.org/ns') doxml['d'].response do- xml['d'].href('/remote.php/dav/files/admin/')+ xml['d'].href(base_path)xml['d'].propstat doxml['d'].prop doxml['oc'].fileid('6')@@ -58,7 +65,7 @@ FactoryBot.define doendendxml['d'].response do- xml['d'].href('/remote.php/dav/files/admin/Folder1/')+ xml['d'].href(File.join(base_path, 'Folder1', ''))xml['d'].propstat doxml['d'].prop doxml['oc'].fileid('11')@@ -77,7 +84,7 @@ FactoryBot.define doendendxml['d'].response do- xml['d'].href('/remote.php/dav/files/admin/Folder2/')+ xml['d'].href(File.join(base_path, 'Folder2', ''))xml['d'].propstat doxml['d'].prop doxml['oc'].fileid('20')@@ -96,7 +103,7 @@ FactoryBot.define doendendxml['d'].response do- xml['d'].href('/remote.php/dav/files/admin/README.md')+ xml['d'].href(File.join(base_path, 'README.md'))xml['d'].propstat doxml['d'].prop doxml['oc'].fileid('12')@@ -110,7 +117,7 @@ FactoryBot.define doendendxml['d'].response do- xml['d'].href('/remote.php/dav/files/admin/Manual.pdf')+ xml['d'].href(File.join(base_path, 'Manual.pdf'))xml['d'].propstat doxml['d'].prop doxml['oc'].fileid('13')