2019-03-30 07:23:56 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2018-01-26 16:07:35 +00:00
|
|
|
|
2020-06-24 06:09:01 +00:00
|
|
|
RSpec.describe UserCallout do
|
2018-12-03 12:43:34 +00:00
|
|
|
let!(:callout) { create(:user_callout) }
|
|
|
|
|
2018-12-04 10:24:21 +00:00
|
|
|
it_behaves_like 'having unique enum values'
|
|
|
|
|
2018-01-26 16:07:35 +00:00
|
|
|
describe 'relationships' do
|
|
|
|
it { is_expected.to belong_to(:user) }
|
|
|
|
end
|
2018-02-02 02:07:33 +00:00
|
|
|
|
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:user) }
|
|
|
|
|
|
|
|
it { is_expected.to validate_presence_of(:feature_name) }
|
2018-02-02 23:16:24 +00:00
|
|
|
it { is_expected.to validate_uniqueness_of(:feature_name).scoped_to(:user_id).ignoring_case_sensitivity }
|
2018-02-02 02:07:33 +00:00
|
|
|
end
|
2020-02-06 18:08:54 +00:00
|
|
|
|
2021-03-30 09:10:51 +00:00
|
|
|
describe '#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 )}
|
|
|
|
let(:callout_dismissed_day_ago) { create(:user_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)
|
|
|
|
expect(callout_dismissed_day_ago.dismissed_after?(15.days.ago)).to eq(true)
|
2020-02-06 18:08:54 +00:00
|
|
|
end
|
|
|
|
end
|
2018-01-26 16:07:35 +00:00
|
|
|
end
|