Sha256: 30995b71c0bb33ccbe0b86b916182ee45a682b77d38fa79ce210540e852e62dd

Contents?: true

Size: 1.33 KB

Versions: 27

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class SignUpTest < ActionController::IntegrationTest
  
  context 'Signing up as a new user' do
    
    setup do
      ActionMailer::Base.deliveries.clear
    end

    teardown do
      ActionMailer::Base.deliveries.clear
    end
    
    context 'with invalid data' do
      
      should 'show error messages' do
        sign_up(:email => 'invalidemail', :password_confirmation => '', :first_name => '', :last_name => '')
        assert_match /Email is invalid/, response.body
        assert_match /First name.*blank/, response.body
        assert_match /Last name.*blank/, response.body
        assert_match /Password doesn't match confirmation/, response.body
      end
      
    end
    
    context 'with valid data' do
      
      should 'sign in the user' do
        sign_up(:email => 'bob@bob.bob', :password => 'password', :password_confirmation => 'password')
        assert controller.signed_in?
      end
    
      should 'send a welcome email' do
        sign_up(:email => 'bob@bob.bob', :password => 'password', :password_confirmation => 'password')
        user = User.find_by_email('bob@bob.bob')
        Delayed::Job.work_off
        sent = ActionMailer::Base.deliveries.last
        assert_equal user.email, sent.recipients
        assert_match /welcome/i, sent.subject
      end
      
    end
    
  end

end

Version data entries

27 entries across 26 versions & 4 rubygems

Version Path
headstart-0.11.2 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.11.1 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.9.2 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.9.1 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.9.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.8.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.7.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.6.2 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.6.1 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.6.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.5 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.4 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.3 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.2 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.1 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.5.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.4.2 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.4.1 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.4.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb
headstart-0.3.0 generators/headstart_tests/templates/test/integration/sign_up_test.rb