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
Kazuhiko Shiozaki
gitlab-ce
Commits
41fdd20c
Commit
41fdd20c
authored
Aug 19, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Gitlab::ReplyByEmail.
parent
eacdd508
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
0 deletions
+86
-0
spec/lib/gitlab/reply_by_email_spec.rb
spec/lib/gitlab/reply_by_email_spec.rb
+86
-0
No files found.
spec/lib/gitlab/reply_by_email_spec.rb
0 → 100644
View file @
41fdd20c
require
"spec_helper"
describe
Gitlab
::
ReplyByEmail
do
describe
"self.enabled?"
do
context
"when reply by email is enabled"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:enabled
).
and_return
(
true
)
end
context
"when the address is valid"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:address
).
and_return
(
"replies+%{reply_key}@example.com"
)
end
it
"returns true"
do
expect
(
described_class
.
enabled?
).
to
be_truthy
end
end
context
"when the address is invalid"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:address
).
and_return
(
"replies@example.com"
)
end
it
"returns false"
do
expect
(
described_class
.
enabled?
).
to
be_falsey
end
end
end
context
"when reply by email is disabled"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:enabled
).
and_return
(
false
)
end
it
"returns false"
do
expect
(
described_class
.
enabled?
).
to
be_falsey
end
end
end
describe
"self.reply_key"
do
context
"when enabled"
do
before
do
allow
(
described_class
).
to
receive
(
:enabled?
).
and_return
(
true
)
end
it
"returns a random hex"
do
key
=
described_class
.
reply_key
key2
=
described_class
.
reply_key
expect
(
key
).
not_to
eq
(
key2
)
end
end
context
"when disabled"
do
before
do
allow
(
described_class
).
to
receive
(
:enabled?
).
and_return
(
false
)
end
it
"returns nil"
do
expect
(
described_class
.
reply_key
).
to
be_nil
end
end
end
context
"self.reply_address"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:address
).
and_return
(
"replies+%{reply_key}@example.com"
)
end
it
"returns the address with an interpolated reply key"
do
expect
(
described_class
.
reply_address
(
"key"
)).
to
eq
(
"replies+key@example.com"
)
end
end
context
"self.reply_key_from_address"
do
before
do
allow
(
Gitlab
.
config
.
reply_by_email
).
to
receive
(
:address
).
and_return
(
"replies+%{reply_key}@example.com"
)
end
it
"returns reply key"
do
expect
(
described_class
.
reply_key_from_address
(
"replies+key@example.com"
)).
to
eq
(
"key"
)
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