Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6f714dfb
Commit
6f714dfb
authored
Nov 16, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve code design after code review
parent
2749e7a5
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
24 additions
and
21 deletions
+24
-21
app/controllers/profiles/chat_names_controller.rb
app/controllers/profiles/chat_names_controller.rb
+2
-2
app/services/chat_names/find_user_service.rb
app/services/chat_names/find_user_service.rb
+1
-1
app/views/profiles/chat_names/index.html.haml
app/views/profiles/chat_names/index.html.haml
+8
-6
app/views/profiles/chat_names/new.html.haml
app/views/profiles/chat_names/new.html.haml
+2
-2
db/migrate/20161113184239_create_user_chat_names_table.rb
db/migrate/20161113184239_create_user_chat_names_table.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
lib/gitlab/chat_name_token.rb
lib/gitlab/chat_name_token.rb
+1
-1
spec/lib/gitlab/chat_name_token_spec.rb
spec/lib/gitlab/chat_name_token_spec.rb
+1
-3
spec/services/chat_names/authorize_user_service_spec.rb
spec/services/chat_names/authorize_user_service_spec.rb
+1
-3
spec/services/chat_names/find_user_service_spec.rb
spec/services/chat_names/find_user_service_spec.rb
+1
-1
spec/support/matchers/be_url.rb
spec/support/matchers/be_url.rb
+5
-0
No files found.
app/controllers/profiles/chat_names_controller.rb
View file @
6f714dfb
...
...
@@ -13,7 +13,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController
new_chat_name
=
current_user
.
chat_names
.
new
(
chat_name_params
)
if
new_chat_name
.
save
flash
[
:notice
]
=
"Authorized
chat nickname
#{
new_chat_name
.
chat_name
}
"
flash
[
:notice
]
=
"Authorized
#{
new_chat_name
.
chat_name
}
"
else
flash
[
:alert
]
=
"Could not authorize chat nickname. Try again!"
end
...
...
@@ -34,7 +34,7 @@ class Profiles::ChatNamesController < Profiles::ApplicationController
@chat_name
=
chat_names
.
find
(
params
[
:id
])
if
@chat_name
.
destroy
flash
[
:notice
]
=
"Delete chat nickname:
#{
@chat_name
.
chat_name
}
!"
flash
[
:notice
]
=
"Delete
d
chat nickname:
#{
@chat_name
.
chat_name
}
!"
else
flash
[
:alert
]
=
"Could not delete chat nickname
#{
@chat_name
.
chat_name
}
."
end
...
...
app/services/chat_names/find_user_service.rb
View file @
6f714dfb
...
...
@@ -9,7 +9,7 @@ module ChatNames
chat_name
=
find_chat_name
return
unless
chat_name
chat_name
.
update
(
used_at:
Time
.
now
)
chat_name
.
update
(
last_
used_at:
Time
.
now
)
chat_name
.
user
end
...
...
app/views/profiles/chat_names/index.html.haml
View file @
6f714dfb
...
...
@@ -6,7 +6,7 @@
%h4
.prepend-top-0
=
page_title
%p
You can see your Chat
integration
s.
You can see your Chat
account
s.
.col-lg-9
%h5
Active chat names (
#{
@chat_names
.
length
}
)
...
...
@@ -39,11 +39,13 @@
=
link_to
service
.
title
,
edit_namespace_project_service_path
(
project
.
namespace
,
project
,
service
)
-
else
=
chat_name
.
service
.
title
%td
=
chat_name
.
team_domain
%td
=
chat_name
.
chat_name
%td
=
-
if
chat_name
.
used_at
time_ago_with_tooltip(chat_name.used_at)
%td
=
chat_name
.
team_domain
%td
=
chat_name
.
chat_name
%td
-
if
chat_name
.
last_used_at
time_ago_with_tooltip(chat_name.last_used_at)
-
else
Never
...
...
app/views/profiles/chat_names/new.html.haml
View file @
6f714dfb
%h3
.page-title
Authorization required
%main
{
:role
=>
"main"
}
%p
.h4
Authorize
the chat user
Authorize
%strong
.text-info
=
@chat_name_params
[
:chat_name
]
to use your account?
%hr
/
%hr
.actions
=
form_tag
profile_chat_names_path
,
method: :post
do
=
hidden_field_tag
:token
,
@chat_name_token
.
token
...
...
db/migrate/20161113184239_create_user_chat_names_table.rb
View file @
6f714dfb
...
...
@@ -11,7 +11,7 @@ class CreateUserChatNamesTable < ActiveRecord::Migration
t
.
string
:team_domain
t
.
string
:chat_id
,
null:
false
t
.
string
:chat_name
t
.
datetime
:used_at
t
.
datetime
:
last_
used_at
t
.
timestamps
null:
false
end
...
...
db/schema.rb
View file @
6f714dfb
...
...
@@ -159,7 +159,7 @@ ActiveRecord::Schema.define(version: 20161113184239) do
t
.
string
"team_domain"
t
.
string
"chat_id"
,
null:
false
t
.
string
"chat_name"
t
.
datetime
"used_at"
t
.
datetime
"
last_
used_at"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
end
...
...
lib/gitlab/chat_name_token.rb
View file @
6f714dfb
...
...
@@ -5,7 +5,7 @@ module Gitlab
attr_reader
:token
TOKEN_LENGTH
=
50
EXPIRY_TIME
=
10
.
minutes
# 10 minutes
EXPIRY_TIME
=
10
.
minutes
def
initialize
(
token
=
new_token
)
@token
=
token
...
...
spec/lib/gitlab/chat_name_token_spec.rb
View file @
6f714dfb
...
...
@@ -12,9 +12,7 @@ describe Gitlab::ChatNameToken, lib: true do
end
context
'when storing data'
do
let
(
:data
)
{
{
key:
'value'
}
}
let
(
:data
)
{
{
key:
'value'
}
}
subject
{
described_class
.
new
(
@token
)
}
...
...
spec/services/chat_names/authorize_user_service_spec.rb
View file @
6f714dfb
...
...
@@ -10,9 +10,7 @@ describe ChatNames::AuthorizeUserService, services: true do
let
(
:params
)
{
{
team_id:
'T0001'
,
team_domain:
'myteam'
,
user_id:
'U0001'
,
user_name:
'user'
}
}
it
'requests a new token'
do
is_expected
.
to
include
(
'http'
)
is_expected
.
to
include
(
'://'
)
is_expected
.
to
include
(
'token='
)
is_expected
.
to
be_url
end
end
...
...
spec/services/chat_names/find_user_service_spec.rb
View file @
6f714dfb
...
...
@@ -20,7 +20,7 @@ describe ChatNames::FindUserService, services: true do
it
'updates when last time chat name was used'
do
subject
expect
(
chat_name
.
reload
.
used_at
).
to
be_like_time
(
Time
.
now
)
expect
(
chat_name
.
reload
.
last_
used_at
).
to
be_like_time
(
Time
.
now
)
end
end
...
...
spec/support/matchers/be_url.rb
0 → 100644
View file @
6f714dfb
RSpec
::
Matchers
.
define
:be_url
do
|
_
|
match
do
|
actual
|
URI
.
parse
(
actual
)
rescue
false
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment