Sha256: 5d93a9fab4aa8b24348712b778349cf28e92af2bc46f1be0906027923494b1b8

Contents?: true

Size: 1.89 KB

Versions: 34

Compression:

Stored size: 1.89 KB

Contents

require 'test_helper'

class OmniAuthConfigTest < ActiveSupport::TestCase
  class MyStrategy
    include OmniAuth::Strategy
  end

  test 'strategy_name returns provider if no options given' do
    config = Devise::OmniAuth::Config.new :facebook, [{}]
    assert_equal :facebook, config.strategy_name
  end

  test 'strategy_name returns provider if no name option are given' do
    config = Devise::OmniAuth::Config.new :facebook, [{ other: :option }]
    assert_equal :facebook, config.strategy_name
  end

  test 'returns name option when have a name' do
    config = Devise::OmniAuth::Config.new :facebook, [{ name: :github }]
    assert_equal :github, config.strategy_name
  end

  test "finds contrib strategies" do
    config = Devise::OmniAuth::Config.new :facebook, [{}]
    assert_equal OmniAuth::Strategies::Facebook, config.strategy_class
  end

  test "finds the strategy in OmniAuth's list by name" do
    NamedTestStrategy = Class.new
    NamedTestStrategy.send :include, OmniAuth::Strategy
    NamedTestStrategy.option :name, :the_one

    config = Devise::OmniAuth::Config.new :the_one, [{}]
    assert_equal NamedTestStrategy, config.strategy_class
  end

  test "finds the strategy in OmniAuth's list by class name" do
    UnNamedTestStrategy = Class.new
    UnNamedTestStrategy.send :include, OmniAuth::Strategy

    config = Devise::OmniAuth::Config.new :un_named_test_strategy, [{}]
    assert_equal UnNamedTestStrategy, config.strategy_class
  end

  test 'raises an error if strategy cannot be found' do
    config = Devise::OmniAuth::Config.new :my_other_strategy, [{}]
    assert_raise Devise::OmniAuth::StrategyNotFound do
      config.strategy_class
    end
  end

  test 'allows the user to define a custom require path' do
    config = Devise::OmniAuth::Config.new :my_strategy, [{strategy_class: MyStrategy}]
    config_class = config.strategy_class
    assert_equal MyStrategy, config_class
  end
end

Version data entries

34 entries across 34 versions & 6 rubygems

Version Path
devise-4.2.0 test/omniauth/config_test.rb
devise-3.5.10 test/omniauth/config_test.rb
devise-4.0.3 test/omniauth/config_test.rb
devise-4.1.1 test/omniauth/config_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/devise-4.1.0/test/omniauth/config_test.rb
devise-4.1.0 test/omniauth/config_test.rb
devise-3.5.9 test/omniauth/config_test.rb
devise-4.0.2 test/omniauth/config_test.rb
devise-4.0.1 test/omniauth/config_test.rb
devise-3.5.8 test/omniauth/config_test.rb
devise-3.5.7 test/omniauth/config_test.rb
devise-4.0.0 test/omniauth/config_test.rb
devise-4.0.0.rc2 test/omniauth/config_test.rb
devise-4.0.0.rc1 test/omniauth/config_test.rb
devise-3.5.6 test/omniauth/config_test.rb
devise-3.5.5 test/omniauth/config_test.rb
devise-3.5.4 test/omniauth/config_test.rb
devise-3.5.3 test/omniauth/config_test.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/devise-3.5.2/test/omniauth/config_test.rb
devise-3.5.2 test/omniauth/config_test.rb