diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-16 16:56:30 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-11-16 16:56:30 +0300 |
commit | d64183e1fa26ab77107e3a2a20be1fe4df3a1875 (patch) | |
tree | 00d7b51545c116ce67bb857fd1003ea381250584 /app/services | |
parent | c60437786bfe43344b4a5eb040437f73f37c6396 (diff) |
Add most of specs for chat names
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/chat_names/authorize_user_service.rb (renamed from app/services/chat_names/request_service.rb) | 10 | ||||
-rw-r--r-- | app/services/chat_names/find_user_service.rb | 17 |
2 files changed, 22 insertions, 5 deletions
diff --git a/app/services/chat_names/request_service.rb b/app/services/chat_names/authorize_user_service.rb index c67b93f932f..321bf3a9205 100644 --- a/app/services/chat_names/request_service.rb +++ b/app/services/chat_names/authorize_user_service.rb @@ -1,5 +1,5 @@ module ChatNames - class RequestService + class AuthorizeUserService include Gitlab::Routing.url_helpers def initialize(service, params) @@ -8,13 +8,19 @@ module ChatNames end def execute - token = chat_name_token.store!(chat_name_params) + return unless chat_name_params.values.all?(&:present?) + + token = request_token new_profile_chat_name_url(token: token) if token end private + def request_token + chat_name_token.store!(chat_name_params) + end + def chat_name_token Gitlab::ChatNameToken.new end diff --git a/app/services/chat_names/find_user_service.rb b/app/services/chat_names/find_user_service.rb index 6b7f75430a8..28e3e155be1 100644 --- a/app/services/chat_names/find_user_service.rb +++ b/app/services/chat_names/find_user_service.rb @@ -1,12 +1,23 @@ module ChatNames class FindUserService - def initialize(chat_names, params) - @chat_names = chat_names + def initialize(service, params) + @service = service @params = params end def execute - @chat_names.find_by( + chat_name = find_chat_name + return unless chat_name + + chat_name.update(used_at: Time.now) + chat_name.user + end + + private + + def find_chat_name + ChatName.find_by( + service: @service, team_id: @params[:team_id], chat_id: @params[:user_id] ) |