BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3acbbb1a
Unverified
Commit
3acbbb1a
authored
Oct 09, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't show an "Unsubscribe" link in snippet comment notifications
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
f277fa14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
3 deletions
+130
-3
sent_notification.rb
app/models/sent_notification.rb
+5
-1
23888-fix-unsubscription-link-for-snippet-notification.yml
...3888-fix-unsubscription-link-for-snippet-notification.yml
+5
-0
notify_spec.rb
spec/mailers/notify_spec.rb
+0
-0
sent_notification_spec.rb
spec/models/sent_notification_spec.rb
+120
-2
No files found.
app/models/sent_notification.rb
View file @
3acbbb1a
...
...
@@ -53,13 +53,17 @@ class SentNotification < ActiveRecord::Base
end
def
unsubscribable?
!
for_commit?
!
(
for_commit?
||
for_snippet?
)
end
def
for_commit?
noteable_type
==
"Commit"
end
def
for_snippet?
noteable_type
.
end_with?
(
'Snippet'
)
end
def
noteable
if
for_commit?
project
.
commit
(
commit_id
)
rescue
nil
...
...
changelogs/unreleased/23888-fix-unsubscription-link-for-snippet-notification.yml
0 → 100644
View file @
3acbbb1a
---
title
:
Don't show an "Unsubscribe" link in snippet comment notifications
merge_request
:
14764
author
:
type
:
fixed
spec/mailers/notify_spec.rb
View file @
3acbbb1a
This diff is collapsed.
Click to expand it.
spec/models/sent_notification_spec.rb
View file @
3acbbb1a
require
'spec_helper'
describe
SentNotification
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:project
)
{
create
(
:project
)
}
describe
'validation'
do
describe
'note validity'
do
context
"when the project doesn't match the noteable's project"
do
...
...
@@ -34,7 +37,6 @@ describe SentNotification do
end
describe
'.record'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
)
}
it
'creates a new SentNotification'
do
...
...
@@ -43,7 +45,6 @@ describe SentNotification do
end
describe
'.record_note'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:note
)
{
create
(
:diff_note_on_merge_request
)
}
it
'creates a new SentNotification'
do
...
...
@@ -51,6 +52,123 @@ describe SentNotification do
end
end
describe
'#unsubscribable?'
do
shared_examples
'an unsubscribable notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_unsubscribable
}
end
end
shared_examples
'a non-unsubscribable notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_unsubscribable
}
end
end
it_behaves_like
'an unsubscribable notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'an unsubscribable notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a non-unsubscribable notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#for_commit?'
do
shared_examples
'a commit notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_for_commit
}
end
end
shared_examples
'a non-commit notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_for_commit
}
end
end
it_behaves_like
'a non-commit notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'a non-commit notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a commit notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a non-commit notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a non-commit notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#for_snippet?'
do
shared_examples
'a snippet notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
to
be_for_snippet
}
end
end
shared_examples
'a non-snippet notification'
do
|
noteable_type
|
subject
{
described_class
.
record
(
noteable
,
user
.
id
)
}
context
"for a
#{
noteable_type
}
"
do
it
{
expect
(
subject
).
not_to
be_for_snippet
}
end
end
it_behaves_like
'a non-snippet notification'
,
'issue'
do
let
(
:noteable
)
{
create
(
:issue
,
project:
project
)
}
end
it_behaves_like
'a non-snippet notification'
,
'merge request'
do
let
(
:noteable
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
it_behaves_like
'a non-snippet notification'
,
'commit'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:noteable
)
{
project
.
commit
}
end
it_behaves_like
'a snippet notification'
,
'personal snippet'
do
let
(
:noteable
)
{
create
(
:personal_snippet
,
project:
project
)
}
end
it_behaves_like
'a snippet notification'
,
'project snippet'
do
let
(
:noteable
)
{
create
(
:project_snippet
,
project:
project
)
}
end
end
describe
'#create_reply'
do
context
'for issue'
do
let
(
:issue
)
{
create
(
:issue
)
}
...
...
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