diff options
Diffstat (limited to 'spec/models/users')
-rw-r--r-- | spec/models/users/calloutable_spec.rb | 4 | ||||
-rw-r--r-- | spec/models/users/ghost_user_migration_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/users/namespace_commit_email_spec.rb | 21 |
3 files changed, 35 insertions, 3 deletions
diff --git a/spec/models/users/calloutable_spec.rb b/spec/models/users/calloutable_spec.rb index 791fe1c1bc4..7e186445c1b 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/ghost_user_migration_spec.rb b/spec/models/users/ghost_user_migration_spec.rb index d4a0657c3be..a0b2af6175a 100644 --- a/spec/models/users/ghost_user_migration_spec.rb +++ b/spec/models/users/ghost_user_migration_spec.rb @@ -8,7 +8,18 @@ RSpec.describe Users::GhostUserMigration do it { is_expected.to belong_to(:initiator_user) } end - describe 'validation' do + describe 'validations' do it { is_expected.to validate_presence_of(:user_id) } end + + describe 'scopes' do + describe '.consume_order' do + let!(:ghost_user_migration_1) { create(:ghost_user_migration, consume_after: Time.current) } + let!(:ghost_user_migration_2) { create(:ghost_user_migration, consume_after: 5.minutes.ago) } + + subject { described_class.consume_order.to_a } + + it { is_expected.to eq([ghost_user_migration_2, ghost_user_migration_1]) } + end + end end diff --git a/spec/models/users/namespace_commit_email_spec.rb b/spec/models/users/namespace_commit_email_spec.rb new file mode 100644 index 00000000000..696dac25f9b --- /dev/null +++ b/spec/models/users/namespace_commit_email_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Users::NamespaceCommitEmail, type: :model do + subject { build(:namespace_commit_email) } + + describe 'associations' do + it { is_expected.to belong_to(:user) } + it { is_expected.to belong_to(:namespace) } + it { is_expected.to belong_to(:email) } + end + + describe 'validations' do + it { is_expected.to validate_presence_of(:user) } + it { is_expected.to validate_presence_of(:namespace) } + it { is_expected.to validate_presence_of(:email) } + end + + it { is_expected.to be_valid } +end |