Some changes on config_test to make it looks like the other ones
This commit is contained in:
parent
97d8e39932
commit
3ab68a6896
|
@ -1,58 +1,56 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class OmniAuthConfigTest < ActiveSupport::TestCase
|
class OmniAuthConfigTest < ActiveSupport::TestCase
|
||||||
def self.context(name, &block)
|
|
||||||
instance_eval(&block)
|
|
||||||
end
|
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
$: << File.dirname(__FILE__)
|
$: << File.dirname(__FILE__)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Devise::OmniAuth::Config#strategy_name' do
|
test 'strategy_name returns provider if no options given' do
|
||||||
test 'returns provider if no options given' do
|
config = Devise::OmniAuth::Config.new :facebook, [{}]
|
||||||
config = Devise::OmniAuth::Config.new :facebook, [{}]
|
assert_equal :facebook, config.strategy_name
|
||||||
assert_equal :facebook, config.strategy_name
|
|
||||||
end
|
|
||||||
test 'returns provider if no name option given' do
|
|
||||||
config = Devise::OmniAuth::Config.new :facebook, [{ :other => :option }]
|
|
||||||
assert_equal :facebook, config.strategy_name
|
|
||||||
end
|
|
||||||
test 'returns name option' do
|
|
||||||
config = Devise::OmniAuth::Config.new :facebook, [{ :name => :github }]
|
|
||||||
assert_equal :github, config.strategy_name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Devise::OmniAuth::Config#strategy_class' do
|
test 'strategy_name returns provider if no name option are given' do
|
||||||
test "finds contrib strategies" do
|
config = Devise::OmniAuth::Config.new :facebook, [{ :other => :option }]
|
||||||
config = Devise::OmniAuth::Config.new :facebook, [{}]
|
assert_equal :facebook, config.strategy_name
|
||||||
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 'attempts to load an as-yet not loaded plugin' do
|
|
||||||
config = Devise::OmniAuth::Config.new :my_strategy, [{}]
|
|
||||||
config_class = config.strategy_class
|
|
||||||
assert_equal MyStrategy, config_class
|
|
||||||
end
|
|
||||||
test 'allows the user to define a custom require path' do
|
|
||||||
config = Devise::OmniAuth::Config.new :my_other_strategy, [{:require => 'my_other_strategy'}]
|
|
||||||
config_class = config.strategy_class
|
|
||||||
assert_equal MyOtherStrategy, config_class
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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 'attempts to load an as-yet not loaded plugin' do
|
||||||
|
config = Devise::OmniAuth::Config.new :my_strategy, [{}]
|
||||||
|
config_class = config.strategy_class
|
||||||
|
assert_equal MyStrategy, config_class
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'allows the user to define a custom require path' do
|
||||||
|
config = Devise::OmniAuth::Config.new :my_other_strategy, [{:require => 'my_other_strategy'}]
|
||||||
|
config_class = config.strategy_class
|
||||||
|
assert_equal MyOtherStrategy, config_class
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue