diff --git a/oa-identity/lib/omniauth/strategies/identity.rb b/oa-identity/lib/omniauth/strategies/identity.rb index 72c30a7..51da555 100644 --- a/oa-identity/lib/omniauth/strategies/identity.rb +++ b/oa-identity/lib/omniauth/strategies/identity.rb @@ -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 diff --git a/oa-identity/spec/omniauth/strategies/identity_spec.rb b/oa-identity/spec/omniauth/strategies/identity_spec.rb index 6a190ff..2493f42 100644 --- a/oa-identity/spec/omniauth/strategies/identity_spec.rb +++ b/oa-identity/spec/omniauth/strategies/identity_spec.rb @@ -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