Also test if email is being sent

parent cd45fd70
......@@ -8,3 +8,4 @@ Feature: Admin email
Given I visit admin email page
When I submit form with email notification info
Then I should see a notification email is begin send
And admin emails are being sent
......@@ -4,12 +4,18 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
include SharedAdmin
step 'I submit form with email notification info' do
@email_text = "I've moved the project"
@selected_project = Group.last.projects.first
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
within('form#new-admin-email') do
fill_in :subject, with: 'my subject'
fill_in :body, with: @email_text
select "#{@selected_project.group.name} / #{@selected_project.name}", from: :recipients
select @selected_group.name, from: :recipients
find('.btn-create').click
end
end
......@@ -17,4 +23,10 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
step 'I should see a notification email is begin send' do
expect(find('.flash-notice')).to have_content 'Email send'
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
end
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment