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
Dynamically set the Support Link on the Community Block
Aaron Contreras4afb61b343dd
diff --git a/app/views/homescreen/blocks/_community.html.erb b/app/views/homescreen/blocks/_community.html.erbindex 233d060199b..05cdcda2de9 100644--- a/app/views/homescreen/blocks/_community.html.erb+++ b/app/views/homescreen/blocks/_community.html.erb@@ -10,7 +10,7 @@<li><%= static_link_to :forums %></li><li>- <%= static_link_to :enterprise_support_as_community %>+ <%= static_link_to (EnterpriseToken.active? ? :enterprise_support : :enterprise_support_as_community) %></li><li><%= link_to(t('label_openproject_website'), "#{OpenProject::Static::Links.links[:website][:href]}/?utm_source=unknown&utm_medium=op-instance&utm_campaign=website-home-screen",diff --git a/spec/features/homescreen/index_spec.rb b/spec/features/homescreen/index_spec.rbindex e35f6f3fb9f..18d2b2c82af 100644--- a/spec/features/homescreen/index_spec.rb+++ b/spec/features/homescreen/index_spec.rb@@ -28,13 +28,13 @@require 'spec_helper'-describe 'Homescreen index' do+RSpec.describe 'Homescreen index' dolet(:admin) { create(:admin) }let(:user) { build_stubbed(:user) }let!(:project) { create(:public_project, identifier: 'public-project') }let(:general_settings_page) { Pages::Admin::SystemSettings::General.new }- describe 'with a dynamic URL in the welcome text' do+ context 'with a dynamic URL in the welcome text' dobefore doSetting.welcome_text = "With [a link to the public project]({{opSetting:base_url}}/projects/public-project)"Setting.welcome_on_homescreen = true@@ -70,4 +70,34 @@ describe 'Homescreen index' doexpect(page).to have_current_path /#{Regexp.escape(project_path(project))}\/?$/endend++ describe 'Enterprise Support Link' do+ include_context 'support links'++ context 'on an Enterprise Edition' do+ before do+ allow(EnterpriseToken).to receive(:active?).and_return(true)+ end++ it 'renders the correct link' do+ login_as user+ visit root_url+ expect(page).to have_link(I18n.t(:label_enterprise_support),+ href: support_link_as_enterprise)+ end+ end++ context 'on a Community Edition' do+ before do+ allow(EnterpriseToken).to receive(:active?).and_return(false)+ end++ it 'renders the correct link' do+ login_as user+ visit root_url+ expect(page).to have_link(I18n.t(:label_enterprise_support),+ href: support_link_as_community)+ end+ end+ endenddiff --git a/spec/features/menu_items/help_menu_spec.rb b/spec/features/menu_items/help_menu_spec.rbindex 528d59c82a0..9193e352471 100644--- a/spec/features/menu_items/help_menu_spec.rb+++ b/spec/features/menu_items/help_menu_spec.rb@@ -65,8 +65,7 @@ RSpec.describe 'Help menu items', js: true doenddescribe 'Enterprise Support Link' do- let(:support_link_without_being_enterprise) { 'https://www.openproject.org/pricing/#support' }- let(:support_link_as_enterprise) { 'https://www.openproject.org/docs/enterprise-guide/support/' }+ include_context 'support links'def fake_an_enterprise_tokenallow(EnterpriseToken).to receive(:show_banners?).and_return(false)@@ -79,7 +78,7 @@ RSpec.describe 'Help menu items', js: true dohelp_item.clickwithin help_menu_dropdown_selector doexpect(page).to have_link(I18n.t(:label_enterprise_support),- href: support_link_without_being_enterprise)+ href: support_link_as_community)endfake_an_enterprise_tokendiff --git a/spec/support/support_links.rb b/spec/support/support_links.rbnew file mode 100644index 00000000000..42c4b512282--- /dev/null+++ b/spec/support/support_links.rb@@ -0,0 +1,36 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2023 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.+# ++++# rubocop:disable RSpec/ContextWording+shared_context 'support links' do+ let(:support_link_as_community) { 'https://www.openproject.org/pricing/#support' }+ let(:support_link_as_enterprise) { 'https://www.openproject.org/docs/enterprise-guide/support/' }+end+# rubocop:enable RSpec/ContextWording