blob: 87d1fa14aca109d3965b4a6fbaf7742a0b700144 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe UserStatus do
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)
expect { status.user.destroy! }.to change { described_class.count }.from(1).to(0)
end
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
end
|