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
Primerize trial creation
Oliver Günther7cf82a737bab
diff --git a/app/components/enterprise_edition/upsell_buttons_component.rb b/app/components/enterprise_edition/upsell_buttons_component.rbindex 82cce0f45cf..79206a9c553 100644--- a/app/components/enterprise_edition/upsell_buttons_component.rb+++ b/app/components/enterprise_edition/upsell_buttons_component.rb@@ -66,13 +66,7 @@ module EnterpriseEditionenddef free_trial_button- return if EnterpriseToken.active?- return unless User.current.admin?-- helpers.angular_component_tag(- "opce-free-trial-button",- inputs: helpers.enterprise_angular_trial_inputs- )+ render ::EnterpriseTrials::TrialButtonComponent.newenddef buy_now_buttondiff --git a/app/components/enterprise_trials/dialog_component.html.erb b/app/components/enterprise_trials/dialog_component.html.erbnew file mode 100644index 00000000000..1ec312bc262--- /dev/null+++ b/app/components/enterprise_trials/dialog_component.html.erb@@ -0,0 +1,37 @@+<%=+ render(+ Primer::Alpha::Dialog.new(+ id: "enterprise-trial-dialog",+ title:,+ size: :medium_portrait,+ data: { "keep-open-on-submit": true }+ )+ ) do |dialog|+ dialog.with_header(variant: :large)+ dialog.with_body do+ render(EnterpriseTrials::FormComponent.new(model))+ end++ dialog.with_footer do+ component_collection do |modal_footer|+ modal_footer.with_component(+ Primer::Beta::Button.new(+ data: { "close-dialog-id": "enterprise-trial-dialog" }+ )+ ) do+ I18n.t(:button_cancel)+ end++ modal_footer.with_component(+ Primer::Beta::Button.new(+ scheme: :primary,+ form: "enterprise-trial-form",+ type: :submit+ )+ ) do+ I18n.t(:button_continue)+ end+ end+ end+ end+%>diff --git a/app/components/enterprise_trials/dialog_component.rb b/app/components/enterprise_trials/dialog_component.rbnew file mode 100644index 00000000000..2f4df3c4f7c--- /dev/null+++ b/app/components/enterprise_trials/dialog_component.rb@@ -0,0 +1,37 @@+# 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.+#++++module EnterpriseTrials+ class DialogComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers+ end+enddiff --git a/app/components/enterprise_trials/form_component.html.erb b/app/components/enterprise_trials/form_component.html.erbnew file mode 100644index 00000000000..031270f22b2--- /dev/null+++ b/app/components/enterprise_trials/form_component.html.erb@@ -0,0 +1,25 @@+<%=+ component_wrapper do+ primer_form_with(+ scope: :enterprise_trial,+ model:,+ method: :post,+ url: enterprise_trial_path,+ html: {+ id: "enterprise-trial-form"+ },+ ) do |f|+ flex_layout(mb: 3) do |modal_body|+ if model.errors[:base].present?+ modal_body.with_row do+ render(Primer::Alpha::Banner.new(mb: 3, icon: :stop, scheme: :danger)) { model.errors[:base].join("\n") }+ end+ end++ modal_body.with_row do+ render(EnterpriseTrials::Form.new(f))+ end+ end+ end+ end+%>diff --git a/app/components/enterprise_trials/form_component.rb b/app/components/enterprise_trials/form_component.rbnew file mode 100644index 00000000000..01ae64d70ce--- /dev/null+++ b/app/components/enterprise_trials/form_component.rb@@ -0,0 +1,37 @@+# 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.+#++++module EnterpriseTrials+ class FormComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers+ end+enddiff --git a/app/components/enterprise_trials/status_component.html.erb b/app/components/enterprise_trials/status_component.html.erbnew file mode 100644index 00000000000..ca61b894446--- /dev/null+++ b/app/components/enterprise_trials/status_component.html.erb@@ -0,0 +1,3 @@+<% if @trial_status %>+ <%= @trial_status.inspect %>+<% end %>diff --git a/app/components/enterprise_trials/status_component.rb b/app/components/enterprise_trials/status_component.rbnew file mode 100644index 00000000000..0e6b5ab19e2--- /dev/null+++ b/app/components/enterprise_trials/status_component.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.+#++++module EnterpriseTrials+ class StatusComponent < ApplicationComponent+ include ApplicationHelper+ include OpenProject::FormTagHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(trial_key)+ @trial_key = trial_key+ @trial_status = EnterpriseTrials::AugurLoadTrialService.new(@trial_key).call++ super+ end++ def render?+ @trial_status.present?+ end+ end+enddiff --git a/app/components/enterprise_trials/trial_button_component.rb b/app/components/enterprise_trials/trial_button_component.rbnew file mode 100644index 00000000000..f05cea3a3d9--- /dev/null+++ b/app/components/enterprise_trials/trial_button_component.rb@@ -0,0 +1,68 @@+# 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.+# ++++module EnterpriseTrials+ class TrialButtonComponent < ApplicationComponent++ def initialize+ @trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)++ super+ end++ def render?+ User.current.admin? && !EnterpriseToken.active?+ end++ def call+ if @trial_key+ render(+ Primer::Beta::Button.new(+ tag: :a,+ href: enterprise_path+ )+ ) do+ I18n.t("admin.enterprise.check_trial_status")+ end+ else+ render(+ Primer::Beta::Button.new(+ tag: :a,+ href: trial_dialog_enterprise_trial_path,+ data: { turbo_stream: true }+ )+ ) do+ I18n.t("admin.enterprise.start_trial")+ end+ end+ end++ end+enddiff --git a/app/contracts/enterprise_trials/create_contract.rb b/app/contracts/enterprise_trials/create_contract.rbnew file mode 100644index 00000000000..a814728d575--- /dev/null+++ b/app/contracts/enterprise_trials/create_contract.rb@@ -0,0 +1,41 @@+#-- 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.+#++++module EnterpriseTrials+ class CreateContract < ::ModelContract+ include RequiresAdminGuard++ attribute :firstname+ attribute :lastname+ attribute :email+ attribute :company++ attribute :general_consent+ attribute :newsletter_consent+ end+enddiff --git a/app/controllers/enterprise_tokens_controller.rb b/app/controllers/enterprise_tokens_controller.rbindex 24eaf307de9..9fa152ecdcf 100644--- a/app/controllers/enterprise_tokens_controller.rb+++ b/app/controllers/enterprise_tokens_controller.rb@@ -37,6 +37,7 @@ class EnterpriseTokensController < ApplicationControllerbefore_action :require_adminbefore_action :check_user_limit, only: [:index]before_action :find_token, only: %i[destroy destroy_dialog]+ before_action :get_trial_key, only: [:show]def index# TODO: delete next line. @current_token is used in the old angular thingy.@@ -114,4 +115,8 @@ class EnterpriseTokensController < ApplicationController)endend++ def get_trial_key+ @trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)+ endenddiff --git a/app/controllers/enterprise_trials_controller.rb b/app/controllers/enterprise_trials_controller.rbnew file mode 100644index 00000000000..92580c32652--- /dev/null+++ b/app/controllers/enterprise_trials_controller.rb@@ -0,0 +1,68 @@+#-- 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.+#+++class EnterpriseTrialsController < ApplicationController+ include OpTurbo::ComponentStream+ include OpTurbo::DialogStreamHelper++ before_action :require_admin+ before_action :load_trial_details, only: %i[trial_status]++ def trial_dialog+ respond_with_dialog EnterpriseTrials::DialogComponent.new(EnterpriseTrial.new)+ end++ def trial_status++ end++ def create+ call = EnterpriseTrials::CreateService+ .new(user: current_user)+ .call(trial_params)++ if call.success?+ redirect_to enterprise_path, status: :see_other+ else+ form_component = EnterpriseTrials::FormComponent.new(call.result)+ update_via_turbo_stream(component: form_component, status: :bad_request)+ respond_with_turbo_streams+ end+ end++ private++ def load_trial_details+ @trial_status = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)+ end++ def trial_params+ params+ .require(:enterprise_trial)+ .permit(:company, :firstname, :lastname, :email, :general_consent, :newsletter_consent)+ end+enddiff --git a/app/forms/enterprise_trials/form.rb b/app/forms/enterprise_trials/form.rbnew file mode 100644index 00000000000..38faf487b72--- /dev/null+++ b/app/forms/enterprise_trials/form.rb@@ -0,0 +1,80 @@+# 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.+#++++module EnterpriseTrials+ class Form < ApplicationForm+ form do |f|+ f.text_field(+ name: :company,+ label: I18n.t("js.admin.enterprise.trial.form.label_company"),+ required: true+ )++ f.group(layout: :horizontal) do |g|+ g.text_field(+ name: :firstname,+ label: I18n.t("activerecord.attributes.user.first_name"),+ required: true+ )++ g.text_field(+ name: :lastname,+ label: I18n.t("activerecord.attributes.user.last_name"),+ required: true+ )+ end++ f.text_field(+ name: :email,+ label: I18n.t("attributes.email"),+ required: true+ )++ f.text_field(+ name: :domain,+ value: Setting.host_name,+ label: EnterpriseTrial.human_attribute_name(:domain),+ caption: I18n.t("ee.trial.domain_caption"),+ disabled: true+ )++ f.check_box(+ required: true,+ label: I18n.t("ee.trial.consent_html").html_safe,+ name: :general_consent+ )++ f.check_box(+ required: false,+ label: I18n.t("ee.trial.receive_newsletter_html").html_safe,+ name: :newsletter_consent+ )+ end+ end+enddiff --git a/app/models/enterprise_trial.rb b/app/models/enterprise_trial.rbnew file mode 100644index 00000000000..7f3a3f4d282--- /dev/null+++ b/app/models/enterprise_trial.rb@@ -0,0 +1,64 @@+# 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.+#++++class EnterpriseTrial < ApplicationRecord+ include Tableless+ include Scopes::Scoped++ attribute :company, :text, default: nil+ attribute :firstname, :text, default: nil+ attribute :lastname, :text, default: nil+ attribute :email, :text, default: nil++ attribute :general_consent, :boolean, default: false+ attribute :newsletter_consent, :boolean, default: false++ validates_presence_of :company, :firstname, :lastname, :email+ validates :email, email: true, if: Proc.new { |data| data.email.present? }++ validate :accepted_terms++ def to_json+ {+ company:,+ first_name: firstname,+ last_name: lastname,+ email:,+ newsletter_consent:,+ general_consent:+ }+ end++ private++ def accepted_terms+ errors.add(:base, :general_consent) unless general_consent+ end+enddiff --git a/app/services/enterprise_trials/augur_create_trial_service.rb b/app/services/enterprise_trials/augur_create_trial_service.rbnew file mode 100644index 00000000000..6421442955d--- /dev/null+++ b/app/services/enterprise_trials/augur_create_trial_service.rb@@ -0,0 +1,118 @@+# 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.+#++++module EnterpriseTrials+ class AugurCreateTrialService < BaseServices::BaseCallable+ attr_reader :trial++ def initialize(trial)+ @trial = trial+ super()+ end++ def perform+ handle_response(+ OpenProject.httpx.post(+ URI.join(augur_host, "/public/v1/trials"),+ json: trial.to_json.merge(+ version: OpenProject::VERSION.to_semver,+ token_version: OpenProject::Token::VERSION,+ domain: Setting.host_name+ )+ )+ )+ end++ private++ def handle_response(response)+ case response+ in { status: 202 }+ handle_successful_trial(response.json)+ in { status: 422 }+ handle_conflicts(response)+ else+ handle_error(response)+ end+ end++ def handle_successful_trial(trial_json)+ value = trial_json["id"]++ if value.blank?+ trial.errors.add(:base, :failed_to_create, status: "Missing trial ID")+ return ServiceResult.failure(result: trial)+ end++ trial_key = Token::EnterpriseTrialKey.create!(user_id: User.system.id, value:)+ ServiceResult.success(result: trial_key)+ end++ def handle_error(error_response)+ error = safe_response_json(error_response)++ if error.is_a?(Hash) && error["description"]+ trial.errors.add(:base, error["description"])+ else+ status = error_response&.status || "internal error"+ trial.errors.add(:base, :failed_to_create, status: "HTTP response failed: #{status}")+ end++ ServiceResult.failure(result: trial)+ end++ def handle_conflicts(response)+ error = safe_response_json(response)++ case error["identifier"]+ when "user_already_created_trial"+ trial.errors.add(:email, :already_used)+ when "domain_taken"+ trial.errors.add(:domain, :already_used)+ when "invalid_email"+ trial.errors.add(:email, :invalid)+ else+ handle_error(response)+ end++ ServiceResult.failure(result: trial)+ end++ def safe_response_json(response)+ response.json+ rescue HTTPX::Error+ {}+ end++ def augur_host+ OpenProject::Configuration.enterprise_trial_creation_host+ end+ end+enddiff --git a/app/services/enterprise_trials/augur_load_trial_service.rb b/app/services/enterprise_trials/augur_load_trial_service.rbnew file mode 100644index 00000000000..33caddaab9b--- /dev/null+++ b/app/services/enterprise_trials/augur_load_trial_service.rb@@ -0,0 +1,78 @@+#-- 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.+#++++module EnterpriseTrials+ class AugurLoadTrialService+ def initialize(trial_key)+ @trial_key = trial_key+ end++ def call+ handle_response(+ OpenProject.httpx.get(+ URI.join(augur_host, "/public/v1/trials/", @trial_key.value)+ )+ )+ end++ private++ def handle_response(response)+ case response+ in { status: 200 }+ handle_successful_trial(response.json)+ in { status: 404 }+ @trial_key.destroy+ ServiceResult.failure(message: I18n.t("ee.trial.not_found"))+ in { status: 422 }+ ServiceResult.failure(message: I18n.t("ee.trial.wait_for_confirmation"))+ else+ Rails.logger.error { "Unexpected response from Augur: #{response.inspect}" }+ ServiceResult.failure(message: I18n.t("js.error.internal"))+ end+ end++ def handle_successful_trial(trial_json)+ if trial_json["token"]+ token = EnterpriseToken.new(encoded_token: trial_json["token"])+ if token.save+ @trial_key.destroy+ return ServiceResult.success(result: token, message: I18n.t("ee.trial.already_retrieved"))+ else+ return ServiceResult.failure(result: token)+ end+ end++ ServiceResult.success(result: nil, message: I18n.t("ee.trial.already_retrieved"))+ end++ def augur_host+ OpenProject::Configuration.enterprise_trial_creation_host+ end+ end+enddiff --git a/app/services/enterprise_trials/create_service.rb b/app/services/enterprise_trials/create_service.rbnew file mode 100644index 00000000000..52534e6cb2c--- /dev/null+++ b/app/services/enterprise_trials/create_service.rb@@ -0,0 +1,37 @@+#-- 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.+#++++module EnterpriseTrials+ class CreateService < BaseServices::Create++ def persist(call)+ trial = call.result+ AugurCreateTrialService.new(trial).call+ end+ end+enddiff --git a/app/services/enterprise_trials/delete_service.rb b/app/services/enterprise_trials/delete_service.rbnew file mode 100644index 00000000000..d0f2bfcc54d--- /dev/null+++ b/app/services/enterprise_trials/delete_service.rb@@ -0,0 +1,32 @@+#-- 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.+#++++module EnterpriseTrials+ class DeleteService < BaseServices::Delete+ end+enddiff --git a/app/services/enterprise_trials/set_attributes_service.rb b/app/services/enterprise_trials/set_attributes_service.rbnew file mode 100644index 00000000000..85316708b91--- /dev/null+++ b/app/services/enterprise_trials/set_attributes_service.rb@@ -0,0 +1,32 @@+#-- 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.+#++++module EnterpriseTrials+ class SetAttributesService < ::BaseServices::SetAttributes+ end+enddiff --git a/app/views/enterprise_tokens/_info.html.erb b/app/views/enterprise_tokens/_info.html.erbindex dd4ea6dd857..44aba244bfd 100644--- a/app/views/enterprise_tokens/_info.html.erb+++ b/app/views/enterprise_tokens/_info.html.erb@@ -32,12 +32,12 @@ See COPYRIGHT and LICENSE files for more details.<% end %><div class="upsell--information-container">- <div class='upsell-information'>- <%= angular_component_tag(- "opce-enterprise-base",- inputs: enterprise_angular_trial_inputs- ) %>- </div>++ <% if @trial_key.present? %>+ <%= render EnterpriseTrials::StatusComponent.new(@trial_key) %>+ <% else %>+ <%= render EnterpriseTrials::TrialButtonComponent.new %>+ <% end %><div class='upsell-actions'><a href="#"diff --git a/config/locales/en.yml b/config/locales/en.ymlindex a2365a15f09..7ae050f1566 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -106,6 +106,7 @@ en:required_for_feature: "This add-on is only available with an active Enterprise edition support token."enterprise_link: "For more information, click here."start_trial: "Start free trial"+ check_trial_status: "Check trial status"book_now: "Book now"get_quote: "Get a quote"buttons:@@ -997,12 +998,13 @@ en:emoji_reaction:reactable: "Reacted on"enterprise_token:- domain: "Domain"starts_at: "Valid since"subscriber: "Subscriber"plan: "Plan"encoded_token: "Enterprise support token"active_user_count_restriction: "Maximum active users"+ enterprise_trial:+ company: "Company"grids/grid:page: "Page"row_count: "Number of rows"@@ -1331,6 +1333,10 @@ en:forbidden_uri: "is forbidden by the server."scopes:not_match_configured: "doesn't match available scopes."+ enterprise_trial:+ already_used: "was already used to create a trial."+ failed_to_create: "Trial could not be created (%{status})"+ general_consent: "Please accept the terms and conditions."enterprise_token:unreadable: "can't be read. Are you sure it is a support token?"grids/grid:@@ -1737,6 +1743,7 @@ en:derived_start_date: "Derived start date"direction: "Direction"display_sums: "Display Sums"+ domain: "Domain"due_date: "Finish date"estimated_hours: "Work"estimated_time: "Work"@@ -2181,6 +2188,17 @@ en:internal_comments_inline:title: "Write internal comments only a small group can see"description: " "+ trial:+ not_found: "The trial object could not be found."+ wait_for_confirmation: "Waiting for email confirmation."+ already_retrieved: "Trial token was already retrieved. Please reach out to our support team if you need a new one."+ domain_caption:+ The token will be valid for your currently configured host name.+ receive_newsletter_html: >+ I want to receive the OpenProject <a target="_blank" href="https://www.openproject.org/newsletter/">newsletter</a>.+ consent_html: >+ I agree with the <a target="_blank" href="https://www.openproject.org/terms-of-service/">terms of service</a>+ and the <a target="_blank" href="https://www.openproject.org/data-privacy-and-security/">privacy policy</a>.enumeration_activities: "Time tracking activities"enumeration_work_package_priorities: "Work package priorities"enumeration_reported_project_statuses: "Reported project status"diff --git a/config/routes.rb b/config/routes.rbindex 7e5febb22a5..16f7712a576 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -487,6 +487,10 @@ Rails.application.routes.draw dodelete :delete_trial_keyendend++ resource :enterprise_trial, only: %i[show create destroy] do+ get :trial_dialog+ endenddelete "design/logo" => "custom_styles#logo_delete", as: "custom_style_logo_delete"diff --git a/lib_static/open_project/configuration/helpers.rb b/lib_static/open_project/configuration/helpers.rbindex 4c4ee9540d0..64ddcfbbcde 100644--- a/lib_static/open_project/configuration/helpers.rb+++ b/lib_static/open_project/configuration/helpers.rb@@ -82,6 +82,14 @@ module OpenProjectendend+ def enterprise_chargebee_site+ if Rails.env.production?+ self["enterprise_chargebee_site"]+ else+ "openproject-enterprise-test"+ end+ end+def file_storage?attachments_storage == :fileenddiff --git a/spec/services/enterprise_trials/augur_create_trial_service_spec.rb b/spec/services/enterprise_trials/augur_create_trial_service_spec.rbnew file mode 100644index 00000000000..365035dbda1--- /dev/null+++ b/spec/services/enterprise_trials/augur_create_trial_service_spec.rb@@ -0,0 +1,318 @@+# 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 "webmock/rspec"++RSpec.describe EnterpriseTrials::AugurCreateTrialService, :webmock do+ let(:system_user) { User.system }+ let(:trial) { EnterpriseTrial.new(trial_attributes) }+ let(:trial_attributes) do+ {+ company: "Test Company",+ firstname: "John",+ lastname: "Doe",+ email: "[email protected]",+ general_consent: true,+ newsletter_consent: false+ }+ end+ let(:service) { described_class.new(trial) }+ let(:augur_host) { "https://augur.example.org" }+ let(:trials_url) { "#{augur_host}/public/v1/trials" }++ before do+ allow(OpenProject::Configuration).to receive(:enterprise_trial_creation_host).and_return(augur_host)+ end++ context "when the request is successful" do+ let(:trial_id) { "1b6486b4-5a30-4042-8714-99d7c8e6b637" }+ let(:success_response) { { "id" => trial_id } }++ before do+ stub_request(:post, trials_url)+ .with(+ body: {+ company: "Test Company",+ first_name: "John",+ last_name: "Doe",+ email: "[email protected]",+ newsletter_consent: false,+ general_consent: true,+ version: OpenProject::VERSION.to_semver,+ token_version: OpenProject::Token::VERSION,+ domain: Setting.host_name+ }.to_json,+ )+ .to_return(status: 202, body: success_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "creates a trial key and returns success" do+ result = service.call++ expect(result).to be_success+ expect(result.result).to be_a(Token::EnterpriseTrialKey)+ expect(result.result.user_id).to eq(system_user.id)+ expect(result.result.value).to eq(trial_id)+ expect(result.result.data).to eq({ "email" => "[email protected]" })++ expect(Token::EnterpriseTrialKey.count).to eq(1)+ end++ context "when the response is missing the trial ID" do+ let(:success_response) { { "id" => nil } }++ it "adds an error to the trial and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to include("Trial could not be created (Missing trial ID)")+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when the response has an empty trial ID" do+ let(:success_response) { { "id" => "" } }++ it "adds an error to the trial and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to include("Trial could not be created (Missing trial ID)")+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end+ end++ context "when there are conflicts (422 status)" do+ context "when user already created a trial" do+ let(:conflict_response) do+ {+ "identifier" => "user_already_created_trial",+ "description" => "Each user can only create one trial."+ }+ end++ before do+ stub_request(:post, trials_url)+ .to_return(status: 422, body: conflict_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "adds an error to the email field and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:email]).to be_present+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when domain is already taken" do+ let(:conflict_response) do+ {+ "identifier" => "domain_taken",+ "description" => "There can only be one active trial per domain."+ }+ end++ before do+ stub_request(:post, trials_url)+ .to_return(status: 422, body: conflict_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "adds an error to the domain field and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:domain]).to be_present+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when email is invalid" do+ let(:conflict_response) do+ {+ "identifier" => "invalid_email",+ "description" => "The provided email address is invalid."+ }+ end++ before do+ stub_request(:post, trials_url)+ .to_return(status: 422, body: conflict_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "adds an error to the email field and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:email]).to be_present+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when there's an unknown conflict" do+ let(:conflict_response) do+ {+ "identifier" => "unknown_error",+ "description" => "Some unknown error occurred."+ }+ end++ before do+ stub_request(:post, trials_url)+ .to_return(status: 422, body: conflict_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "adds a generic error and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to include("Some unknown error occurred.")+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end+ end++ context "when there are other errors" do+ context "when the response includes a description" do+ let(:error_response) do+ {+ "description" => "Token version is invalid"+ }+ end++ before do+ stub_request(:post, trials_url)+ .to_return(status: 409, body: error_response.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "adds the error description to the trial and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to include("Token version is invalid")+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when there's a server error without description" do+ before do+ stub_request(:post, trials_url)+ .to_return(status: 500, body: "", headers: {})+ end++ it "adds a generic error with status and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to be_present+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end++ context "when the response is not valid JSON" do+ before do+ stub_request(:post, trials_url)+ .to_return(status: 400, body: "Invalid request", headers: {})+ end++ it "adds a generic error and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(trial)+ expect(trial.errors[:base]).to be_present+ expect(Token::EnterpriseTrialKey.count).to eq(0)+ end+ end+ end++ describe "request payload" do+ let(:trial_id) { "test-trial-id" }+ let(:success_response) { { "id" => trial_id } }++ it "sends the correct payload structure" do+ request_stub = stub_request(:post, trials_url)+ .with(+ body: {+ company: "Test Company",+ first_name: "John",+ last_name: "Doe",+ email: "[email protected]",+ newsletter_consent: false,+ general_consent: true,+ version: OpenProject::VERSION.to_semver,+ token_version: OpenProject::Token::VERSION,+ domain: Setting.host_name+ }.to_json,+ )+ .to_return(status: 202, body: success_response.to_json, headers: { "Content-Type" => "application/json" })++ service.call++ expect(request_stub).to have_been_requested+ end++ context "with newsletter consent enabled" do+ let(:trial_attributes) do+ {+ company: "Test Company",+ firstname: "John",+ lastname: "Doe",+ email: "[email protected]",+ general_consent: true,+ newsletter_consent: true+ }+ end++ it "includes newsletter consent in the payload" do+ request_stub = stub_request(:post, trials_url)+ .with(+ body: hash_including(+ newsletter_consent: true+ )+ )+ .to_return(status: 202, body: success_response.to_json, headers: { "Content-Type" => "application/json" })++ service.call++ expect(request_stub).to have_been_requested+ end+ end+ end+enddiff --git a/spec/services/enterprise_trials/augur_load_trial_service_spec.rb b/spec/services/enterprise_trials/augur_load_trial_service_spec.rbnew file mode 100644index 00000000000..f797557c222--- /dev/null+++ b/spec/services/enterprise_trials/augur_load_trial_service_spec.rb@@ -0,0 +1,154 @@+# 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 "webmock/rspec"++RSpec.describe EnterpriseTrials::AugurLoadTrialService, :webmock do+ let(:system_user) { User.system }+ let(:trial_key) { Token::EnterpriseTrialKey.create!(user: system_user) }+ let(:service) { described_class.new(trial_key) }+ let(:augur_host) { "https://augur.example.org" }+ let(:trial_url) { "#{augur_host}/public/v1/trials/#{trial_key.value}" }++ before do+ allow(OpenProject::Configuration).to receive(:enterprise_trial_creation_host).and_return(augur_host)+ trial_key # ensure trial key is created+ end++ context "when a trial key exists" do+ context "when the request is successful" do+ context "when token is provided in the response" do+ let(:token_data) { { "token" => "valid-token-data" } }++ before do+ stub_request(:get, /#{Regexp.escape(augur_host)}\/public\/v1\/trials\/.*/)+ .to_return(status: 200, body: token_data.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "creates an enterprise token and returns success" do+ token_double = instance_double(EnterpriseToken)+ allow(EnterpriseToken)+ .to receive(:new)+ .with(encoded_token: "valid-token-data")+ .and_return(token_double)+ allow(token_double).to receive(:save).and_return(true)++ result = service.call++ expect(result).to be_success+ expect(result.message).to eq(I18n.t("ee.trial.already_retrieved"))+ expect(Token::EnterpriseTrialKey).not_to exist(trial_key.id)++ expect(token_double).to have_received(:save)+ end++ context "when the token cannot be saved" do+ let(:enterprise_token) { instance_double(EnterpriseToken, save: false) }++ before do+ allow(EnterpriseToken).to receive(:new).and_return(enterprise_token)+ end++ it "returns a failure result" do+ result = service.call++ expect(result).to be_failure+ expect(result.result).to eq(enterprise_token)+ expect(Token::EnterpriseTrialKey).to exist(trial_key.id)+ end+ end+ end++ context "when token is not in the response" do+ let(:token_data) { { "token" => nil } }++ before do+ stub_request(:get, /#{Regexp.escape(augur_host)}\/public\/v1\/trials\/.*/)+ .to_return(status: 200, body: token_data.to_json, headers: { "Content-Type" => "application/json" })+ end++ it "returns success without creating a token" do+ allow(EnterpriseToken).to receive(:new)+ result = service.call++ expect(result).to be_success+ expect(result.message).to eq(I18n.t("ee.trial.already_retrieved"))+ expect(Token::EnterpriseTrialKey).to exist(trial_key.id)+ expect(EnterpriseToken).not_to have_received(:new)+ end+ end+ end++ context "when the trial is not found" do+ before do+ stub_request(:get, /#{Regexp.escape(augur_host)}\/public\/v1\/trials\/.*/)+ .to_return(status: 404, body: "", headers: {})+ end++ it "destroys the trial key and returns failure" do+ result = service.call++ expect(result).to be_failure+ expect(result.message).to eq(I18n.t("ee.trial.not_found"))+ expect(Token::EnterpriseTrialKey).not_to exist(trial_key.id)+ end+ end++ context "when the trial is pending confirmation" do+ before do+ stub_request(:get, /#{Regexp.escape(augur_host)}\/public\/v1\/trials\/.*/)+ .to_return(status: 422, body: "", headers: {})+ end++ it "returns a failure result with a message to wait" do+ result = service.call++ expect(result).to be_failure+ expect(result.message).to eq(I18n.t("ee.trial.wait_for_confirmation"))+ expect(Token::EnterpriseTrialKey).to exist(trial_key.id)+ end+ end++ context "when an unexpected error occurs" do+ before do+ stub_request(:get, /#{Regexp.escape(augur_host)}\/public\/v1\/trials\/.*/)+ .to_return(status: 500, body: "", headers: {})+ end++ it "logs the error and returns a generic failure message" do+ result = service.call++ expect(result).to be_failure+ expect(result.message).to eq(I18n.t("js.error.internal"))+ expect(Token::EnterpriseTrialKey).to exist(trial_key.id)+ end+ end+ end+end