Skip to content

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

Show correct text when audience is nil

Jan Sandbrink48e842b4e587
diff --git a/modules/storages/app/components/storages/admin/storage_audience_info_component.rb b/modules/storages/app/components/storages/admin/storage_audience_info_component.rb
index 2571cd4c091..00472d62008 100644
--- a/modules/storages/app/components/storages/admin/storage_audience_info_component.rb
+++ b/modules/storages/app/components/storages/admin/storage_audience_info_component.rb
@@ -35,7 +35,7 @@ module Storages
def audience_summary
case storage.storage_audience
- when ""
+ when "", nil
I18n.t("storages.file_storage_view.storage_audience_blank")
when OpenIDConnect::UserToken::IDP_AUDIENCE
I18n.t("storages.file_storage_view.storage_audience_idp")
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 3b6edbf272f..81d3cf9feef 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -225,7 +225,7 @@ en:
project_folders: Project folders
redirect_uri: Redirect URI
storage_audience: Storage Audience
- storage_audience_blank: No audience has been configured
+ storage_audience_blank: No audience has been configured.
storage_audience_description: Obtaining tokens for audience "%{audience}".
storage_audience_idp: Using first access token received by identity provider, regardless of audience.
storage_oauth: Nextcloud OAuth
diff --git a/modules/storages/spec/components/storages/admin/storage_audience_info_component_spec.rb b/modules/storages/spec/components/storages/admin/storage_audience_info_component_spec.rb
index 72e39108781..0ec18ba6a87 100644
--- a/modules/storages/spec/components/storages/admin/storage_audience_info_component_spec.rb
+++ b/modules/storages/spec/components/storages/admin/storage_audience_info_component_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -29,32 +31,50 @@
require "spec_helper"
require_module_spec_helper
-RSpec.describe Storages::Admin::OAuthClientInfoComponent, type: :component do # rubocop:disable RSpec/SpecFilePathFormat
- describe "#edit_icon_button_options" do
- context "with oauth client configured" do
- it "returns false, does not render view component" do
- storage = build_stubbed(:nextcloud_storage,
- oauth_client: build_stubbed(:oauth_client))
- component = described_class.new(storage)
- expect(component.edit_icon_button_options)
- .to include(icon: :sync,
- data: { turbo_confirm:
- "This action will reset the current OAuth credentials. After confirming you will " \
- "have to enter new credentials from the storage provider and all users will have " \
- "to authorize against Nextcloud again. Are you sure you want to proceed?",
- turbo_stream: true })
- end
+RSpec.describe Storages::Admin::StorageAudienceInfoComponent, type: :component do
+ let(:storage) { create(:nextcloud_storage, storage_audience:) }
+ let(:storage_audience) { "Alice" }
+
+ subject(:render_component) do
+ render_inline(described_class.new(storage))
+ end
+
+ it "presents a component title of 'Storage Audience'", :aggregate_failures do
+ render_component
+
+ expect(page).to have_test_selector("storage-audience-label")
+ expect(page).to have_content("Storage Audience")
+ end
+
+ it "indicates the name of the selected audience" do
+ render_component
+ expect(page).to have_content('Obtaining tokens for audience "Alice".')
+ end
+
+ context "when audience is empty string" do
+ let(:storage_audience) { "" }
+
+ it "indicates that no audience has been selected" do
+ render_component
+ expect(page).to have_content("No audience has been configured.")
end
+ end
+
+ context "when audience is nil" do
+ let(:storage_audience) { nil }
+
+ it "indicates that no audience has been selected" do
+ render_component
+ expect(page).to have_content("No audience has been configured.")
+ end
+ end
- context "without oauth client" do
- it "returns true, renders view component" do
- storage = build_stubbed(:nextcloud_storage)
- component = described_class.new(storage)
+ context "when audience is the magic value for the IDP audience" do
+ let(:storage_audience) { OpenIDConnect::UserToken::IDP_AUDIENCE }
- edit_icon_button_data_options = component.edit_icon_button_options
- expect(edit_icon_button_data_options).to include(icon: :pencil, data: { turbo_stream: true })
- expect(edit_icon_button_data_options[:data]).not_to include(:confirm)
- end
+ it "indicates that the IDP audience has been selected" do
+ render_component
+ expect(page).to have_content("Using first access token received by identity provider, regardless of audience.")
end
end
end