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
Léo-Paul Géneau
gitlab-ce
Commits
1f3849b0
Commit
1f3849b0
authored
Feb 14, 2018
by
🙈 jacopo beschi 🙉
Committed by
Sean McGivern
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Remove notification settings for groups and projects you were previously a member of"
parent
1c91c4e3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
7 deletions
+57
-7
app/models/member.rb
app/models/member.rb
+1
-1
app/services/members/authorized_destroy_service.rb
app/services/members/authorized_destroy_service.rb
+1
-0
changelogs/unreleased/42481-remove-notification-settings-left-projects.yml
...ased/42481-remove-notification-settings-left-projects.yml
+5
-0
spec/services/members/authorized_destroy_service_spec.rb
spec/services/members/authorized_destroy_service_spec.rb
+50
-6
No files found.
app/models/member.rb
View file @
1f3849b0
...
@@ -314,7 +314,7 @@ class Member < ActiveRecord::Base
...
@@ -314,7 +314,7 @@ class Member < ActiveRecord::Base
end
end
def
notification_setting
def
notification_setting
@notification_setting
||=
user
.
notification_settings_for
(
source
)
@notification_setting
||=
user
&
.
notification_settings_for
(
source
)
end
end
def
notifiable?
(
type
,
opts
=
{})
def
notifiable?
(
type
,
opts
=
{})
...
...
app/services/members/authorized_destroy_service.rb
View file @
1f3849b0
...
@@ -11,6 +11,7 @@ module Members
...
@@ -11,6 +11,7 @@ module Members
Member
.
transaction
do
Member
.
transaction
do
unassign_issues_and_merge_requests
(
member
)
unless
member
.
invite?
unassign_issues_and_merge_requests
(
member
)
unless
member
.
invite?
member
.
notification_setting
&
.
destroy
member
.
destroy
member
.
destroy
end
end
...
...
changelogs/unreleased/42481-remove-notification-settings-left-projects.yml
0 → 100644
View file @
1f3849b0
---
title
:
Remove user notification settings for groups and projects when user leaves
merge_request
:
16906
author
:
Jacopo Beschi @jacopo-beschi
type
:
fixed
spec/services/members/authorized_destroy_service_spec.rb
View file @
1f3849b0
...
@@ -21,6 +21,15 @@ describe Members::AuthorizedDestroyService do
...
@@ -21,6 +21,15 @@ describe Members::AuthorizedDestroyService do
.
to
change
{
Member
.
count
}.
from
(
3
).
to
(
2
)
.
to
change
{
Member
.
count
}.
from
(
3
).
to
(
2
)
end
end
it
"doesn't destroy invited project member notification_settings"
do
project
.
add_developer
(
member_user
)
member
=
create
:project_member
,
:invited
,
project:
project
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
not_to
change
{
NotificationSetting
.
count
}
end
it
'destroys invited group member'
do
it
'destroys invited group member'
do
group
.
add_developer
(
member_user
)
group
.
add_developer
(
member_user
)
...
@@ -29,38 +38,73 @@ describe Members::AuthorizedDestroyService do
...
@@ -29,38 +38,73 @@ describe Members::AuthorizedDestroyService do
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
Member
.
count
}.
from
(
2
).
to
(
1
)
.
to
change
{
Member
.
count
}.
from
(
2
).
to
(
1
)
end
end
it
"doesn't destroy invited group member notification_settings"
do
group
.
add_developer
(
member_user
)
member
=
create
:group_member
,
:invited
,
group:
group
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
not_to
change
{
NotificationSetting
.
count
}
end
end
context
'Requested user'
do
it
"doesn't destroy member notification_settings"
do
member
=
create
(
:project_member
,
user:
member_user
,
requested_at:
Time
.
now
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
not_to
change
{
NotificationSetting
.
count
}
end
end
end
context
'Group member'
do
context
'Group member'
do
it
"unassigns issues and merge requests"
do
let
(
:member
)
{
group
.
members
.
find_by
(
user_id:
member_user
.
id
)
}
before
do
group
.
add_developer
(
member_user
)
group
.
add_developer
(
member_user
)
end
it
"unassigns issues and merge requests"
do
issue
=
create
:issue
,
project:
group_project
,
assignees:
[
member_user
]
issue
=
create
:issue
,
project:
group_project
,
assignees:
[
member_user
]
create
:issue
,
assignees:
[
member_user
]
create
:issue
,
assignees:
[
member_user
]
merge_request
=
create
:merge_request
,
target_project:
group_project
,
source_project:
group_project
,
assignee:
member_user
merge_request
=
create
:merge_request
,
target_project:
group_project
,
source_project:
group_project
,
assignee:
member_user
create
:merge_request
,
target_project:
project
,
source_project:
project
,
assignee:
member_user
create
:merge_request
,
target_project:
project
,
source_project:
project
,
assignee:
member_user
member
=
group
.
members
.
find_by
(
user_id:
member_user
.
id
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
4
).
to
(
2
)
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
4
).
to
(
2
)
expect
(
issue
.
reload
.
assignee_ids
).
to
be_empty
expect
(
issue
.
reload
.
assignee_ids
).
to
be_empty
expect
(
merge_request
.
reload
.
assignee_id
).
to
be_nil
expect
(
merge_request
.
reload
.
assignee_id
).
to
be_nil
end
end
it
'destroys member notification_settings'
do
group
.
add_developer
(
member_user
)
member
=
group
.
members
.
find_by
(
user_id:
member_user
.
id
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
member_user
.
notification_settings
.
count
}.
by
(
-
1
)
end
end
end
context
'Project member'
do
context
'Project member'
do
it
"unassigns issues and merge requests"
do
let
(
:member
)
{
project
.
members
.
find_by
(
user_id:
member_user
.
id
)
}
before
do
project
.
add_developer
(
member_user
)
project
.
add_developer
(
member_user
)
end
it
"unassigns issues and merge requests"
do
create
:issue
,
project:
project
,
assignees:
[
member_user
]
create
:issue
,
project:
project
,
assignees:
[
member_user
]
create
:merge_request
,
target_project:
project
,
source_project:
project
,
assignee:
member_user
create
:merge_request
,
target_project:
project
,
source_project:
project
,
assignee:
member_user
member
=
project
.
members
.
find_by
(
user_id:
member_user
.
id
)
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
2
).
to
(
0
)
.
to
change
{
number_of_assigned_issuables
(
member_user
)
}.
from
(
2
).
to
(
0
)
end
end
it
'destroys member notification_settings'
do
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
member_user
.
notification_settings
.
count
}.
by
(
-
1
)
end
end
end
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