Sha256: cc24617d45ffb857f5b0782c45d40fe5873be61ec79bea775363166bfbebfe6f

Contents?: true

Size: 1.44 KB

Versions: 8

Compression:

Stored size: 1.44 KB

Contents

require 'test_helper'

class UsersControllerTest < ActionController::TestCase

  tests Clearance::UsersController

  should_filter_params :password

  context "when signed out" do
    setup { sign_out }

    context "on GET to #new" do
      setup { get :new }

      should_respond_with :success
      should_render_template :new
      should_not_set_the_flash

      should_display_a_sign_up_form
    end

    context "on GET to #new with email" do
      setup do
        @email = "a@example.com"
        get :new, :user => { :email => @email }
      end

      should "set assigned user's email" do
        assert_equal @email, assigns(:user).email
      end
    end

    context "on POST to #create with valid attributes" do
      setup do
        user_attributes = Factory.attributes_for(:user)
        post :create, :user => user_attributes
      end

      should_assign_to :user
      should_change 'User.count', :by => 1

      should "send the confirmation email" do
        assert_sent_email do |email|
          email.subject =~ /account confirmation/i
        end
      end

      should_set_the_flash_to /confirm/i
      should_redirect_to_url_after_create
    end
  end

  signed_in_user_context do
    context "GET to new" do
      setup { get :new }
      should_redirect_to("the home page") { root_url }
    end

    context "POST to create" do
      setup { post :create, :user => {} }
      should_redirect_to("the home page") { root_url }
    end
  end

end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
janova-clearance-0.8.8 test/controllers/users_controller_test.rb
forgetful-clearance-0.8.11 test/controllers/users_controller_test.rb
forgetful-clearance-0.8.10 test/controllers/users_controller_test.rb
benaldred-clearance-0.8.8 test/controllers/users_controller_test.rb
clearance-0.8.8 test/controllers/users_controller_test.rb
clearance-0.8.7 test/controllers/users_controller_test.rb
clearance-0.8.6 test/controllers/users_controller_test.rb
clearance-0.8.5 test/controllers/users_controller_test.rb