Sha256: 91cc995a2d50f88cd0eb3037d328165e0c43cf182cb2b18cb4ec524b30077c29

Contents?: true

Size: 1.29 KB

Versions: 8

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

module PushType
  class ConfirmationsControllerTest < ActionController::TestCase

    before { @request.env["devise.mapping"] = Devise.mappings[:user] }

    let(:user)  { FactoryGirl.create(:user) }
    let(:token) { user.confirmation_token }
    
    describe 'GET #show' do
      before { get :show, params: { confirmation_token: token } }
      describe 'with invalid confirmation token' do
        let(:token) { 'invalid' }
        it { response.must_render_template 'new' }
        it { assigns[:user].must_be :new_record? }
      end
      describe 'with valid confirmation token' do
        it { response.must_render_template 'show' }
        it { assigns[:user].must_equal user }
      end
    end

    describe 'PUT #update' do
      before { put :update, params: { user: { confirmation_token: token, password: password, password_confirmation: password } } }
      describe 'with invalid user' do
        let(:password) { '' }
        it { assigns[:user].errors.wont_be_empty }
        it { assigns[:user].wont_be :confirmed? }
        it { response.must_render_template :show }
      end
      describe 'with valid user' do
        let(:password) { 'pa$$word' }
        it { user.reload.must_be :confirmed? }
        it { response.must_redirect_to root_path }
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
push_type_auth-0.9.5 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.3 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.2 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.1 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.0 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.0.beta.4 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.0.beta.3 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.9.0.beta.2 test/controllers/push_type/confirmations_controller_test.rb