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
132340d2
Commit
132340d2
authored
May 02, 2018
by
blackst0ne
Committed by
Rémy Coutable
May 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace the `admin/emails.feature` spinach test with an rspec analog
parent
192b08df
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
80 additions
and
119 deletions
+80
-119
ee/changelogs/unreleased/blackst0ne-replace-spinach-admin-emails-feature.yml
...eased/blackst0ne-replace-spinach-admin-emails-feature.yml
+5
-0
ee/spec/features/admin/admin_emails_spec.rb
ee/spec/features/admin/admin_emails_spec.rb
+0
-27
ee/spec/features/admin/admin_sends_notification_spec.rb
ee/spec/features/admin/admin_sends_notification_spec.rb
+50
-0
ee/spec/features/user_unsubscribes_from_admin_notifications_spec.rb
...atures/user_unsubscribes_from_admin_notifications_spec.rb
+25
-0
features/admin/emails.feature
features/admin/emails.feature
+0
-17
features/steps/admin/email.rb
features/steps/admin/email.rb
+0
-64
features/steps/shared/admin.rb
features/steps/shared/admin.rb
+0
-7
features/steps/shared/paths.rb
features/steps/shared/paths.rb
+0
-4
No files found.
ee/changelogs/unreleased/blackst0ne-replace-spinach-admin-emails-feature.yml
0 → 100644
View file @
132340d2
---
title
:
'
Replace
the
`admin/emails.feature`
spinach
test
with
an
rspec
analog'
merge_request
:
5513
author
:
'
@blackst0ne'
type
:
other
ee/spec/features/admin/admin_emails_spec.rb
deleted
100644 → 0
View file @
192b08df
require
'spec_helper'
describe
"Admin::Emails"
,
:js
do
let!
(
:current_user
)
{
create
(
:admin
)
}
let!
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
group
)
}
describe
"GET /admin/email"
do
before
do
sign_in
(
current_user
)
visit
admin_email_path
end
describe
'Recipient group select'
do
it
"includes groups and projects"
do
find
(
'.ajax-admin-email-select'
).
click
wait_for_requests
expect
(
page
).
to
have_selector
(
'.ajax-admin-email-dropdown li'
,
count:
3
)
group_names
=
page
.
all
(
'.ajax-admin-email-dropdown li .group-name'
)
expect
(
group_names
[
0
].
text
).
to
eq
(
'All'
)
expect
(
group_names
[
1
].
text
).
to
eq
(
group
.
name
)
expect
(
find
(
'.ajax-admin-email-dropdown li .project-name'
).
text
).
to
eq
(
project
.
name
)
end
end
end
end
ee/spec/features/admin/admin_sends_notification_spec.rb
0 → 100644
View file @
132340d2
require
"spec_helper"
describe
"Admin sends notification"
,
:js
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_developer
(
user
)
sign_in
(
admin
)
visit
(
admin_email_path
)
end
it
"sends notification"
do
perform_enqueued_jobs
do
NOTIFICATION_TEXT
=
"Your project has been moved."
.
freeze
body
=
find
(
:xpath
,
"//body"
)
page
.
within
(
"form#new-admin-email"
)
do
fill_in
(
:subject
,
with:
"My Subject"
)
fill_in
(
:body
,
with:
NOTIFICATION_TEXT
)
find
(
".ajax-admin-email-select"
).
click
wait_for_requests
options
=
body
.
all
(
"li.select2-result"
)
expect
(
body
).
to
have_selector
(
"li.select2-result"
,
count:
3
)
expect
(
options
[
0
].
text
).
to
include
(
"All"
)
expect
(
options
[
1
].
text
).
to
include
(
group
.
name
)
expect
(
options
[
2
].
text
).
to
include
(
project
.
name
)
body
.
find
(
"input.select2-input"
).
set
(
group
.
name
)
body
.
find
(
".group-name"
,
text:
group
.
name
).
click
click_button
(
"Send message"
)
end
end
emails
=
ActionMailer
::
Base
.
deliveries
expect
(
find
(
".flash-notice"
)).
to
have_content
(
"Email sent"
)
expect
(
emails
.
count
).
to
eql
(
group
.
users
.
count
)
expect
(
emails
.
last
.
text_part
.
body
.
decoded
).
to
include
(
NOTIFICATION_TEXT
)
end
end
ee/spec/features/user_unsubscribes_from_admin_notifications_spec.rb
0 → 100644
View file @
132340d2
require
"spec_helper"
describe
"Admin unsubscribes from notification"
do
set
(
:user
)
{
create
(
:user
)
}
set
(
:urlsafe_email
)
{
Base64
.
urlsafe_encode64
(
user
.
email
)
}
before
do
sign_in
(
user
)
visit
(
unsubscribe_path
(
urlsafe_email
))
end
it
"unsubscribes from notifications"
do
NOTIFICATION_TEXT
=
"You have been unsubscribed from receiving GitLab administrator notifications."
.
freeze
perform_enqueued_jobs
do
click_button
(
"Unsubscribe"
)
end
last_email
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
current_path
).
to
eq
(
root_path
)
expect
(
last_email
.
text_part
.
body
.
decoded
).
to
include
(
NOTIFICATION_TEXT
)
end
end
features/admin/emails.feature
deleted
100644 → 0
View file @
192b08df
Feature
:
Admin email
Background
:
Given
I sign in as an admin
And
there are groups with projects
@javascript
Scenario
:
Create a new email notification
Given
I visit admin email page
When
I submit form with email notification info
Then
I should see a notification email is begin sent
And
admin emails are being sent
Scenario
:
Create a new email notification
Given
I visit unsubscribe from admin notification page
When
I click unsubscribe
Then
I get redirected to the sign in path
And
unsubscribed email is sent
features/steps/admin/email.rb
deleted
100644 → 0
View file @
192b08df
class
Spinach::Features::AdminEmail
<
Spinach
::
FeatureSteps
include
SharedAuthentication
include
SharedPaths
include
SharedAdmin
step
'I submit form with email notification info'
do
perform_enqueued_jobs
do
ActionMailer
::
Base
.
deliveries
=
[]
@email_text
=
"Your project has been moved."
@selected_group
=
Group
.
last
# ensure there are ppl to be emailed
2
.
times
do
@selected_group
.
add_user
(
create
(
:user
),
Gitlab
::
Access
::
DEVELOPER
)
end
page
.
within
(
'form#new-admin-email'
)
do
fill_in
:subject
,
with:
'my subject'
fill_in
:body
,
with:
@email_text
# Note: Unable to use select2 helper because
# the helper uses select2 method "val" to select the group from the dropdown
# and the method "val" requires "initSelection" to be used in the select2 call
select2_container
=
first
(
"#s2id_recipients"
)
select2_container
.
find
(
".select2-choice"
).
click
find
(
:xpath
,
"//body"
).
find
(
"input.select2-input"
).
set
(
@selected_group
.
name
)
page
.
execute_script
(
%|$("input.select2-input:visible").keyup();|
)
find
(
:xpath
,
"//body"
).
find
(
".group-name"
,
text:
@selected_group
.
name
).
click
find
(
'.btn-create'
).
click
end
end
end
step
'I should see a notification email is begin sent'
do
expect
(
find
(
'.flash-notice'
)).
to
have_content
'Email sent'
end
step
'admin emails are being sent'
do
expect
(
ActionMailer
::
Base
.
deliveries
.
count
).
to
eql
@selected_group
.
users
.
count
mail
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
mail
.
text_part
.
body
.
decoded
).
to
include
@email_text
end
step
'I visit unsubscribe from admin notification page'
do
@user
=
create
(
:user
)
urlsafe_email
=
Base64
.
urlsafe_encode64
(
@user
.
email
)
visit
unsubscribe_path
(
urlsafe_email
)
end
step
'I click unsubscribe'
do
perform_enqueued_jobs
do
click_button
'Unsubscribe'
end
end
step
'I get redirected to the sign in path'
do
expect
(
current_path
).
to
eq
root_path
end
step
'unsubscribed email is sent'
do
mail
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
mail
.
text_part
.
body
.
decoded
).
to
include
"You have been unsubscribed from receiving GitLab administrator notifications."
end
end
features/steps/shared/admin.rb
View file @
132340d2
...
...
@@ -8,11 +8,4 @@ module SharedAdmin
step
'system has users'
do
2
.
times
{
create
(
:user
)
}
end
And
'there are groups with projects'
do
2
.
times
do
group
=
create
:group
create
:project
,
group:
group
end
end
end
features/steps/shared/paths.rb
View file @
132340d2
...
...
@@ -188,10 +188,6 @@ module SharedPaths
visit
admin_teams_path
end
step
'I visit admin email page'
do
visit
admin_email_path
end
step
'I visit admin settings page'
do
visit
admin_application_settings_path
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