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
WIP - Fixed Rubocop issues and last ToDos
Frank Bergmannf74e73370d6f
diff --git a/app/services/oauth_clients/connection_manager.rb b/app/services/oauth_clients/connection_manager.rbindex 76de3f3d4af..1b308438feb 100644--- a/app/services/oauth_clients/connection_manager.rb+++ b/app/services/oauth_clients/connection_manager.rb@@ -47,6 +47,7 @@ module OAuthClients# @param state (OAuth2 RFC) encapsulates the state of the calling page (URL + params) to return# @param scope (OAuth2 RFC) specifies the resources to access. Nextcloud only has one global scope.# @return ServiceResult with ServiceResult.result being either an OAuthClientToken or a redirection URL+ # ToDo: get_access_token against a timeout server produces a OAuth URL response, that's not really correct.def get_access_token(scope: [], state: nil)# Check for an already existing token from last calltoken = get_existing_tokendiff --git a/modules/storages/app/models/storages/file_link.rb b/modules/storages/app/models/storages/file_link.rbindex 84d90c9bd8e..786295bf86f 100644--- a/modules/storages/app/models/storages/file_link.rb+++ b/modules/storages/app/models/storages/file_link.rb@@ -59,6 +59,7 @@ class Storages::FileLink < ApplicationRecord# Is this file shared with me in Nextcloud?# This attribute is _not_ to be stored in the DBattr_writer :origin_permission+def origin_permission@origin_permission || nilenddiff --git a/modules/storages/app/services/storages/file_link_sync_service.rb b/modules/storages/app/services/storages/file_link_sync_service.rbindex 9efc6d4ebde..ef28dec108c 100644--- a/modules/storages/app/services/storages/file_link_sync_service.rb+++ b/modules/storages/app/services/storages/file_link_sync_service.rb@@ -128,7 +128,6 @@ class Storages::FileLinkSyncService# failure: result= :error or :not_authorizedparse_files_info_response(response)end- # ToDo: discuss: without_success: true# Pass errors from Nextcloud into service result@service_result.merge!(nextcloud_request_result)@@ -142,7 +141,6 @@ class Storages::FileLinkSyncServicedef set_error_for_file_links(storage_file_links)@service_result.result += storage_file_links.each { |file_link| file_link.origin_permission = :error }- # ToDo: Discuss: Remove next line?@service_result.success = falseenddiff --git a/modules/storages/openproject-storages.gemspec b/modules/storages/openproject-storages.gemspecindex 37e6c411210..d25baefd6a8 100644--- a/modules/storages/openproject-storages.gemspec+++ b/modules/storages/openproject-storages.gemspec@@ -25,7 +25,7 @@# prepare one.## - Frank Bergmann has put together additional tips and tricks on how to setup a-# development environment and to get started developing: ToDo: Publish PPTs+# development environment and to get started developing## Other good resources:# - Modules vs. Classes:diff --git a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rbindex bcb1e3fc51a..3cb283ca6e0 100644--- a/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb+++ b/modules/storages/spec/requests/api/v3/file_links/mixed_case_file_links_integration_spec.rb@@ -117,6 +117,7 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: truetrashed: true}end+subject { last_response }before do@@ -175,7 +176,6 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true# https://host-error/: Simulates a Nextcloud with network timeoutstub_request(:post, host_error).to_return(status: 500)- # ToDo: get_access_token against a timeout server produces a OAuth URL response, that's not really correct.# https://host-timeout/: Simulates a Nextcloud with network timeoutstub_request(:post, host_timeout).to_timeout@@ -188,27 +188,27 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true# total, count, element_type, collection_type = 'Collection'it_behaves_like 'API V3 collection response', 5, 5, 'FileLink', 'Collection' do- let(:elements) {+ let(:elements) do[file_link_timeout_happy,file_link_error_happy,file_link_unauth_happy,file_link_other_user,file_link_happy- # We didn't include file_link_trashed here, as it won't appear+ # We didn't include file_link_trashed here, as it's not returned by API]- }+ endendit 'returns the file_links with correct Nextcloud data applied' do- puts subject.body+ # GET returns a collection of FileLinks in "_embedded/elements"elements = JSON.parse(subject.body).dig("_embedded", "elements")- puts JSON.pretty_generate(elements)- puts elements.map { |e| e["originData"]["id"] }# A "happy" file link should be visiblehappy_file_link = elements.detect { |e| e["originData"]["id"] == "24" }expect(happy_file_link["_links"]["permission"]["href"]).to eql API::V3::FileLinks::URN_PERMISSION_VIEW+ # Check that we've got an updated mtime+ expect(happy_file_link["originData"]["lastModifiedAt"]).to eql Time.zone.at(1655301234).iso8601# A file link created by another user is not_allowedother_user_file_link = elements.detect { |e| e["originData"]["id"] == "25" }@@ -221,7 +221,7 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: true# The deleted_file_link should not even appear in the Database anymoredeleted_file_link = elements.detect { |e| e["originData"]["id"] == "27" }expect(deleted_file_link).to be_nil- expect(::Storages::FileLink.where(origin_id: '27').any?).to be_falsey+ expect(::Storages::FileLink.where(origin_id: '27').count).to be 0# The FileLink from a Nextcloud with error should have origin_permission=:errorerror_file_link = elements.detect { |e| e["originData"]["id"] == "29" }@@ -231,6 +231,5 @@ describe 'API v3 file links resource', with_flag: { storages_module_active: trueerror_file_link = elements.detect { |e| e["originData"]["id"] == "30" }expect(error_file_link["_links"]["permission"]["href"]).to eql API::V3::FileLinks::URN_PERMISSION_ERRORend- # ToDo: it 'returns file_link1 with updated mtime' do expect(subject.status).to be 200 endendenddiff --git a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rbindex 40c049aa1e9..bb4f2b74e15 100644--- a/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb+++ b/modules/storages/spec/services/storages/file_links/file_link_sync_service_spec.rb@@ -96,9 +96,8 @@ describe ::Storages::FileLinkSyncService, type: :model dolet(:ocs_meta_s401) { { status: "failure", statuscode: 997, message: "No login", totalitems: "", itemsperpage: "" } }# Reply from Nextcloud if not allowed to access file:- # OP should still show the file.- # This reply appears for example when some other user shares a file with a OP WorkPackage.- # ToDo: Design error of Nextcloud openproject_integration? Should include attributes!+ # OpenProject should still show the file.+ # This reply appears for example when some other user shares a file.let(:file_info_s403) { { status: "Forbidden", statuscode: 403 } }# Reply from Nextcloud if Nextcloud internally can't find the file:@@ -252,13 +251,13 @@ describe ::Storages::FileLinkSyncService, type: :model doheaders: { 'Content-Type': 'application/json; charset=utf-8' },body: { ocs: { meta: ocs_meta_s200, data: { '24': file_info1_s200 } } }.to_json)end- # ToDo: Do I check that refresh_token is only called once?# Just check that some update has happened.it 'updates the file_link information' doexpect(subject).to be_a ServiceResultexpect(subject.success).to be_truthyexpect(subject.result[0].origin_updated_at).to eql Time.zone.at(1655301234) # updated+ expect(connection_manager).to have_received(:refresh_token).onceendend