File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def authorize_params
2828 info do
2929 {
3030 'nickname' => raw_info [ 'login' ] ,
31- 'email' => email ,
31+ 'email' => primary_email ,
3232 'name' => raw_info [ 'name' ] ,
3333 'image' => raw_info [ 'avatar_url' ] ,
3434 'urls' => {
@@ -39,7 +39,7 @@ def authorize_params
3939 end
4040
4141 extra do
42- { :raw_info => raw_info }
42+ { :raw_info => raw_info , :all_emails => emails }
4343 end
4444
4545 def raw_info
@@ -52,8 +52,8 @@ def email
5252 end
5353
5454 def primary_email
55- primary = emails . find { |i | i [ 'primary' ] }
56- primary && primary [ 'email' ] || emails . first && emails . first [ 'email' ]
55+ primary = emails . find { |i | i [ 'primary' ] && i [ 'verified '] }
56+ primary && primary [ 'email' ] || nil
5757 end
5858
5959 # The new /user/emails API - http://developer.github.com/v3/users/emails/#future-response
Original file line number Diff line number Diff line change 9494 subject . email . should be_nil
9595 end
9696
97- it "should return the primary email if there is no raw_info and email access is allowed" do
97+ it "should not return the primary email if there is no raw_info and email access is allowed" do
9898 emails = [
9999 { 'email' => 'secondary@example.com' , 'primary' => false } ,
100100 { 'email' => 'primary@example.com' , 'primary' => true }
101101 ]
102102 subject . stub! ( :raw_info ) . and_return ( { } )
103103 subject . options [ 'scope' ] = 'user'
104104 subject . stub! ( :emails ) . and_return ( emails )
105- subject . email . should eq ( 'primary@example.com' )
105+ subject . email . should eq ( nil )
106106 end
107107
108- it "should return the first email if there is no raw_info and email access is allowed" do
108+ it "should not return the first email if there is no raw_info and email access is allowed" do
109109 emails = [
110110 { 'email' => 'first@example.com' , 'primary' => false } ,
111111 { 'email' => 'second@example.com' , 'primary' => false }
112112 ]
113113 subject . stub! ( :raw_info ) . and_return ( { } )
114114 subject . options [ 'scope' ] = 'user'
115115 subject . stub! ( :emails ) . and_return ( emails )
116- subject . email . should eq ( 'first@example.com' )
116+ subject . email . should eq ( nil )
117117 end
118118 end
119119
You can’t perform that action at this time.
0 commit comments