debian-mirror-gitlab/spec/models/raw_usage_data_spec.rb

33 lines
886 B
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# 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
2021-04-29 21:17:54 +05:30
describe '#update_version_metadata!' do
2020-10-24 23:57:45 +05:30
let(:raw_usage_data) { create(:raw_usage_data) }
2021-02-22 17:27:13 +05:30
it 'updates sent_at' do
2021-04-29 21:17:54 +05:30
raw_usage_data.update_version_metadata!(usage_data_id: 123)
2020-10-24 23:57:45 +05:30
2021-02-22 17:27:13 +05:30
expect(raw_usage_data.sent_at).not_to be_nil
2020-10-24 23:57:45 +05:30
end
2021-04-29 21:17:54 +05:30
it 'updates version_usage_data_id_value' do
raw_usage_data.update_version_metadata!(usage_data_id: 123)
expect(raw_usage_data.version_usage_data_id_value).not_to be_nil
end
2020-10-24 23:57:45 +05:30
end
end
end