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
5913a7aa
Commit
5913a7aa
authored
Jul 10, 2017
by
Sean McGivern
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'gitlab_app_fixes' into 'master'
Fix GitLab Slack application configuration See merge request !2392
parents
48cda4b3
09b90e89
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
44 additions
and
15 deletions
+44
-15
app/controllers/projects/settings/integrations_controller.rb
app/controllers/projects/settings/integrations_controller.rb
+12
-1
app/models/project.rb
app/models/project.rb
+4
-2
app/models/service.rb
app/models/service.rb
+2
-9
spec/controllers/projects/settings/integrations_controller_spec.rb
...rollers/projects/settings/integrations_controller_spec.rb
+23
-0
spec/controllers/projects/settings/slacks_controller_spec.rb
spec/controllers/projects/settings/slacks_controller_spec.rb
+2
-2
spec/features/projects/settings/slack_application_spec.rb
spec/features/projects/settings/slack_application_spec.rb
+1
-1
No files found.
app/controllers/projects/settings/integrations_controller.rb
View file @
5913a7aa
...
...
@@ -11,7 +11,18 @@ module Projects
@hook
=
ProjectHook
.
new
# Services
@services
=
@project
.
find_or_initialize_services
@services
=
@project
.
find_or_initialize_services
(
exceptions:
service_exceptions
)
end
private
# Returns a list of services that should be hidden from the list
def
service_exceptions
if
current_application_settings
.
slack_app_enabled
[
'slack_slash_commands'
]
else
[
'gitlab_slack_application'
]
end
end
end
end
...
...
app/models/project.rb
View file @
5913a7aa
...
...
@@ -795,10 +795,12 @@ class Project < ActiveRecord::Base
update_column
(
:has_external_wiki
,
services
.
external_wikis
.
any?
)
end
def
find_or_initialize_services
def
find_or_initialize_services
(
exceptions:
[])
services_templates
=
Service
.
where
(
template:
true
)
Service
.
available_services_names
.
map
do
|
service_name
|
available_services_names
=
Service
.
available_services_names
-
exceptions
available_services_names
.
map
do
|
service_name
|
service
=
find_service
(
services
,
service_name
)
if
service
...
...
app/models/service.rb
View file @
5913a7aa
...
...
@@ -246,6 +246,7 @@ class Service < ActiveRecord::Base
pushover
redmine
slack
slack_slash_commands
teamcity
microsoft_teams
]
...
...
@@ -253,14 +254,10 @@ class Service < ActiveRecord::Base
service_names
+=
%w[mock_ci mock_deployment mock_monitoring]
end
if
show_gitlab_slack_application
?
if
Gitlab
.
com?
||
Rails
.
env
.
development
?
service_names
.
push
(
'gitlab_slack_application'
)
end
unless
Gitlab
.
com?
service_names
.
push
(
'slack_slash_commands'
)
end
service_names
.
sort_by
(
&
:downcase
)
end
...
...
@@ -271,10 +268,6 @@ class Service < ActiveRecord::Base
service
end
def
self
.
show_gitlab_slack_application?
(
Gitlab
.
com?
&&
current_application_settings
.
slack_app_enabled
)
||
Rails
.
env
.
development?
end
private
def
cache_project_has_external_issue_tracker
...
...
spec/controllers/projects/settings/integrations_controller_spec.rb
View file @
5913a7aa
...
...
@@ -17,4 +17,27 @@ describe Projects::Settings::IntegrationsController do
expect
(
response
).
to
render_template
(
:show
)
end
end
context
'Sets correct services list'
do
it
'enables SlackSlashCommandsService and disables GitlabSlackApplication'
do
get
:show
,
namespace_id:
project
.
namespace
,
project_id:
project
services
=
assigns
(
:services
).
map
(
&
:type
)
expect
(
services
).
to
include
(
'SlackSlashCommandsService'
)
expect
(
services
).
not_to
include
(
'GitlabSlackApplicationService'
)
end
it
'enables GitlabSlackApplication and disables SlackSlashCommandsService'
do
stub_application_setting
(
slack_app_enabled:
true
)
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
get
:show
,
namespace_id:
project
.
namespace
,
project_id:
project
services
=
assigns
(
:services
).
map
(
&
:type
)
expect
(
services
).
to
include
(
'GitlabSlackApplicationService'
)
expect
(
services
).
not_to
include
(
'SlackSlashCommandsService'
)
end
end
end
spec/controllers/projects/settings/slacks_controller_spec.rb
View file @
5913a7aa
...
...
@@ -24,7 +24,7 @@ describe Projects::Settings::SlacksController do
.
to
receive
(
:new
).
with
(
project
,
user
,
anything
).
and_return
(
service
)
end
it
'calls service and redirects with no
flash message
if result is successful'
do
it
'calls service and redirects with no
alerts
if result is successful'
do
stub_service
(
status: :success
)
get
:slack_auth
,
namespace_id:
project
.
namespace
,
project_id:
project
...
...
@@ -34,7 +34,7 @@ describe Projects::Settings::SlacksController do
expect
(
flash
[
:alert
]).
to
be_nil
end
it
'calls service and redirects with
flash message
if there is error'
do
it
'calls service and redirects with
the alert
if there is error'
do
stub_service
(
status: :error
,
message:
'error'
)
get
:slack_auth
,
namespace_id:
project
.
namespace
,
project_id:
project
...
...
spec/features/projects/settings/slack_application_spec.rb
View file @
5913a7aa
...
...
@@ -13,7 +13,7 @@ feature 'Slack application', feature: true do
create
(
:slack_integration
,
service:
service
)
allow
(
Service
).
to
receive
(
:show_gitlab_slack_application
?
).
and_return
(
true
)
allow
(
Gitlab
).
to
receive
(
:com
?
).
and_return
(
true
)
end
scenario
'I can edit slack integration'
do
...
...
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