Sha256: 3786e787d6e93e5d0c56ecb3c837ca22d86ea414022c389173f338236103204f

Contents?: true

Size: 1.64 KB

Versions: 35

Compression:

Stored size: 1.64 KB

Contents

require 'test/test_helper'

class MyController < ApplicationController
  include Devise::Controllers::InternalHelpers
end

class HelpersTest < ActionController::TestCase
  tests MyController

  test 'get resource name from request path' do
    @request.path = '/users/session'
    assert_equal :user, @controller.resource_name
  end

  test 'get resource name from specific request path' do
    @request.path = '/admin_area/session'
    assert_equal :admin, @controller.resource_name
  end

  test 'get resource class from request path' do
    @request.path = '/users/session'
    assert_equal User, @controller.resource_class
  end

  test 'get resource instance variable from request path' do
    @request.path = '/admin_area/session'
    @controller.instance_variable_set(:@admin, admin = Admin.new)
    assert_equal admin, @controller.resource
  end

  test 'set resource instance variable from request path' do
    @request.path = '/admin_area/session'

    admin = @controller.send(:resource_class).new
    @controller.send(:resource=, admin)

    assert_equal admin, @controller.send(:resource)
    assert_equal admin, @controller.instance_variable_get(:@admin)
  end

  test 'resources methods are not controller actions' do
    assert @controller.class.action_methods.empty?
  end

  test 'require no authentication tests current mapping' do
    @controller.expects(:resource_name).returns(:user).twice
    @mock_warden.expects(:authenticated?).with(:user).returns(true)
    @controller.expects(:redirect_to).with(root_path)
    @controller.send :require_no_authentication
  end
  
  test 'is a devise controller' do
    assert @controller.devise_controller?
  end
end

Version data entries

35 entries across 30 versions & 7 rubygems

Version Path
graffititracker_devise-1.0.11 test/controllers/internal_helpers_test.rb
devise-1.0.11 test/controllers/internal_helpers_test.rb
devise-1.0.10 test/controllers/internal_helpers_test.rb
devise_ennder-1.4.1.0.9 test/controllers/internal_helpers_test.rb
devise_ennder-1.4.1.0.9 test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb
devise_ennder-1.3.1.0.9 test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb
devise_ennder-1.3.1.0.9 test/controllers/internal_helpers_test.rb
devise_ennder-1.2.1.0.9 test/controllers/internal_helpers_test.rb
devise_ennder-1.2.1.0.9 test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb
devise_ennder-1.1.1.0.9 test/controllers/internal_helpers_test.rb
devise_ennder-1.1.1.0.9 test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb
devise_ennder-1.0.1.0.9 test/controllers/internal_helpers_test.rb
devise_ennder-1.0.1.0.9 test/rails_app/vendor/plugins/devise/test/controllers/internal_helpers_test.rb
devise-1.0.9 test/controllers/internal_helpers_test.rb
dcu-devise-1.0.7 test/controllers/internal_helpers_test.rb
devise-1.0.8 test/controllers/internal_helpers_test.rb
ivanvc-devise-1.0.7.1 test/controllers/internal_helpers_test.rb
mongoid-devise-1.0.1 test/controllers/internal_helpers_test.rb
devise-1.0.7 test/controllers/internal_helpers_test.rb
devise-1.0.6 test/controllers/internal_helpers_test.rb