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

fix upsell page

Markus Kahl01c40b10dcda
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index 8238dbc9f0f..9212d1599ba 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/app/controllers/custom_styles_controller.rb
@@ -27,6 +27,8 @@
#++
class CustomStylesController < ApplicationController
+ include EnterpriseHelper
+
layout "admin"
menu_item :custom_style
@@ -42,6 +44,7 @@ class CustomStylesController < ApplicationController
except: UNGUARDED_ACTIONS + %i[upsell]
skip_before_action :check_if_login_required,
only: UNGUARDED_ACTIONS
+ before_action :write_augur_to_gon, only: %i[upsell]
no_authorization_required! *UNGUARDED_ACTIONS
def default_url_options
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index ffeedfd870c..af19e1088d8 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -34,6 +34,7 @@ class Storages::Admin::StoragesController < ApplicationController
include FlashMessagesOutputSafetyHelper
include OpTurbo::ComponentStream
+ include EnterpriseHelper
# See https://guides.rubyonrails.org/layouts_and_rendering.html for reference on layout
layout "admin"
@@ -49,6 +50,7 @@ class Storages::Admin::StoragesController < ApplicationController
change_health_notifications_enabled replace_oauth_application]
before_action :ensure_valid_wizard_parameters, only: [:new]
before_action :require_ee_token_for_one_drive, only: [:new]
+ before_action :write_augur_to_gon, only: %i[upsell]
menu_item :external_file_storages
diff --git a/modules/storages/spec/controllers/storages/admin/storages_controller_spec.rb b/modules/storages/spec/controllers/storages/admin/storages_controller_spec.rb
new file mode 100644
index 00000000000..69e08b276de
--- /dev/null
+++ b/modules/storages/spec/controllers/storages/admin/storages_controller_spec.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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"
+require_relative "../../../../../../spec/controllers/shared_upsell_examples"
+
+RSpec.describe Storages::Admin::StoragesController do
+ let(:user) { build(:admin) }
+
+ before do
+ login_as user
+ end
+
+ it_behaves_like "the upsell banner is shown"
+end
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index cf2591caad2..e16d0e49f60 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -1,11 +1,13 @@
module ::TeamPlanner
class TeamPlannerController < BaseController
include EnterpriseTrialHelper
+ include EnterpriseHelper
include Layout
before_action :load_and_authorize_in_optional_project
before_action :build_plan_view, only: %i[new]
before_action :require_ee_token, except: %i[upsell]
before_action :find_plan_view, only: %i[destroy]
+ before_action :write_augur_to_gon, only: %i[upsell]
menu_item :team_planner_view
diff --git a/modules/team_planner/spec/controllers/team_planner/team_planner_controller_spec.rb b/modules/team_planner/spec/controllers/team_planner/team_planner_controller_spec.rb
new file mode 100644
index 00000000000..a758b469adc
--- /dev/null
+++ b/modules/team_planner/spec/controllers/team_planner/team_planner_controller_spec.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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"
+require_relative "../../../../../spec/controllers/shared_upsell_examples"
+
+RSpec.describe TeamPlanner::TeamPlannerController do
+ let(:user) { create(:admin) }
+ let(:project) { create(:project) }
+
+ before do
+ login_as user
+
+ controller.instance_variable_set(:@project, project)
+ end
+
+ it_behaves_like "the upsell banner is shown"
+end
diff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rb
index 490bbde9cc1..93a81c94673 100644
--- a/spec/controllers/custom_styles_controller_spec.rb
+++ b/spec/controllers/custom_styles_controller_spec.rb
@@ -27,6 +27,7 @@
#++
require "spec_helper"
+require_relative "shared_upsell_examples"
RSpec.describe CustomStylesController do
before do
@@ -56,14 +57,7 @@ RSpec.describe CustomStylesController do
end
end
- describe "#upsell" do
- subject { get :upsell }
-
- it "renders upsell" do
- expect(subject).to be_successful
- expect(subject).to render_template "upsell"
- end
- end
+ it_behaves_like "the upsell banner is shown"
describe "#create", with_ee: %i[define_custom_style] do
let(:custom_style) { CustomStyle.new }
diff --git a/spec/controllers/shared_upsell_examples.rb b/spec/controllers/shared_upsell_examples.rb
new file mode 100644
index 00000000000..32be0739b3d
--- /dev/null
+++ b/spec/controllers/shared_upsell_examples.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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.shared_examples_for "the upsell banner is shown" do
+ subject { get :upsell }
+
+ it "renders the upsell page" do
+ expect(subject).to be_successful
+ expect(subject).to render_template "upsell"
+ end
+
+ it "writes the augur URL and token version to gon" do
+ subject
+ gon = controller.gon
+
+ expect(gon.augur_url).to eq OpenProject::Configuration.enterprise_trial_creation_host
+ expect(gon.token_version).to eq OpenProject::Token::VERSION
+ end
+end