Skip to content

Instantly share code, notes, and snippets.

@ogredude
Created February 1, 2013 22:22
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 ogredude/4694559 to your computer and use it in GitHub Desktop.
Save ogredude/4694559 to your computer and use it in GitHub Desktop.
require 'spec_helper'
feature "New invitation" do
let!(:user) { Fabricate(:user) }
background do
reset_mailer
user.activate!
activate_authlogic
sign_in user
end
scenario "user should be able to send invitations" do
visit root_url
should_see "(5 left)"
click_link "invite_link"
fill_in "Recipient email", :with => "joe@example.com"
click_button "invite_submit"
should_see "Invitation sent"
should_see "(4 left)"
click_link "logout"
open_email_for "joe@example.com"
current_email.should have_subject("[destico] You have been invited to participate!")
end
scenario "invited user should be able to sign up" do
sign_out
invitation = Fabricate(:invitation, :recipient_email => "joe@example.com")
invitation.deliver!
open_email_for "joe@example.com"
current_email.should have_subject("[destico] You have been invited to participate!")
click_first_link_in_email
should_see "New User"
page.should have_selector("input", :type => "text", :value => invitation.token)
fill_in "user_first_name", :with => "Joe"
fill_in "user_last_name", :with => "Doe"
fill_in "user_username", :with => "joeydoey"
fill_in "user_password", :with => "sekrit"
fill_in "user_password_confirmation", :with => "sekrit"
click_button "register_submit"
should_see "Your account has been created"
open_last_email
current_email.should have_subject("[destico] Activation Instructions")
click_first_link_in_email
should_see "your account has been activated"
should_see "Profile - Joe Doe"
open_last_email
current_email.should have_subject("[destico] Activation Complete")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment