Permalink
Browse files

all tests passing - linkedin

  • Loading branch information...
dttg committed Oct 30, 2012
1 parent fe10418 commit 34ff64fd5253dd63799e861eaf86b515e482d3f6
@@ -1,13 +1,17 @@
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def all
user = User.from_omniauth(request.env["omniauth.auth"])
auth = request.env["omniauth.auth"]
user = User.from_omniauth(auth)
if user.persisted?
user.update_attributes({:provider => auth.provider, :uid => auth.uid})
flash.notice = "Sucessfully logged in with Linkedin!"
sign_in_and_redirect user
else
session["devise.user_attributes"] = user.attributes
redirect_to new_user_registration_url
end
end
alias_method :linkedin, :all
end
View
@@ -30,7 +30,7 @@ def is?(role)
#OmniAuth
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
where(email: auth.info.email).first_or_create do |user|
user.provider = auth.provider
user.uid = auth.uid
user.full_name = auth.info.name
@@ -46,9 +46,7 @@ def login_mod
end
def login_linkedin
visit "/"
click_link 'Join Now'
click_link 'Sign Up with Linkedin'
visit "/users/auth/linkedin"
end
def sign_up_linkedin
@@ -13,6 +13,8 @@
user = User.make!
login(user)
link_linkedin
visit "/users/edit"
page.should_not have_content "Unlink to your Linkedin account"
end
scenario 'invalid linkedin credentials' do
@@ -1,14 +1,23 @@
require File.expand_path(File.dirname(__FILE__) + '/../acceptance_helper')
feature 'unlink account from linkedin' do
before do
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:linkedin] = OmniAuth::AuthHash.new({
:provider => 'linkedin',
:uid => '12345',
:info => { :name => 'user', :email => "user@example.com" }
})
end
after { OmniAuth.config.test_mode = false }
context 'user has password' do
scenario 'unlink successful' do
sign_up_new_user
link_linkedin
login_linkedin
visit "/users/edit"
click_link 'Unlink Linkedin account'
visit "/users/unlink"
page.should have_content "Your LinkedIn account has been unlinked from your profile."
end
end

0 comments on commit 34ff64f

Please sign in to comment.