Skip to content

Instantly share code, notes, and snippets.

@gma
Last active December 11, 2015 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gma/4666549 to your computer and use it in GitHub Desktop.
Save gma/4666549 to your computer and use it in GitHub Desktop.
the 'create action' do
def post_create(params = {})
post :create, invitation: params
end
def valid_params
{ email: 'user@domain.com', first_name: 'First', last_name: 'Last' }
end
it 'should send an email to invite new users' do
assert_difference 'ActionMailer::Base.deliveries.size' do
post_create valid_params
end
end
# lots of other tests removed for clarity
end
an 'Account invitation email' do
before do
@code = Invitation.generate_code
invitation = build(
:invitation, kind: 'account', email: @email, code: @code)
@message = SignupMailer.account_invite(invitation).deliver
end
it 'should be sent to the invitee' do
assert_equal [@email], @message.to
assert_equal 'Invite code for The Agile Planner', @message.subject
end
it 'should contain a link to the signup page' do
assert_match %r{com/signup\?code=#{@code}}, @message.encoded
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment