Files
nairobi/spec/support/common_actions/emails.rb
Javi Martín f3595833fd Improve readability in some system specs
We're improving the readability of the ones we're about to modify.
Using human texts makes tests easier to read and guarantees we're
testing from the user's point of view. For instance, if we write
`fill_in banner_target_url`, the test will pass even if the field has no
label associated to it. However, `fill_in "Link"` makes sure there's a
field with an associated label.
2021-04-07 14:32:49 +02:00

27 lines
946 B
Ruby

module Emails
def create_direct_message(sender, receiver)
login_as(sender)
visit user_path(receiver)
click_link "Send private message"
expect(page).to have_content "Send private message to #{receiver.name}"
fill_in "direct_message_title", with: "Hey #{receiver.name}!"
fill_in "direct_message_body", with: "How are you doing? This is #{sender.name}"
click_button "Send message"
expect(page).to have_content "You message has been sent successfully."
DirectMessage.last
end
def fill_in_newsletter_form(options = {})
select (options[:segment_recipient] || "All users"), from: "Recipients"
fill_in "Subject", with: (options[:subject] || "This is a different subject")
fill_in "E-mail address that will appear as sending the newsletter",
with: (options[:from] || "no-reply@consul.dev")
fill_in "Email content", with: (options[:body] || "This is a different body")
end
end