mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
check whether identity model is persisted with ActiveModel's #persisted? method
This commit is contained in:
parent
bc44e1397c
commit
a423c5fdfc
2 changed files with 4 additions and 3 deletions
|
@ -55,7 +55,7 @@ module OmniAuth
|
|||
def registration_phase
|
||||
attributes = (options[:fields] + [:password, :password_confirmation]).inject({}){|h,k| h[k] = request[k.to_s]; h}
|
||||
@identity = model.create(attributes)
|
||||
if @identity.id
|
||||
if @identity.persisted?
|
||||
env['PATH_INFO'] = callback_path
|
||||
callback_phase
|
||||
else
|
||||
|
|
|
@ -72,7 +72,8 @@ describe OmniAuth::Strategies::Identity do
|
|||
} }
|
||||
|
||||
before do
|
||||
MockIdentity.should_receive(:create).with(properties).and_return(mock(:id => 1, :uid => 'abc', :name => 'Awesome Dude', :email => 'awesome@example.com', :user_info => {:name => 'DUUUUDE!'}))
|
||||
m = mock(:uid => 'abc', :name => 'Awesome Dude', :email => 'awesome@example.com', :user_info => {:name => 'DUUUUDE!'}, :persisted? => true)
|
||||
MockIdentity.should_receive(:create).with(properties).and_return(m)
|
||||
end
|
||||
|
||||
it 'should set the auth hash' do
|
||||
|
@ -90,7 +91,7 @@ describe OmniAuth::Strategies::Identity do
|
|||
} }
|
||||
|
||||
before do
|
||||
MockIdentity.should_receive(:create).with(properties).and_return(mock(:id => nil))
|
||||
MockIdentity.should_receive(:create).with(properties).and_return(mock(:persisted? => false))
|
||||
end
|
||||
|
||||
it 'should show registration form' do
|
||||
|
|
Loading…
Reference in a new issue