diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-22 18:34:04 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-02-23 14:37:53 +0100 |
commit | 57719d34d3fcc15f39354b0e9dc1da41bbe5d1a8 (patch) | |
tree | 255d9a3df371793748c64792a715102dca98512c /spec/services/chat_names | |
parent | c679fa163148601e77803f45cf5dea8e1b3feb0a (diff) | |
download | gitlab-ce-57719d34d3fcc15f39354b0e9dc1da41bbe5d1a8.tar.gz |
Expose ChatName objects to slash commandsslash-commands-changes-for-chatops
Instead of only exposing a User to slash commands we now also expose the
ChatName object that the User object is retrieved from. This is
necessary for GitLab Chatops as we need for example the user ID of the
chat user.
Diffstat (limited to 'spec/services/chat_names')
-rw-r--r-- | spec/services/chat_names/find_user_service_spec.rb | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/spec/services/chat_names/find_user_service_spec.rb b/spec/services/chat_names/find_user_service_spec.rb index 79aaac3aeb6..5734b10109a 100644 --- a/spec/services/chat_names/find_user_service_spec.rb +++ b/spec/services/chat_names/find_user_service_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ChatNames::FindUserService do +describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do describe '#execute' do let(:service) { create(:service) } @@ -13,21 +13,30 @@ describe ChatNames::FindUserService do context 'when existing user is requested' do let(:params) { { team_id: chat_name.team_id, user_id: chat_name.chat_id } } - it 'returns the existing user' do - is_expected.to eq(user) + it 'returns the existing chat_name' do + is_expected.to eq(chat_name) end - it 'updates when last time chat name was used' do + it 'updates the last used timestamp if one is not already set' do expect(chat_name.last_used_at).to be_nil subject - initial_last_used = chat_name.reload.last_used_at - expect(initial_last_used).to be_present + expect(chat_name.reload.last_used_at).to be_present + end + + it 'only updates an existing timestamp once within a certain time frame' do + service = described_class.new(service, params) + + expect(chat_name.last_used_at).to be_nil + + service.execute + + time = chat_name.reload.last_used_at - Timecop.travel(2.days.from_now) { described_class.new(service, params).execute } + service.execute - expect(chat_name.reload.last_used_at).to be > initial_last_used + expect(chat_name.reload.last_used_at).to eq(time) end end |