Sha256: 70df7191592d682a61e33e153341b219e7ed113ccc68d2dbba499a640247b163

Contents?: true

Size: 1.63 KB

Versions: 25

Compression:

Stored size: 1.63 KB

Contents

require 'test/test_helper'

class MyController < ApplicationController
  include Devise::Controllers::Helpers
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

25 entries across 25 versions & 3 rubygems

Version Path
devise-0.8.2 test/controllers/helpers_test.rb
devise-0.8.1 test/controllers/helpers_test.rb
devise-0.8.0 test/controllers/helpers_test.rb
devise-0.7.5 test/controllers/helpers_test.rb
devise-0.7.4 test/controllers/helpers_test.rb
devise-0.7.3 test/controllers/helpers_test.rb
devise-0.7.2 test/controllers/helpers_test.rb
devise-0.7.1 test/controllers/helpers_test.rb
devise-0.7.0 test/controllers/helpers_test.rb
devise-0.6.3 test/controllers/helpers_test.rb
devise-0.6.2 test/controllers/helpers_test.rb
devise-0.6.1 test/controllers/helpers_test.rb
devise-0.6.0 test/controllers/helpers_test.rb
devise-0.5.6 test/controllers/helpers_test.rb
devise-0.5.5 test/controllers/helpers_test.rb
devise-0.5.4 test/controllers/helpers_test.rb
devise-0.5.3 test/controllers/helpers_test.rb
devise-0.5.2 test/controllers/helpers_test.rb
devise-0.5.1 test/controllers/helpers_test.rb
devise-0.5.0 test/controllers/helpers_test.rb