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
e4fd71e2
Commit
e4fd71e2
authored
Sep 10, 2020
by
manojmj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor code in emails_controller_spec.rb
parent
096577ee
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
15 deletions
+22
-15
spec/controllers/profiles/emails_controller_spec.rb
spec/controllers/profiles/emails_controller_spec.rb
+22
-15
No files found.
spec/controllers/profiles/emails_controller_spec.rb
View file @
e4fd71e2
...
...
@@ -3,7 +3,7 @@
require
'spec_helper'
RSpec
.
describe
Profiles
::
EmailsController
do
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
...
...
@@ -16,36 +16,43 @@ RSpec.describe Profiles::EmailsController do
end
describe
'#create'
do
context
'when email address is valid'
do
let
(
:email_params
)
{
{
email:
"add_email@example.com"
}
}
let
(
:email
)
{
'add_email@example.com'
}
let
(
:params
)
{
{
email:
{
email:
email
}
}
}
subject
{
post
(
:create
,
params:
params
)
}
it
'sends an email confirmation'
do
expect
{
post
(
:create
,
params:
{
email:
email_params
})
}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
end
expect
{
subject
}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
end
context
'when email address is invalid'
do
let
(
:email
_params
)
{
{
email:
"test.@example.com"
}
}
let
(
:email
)
{
'invalid.@example.com'
}
it
'does not send an email confirmation'
do
expect
{
post
(
:create
,
params:
{
email:
email_params
})
}.
not_to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
expect
{
subject
}.
not_to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
end
end
end
describe
'#resend_confirmation_instructions'
do
let
(
:email_params
)
{
{
email:
"add_email@example.com"
}
}
let_it_be
(
:email
)
{
create
(
:email
,
user:
user
)
}
let
(
:params
)
{
{
id:
email
.
id
}
}
subject
{
put
(
:resend_confirmation_instructions
,
params:
params
)
}
it
'resends an email confirmation'
do
e
mail
=
user
.
emails
.
create
(
email:
'add_email@example.com'
)
e
xpect
{
subject
}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
expect
{
put
(
:resend_confirmation_instructions
,
params:
{
id:
email
})
}.
to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
to
).
to
eq
[
email_params
[
:email
]]
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
subject
).
to
match
"Confirmation instructions"
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
to
).
to
eq
[
email
.
email
]
expect
(
ActionMailer
::
Base
.
deliveries
.
last
.
subject
).
to
match
'Confirmation instructions'
end
it
'unable to resend an email confirmation'
do
expect
{
put
(
:resend_confirmation_instructions
,
params:
{
id:
1
})
}.
not_to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
context
'email does not exist'
do
let
(
:params
)
{
{
id:
non_existing_record_id
}
}
it
'does not send an email confirmation'
do
expect
{
subject
}.
not_to
change
{
ActionMailer
::
Base
.
deliveries
.
size
}
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