diff options
Diffstat (limited to 'spec/models/users')
-rw-r--r-- | spec/models/users/calloutable_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/users/in_product_marketing_email_spec.rb | 3 | ||||
-rw-r--r-- | spec/models/users/project_callout_spec.rb | 24 |
3 files changed, 29 insertions, 2 deletions
diff --git a/spec/models/users/calloutable_spec.rb b/spec/models/users/calloutable_spec.rb index 01603d8bbd6..791fe1c1bc4 100644 --- a/spec/models/users/calloutable_spec.rb +++ b/spec/models/users/calloutable_spec.rb @@ -15,8 +15,8 @@ RSpec.describe Users::Calloutable do describe '#dismissed_after?' do let(:some_feature_name) { Users::Callout.feature_names.keys.second } - let(:callout_dismissed_month_ago) { create(:callout, feature_name: some_feature_name, dismissed_at: 1.month.ago )} - let(:callout_dismissed_day_ago) { create(:callout, feature_name: some_feature_name, dismissed_at: 1.day.ago )} + let(:callout_dismissed_month_ago) { create(:callout, feature_name: some_feature_name, dismissed_at: 1.month.ago ) } + let(:callout_dismissed_day_ago) { create(:callout, feature_name: some_feature_name, dismissed_at: 1.day.ago ) } it 'returns whether a callout dismissed after specified date' do expect(callout_dismissed_month_ago.dismissed_after?(15.days.ago)).to eq(false) diff --git a/spec/models/users/in_product_marketing_email_spec.rb b/spec/models/users/in_product_marketing_email_spec.rb index 7796b54babc..78de9ad8bdb 100644 --- a/spec/models/users/in_product_marketing_email_spec.rb +++ b/spec/models/users/in_product_marketing_email_spec.rb @@ -18,6 +18,7 @@ RSpec.describe Users::InProductMarketingEmail, type: :model do context 'for a track+series email' do it { is_expected.to validate_presence_of(:track) } it { is_expected.to validate_presence_of(:series) } + it { is_expected.to validate_uniqueness_of(:user_id) .scoped_to([:track, :series]).with_message('track series email has already been sent') @@ -30,10 +31,12 @@ RSpec.describe Users::InProductMarketingEmail, type: :model do it { is_expected.to validate_presence_of(:campaign) } it { is_expected.not_to validate_presence_of(:track) } it { is_expected.not_to validate_presence_of(:series) } + it { is_expected.to validate_uniqueness_of(:user_id) .scoped_to(:campaign).with_message('campaign email has already been sent') } + it { is_expected.to validate_inclusion_of(:campaign).in_array(described_class::CAMPAIGNS) } end diff --git a/spec/models/users/project_callout_spec.rb b/spec/models/users/project_callout_spec.rb new file mode 100644 index 00000000000..87d865c4bdf --- /dev/null +++ b/spec/models/users/project_callout_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Users::ProjectCallout do + let_it_be(:user) { create_default(:user) } + let_it_be(:project) { create_default(:project) } + let_it_be(:callout) { create(:project_callout) } + + it_behaves_like 'having unique enum values' + + describe 'relationships' do + it { is_expected.to belong_to(:project) } + end + + describe 'validations' do + it { is_expected.to validate_presence_of(:project) } + it { is_expected.to validate_presence_of(:feature_name) } + + it { + is_expected.to validate_uniqueness_of(:feature_name).scoped_to(:user_id, :project_id).ignoring_case_sensitivity + } + end +end |