diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb b/spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb new file mode 100644 index 00000000000..211beb5b32f --- /dev/null +++ b/spec/support/shared_examples/models/integrations/base_data_fields_shared_examples.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.shared_examples Integrations::BaseDataFields do + subject(:model) { described_class.new } + + describe 'associations' do + it { is_expected.to belong_to :integration } + end + + describe '#activated?' do + subject(:activated?) { model.activated? } + + context 'with integration' do + let(:integration) { instance_spy(Integration, activated?: activated) } + + before do + allow(model).to receive(:integration).and_return(integration) + end + + context 'with value set to false' do + let(:activated) { false } + + it { is_expected.to eq(false) } + end + + context 'with value set to true' do + let(:activated) { true } + + it { is_expected.to eq(true) } + end + end + + context 'without integration' do + before do + allow(model).to receive(:integration).and_return(nil) + end + + it { is_expected.to eq(false) } + end + end + + describe '#to_database_hash' do + it 'does not include certain attributes' do + hash = model.to_database_hash + + expect(hash.keys).not_to include('id', 'service_id', 'integration_id', 'created_at', 'updated_at') + end + end +end |