Module: Clearance::Test::Functional::ConfirmationsControllerTest

Defined in:
lib/clearance/test/functional/confirmations_controller_test.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/clearance/test/functional/confirmations_controller_test.rb', line 6

def self.included(base)
  base.class_eval do

    context 'A GET to #confirm' do
      context "with the User's given confirmation code" do
        setup do
          @user = Factory :user
          @user.generate_confirmation_code
          get :confirm, :confirmation_code => @user.confirmation_code
          @user.reload
        end

        should 'find and confirm the User record with the given confimation code' do
          assert @user.confirmed?
        end

        should_return_from_session :user_id, "@user.id"

        should_respond_with :redirect
        should_redirect_to "@controller.send(:url_after_confirm)"
        
      end

      context "without the User's given confirmation code" do
        setup do
          user = Factory :user
          get :confirm, :confirmation_code => ''
        end

        should_respond_with :not_found

        should 'render nothing' do
          assert @response.body.blank?
        end
      end
      
    end

  end
end