diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 21:08:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-06 21:08:54 +0300 |
commit | 0d6fa033121a9bef708b8f2de186c4034c61d4a3 (patch) | |
tree | 851d65a09efbffa114c9a273e590d55cfb1436ab /spec/models/user_callout_spec.rb | |
parent | 0eb3d2f799ce4f4de87fb9fc6fd98e592323bc89 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/user_callout_spec.rb')
-rw-r--r-- | spec/models/user_callout_spec.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/models/user_callout_spec.rb b/spec/models/user_callout_spec.rb index de6534b480a..a084b1ac662 100644 --- a/spec/models/user_callout_spec.rb +++ b/spec/models/user_callout_spec.rb @@ -17,4 +17,37 @@ describe UserCallout do it { is_expected.to validate_presence_of(:feature_name) } it { is_expected.to validate_uniqueness_of(:feature_name).scoped_to(:user_id).ignoring_case_sensitivity } end + + describe 'scopes' do + describe '.with_feature_name' do + let(:second_feature_name) { described_class.feature_names.keys.second } + let(:last_feature_name) { described_class.feature_names.keys.last } + + it 'returns callout for requested feature name only' do + callout1 = create(:user_callout, feature_name: second_feature_name ) + create(:user_callout, feature_name: last_feature_name ) + + callouts = described_class.with_feature_name(second_feature_name) + + expect(callouts).to match_array([callout1]) + end + end + + describe '.with_dismissed_after' do + let(:some_feature_name) { described_class.feature_names.keys.second } + let(:callout_dismissed_month_ago) { create(:user_callout, feature_name: some_feature_name, dismissed_at: 1.month.ago )} + + it 'does not return callouts dismissed before specified date' do + callouts = described_class.with_dismissed_after(15.days.ago) + + expect(callouts).to match_array([]) + end + + it 'returns callouts dismissed after specified date' do + callouts = described_class.with_dismissed_after(2.months.ago) + + expect(callouts).to match_array([callout_dismissed_month_ago]) + end + end + end end |