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
Tatuya Kamada
gitlab-ce
Commits
fe390a8b
Commit
fe390a8b
authored
Mar 21, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Miscellaneous cleanup of Notify shared examples
parent
6fb81afe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
56 deletions
+64
-56
spec/support/notify_shared_examples.rb
spec/support/notify_shared_examples.rb
+64
-56
No files found.
spec/support/notify_shared_examples.rb
View file @
fe390a8b
...
@@ -27,15 +27,15 @@ shared_examples 'a multiple recipients email' do
...
@@ -27,15 +27,15 @@ shared_examples 'a multiple recipients email' do
end
end
shared_examples
'an email sent from GitLab'
do
shared_examples
'an email sent from GitLab'
do
it
'
is
sent from GitLab'
do
it
'
has the characteristics of an email
sent from GitLab'
do
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
sender
=
subject
.
header
[
:from
].
addrs
[
0
]
expect
(
sender
.
display_name
).
to
eq
(
gitlab_sender_display_name
)
expect
(
sender
.
address
).
to
eq
(
gitlab_sender
)
end
it
'has a Reply-To address'
do
reply_to
=
subject
.
header
[
:reply_to
].
addresses
reply_to
=
subject
.
header
[
:reply_to
].
addresses
expect
(
reply_to
).
to
eq
([
gitlab_sender_reply_to
])
aggregate_failures
do
expect
(
sender
.
display_name
).
to
eq
(
gitlab_sender_display_name
)
expect
(
sender
.
address
).
to
eq
(
gitlab_sender
)
expect
(
reply_to
).
to
eq
([
gitlab_sender_reply_to
])
end
end
end
end
end
...
@@ -46,43 +46,40 @@ shared_examples 'an email that contains a header with author username' do
...
@@ -46,43 +46,40 @@ shared_examples 'an email that contains a header with author username' do
end
end
shared_examples
'an email with X-GitLab headers containing project details'
do
shared_examples
'an email with X-GitLab headers containing project details'
do
it
'has X-GitLab-Project* headers'
do
it
'has X-GitLab-Project headers'
do
is_expected
.
to
have_header
'X-GitLab-Project'
,
/
#{
project
.
name
}
/
aggregate_failures
do
is_expected
.
to
have_header
'X-GitLab-Project-Id'
,
/
#{
project
.
id
}
/
is_expected
.
to
have_header
(
'X-GitLab-Project'
,
/
#{
project
.
name
}
/
)
is_expected
.
to
have_header
'X-GitLab-Project-Path'
,
/
#{
project
.
path_with_namespace
}
/
is_expected
.
to
have_header
(
'X-GitLab-Project-Id'
,
/
#{
project
.
id
}
/
)
is_expected
.
to
have_header
(
'X-GitLab-Project-Path'
,
/
#{
project
.
path_with_namespace
}
/
)
end
end
end
end
end
shared_examples
'a new thread email with reply-by-email enabled'
do
shared_examples
'a new thread email with reply-by-email enabled'
do
let
(
:regex
)
{
/\A<reply\-(.*)@
#{
Gitlab
.
config
.
gitlab
.
host
}
>\Z/
}
it
'has the characteristics of a threaded email'
do
host
=
Gitlab
.
config
.
gitlab
.
host
it
'has a Message-ID header'
do
route_key
=
"
#{
model
.
class
.
model_name
.
singular_route_key
}
_
#{
model
.
id
}
"
is_expected
.
to
have_header
'Message-ID'
,
"<
#{
model
.
class
.
model_name
.
singular_route_key
}
_
#{
model
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
it
'has a References header'
do
aggregate_failures
do
is_expected
.
to
have_header
'References'
,
regex
is_expected
.
to
have_header
(
'Message-ID'
,
"<
#{
route_key
}
@
#{
host
}
>"
)
is_expected
.
to
have_header
(
'References'
,
/\A<reply\-.*@
#{
host
}
>\Z/
)
end
end
end
end
end
shared_examples
'a thread answer email with reply-by-email enabled'
do
shared_examples
'a thread answer email with reply-by-email enabled'
do
include_examples
'an email with X-GitLab headers containing project details'
include_examples
'an email with X-GitLab headers containing project details'
let
(
:regex
)
{
/\A<
#{
model
.
class
.
model_name
.
singular_route_key
}
_
#{
model
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
> <reply\-(.*)@
#{
Gitlab
.
config
.
gitlab
.
host
}
>\Z/
}
it
'has a Message-ID header'
do
is_expected
.
to
have_header
'Message-ID'
,
/\A<(.*)@
#{
Gitlab
.
config
.
gitlab
.
host
}
>\Z/
end
it
'has a In-Reply-To header'
do
is_expected
.
to
have_header
'In-Reply-To'
,
"<
#{
model
.
class
.
model_name
.
singular_route_key
}
_
#{
model
.
id
}
@
#{
Gitlab
.
config
.
gitlab
.
host
}
>"
end
it
'has
a References header
'
do
it
'has
the characteristics of a threaded reply
'
do
is_expected
.
to
have_header
'References'
,
regex
host
=
Gitlab
.
config
.
gitlab
.
host
end
route_key
=
"
#{
model
.
class
.
model_name
.
singular_route_key
}
_
#{
model
.
id
}
"
it
'has a subject that begins with Re: '
do
aggregate_failures
do
is_expected
.
to
have_subject
/^Re: /
is_expected
.
to
have_header
(
'Message-ID'
,
/\A<.*@
#{
host
}
>\Z/
)
is_expected
.
to
have_header
(
'In-Reply-To'
,
"<
#{
route_key
}
@
#{
host
}
>"
)
is_expected
.
to
have_header
(
'References'
,
/\A<
#{
route_key
}
@
#{
host
}
> <reply\-.*@
#{
host
}
>\Z/
)
is_expected
.
to
have_subject
(
/^Re: /
)
end
end
end
end
end
...
@@ -127,65 +124,76 @@ shared_examples 'an answer to an existing thread with reply-by-email enabled' do
...
@@ -127,65 +124,76 @@ shared_examples 'an answer to an existing thread with reply-by-email enabled' do
end
end
shared_examples
'it should have Gmail Actions links'
do
shared_examples
'it should have Gmail Actions links'
do
it
{
is_expected
.
to
have_body_text
'<script type="application/ld+json">'
}
it
do
it
{
is_expected
.
to
have_body_text
/ViewAction/
}
aggregate_failures
do
is_expected
.
to
have_body_text
(
'<script type="application/ld+json">'
)
is_expected
.
to
have_body_text
(
'ViewAction'
)
end
end
end
end
shared_examples
'it should not have Gmail Actions links'
do
shared_examples
'it should not have Gmail Actions links'
do
it
{
is_expected
.
not_to
have_body_text
'<script type="application/ld+json">'
}
it
do
it
{
is_expected
.
not_to
have_body_text
/ViewAction/
}
aggregate_failures
do
is_expected
.
not_to
have_body_text
(
'<script type="application/ld+json">'
)
is_expected
.
not_to
have_body_text
(
'ViewAction'
)
end
end
end
end
shared_examples
'it should show Gmail Actions View Issue link'
do
shared_examples
'it should show Gmail Actions View Issue link'
do
it_behaves_like
'it should have Gmail Actions links'
it_behaves_like
'it should have Gmail Actions links'
it
{
is_expected
.
to
have_body_text
/View Issue/
}
it
{
is_expected
.
to
have_body_text
(
'View Issue'
)
}
end
end
shared_examples
'it should show Gmail Actions View Merge request link'
do
shared_examples
'it should show Gmail Actions View Merge request link'
do
it_behaves_like
'it should have Gmail Actions links'
it_behaves_like
'it should have Gmail Actions links'
it
{
is_expected
.
to
have_body_text
/View Merge request/
}
it
{
is_expected
.
to
have_body_text
(
'View Merge request'
)
}
end
end
shared_examples
'it should show Gmail Actions View Commit link'
do
shared_examples
'it should show Gmail Actions View Commit link'
do
it_behaves_like
'it should have Gmail Actions links'
it_behaves_like
'it should have Gmail Actions links'
it
{
is_expected
.
to
have_body_text
/View Commit/
}
it
{
is_expected
.
to
have_body_text
(
'View Commit'
)
}
end
end
shared_examples
'an unsubscribeable thread'
do
shared_examples
'an unsubscribeable thread'
do
it_behaves_like
'an unsubscribeable thread with incoming address without %{key}'
it_behaves_like
'an unsubscribeable thread with incoming address without %{key}'
it
'has a List-Unsubscribe header in the correct format'
do
it
'has a List-Unsubscribe header in the correct format, and a body link'
do
is_expected
.
to
have_header
'List-Unsubscribe'
,
/unsubscribe/
aggregate_failures
do
is_expected
.
to
have_header
'List-Unsubscribe'
,
/mailto/
is_expected
.
to
have_header
(
'List-Unsubscribe'
,
/unsubscribe/
)
is_expected
.
to
have_header
'List-Unsubscribe'
,
/^<.+,.+>$/
is_expected
.
to
have_header
(
'List-Unsubscribe'
,
/mailto/
)
is_expected
.
to
have_header
(
'List-Unsubscribe'
,
/^<.+,.+>$/
)
is_expected
.
to
have_body_text
(
'unsubscribe'
)
end
end
end
it
{
is_expected
.
to
have_body_text
/unsubscribe/
}
end
end
shared_examples
'an unsubscribeable thread with incoming address without %{key}'
do
shared_examples
'an unsubscribeable thread with incoming address without %{key}'
do
include_context
'reply-by-email is enabled with incoming address without %{key}'
include_context
'reply-by-email is enabled with incoming address without %{key}'
it
'has a List-Unsubscribe header in the correct format'
do
it
'has a List-Unsubscribe header in the correct format, and a body link'
do
is_expected
.
to
have_header
'List-Unsubscribe'
,
/unsubscribe/
aggregate_failures
do
is_expected
.
not_to
have_header
'List-Unsubscribe'
,
/mailto/
is_expected
.
to
have_header
(
'List-Unsubscribe'
,
/unsubscribe/
)
is_expected
.
to
have_header
'List-Unsubscribe'
,
/^<[^,]+>$/
is_expected
.
not_to
have_header
(
'List-Unsubscribe'
,
/mailto/
)
is_expected
.
to
have_header
(
'List-Unsubscribe'
,
/^<[^,]+>$/
)
is_expected
.
to
have_body_text
(
'unsubscribe'
)
end
end
end
it
{
is_expected
.
to
have_body_text
/unsubscribe/
}
end
end
shared_examples
'a user cannot unsubscribe through footer link'
do
shared_examples
'a user cannot unsubscribe through footer link'
do
it
'does not have a List-Unsubscribe header'
do
it
'does not have a List-Unsubscribe header or a body link'
do
is_expected
.
not_to
have_header
'List-Unsubscribe'
,
/unsubscribe/
aggregate_failures
do
is_expected
.
not_to
have_header
(
'List-Unsubscribe'
,
/unsubscribe/
)
is_expected
.
not_to
have_body_text
(
'unsubscribe'
)
end
end
end
it
{
is_expected
.
not_to
have_body_text
/unsubscribe/
}
end
end
shared_examples
'an email with a labels subscriptions link in its footer'
do
shared_examples
'an email with a labels subscriptions link in its footer'
do
it
{
is_expected
.
to
have_body_text
/label subscriptions/
}
it
{
is_expected
.
to
have_body_text
(
'label subscriptions'
)
}
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