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
570b1885
Commit
570b1885
authored
Apr 20, 2019
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix updating/deleting insights
See
https://gitlab.com/gitlab-org/gitlab-ee/issues/11099
parent
485d3c9d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
9 deletions
+36
-9
ee/app/controllers/ee/groups_controller.rb
ee/app/controllers/ee/groups_controller.rb
+1
-1
ee/app/models/ee/group.rb
ee/app/models/ee/group.rb
+1
-1
ee/app/services/ee/groups/update_service.rb
ee/app/services/ee/groups/update_service.rb
+9
-0
ee/app/views/groups/_insights.html.haml
ee/app/views/groups/_insights.html.haml
+1
-0
ee/changelogs/unreleased/11099-removing-the-project-that-holds-the-insights-configuration-raises-an-error.yml
...that-holds-the-insights-configuration-raises-an-error.yml
+5
-0
ee/spec/controllers/groups/groups_controller_spec.rb
ee/spec/controllers/groups/groups_controller_spec.rb
+17
-5
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+2
-2
No files found.
ee/app/controllers/ee/groups_controller.rb
View file @
570b1885
...
...
@@ -25,7 +25,7 @@ module EE
:membership_lock
,
:repository_size_limit
].
tap
do
|
params_ee
|
params_ee
<<
{
insight_attributes:
:project_id
}
if
current_group
&
.
insights_available?
params_ee
<<
{
insight_attributes:
[
:id
,
:project_id
,
:_destroy
]
}
if
current_group
&
.
insights_available?
params_ee
<<
:file_template_project_id
if
current_group
&
.
feature_available?
(
:custom_file_templates_for_namespace
)
params_ee
<<
:custom_project_templates_group_id
if
current_group
&
.
group_project_template_available?
end
...
...
ee/app/models/ee/group.rb
View file @
570b1885
...
...
@@ -19,7 +19,7 @@ module EE
has_one
:saml_provider
has_one
:insight
,
foreign_key: :namespace_id
accepts_nested_attributes_for
:insight
accepts_nested_attributes_for
:insight
,
allow_destroy:
true
has_one
:scim_oauth_access_token
has_many
:ldap_group_links
,
foreign_key:
'group_id'
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
...
...
ee/app/services/ee/groups/update_service.rb
View file @
570b1885
...
...
@@ -12,6 +12,8 @@ module EE
return
false
if
group
.
errors
.
present?
end
remove_insight_if_insight_project_absent
super
.
tap
{
|
success
|
log_audit_event
if
success
}
end
...
...
@@ -60,6 +62,13 @@ module EE
).
execute
.
exists?
end
def
remove_insight_if_insight_project_absent
if
params
.
dig
(
:insight_attributes
,
:project_id
)
==
''
params
[
:insight_attributes
][
:_destroy
]
=
true
params
[
:insight_attributes
].
delete
(
:project_id
)
end
end
def
log_audit_event
EE
::
Audit
::
GroupChangesAuditor
.
new
(
current_user
,
group
).
execute
end
...
...
ee/app/views/groups/_insights.html.haml
View file @
570b1885
...
...
@@ -16,6 +16,7 @@
.form-group
-
insight
=
@group
.
insight
||
@group
.
build_insight
=
form
.
fields_for
:insight_attributes
,
insight
do
|
insight_form
|
=
insight_form
.
hidden_field
:id
=
insight_form
.
label
:project_id
,
class:
'label-light'
do
.form-text.text-muted
=
_
(
'Select a repository'
)
...
...
ee/changelogs/unreleased/11099-removing-the-project-that-holds-the-insights-configuration-raises-an-error.yml
0 → 100644
View file @
570b1885
---
title
:
Fix removing and updating insights config, and foreign key constraints.
merge_request
:
11030
author
:
type
:
fixed
ee/spec/controllers/groups/groups_controller_spec.rb
View file @
570b1885
...
...
@@ -45,14 +45,26 @@ describe GroupsController do
end
.
to
change
{
group
.
reload
.
file_template_project_id
}.
to
(
project
.
id
)
end
it
'updates insight project_id successfully'
do
project
=
create
(
:project
,
group:
group
)
context
'with insights feature'
do
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
before
do
stub_licensed_features
(
insights:
true
)
end
stub_licensed_features
(
insights:
true
)
it
'updates insight project_id successfully'
do
post
:update
,
params:
{
id:
group
.
to_param
,
group:
{
insight_attributes:
{
project_id:
project
.
id
}
}
}
post
:update
,
params:
{
id:
group
.
to_param
,
group:
{
insight_attributes:
{
project_id:
project
.
id
}
}
}
expect
(
group
.
reload
.
insight
.
project
).
to
eq
(
project
)
end
it
'removes insight successfully'
do
insight
=
group
.
create_insight
(
project:
project
)
expect
(
group
.
reload
.
insight
.
project
).
to
eq
(
project
)
post
:update
,
params:
{
id:
group
.
to_param
,
group:
{
insight_attributes:
{
id:
insight
.
id
,
project_id:
''
}
}
}
expect
(
group
.
reload
.
insight
).
to
be_nil
end
end
end
end
...
...
lib/gitlab/database/migration_helpers.rb
View file @
570b1885
...
...
@@ -906,8 +906,8 @@ module Gitlab
end
def
remove_foreign_key_if_exists
(
*
args
)
if
foreign_key_exists?
(
args
)
remove_foreign_key
(
args
)
if
foreign_key_exists?
(
*
args
)
remove_foreign_key
(
*
args
)
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