Sha256: d2622ca9fc68e842f3fe1f517e52c7ae1c9b938e1e06e8f0dfada85e52220e7d

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Clearance::UsersController do
  describe "when signed out" do
    before { sign_out }

    describe "on GET to #new" do
      before { get :new }

      it { should respond_with(:success) }
      it { should render_template(:new) }
      it { should_not set_the_flash }
    end

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

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

    describe "on POST to #create with valid attributes" do
      before do
        user_attributes = Factory.attributes_for(:user)
        @old_user_count = User.count
        post :create, :user => user_attributes
      end

      it { should assign_to(:user) }

      it "should create a new user" do
        User.count.should == @old_user_count + 1
      end

      it { should set_the_flash.to(/signed up/i) }
      it { should redirect_to_url_after_create }
    end
  end

  describe "A signed-in user" do
    before do
      @user = Factory(:user)
      sign_in_as @user
    end

    describe "GET to new" do
      before { get :new }
      it "redirects to the home page" do
        should redirect_to(root_url)
      end
    end

    describe "POST to create" do
      before { post :create, :user => {} }
      it "redirects to the home page" do
        should redirect_to(root_url)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
clearance-0.11.2 spec/controllers/users_controller_spec.rb
clearance-0.11.1 spec/controllers/users_controller_spec.rb
clearance-0.11.0 spec/controllers/users_controller_spec.rb
clearance-0.10.5 spec/controllers/users_controller_spec.rb
clearance-0.10.4 spec/controllers/users_controller_spec.rb