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
cabbfe94
Commit
cabbfe94
authored
Jun 16, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add more spec examples
parent
3798e894
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
create_service_spec.rb
spec/services/emails/create_service_spec.rb
+11
-1
destroy_service_spec.rb
spec/services/emails/destroy_service_spec.rb
+12
-2
No files found.
spec/services/emails/create_service_spec.rb
View file @
cabbfe94
...
...
@@ -4,7 +4,7 @@ describe Emails::CreateService, services: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:opts
)
{
{
email:
'new@email.com'
}
}
subject
(
:service
)
{
described_class
.
new
(
user
,
opts
)
}
subject
(
:service
)
{
described_class
.
new
(
user
,
user
,
opts
)
}
describe
'#execute'
do
it
'creates an email with valid attributes'
do
...
...
@@ -17,5 +17,15 @@ describe Emails::CreateService, services: true do
expect
(
user
.
emails
).
to
eq
(
Email
.
where
(
opts
))
end
it
'does not create an email if the user has no permissions'
do
expect
{
described_class
.
new
(
create
(
:user
),
user
,
opts
).
execute
}.
not_to
change
{
Email
.
count
}
end
it
'creates an email if we skip authorization'
do
expect
do
described_class
.
new
(
create
(
:user
),
user
,
opts
).
execute
(
skip_authorization:
true
)
end
.
to
change
{
Email
.
count
}.
by
(
1
)
end
end
end
spec/services/emails/destroy_service_spec.rb
View file @
cabbfe94
...
...
@@ -4,11 +4,21 @@ describe Emails::DestroyService, services: true do
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:email
)
{
create
(
:email
,
user:
user
)
}
subject
(
:service
)
{
described_class
.
new
(
user
,
opts
)
}
subject
(
:service
)
{
described_class
.
new
(
user
,
user
,
email:
email
.
email
)
}
describe
'#execute'
do
it
'
creates an email with valid attributes
'
do
it
'
removes an email
'
do
expect
{
service
.
execute
}.
to
change
{
user
.
emails
.
count
}.
by
(
-
1
)
end
it
'does not remove an email if the user has no permissions'
do
expect
{
described_class
.
new
(
create
(
:user
),
user
,
opts
).
execute
}.
not_to
change
{
Email
.
count
}
end
it
'removes an email if we skip authorization'
do
expect
do
described_class
.
new
(
create
(
:user
),
user
,
opts
).
execute
(
skip_authorization:
true
)
end
.
to
change
{
Email
.
count
}.
by
(
-
1
)
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