Welcome to mirror list, hosted at ThFree Co, Russian Federation.

new_project_readme_content_experiment.rb « experiments « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9f0fb3b93eb92ee9c9b036e1b541cb160c29979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class NewProjectReadmeContentExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
  TEMPLATE_PATH = Rails.root.join('app', 'experiments', 'templates', 'new_project_readme_content')
  include Rails.application.routes.url_helpers

  def run_with(project, variant: nil)
    @project = project
    record!
    run(variant)
  end

  def control_behavior
    template('readme_basic.md')
  end

  def advanced_behavior
    template('readme_advanced.md')
  end

  def redirect(to_url)
    experiment_redirect_url(self, url: to_url)
  end

  private

  def template(name)
    ERB.new(File.read(TEMPLATE_PATH.join("#{name}.tt")), trim_mode: '<>').result(binding)
  end
end