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

raw_usage_data_spec.rb « models « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c10db63da56b0ff7271e883ea0a18d4c1e7258cf (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe RawUsageData do
  describe 'validations' do
    it { is_expected.to validate_presence_of(:payload) }
    it { is_expected.to validate_presence_of(:recorded_at) }

    context 'uniqueness validation' do
      let!(:existing_record) { create(:raw_usage_data) }

      it { is_expected.to validate_uniqueness_of(:recorded_at) }
    end

    describe '#update_sent_at!' do
      let(:raw_usage_data) { create(:raw_usage_data) }

      context 'with save_raw_usage_data feature enabled' do
        before do
          stub_feature_flags(save_raw_usage_data: true)
        end

        it 'updates sent_at' do
          raw_usage_data.update_sent_at!

          expect(raw_usage_data.sent_at).not_to be_nil
        end
      end

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

        it 'updates sent_at' do
          raw_usage_data.update_sent_at!

          expect(raw_usage_data.sent_at).to be_nil
        end
      end
    end
  end
end