Skip to content

Instantly share code, notes, and snippets.

@mchung
Created March 25, 2009 09:03
Show Gist options
  • Save mchung/85381 to your computer and use it in GitHub Desktop.
Save mchung/85381 to your computer and use it in GitHub Desktop.
require 'test_helper'
module Clearance
module Shoulda
def should_create_user_successfully
# Don't need this test.
end
end
end
class UsersControllerTest < ActionController::TestCase
include Clearance::Test::Functional::UsersControllerTest
test "Given valid attributes during sign up should send the confirmation email" do
Factory(:invite, :invite_code => "42")
post :create, {
:invite_code => "42",
:user => {:email => "mchung@example.com", :password => "hatshepsut", :password_confirmation => "hatshepsut"}
}
# email is sent
assert_sent_email do |email|
email.subject =~ /Account confirmation/ && email.to.include?("mchung@example.com")
end
# flash indicates success
assert flash[:notice] =~ /instructions/
end
test "Given a non-existant invitation during sign up should respond with invitation error" do
post :create, {
:invite_code => "42",
:user => {:email => "mchung@example.com", :password => "hatshepsut", :password_confirmation => "hatshepsut"}
}
# flash indicating no redeemable invite
assert flash[:notice] =~ /not redeemable/
end
test "Given invalid attributes during sign up should respond with form validation error" do
Factory(:invite, :invite_code => "42")
post :create, {
:invite_code => "42",
:user => {:email => "mchung@example.com", :password => "hatshepsut", :password_confirmation => "cleopatra"}
}
assert assigns(:user).errors[:password]
end
test "Given no invitation during sign up should respond with invitation error" do
post :create, {
:user => {:email => "mchung@example.com", :password => "hatshepsut", :password_confirmation => "hatshepsut"}
}
# flash indicating no redeemable invite
assert flash[:notice] =~ /not redeemable/
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment