blob: 68399118579676e8d11890f4726f9d71f4ef8d92 (
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
|
require 'spec_helper'
describe Users::ActivityService, services: true do
let(:user) { create(:user) }
subject(:service) { described_class.new(user, 'type') }
describe '#execute' do
context 'when last activity is nil' do
it 'sets the last activity timestamp' do
service.execute
expect(user.last_activity_at).not_to be_nil
end
end
context 'when activity_at is not nil' do
it 'updates the activity multiple times' do
activity = create(:user_activity, user: user)
Timecop.travel(activity.last_activity_at + 1.minute) do
expect { service.execute }.to change { user.reload.last_activity_at }
end
end
end
end
end
|