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
[#44841] some more fixes and regression tests
Eric Schuberta1ef0dc706c9
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.ymlindex 1f5baf61fa5..f41cb27c6ca 100644--- a/docs/api/apiv3/openapi-spec.yml+++ b/docs/api/apiv3/openapi-spec.yml@@ -864,6 +864,7 @@ tags:- "$ref": "./tags/memberships.yml"- "$ref": "./tags/news.yml"- "$ref": "./tags/notifications.yml"+ - "$ref": "./tags/oauth.yml"- "$ref": "./tags/posts.yml"- "$ref": "./tags/principals.yml"- "$ref": "./tags/priorities.yml"diff --git a/modules/storages/app/services/storages/storages/set_attributes_service.rb b/modules/storages/app/services/storages/storages/set_attributes_service.rbindex c633aa22cd6..e0ec070aa99 100644--- a/modules/storages/app/services/storages/storages/set_attributes_service.rb+++ b/modules/storages/app/services/storages/storages/set_attributes_service.rb@@ -33,7 +33,7 @@ module Storages::Storagesdef set_default_attributes(_params)storage.creator ||= user- storage.name ||= I18n.t("storages.provider_types.#{storage.provider_type}.default_name")+ storage.name ||= derive_default_storage_nameendprivate@@ -45,5 +45,14 @@ module Storages::Storagesdef storagemodelend++ def derive_default_storage_name+ prefix = I18n.t("storages.provider_types.#{storage.provider_type}.default_name")+ last_id = Storages::Storage.where("name like ?", "#{prefix}%").maximum(:id)++ return prefix if last_id.nil?++ "#{prefix} #{last_id + 1}"+ endendenddiff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex b73052daa8a..ebe5ff57898 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -74,7 +74,7 @@ module API::V3::Storages@connection_manager =::OAuthClients::ConnectionManager.new(user: current_user, oauth_client: model.oauth_client)- super(model, current_user:, embed_links:)+ superendproperty :iddiff --git a/modules/storages/spec/services/storages/storages/create_service_spec.rb b/modules/storages/spec/services/storages/storages/create_service_spec.rbindex 5572f216e8e..a3b4054a7de 100644--- a/modules/storages/spec/services/storages/storages/create_service_spec.rb+++ b/modules/storages/spec/services/storages/storages/create_service_spec.rb@@ -29,11 +29,11 @@require 'spec_helper'require 'services/base_services/behaves_like_create_service'-describe ::Storages::Storages::CreateService, type: :model do+describe Storages::Storages::CreateService, type: :model doit_behaves_like 'BaseServices create service' dolet(:factory) { :storage }- let!(:user) { create :admin }+ let!(:user) { create(:admin) }let(:instance) dodescribed_class.new(user:,@@ -58,11 +58,11 @@ describe ::Storages::Storages::CreateService, type: :model doit "creates an OAuth application (::Doorkeeper::Application)" doexpect(subject).to be_success- expect(subject.result.oauth_application).to be_a(::Doorkeeper::Application)+ expect(subject.result.oauth_application).to be_a(Doorkeeper::Application)expect(subject.result.oauth_application.name).to include call_attributes[:name]expect(subject.result.oauth_application.redirect_uri).to include call_attributes[:host]expect(subject.result.oauth_application.owner).to eql user- expect(subject.dependent_results.first.result.secret).to be_present+ expect(subject.result.oauth_application.plaintext_secret).to be_presentendendenddiff --git a/spec/requests/oauth_clients/oauth_client_credentials_spec.rb b/spec/requests/oauth_clients/oauth_client_credentials_spec.rbindex 641fbb67fe4..d87baaa2f03 100644--- a/spec/requests/oauth_clients/oauth_client_credentials_spec.rb+++ b/spec/requests/oauth_clients/oauth_client_credentials_spec.rb@@ -31,12 +31,11 @@ require 'spec_helper'describe 'API v3 oauth applications resource', content_type: :json doinclude API::V3::Utilities::PathHelper- let(:current_user) { create(:admin) }let(:oauth_client_credentials) { create(:oauth_client) }- before do- login_as current_user+ current_user { create(:admin) }+ before doget pathend@@ -46,7 +45,7 @@ describe 'API v3 oauth applications resource', content_type: :json doit_behaves_like 'successful response'context 'as non-admin' do- let(:current_user) { create(:user) }+ current_user { create(:user) }it_behaves_like 'unauthorized access'enddiff --git a/spec/services/oauth_clients/create_service_spec.rb b/spec/services/oauth_clients/create_service_spec.rbindex 4a2aa6036fa..a11d55c12c0 100644--- a/spec/services/oauth_clients/create_service_spec.rb+++ b/spec/services/oauth_clients/create_service_spec.rb@@ -29,8 +29,21 @@require 'spec_helper'require 'services/base_services/behaves_like_create_service'-describe ::OAuthClients::CreateService, type: :model do+describe OAuthClients::CreateService, type: :model doit_behaves_like 'BaseServices create service' dolet(:factory) { :oauth_client }++ context 'if another oauth client for the given integration exists' do+ let(:storage) { create(:storage) }+ let!(:existing_client) { create(:oauth_client, integration: storage) }+ let!(:model_instance) { build_stubbed(:oauth_client, integration: storage) }+ let(:call_attributes) { { name: 'Death Star', integration: storage } }++ it 'overwrites the existing oauth client' do+ # Test setup still returns success, but `subject` must be initialized+ expect(subject).to be_success+ expect(OAuthClient.where(id: existing_client.id)).not_to exist+ end+ endendend