mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
accept options as default arg values
* prevents empty args from nulling out valid option values
This commit is contained in:
parent
83284ce6c2
commit
926095f93a
2 changed files with 15 additions and 2 deletions
|
@ -136,6 +136,7 @@ module OmniAuth
|
|||
options.name ||= self.class.to_s.split('::').last.downcase
|
||||
|
||||
self.class.args.each do |arg|
|
||||
break if args.empty?
|
||||
options[arg] = args.shift
|
||||
end
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
|
||||
describe ".args" do
|
||||
subject{ c = Class.new; c.send :include, OmniAuth::Strategy; c }
|
||||
subject { c = Class.new; c.send :include, OmniAuth::Strategy; c }
|
||||
|
||||
it "sets args to the specified argument if there is one" do
|
||||
subject.args [:abc, :def]
|
||||
expect(subject.args).to eq([:abc, :def])
|
||||
|
@ -98,6 +99,17 @@ describe OmniAuth::Strategy do
|
|||
c = Class.new(subject)
|
||||
expect(c.args).to eq([:abc, :def])
|
||||
end
|
||||
|
||||
it "accepts corresponding options as default arg values" do
|
||||
subject.args [:a, :b]
|
||||
subject.option :a, "1"
|
||||
subject.option :b, "2"
|
||||
|
||||
expect(subject.new(nil).options.a).to eq "1"
|
||||
expect(subject.new(nil).options.b).to eq "2"
|
||||
expect(subject.new(nil, "3", "4").options.b).to eq "4"
|
||||
expect(subject.new(nil, nil, "4").options.a).to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
context "fetcher procs" do
|
||||
|
@ -700,7 +712,7 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
end
|
||||
|
||||
let(:strategy){ ExampleStrategy.new(app, :setup => setup_proc) }
|
||||
let(:strategy) { ExampleStrategy.new(app, :setup => setup_proc) }
|
||||
|
||||
it "does not call the app on a non-omniauth endpoint" do
|
||||
strategy.call(make_env('/somehwere/else'))
|
||||
|
|
Loading…
Add table
Reference in a new issue