diff options
Diffstat (limited to 'spec/models/analytics/devops_adoption')
-rw-r--r-- | spec/models/analytics/devops_adoption/segment_selection_spec.rb | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/spec/models/analytics/devops_adoption/segment_selection_spec.rb b/spec/models/analytics/devops_adoption/segment_selection_spec.rb deleted file mode 100644 index 5866cbaa48e..00000000000 --- a/spec/models/analytics/devops_adoption/segment_selection_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Analytics::DevopsAdoption::SegmentSelection, type: :model do - subject { build(:devops_adoption_segment_selection, :project) } - - describe 'validation' do - let_it_be(:group) { create(:group) } - let_it_be(:project) { create(:project) } - - it { is_expected.to validate_presence_of(:segment) } - - context do - subject { create(:devops_adoption_segment_selection, :project, project: project) } - - it { is_expected.to validate_uniqueness_of(:project_id).scoped_to(:segment_id) } - end - - context do - subject { create(:devops_adoption_segment_selection, :group, group: group) } - - it { is_expected.to validate_uniqueness_of(:group_id).scoped_to(:segment_id) } - end - - it 'project is required' do - selection = build(:devops_adoption_segment_selection, project: nil, group: nil) - - selection.validate - - expect(selection.errors).to have_key(:project) - end - - it 'project is not required when a group is given' do - selection = build(:devops_adoption_segment_selection, :group, group: group) - - expect(selection).to be_valid - end - - it 'does not allow group to be set when project is present' do - selection = build(:devops_adoption_segment_selection) - - selection.group = group - selection.project = project - - selection.validate - - expect(selection.errors[:group]).to eq([s_('DevopsAdoptionSegmentSelection|The selection cannot be configured for a project and for a group at the same time')]) - end - - context 'limit the number of segment selections' do - let_it_be(:segment) { create(:devops_adoption_segment) } - - subject { build(:devops_adoption_segment_selection, segment: segment, project: project) } - - before do - create(:devops_adoption_segment_selection, :project, segment: segment) - - stub_const("#{described_class}::ALLOWED_SELECTIONS_PER_SEGMENT", 1) - end - - it 'shows validation error' do - subject.validate - - expect(subject.errors[:segment]).to eq([s_('DevopsAdoptionSegment|The maximum number of selections has been reached')]) - end - end - end -end |