debian-mirror-gitlab/spec/models/user_status_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.4 KiB
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe UserStatus do
2018-11-18 11:00:15 +05:30
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to allow_value('smirk').for(:emoji) }
it { is_expected.not_to allow_value('hello world').for(:emoji) }
it { is_expected.not_to allow_value('').for(:emoji) }
it { is_expected.to validate_length_of(:message).is_at_most(100) }
it { is_expected.to allow_value('').for(:message) }
it 'is expected to be deleted when the user is deleted' do
status = create(:user_status)
2021-06-08 01:23:25 +05:30
expect { status.user.destroy! }.to change { described_class.count }.from(1).to(0)
2018-11-18 11:00:15 +05:30
end
2021-03-11 19:13:27 +05:30
describe '#clear_status_after=' do
it 'sets clear_status_at' do
status = build(:user_status)
freeze_time do
status.clear_status_after = '8_hours'
expect(status.clear_status_at).to be_like_time(8.hours.from_now)
end
end
it 'unsets clear_status_at' do
status = build(:user_status, clear_status_at: 8.hours.from_now)
status.clear_status_after = nil
expect(status.clear_status_at).to be_nil
end
context 'when unknown clear status is given' do
it 'unsets clear_status_at' do
status = build(:user_status, clear_status_at: 8.hours.from_now)
status.clear_status_after = 'unknown'
expect(status.clear_status_at).to be_nil
end
end
end
2018-11-18 11:00:15 +05:30
end