This commit is contained in:
Michael Bleigh 2011-06-03 11:52:11 -05:00
commit 0eb6133a70
3 changed files with 23 additions and 2 deletions

View File

@ -12,3 +12,4 @@ gemspec :path => 'oa-oauth'
gemspec :path => 'oa-openid'
gem 'activerecord', '3.1.0.rc1'

View File

@ -54,7 +54,8 @@ module OmniAuth
def registration_phase
attributes = (options[:fields] + [:password, :password_confirmation]).inject({}){|h,k| h[k] = request[k.to_s]; h}
if @identity = model.create(attributes)
@identity = model.create(attributes)
if @identity.persisted?
env['PATH_INFO'] = callback_path
callback_phase
else

View File

@ -72,7 +72,8 @@ describe OmniAuth::Strategies::Identity do
} }
before do
MockIdentity.should_receive(:create).with(properties).and_return(mock(: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
@ -80,5 +81,23 @@ describe OmniAuth::Strategies::Identity do
auth_hash['uid'].should == 'abc'
end
end
context 'with invalid identity' do
let(:properties) { {
:name => 'Awesome Dude',
:email => 'awesome@example.com',
:password => 'NOT',
:password_confirmation => 'MATCHING'
} }
before do
MockIdentity.should_receive(:create).with(properties).and_return(mock(:persisted? => false))
end
it 'should show registration form' do
post '/auth/identity/register', properties
last_response.body.should be_include("Register Identity")
end
end
end
end