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
Fix specs
Oliver Güntherdc369872e882
diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rbindex 89992f90a1e..2eefef0cc33 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -41,13 +41,11 @@ module EnterpriseEdition# Defaults to "ee.upsale.{feature_key}"# @param dismissable [boolean] Allow this banner to be dismissed.# @param dismiss_key [String] Provide a string to identify this banner when being dismissed. Defaults to feature_key- # @param skip_render [Boolean] Whether to skip rendering the banner.# @param system_arguments [Hash] <%= link_to_system_arguments_docs %>def initialize(feature_key,i18n_scope: "ee.upsale.#{feature_key}",dismissable: false,dismiss_key: feature_key,- skip_render: EnterpriseToken.hide_banners?,**system_arguments)@system_arguments = system_arguments@system_arguments[:tag] = :div@@ -58,7 +56,6 @@ module EnterpriseEditionself.feature_key = feature_keyself.i18n_scope = i18n_scope- @skip_render = skip_render@dismissable = dismissable@dismiss_key = dismiss_keyend@@ -68,7 +65,11 @@ module EnterpriseEditionattr_reader :skip_renderdef render?- !(skip_render || dismissed?)+ !(EnterpriseToken.hide_banners? || feature_available? || dismissed?)+ end++ def feature_available?+ EnterpriseToken.allows_to?(feature_key)enddef dismissed?diff --git a/app/helpers/types_helper.rb b/app/helpers/types_helper.rbindex a4766c0a47f..6fc73f7bbb8 100644--- a/app/helpers/types_helper.rb+++ b/app/helpers/types_helper.rb@@ -64,7 +64,7 @@ module ::TypesHelperpath: edit_tab_type_path(id: @type.id, tab: :subject_configuration),label: "types.edit.subject_configuration.tab",view_component: WorkPackages::Types::SubjectConfigurationComponent,- enterprise_feature: :automatic_subject_generation+ enterprise_feature: :work_package_subject_generation}tabs.insert(2, subject_configuration_tab)diff --git a/config/locales/en.yml b/config/locales/en.ymlindex a068a5fc372..e316084f8d1 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -4697,7 +4697,7 @@ en:sso_auth_providers: Single sign-onteam_planner_view: Team Planner Viewtwo_factor_authentication: 2FA Authentication- virus_scanning: Antivirus scanning+ virus_scanning: Antivirus Scanningwork_package_query_relation_columns: Work Package Query Relation Columnswork_package_sharing: Share work packages with external userswork_package_subject_generation: Work Package Subject Generationdiff --git a/modules/auth_plugins/spec/requests/auth_plugins_spec.rb b/modules/auth_plugins/spec/requests/auth_plugins_spec.rbindex 7eaeb43a6ef..0f2ce0c4691 100644--- a/modules/auth_plugins/spec/requests/auth_plugins_spec.rb+++ b/modules/auth_plugins/spec/requests/auth_plugins_spec.rb@@ -29,7 +29,7 @@require "spec_helper"require "open_project/auth_plugins"-RSpec.describe OpenProject::Plugins::AuthPlugin, with_ee: %i[board_view] do+RSpec.describe OpenProject::Plugins::AuthPlugin, with_ee: %i[sso_auth_providers] do # rubocop:disable RSpec/SpecFilePathFormatlet(:dummy_engine_klass) doClass.new { extend OpenProject::Plugins::AuthPlugin }enddiff --git a/spec/components/enterprise_edition/banner_component_spec.rb b/spec/components/enterprise_edition/banner_component_spec.rbindex 84b89ba8fe5..5873e39e66d 100644--- a/spec/components/enterprise_edition/banner_component_spec.rb+++ b/spec/components/enterprise_edition/banner_component_spec.rb@@ -32,18 +32,20 @@ require "rails_helper"RSpec.describe EnterpriseEdition::BannerComponent, type: :component dolet(:title) { "Some title" }+ let(:expected_title) { title }let(:description) { "Some description" }+ let(:expected_description) { description }let(:href) { "https://www.example.org" }- let(:link_title) { "Get more information" }- let(:ee_show_banners) { true }+ let(:component_test_selector) { "op-enterprise-banner-some-enterprise-feature" }+ let(:features) { nil }let(:enforce_available_locales) { I18n.config.enforce_available_locales }let(:i18n_upsale) do{- title:,- link_title:,some_enterprise_feature: {- description:- }+ title:,+ description:,+ features:+ }.compact}endlet(:static_links) do@@ -55,9 +57,20 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component do}}end+ let(:translations) do+ {+ ee: {+ upsale: i18n_upsale+ },+ enterprise_features: {+ some_enterprise_feature: "Enterprise feature translation"+ }+ }+ end+ let(:component_args) { {} }let(:render_component) do- render_inline(described_class.new(:some_enterprise_feature))+ render_inline(described_class.new(:some_enterprise_feature, **component_args))endlet(:render_component_in_mo) do@@ -75,11 +88,7 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component doI18n.backend.store_translations(:mo,- {- ee: {- upsale: i18n_upsale- }- }+ translations)end@@ -92,51 +101,101 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component doit "renders the component" dorender_component_in_mo- expect(page).to have_test_selector("op-ee-banner-some-enterprise-feature")- expect(page).to have_css ".op-ee-banner--title-container", text: title- expect(page).to have_css ".op-ee-banner--description-container", text: description- expect(page).to have_link link_title, href:+ component = find_test_selector(component_test_selector)++ expect(component).to have_text(expected_title)+ expect(component).to have_text(expected_description)+ expect(component).to have_link("More information", href:)+ end+ end++ shared_examples_for "does not render the component" do+ it "does not render the component" do+ render_component_in_mo++ expect(page).not_to have_test_selector(component_test_selector)+ expect(page).to have_no_text("Enterprise feature translation")+ expect(page).to have_no_text(expected_title)+ expect(page).to have_no_text(expected_description)+ expect(page).to have_no_link(href:)endendit_behaves_like "renders the component"- context "with a description_html in the i18n file" do+ context "when feature is available", with_ee: %i[some_enterprise_feature] do+ it_behaves_like "does not render the component"+ end++ context "when banners are hidden" do+ before do+ allow(EnterpriseToken).to receive(:hide_banners?).and_return(true)+ end++ it_behaves_like "does not render the component"+ end++ context "when banner is dismissed" do+ let(:preference) { build_stubbed(:user_preference) }+ let(:user) { build_stubbed(:user, preference:) }+ let(:dismiss_key) { :some_enterprise_feature }+ let(:component_args) { { dismissable: true } }++ before do+ login_as(user)+ allow(preference)+ .to receive(:dismissed_banner?)+ .with(dismiss_key)+ .and_return(true)+ end++ it_behaves_like "does not render the component"++ context "when not dismissable" do+ let(:component_args) { { dismissable: false } }++ it_behaves_like "renders the component"+ end++ context "when using a custom dismiss_key" do+ let(:dismiss_key) { :foo }+ let(:component_args) { { dismiss_key:, dismissable: true } }++ it_behaves_like "does not render the component"+ end+ end++ context "without a title, but a description_html" dolet(:i18n_upsale) do{- title:,- link_title:,some_enterprise_feature: {description_html: description}}end+ let(:expected_title) { "Enterprise feature translation" }it_behaves_like "renders the component"end- context "with a more specific title in the i18n file" do+ context "without a title, but a description" dolet(:i18n_upsale) do{- title: "The general title",- link_title:,some_enterprise_feature: {- title:,description:}}end+ let(:expected_title) { "Enterprise feature translation" }it_behaves_like "renders the component"end- context "with a more specific link title in the i18n file" do+ context "with a more specific title in the i18n file" dolet(:i18n_upsale) do{- title:,- link_title: "The general link title",some_enterprise_feature: {- link_title:,+ title:,description:}}@@ -145,11 +204,32 @@ RSpec.describe EnterpriseEdition::BannerComponent, type: :component doit_behaves_like "renders the component"end+ context "with a custom i18n_scope" do+ let(:translations) do+ {+ my: {+ custom: {+ upsale: {+ title: "Foo",+ description: "Bar"+ }+ }+ },+ enterprise_features: {+ some_enterprise_feature: "Enterprise feature translation"+ }+ }+ end+ let(:expected_title) { "Foo" }+ let(:expected_description) { "Bar" }+ let(:component_args) { { i18n_scope: "my.custom.upsale" } }++ it_behaves_like "renders the component"+ end+context "without a description key in the i18n file" dolet(:i18n_upsale) do{- title:,- link_title:,some_enterprise_feature: {}}enddiff --git a/spec/components/users/hover_card_component_spec.rb b/spec/components/users/hover_card_component_spec.rbindex b2d10036046..d3e95187d97 100644--- a/spec/components/users/hover_card_component_spec.rb+++ b/spec/components/users/hover_card_component_spec.rb@@ -46,11 +46,10 @@ RSpec.describe Users::HoverCardComponent, type: :component dogroupslogin_as(current_user)render_inline(subject)- page.extend TestSelectorFindersendit "renders successfully" do- page.find_test_selector("user-hover-card-name", text: user.name)+ find_test_selector("user-hover-card-name", text: user.name)endcontext "when the user does not exist" do@@ -71,14 +70,14 @@ RSpec.describe Users::HoverCardComponent, type: :component dolet(:current_user) { build(:admin) }it "shows the email address of a user" do- page.find_test_selector("user-hover-card-email", text: user.mail)+ find_test_selector("user-hover-card-email", text: user.mail)endendendcontext "when showing the group summary" doit "shows a no results text for users without group memberships" do- g = page.find_test_selector("user-hover-card-groups")+ g = find_test_selector("user-hover-card-groups")expect(g).to have_text(I18n.t("users.groups.no_results_title_text"))end@@ -88,7 +87,7 @@ RSpec.describe Users::HoverCardComponent, type: :component doendit "lists the group names for a user" do- g = page.find_test_selector("user-hover-card-groups")+ g = find_test_selector("user-hover-card-groups")expect(g).to have_text("Member of #{groups.first.lastname}, #{groups.last.lastname}.")end@@ -98,7 +97,7 @@ RSpec.describe Users::HoverCardComponent, type: :component dolet(:another_user) { create(:user) }it "does not show groups" do- g = page.find_test_selector("user-hover-card-groups")+ g = find_test_selector("user-hover-card-groups")expect(g).to have_text(I18n.t("users.groups.no_results_title_text"))end@@ -111,7 +110,7 @@ RSpec.describe Users::HoverCardComponent, type: :component doendit "lists some group names with truncation" do- g = page.find_test_selector("user-hover-card-groups")+ g = find_test_selector("user-hover-card-groups")expect(g).to have_text("Member of #{groups.slice(0, 4).map(&:lastname).join(', ')} and 4 more.")end@@ -120,7 +119,7 @@ RSpec.describe Users::HoverCardComponent, type: :component docontext "when clicking on the Open Profile button" doit "leads to the users profile" do- b = page.find_test_selector("user-hover-card-profile-btn")+ b = find_test_selector("user-hover-card-profile-btn")expect(b).to have_text(I18n.t("users.open_profile"))expect(b["href"]).to eq(user_path(user))@@ -130,7 +129,7 @@ RSpec.describe Users::HoverCardComponent, type: :component dolet(:current_user) { build(:admin) }it "leads to editing the users profile" do- b = page.find_test_selector("user-hover-card-profile-btn")+ b = find_test_selector("user-hover-card-profile-btn")expect(b).to have_text(I18n.t("users.open_profile"))expect(b["href"]).to eq(edit_user_path(user))diff --git a/spec/components/work_packages/types/subject_configuration_component_spec.rb b/spec/components/work_packages/types/subject_configuration_component_spec.rbindex 18b2900cee1..6ce0a382039 100644--- a/spec/components/work_packages/types/subject_configuration_component_spec.rb+++ b/spec/components/work_packages/types/subject_configuration_component_spec.rb@@ -42,7 +42,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componit "shows no enterprise banner" dorender_component- expect(page).not_to have_test_selector("op-ee-banner-automatic-subject-generation")+ expect(page).not_to have_test_selector("op-enterprise-banner-work-package-subject-generation")endit "enables mode selectors", :aggregate_failures do@@ -109,7 +109,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componit "shows the enterprise banner" dorender_component- expect(page).to have_test_selector("op-ee-banner-automatic-subject-generation")+ expect(page).to have_test_selector("op-enterprise-banner-work-package-subject-generation")endit "disables only automatic mode selector", :aggregate_failures do@@ -125,7 +125,7 @@ RSpec.describe WorkPackages::Types::SubjectConfigurationComponent, type: :componit "shows the enterprise banner" dorender_component- expect(page).to have_test_selector("op-ee-banner-automatic-subject-generation")+ expect(page).to have_test_selector("op-enterprise-banner-work-package-subject-generation")endit "enables mode selectors", :aggregate_failures dodiff --git a/spec/helpers/enterprise_helper_spec.rb b/spec/helpers/enterprise_helper_spec.rbindex dd7f0b7093e..ba768e1ea37 100644--- a/spec/helpers/enterprise_helper_spec.rb+++ b/spec/helpers/enterprise_helper_spec.rb@@ -52,7 +52,7 @@ RSpec.describe EnterpriseHelper dolet(:token) { instance_double(EnterpriseToken, features: %i[baseline_comparison virus_scanning]) }it "returns translated names of features" do- expect(helper.enterprise_plan_additional_features(token)).to eq("Attachment Virus Scanning, Baseline Comparison")+ expect(helper.enterprise_plan_additional_features(token)).to eq("Antivirus Scanning, Baseline Comparisons")endend@@ -63,7 +63,7 @@ RSpec.describe EnterpriseHelper doendit "returns translated names of features and removes unknowns" do- expect(helper.enterprise_plan_additional_features(token)).to eq("Work Package Sharing")+ expect(helper.enterprise_plan_additional_features(token)).to eq("Share work packages with external users")endendenddiff --git a/spec/models/enterprise_token_spec.rb b/spec/models/enterprise_token_spec.rbindex 35dbf232483..cdf1a66deda 100644--- a/spec/models/enterprise_token_spec.rb+++ b/spec/models/enterprise_token_spec.rb@@ -74,7 +74,7 @@ RSpec.describe EnterpriseToken dolet(:ee_manager_visible) { true }it "returns true" do- expect(described_class).to be_show_banners+ expect(described_class).not_to be_hide_bannersendend@@ -82,7 +82,7 @@ RSpec.describe EnterpriseToken dolet(:ee_manager_visible) { false }it "returns false" do- expect(described_class).not_to be_show_banners+ expect(described_class).to be_hide_bannersendendend@@ -176,7 +176,7 @@ RSpec.describe EnterpriseToken doallow(service_double).to receive(:call).with(:forbidden_action)- .and_return ServiceResult.success(result: true)+ .and_return ServiceResult.success(result: false)allow(service_double).to receive(:call).with(:allowed_action)diff --git a/spec/requests/admin/attachments/virus_scanning_settings_spec.rb b/spec/requests/admin/attachments/virus_scanning_settings_spec.rbindex 354bf3b68ed..c218c170a57 100644--- a/spec/requests/admin/attachments/virus_scanning_settings_spec.rb+++ b/spec/requests/admin/attachments/virus_scanning_settings_spec.rb@@ -130,9 +130,10 @@ RSpec.describe "Attachments virus scanning",enddescribe "without ee" do- it "redirects to upsale" do+ it "renders upsale" doget "/admin/settings/virus_scanning"- expect(response.body).to have_text "Virus scanning is an Enterprise add-on", normalize_ws: true+ expect(response.body).to have_text "Virus scanning"+ expect(response.body).to have_text "Available only through the Corporate enterprise plan."endendenddiff --git a/spec/support/finders/test_selector.rb b/spec/support/finders/test_selector.rbindex 775ce19151c..8aed726042e 100644--- a/spec/support/finders/test_selector.rb+++ b/spec/support/finders/test_selector.rb@@ -33,11 +33,13 @@ module TestSelectorFindersenddef find_test_selector(value, **)- find(:test_id, value, **)+ target = respond_to?(:page) ? page : self+ target.find(:test_id, value, **)enddef within_test_selector(value, **, &)- within(:test_id, value, **, &)+ target = respond_to?(:page) ? page : self+ target.within(:test_id, value, **, &)end# expect(page).to have_test_selector('foo')@@ -57,4 +59,5 @@ RSpec.configure do |config|Capybara::Session.include(TestSelectorFinders)Capybara::DSL.extend(TestSelectorFinders)config.include TestSelectorFinders, type: :feature+ config.include TestSelectorFinders, type: :componentend