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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
9f0e23d6
Commit
9f0e23d6
authored
Feb 24, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests
parent
4535129e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
15 deletions
+29
-15
app/assets/javascripts/behaviors/toggler_behavior.js
app/assets/javascripts/behaviors/toggler_behavior.js
+1
-1
app/services/groups/base_service.rb
app/services/groups/base_service.rb
+6
-0
app/services/groups/create_service.rb
app/services/groups/create_service.rb
+0
-6
app/services/groups/update_service.rb
app/services/groups/update_service.rb
+13
-4
app/views/groups/_create_chat_team.html.haml
app/views/groups/_create_chat_team.html.haml
+1
-1
db/migrate/20170120131253_create_chat_teams.rb
db/migrate/20170120131253_create_chat_teams.rb
+3
-2
spec/services/groups/create_service_spec.rb
spec/services/groups/create_service_spec.rb
+5
-1
No files found.
app/assets/javascripts/behaviors/toggler_behavior.js
View file @
9f0e23d6
...
...
@@ -21,7 +21,7 @@
// %a.js-toggle-button
// %div.js-toggle-content
//
$
(
'
body
'
).
on
(
'
click
'
,
'
.js-toggle-button
'
,
function
(
e
)
{
$
(
'
body
'
).
on
(
'
click
'
,
'
.js-toggle-button
'
,
function
()
{
toggleContainer
(
$
(
this
).
closest
(
'
.js-toggle-container
'
));
});
...
...
app/services/groups/base_service.rb
View file @
9f0e23d6
...
...
@@ -5,5 +5,11 @@ module Groups
def
initialize
(
group
,
user
,
params
=
{})
@group
,
@current_user
,
@params
=
group
,
user
,
params
.
dup
end
private
def
create_chat_team?
@chat_team
==
"true"
&&
Gitlab
.
config
.
mattermost
.
enabled
end
end
end
app/services/groups/create_service.rb
View file @
9f0e23d6
...
...
@@ -32,11 +32,5 @@ module Groups
@group
.
add_owner
(
current_user
)
@group
end
private
def
create_chat_team?
@chat_team
&&
Gitlab
.
config
.
mattermost
.
enabled
end
end
end
app/services/groups/update_service.rb
View file @
9f0e23d6
module
Groups
class
UpdateService
<
Groups
::
BaseService
def
execute
if
params
.
delete
(
:create_chat_team
)
==
'1'
chat_name
=
params
[
:chat_team_name
]
options
=
chat_name
?
{
name:
chat_name
}
:
{}
end
@chat_team
=
params
.
delete
(
:create_chat_team
)
# check that user is allowed to set specified visibility_level
new_visibility
=
params
[
:visibility_level
]
...
...
@@ -19,6 +16,12 @@ module Groups
group
.
assign_attributes
(
params
)
if
create_chat_team?
Mattermost
::
CreateTeamService
.
new
(
group
,
current_user
).
execute
return
group
if
group
.
errors
.
any?
end
begin
group
.
save
rescue
Gitlab
::
UpdatePathError
=>
e
...
...
@@ -27,5 +30,11 @@ module Groups
false
end
end
private
def
create_chat_team?
super
&&
group
.
chat_team
.
nil?
end
end
end
app/views/groups/_create_chat_team.html.haml
View file @
9f0e23d6
...
...
@@ -13,4 +13,4 @@
Team URL:
=
Settings
.
mattermost
.
host
%span
>
/
%span
{
"data-bind-out"
=>
"create_chat_team"
}
%span
{
"data-bind-out"
=>
"create_chat_team"
}
db/migrate/20170120131253_create_chat_teams.rb
View file @
9f0e23d6
class
CreateChatTeams
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
DOWNTIME
=
true
DOWNTIME_REASON
=
"Adding a foreign key"
def
change
create_table
:chat_teams
do
|
t
|
...
...
@@ -12,6 +13,6 @@ class CreateChatTeams < ActiveRecord::Migration
t
.
timestamps
null:
false
end
add_foreign_key
:chat_teams
,
:namespaces
,
on_delete: :cascade
add_
concurrent_
foreign_key
:chat_teams
,
:namespaces
,
on_delete: :cascade
end
end
spec/services/groups/create_service_spec.rb
View file @
9f0e23d6
...
...
@@ -40,9 +40,13 @@ describe Groups::CreateService, '#execute', services: true do
end
describe
'creating a mattermost team'
do
let!
(
:params
)
{
group_params
.
merge
(
create_chat_team:
true
)
}
let!
(
:params
)
{
group_params
.
merge
(
create_chat_team:
"true"
)
}
let!
(
:service
)
{
described_class
.
new
(
user
,
params
)
}
before
do
Settings
.
mattermost
[
'enabled'
]
=
true
end
it
'triggers the service'
do
expect_any_instance_of
(
Mattermost
::
CreateTeamService
).
to
receive
(
:execute
)
...
...
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