summaryrefslogtreecommitdiff
path: root/spec/helpers/bizible_helper_spec.rb
blob: b82211d51ec305e4daf70e8fd2623549622d8473 (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
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

require "spec_helper"

RSpec.describe BizibleHelper do
  describe '#bizible_enabled?' do
    before do
      stub_config(extra: { bizible: SecureRandom.uuid })
    end

    context 'when bizible is disabled' do
      before do
        allow(helper).to receive(:bizible_enabled?).and_return(false)
      end

      it { is_expected.to be_falsey }
    end

    context 'when bizible is enabled' do
      before do
        allow(helper).to receive(:bizible_enabled?).and_return(true)
      end

      it { is_expected.to be_truthy }
    end

    subject(:bizible_enabled?) { helper.bizible_enabled? }

    context 'with ecomm_instrumentation feature flag disabled' do
      before do
        stub_feature_flags(ecomm_instrumentation: false)
      end

      it { is_expected.to be_falsey }
    end

    context 'with ecomm_instrumentation feature flag enabled' do
      context 'when no id is set' do
        before do
          stub_config(extra: {})
        end

        it { is_expected.to be_falsey }
      end
    end
  end
end