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
[#49124] fixed nextcloud open link query with trailing slashes
Eric Schubertd43313c91401
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/open_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/open_link_query.rbindex 57ff7cc70cc..6c0b64c2ad3 100644--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/open_link_query.rb+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/open_link_query.rb@@ -44,7 +44,7 @@ module Storages# rubocop:disable Lint/UnusedMethodArgumentdef call(user:, file_id:, open_location: false)location_flag = open_location ? 0 : 1- ServiceResult.success(result: "#{@uri}/index.php/f/#{file_id}?openfile=#{location_flag}")+ ServiceResult.success(result: File.join(@uri.to_s, "index.php/f/#{file_id}?openfile=#{location_flag}"))end# rubocop:enable Lint/UnusedMethodArgumentdiff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/open_link_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/open_link_query_spec.rbindex 02b10af542e..365182befbb 100644--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/open_link_query_spec.rb+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/nextcloud/open_link_query_spec.rb@@ -34,7 +34,7 @@ require_module_spec_helperRSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::OpenLinkQuery doinclude JsonResponseHelper- let(:storage) { create(:nextcloud_storage, host: 'https://example.com/html') }+ let(:storage) { create(:nextcloud_storage, host: 'https://example.com') }let(:user) { create(:user) }let(:file_id) { '1337' }@@ -54,4 +54,13 @@ RSpec.describe Storages::Peripherals::StorageInteraction::Nextcloud::OpenLinkQueurl = described_class.call(storage:, user:, file_id:, open_location: true).resultexpect(url).to eq("#{storage.host}/index.php/f/#{file_id}?openfile=0")end++ context 'with a storage with host url with a sub path' do+ let(:storage) { create(:nextcloud_storage, host: 'https://example.com/html') }++ it 'returns the url for opening the file on storage' do+ url = described_class.call(storage:, user:, file_id:).result+ expect(url).to eq("#{storage.host}/index.php/f/#{file_id}?openfile=1")+ end+ endenddiff --git a/modules/storages/spec/features/storages_menu_links_spec.rb b/modules/storages/spec/features/storages_menu_links_spec.rbindex c918fbd1082..9a726d72820 100644--- a/modules/storages/spec/features/storages_menu_links_spec.rb+++ b/modules/storages/spec/features/storages_menu_links_spec.rb@@ -31,7 +31,7 @@require 'spec_helper'require_module_spec_helper-RSpec.describe 'Project menu', js: true, with_cuprite: true do+RSpec.describe 'Project menu', :js, :with_cuprite dolet(:storage) { create(:nextcloud_storage, name: "Storage 1") }let(:another_storage) { create(:nextcloud_storage, name: "Storage 2") }let(:unlinked_storage) { create(:nextcloud_storage, name: "Storage 3") }@@ -56,7 +56,7 @@ RSpec.describe 'Project menu', js: true, with_cuprite: true doit 'has links to enabled storages' dovisit(project_path(id: project.id))- expect(page).to have_link(storage.name, href: storage.host)+ expect(page).to have_link(storage.name, href: storage.open_link)project_folder_id = project_storage_with_manual_folder.project_folder_idfolder_href = "#{another_storage.host}/index.php/f/#{project_folder_id}?openfile=1"expect(page).to have_link(another_storage.name, href: folder_href)@@ -69,11 +69,11 @@ RSpec.describe 'Project menu', js: true, with_cuprite: true doit 'has no links to enabled storage' dovisit(project_path(id: project.id))- expect(page).not_to have_link(storage.name, href: storage.host)+ expect(page).not_to have_link(storage.name, href: storage.open_link)project_folder_id = project_storage_with_manual_folder.project_folder_idfolder_href = "#{another_storage.host}/index.php/f/#{project_folder_id}?openfile=1"expect(page).not_to have_link(another_storage.name, href: folder_href)- expect(page).not_to have_link(another_storage.name, href: another_storage.host)+ expect(page).not_to have_link(another_storage.name, href: another_storage.open_link)expect(page).not_to have_link(unlinked_storage.name)endend