Sha256: b3ec6a741d48223e191c9f7fcd31af5d74131c40ef6f34a54e48b20f5936388f

Contents?: true

Size: 1.29 KB

Versions: 11

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_respond_with :redirect }
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
push_type_auth-0.11.2 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.11.1 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.11.0.beta.2 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.11.0.beta.1 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.4 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.3 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.2 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.1 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.0 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.0.beta.5 test/controllers/push_type/confirmations_controller_test.rb
push_type_auth-0.10.0.beta.3 test/controllers/push_type/confirmations_controller_test.rb