debian-mirror-gitlab/spec/models/users/calloutable_spec.rb

27 lines
886 B
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
require 'spec_helper'
2022-01-26 12:08:38 +05:30
RSpec.describe Users::Calloutable do
subject { build(:callout) }
2021-11-11 11:23:49 +05:30
describe "Associations" do
it { is_expected.to belong_to(:user) }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:user) }
end
describe '#dismissed_after?' do
2022-01-26 12:08:38 +05:30
let(:some_feature_name) { Users::Callout.feature_names.keys.second }
2023-01-13 00:05:48 +05:30
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) }
2021-11-11 11:23:49 +05:30
it 'returns whether a callout dismissed after specified date' do
expect(callout_dismissed_month_ago.dismissed_after?(15.days.ago)).to eq(false)
expect(callout_dismissed_day_ago.dismissed_after?(15.days.ago)).to eq(true)
end
end
end