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
[#55158] added PR comments
Eric Schubertf01cf4647be3
diff --git a/docs/api/apiv3/components/examples/storage-one-drive-incomplete-response.yml b/docs/api/apiv3/components/examples/storage-one-drive-incomplete-response.ymlindex e5b63875491..22ef0500b13 100644--- a/docs/api/apiv3/components/examples/storage-one-drive-incomplete-response.yml+++ b/docs/api/apiv3/components/examples/storage-one-drive-incomplete-response.yml@@ -8,7 +8,7 @@ value:driveId: nullcreatedAt: '2021-12-20T13:37:00.211Z'updatedAt: '2021-12-20T13:37:00.211Z'- complete: true+ complete: false_links:self:href: /api/v3/storages/1337diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex 728eb983d6e..a95db7e820c 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -102,7 +102,7 @@ module API::V3::Storagesgetter: ->(represented:, **) { represented.drive_id if represented.provider_type_one_drive? },setter: ->(fragment:, represented:, **) { represented.drive_id = fragment }- property :complete,+ property :configured,skip_parse: true,getter: ->(represented:, **) { represented.configured? }diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rbindex 4f0a733d8b0..0a897983be7 100644--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb@@ -59,7 +59,7 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" dolet(:value) { storage.name }end- it_behaves_like "property", :complete do+ it_behaves_like "property", :configured dolet(:value) { true }end@@ -218,11 +218,15 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" doit_behaves_like "common file storage properties"- describe "properties (Nextcloud only)" do- it_behaves_like "property", :hasApplicationPassword do+ context "if file storage is not completely configured" do+ let(:storage) { build_stubbed(:nextcloud_storage, oauth_client: nil) }++ it_behaves_like "property", :configured dolet(:value) { false }end+ end+ describe "properties (Nextcloud only)" dodescribe "hasApplicationPassword" doit_behaves_like "property", :hasApplicationPassword dolet(:value) { false }@@ -296,6 +300,14 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" doit_behaves_like "common file storage properties"+ context "if file storage is not completely configured" do+ let(:storage) { build_stubbed(:one_drive_storage, drive_id: nil, oauth_client: oauth_client_credentials) }++ it_behaves_like "property", :configured do+ let(:value) { false }+ end+ end+describe "properties (OneDrive/SharePoint only)" doit_behaves_like "property", :tenantId dolet(:value) { storage.tenant_id }diff --git a/spec/lib/api/v3/oauth/oauth_applications_representer_rendering_spec.rb b/spec/lib/api/v3/oauth/oauth_applications_representer_rendering_spec.rbnew file mode 100644index 00000000000..5fbf82cf79b--- /dev/null+++ b/spec/lib/api/v3/oauth/oauth_applications_representer_rendering_spec.rb@@ -0,0 +1,133 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require "spec_helper"++RSpec.describe API::V3::OAuth::OAuthApplicationsRepresenter, "rendering" do+ let(:user) { build_stubbed(:user) }+ let(:oauth_application) { build_stubbed(:oauth_application) }+ let(:representer) { described_class.new(oauth_application, current_user: user, embed_links: true) }++ subject(:generated) { representer.to_json }++ describe "properties" do+ it_behaves_like "property", :_type do+ let(:value) { "OAuthApplication" }+ end++ it_behaves_like "property", :id do+ let(:value) { oauth_application.id }+ end++ it_behaves_like "property", :name do+ let(:value) { oauth_application.name }+ end++ it_behaves_like "property", :clientId do+ let(:value) { oauth_application.uid }+ end++ it_behaves_like "datetime property", :createdAt do+ let(:value) { oauth_application.created_at }+ end++ it_behaves_like "datetime property", :updatedAt do+ let(:value) { oauth_application.updated_at }+ end++ it_behaves_like "property", :scopes do+ let(:value) { ["api_v3"] }+ end++ describe "confidential" do+ context "if the oauth application is confidential" do+ it_behaves_like "property", :confidential do+ let(:value) { true }+ end+ end++ context "if the oauth application is not confidential" do+ let(:oauth_application) { build_stubbed(:oauth_application, confidential: false) }++ it_behaves_like "property", :confidential do+ let(:value) { false }+ end+ end+ end++ describe "clientSecret" do+ context "if the oauth application is not confidential" do+ let(:oauth_application) { build_stubbed(:oauth_application, confidential: false) }++ it_behaves_like "no property", :clientSecret+ end++ context "if the oauth application is confidential, but not just created" do+ it_behaves_like "no property", :clientSecret+ end++ context "if the oauth application is confidential and just created" do+ before do+ allow(oauth_application).to receive_messages(plaintext_secret: "my-secret")+ end++ it_behaves_like "property", :clientSecret do+ let(:value) { "my-secret" }+ end+ end+ end+ end++ describe "_links" do+ describe "self" do+ it_behaves_like "has a titled link" do+ let(:link) { "self" }+ let(:href) { "/api/v3/oauth_applications/#{oauth_application.id}" }+ let(:title) { oauth_application.name }+ end+ end++ describe "redirectUri" do+ it_behaves_like "has a link collection" do+ let(:link) { "redirectUri" }+ let(:hrefs) { [{ href: oauth_application.redirect_uri }] }+ end++ context "if multiple redirect uris are defined" do+ let(:oauth_application) do+ build_stubbed(:oauth_application, redirect_uri: "https://my.deathstar.com\nhttps://starkiller.base.fo")+ end++ it_behaves_like "has a link collection" do+ let(:link) { "redirectUri" }+ let(:hrefs) { [{ href: "https://my.deathstar.com" }, { href: "https://starkiller.base.fo" }] }+ end+ end+ end+ end+end