summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/gon_helper_spec.rb
blob: c6f09ca211287dfd66e42ec8ec2d0c77b16ad417 (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::GonHelper do
  let(:helper) do
    Class.new do
      include Gitlab::GonHelper
    end.new
  end

  describe '#push_frontend_feature_flag' do
    it 'pushes a feature flag to the frontend' do
      gon = instance_double('gon')

      allow(helper)
        .to receive(:gon)
        .and_return(gon)

      expect(Feature)
        .to receive(:enabled?)
        .with(:my_feature_flag, 10)
        .and_return(true)

      expect(gon)
        .to receive(:push)
        .with({ features: { 'myFeatureFlag' => true } }, true)

      helper.push_frontend_feature_flag(:my_feature_flag, 10)
    end
  end
end