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

_published_experiments.html.haml_spec.rb « layouts « views « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1ade8ddd6eb7d1de0587dfc8d82dde178540ffa (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
31
32
33
34
35
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'layouts/_published_experiments', :experiment do
  before do
    stub_const('TestControlExperiment', ApplicationExperiment)
    stub_const('TestCandidateExperiment', ApplicationExperiment)
    stub_const('TestExcludedExperiment', ApplicationExperiment)

    TestControlExperiment.new('test_control').tap do |e|
      e.variant(:control)
      e.publish
    end
    TestCandidateExperiment.new('test_candidate').tap do |e|
      e.variant(:candidate)
      e.publish
    end
    TestExcludedExperiment.new('test_excluded').tap do |e|
      e.exclude!
      e.publish
    end

    render
  end

  it 'renders out data for all non-excluded, published experiments' do
    output = rendered

    expect(output).to include('gl.experiments = {')
    expect(output).to match(/"test_control":\{[^}]*"variant":"control"/)
    expect(output).to match(/"test_candidate":\{[^}]*"variant":"candidate"/)
    expect(output).not_to include('"test_excluded"')
  end
end