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
1
Merge Requests
1
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
nexedi
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
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
spec/services/emails/create_service_spec.rb
spec/services/emails/create_service_spec.rb
+11
-1
spec/services/emails/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
...
@@ -4,7 +4,7 @@ describe Emails::CreateService, services: true do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:opts
)
{
{
email:
'new@email.com'
}
}
let
(
:opts
)
{
{
email:
'new@email.com'
}
}
subject
(
:service
)
{
described_class
.
new
(
user
,
opts
)
}
subject
(
:service
)
{
described_class
.
new
(
user
,
user
,
opts
)
}
describe
'#execute'
do
describe
'#execute'
do
it
'creates an email with valid attributes'
do
it
'creates an email with valid attributes'
do
...
@@ -17,5 +17,15 @@ describe Emails::CreateService, services: true do
...
@@ -17,5 +17,15 @@ describe Emails::CreateService, services: true do
expect
(
user
.
emails
).
to
eq
(
Email
.
where
(
opts
))
expect
(
user
.
emails
).
to
eq
(
Email
.
where
(
opts
))
end
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
end
end
spec/services/emails/destroy_service_spec.rb
View file @
cabbfe94
...
@@ -4,11 +4,21 @@ describe Emails::DestroyService, services: true do
...
@@ -4,11 +4,21 @@ describe Emails::DestroyService, services: true do
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:user
)
{
create
(
:user
)
}
let!
(
:email
)
{
create
(
:email
,
user:
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
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
)
expect
{
service
.
execute
}.
to
change
{
user
.
emails
.
count
}.
by
(
-
1
)
end
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
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