File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,7 +91,10 @@ def tip_commits
9191
9292 def tip_for commit
9393 email = commit . commit . author . email
94- user = User . find_by email : email
94+ if nickname = commit . author . try ( :login )
95+ user = User . find_by ( nickname : nickname )
96+ end
97+ user ||= User . find_by ( email : email )
9598
9699 if ( next_tip_amount > 0 ) &&
97100 Tip . find_by ( commit : commit . sha ) . nil?
@@ -103,12 +106,12 @@ def tip_for commit
103106 email : email ,
104107 password : generated_password ,
105108 name : commit . commit . author . name ,
106- nickname : ( commit . author . login rescue nil )
109+ nickname : nickname ,
107110 } )
108111 end
109112
110- if commit . author && commit . author . login
111- user . update nickname : commit . author . login
113+ if nickname
114+ user . update nickname : nickname
112115 end
113116
114117 if hold_tips
Original file line number Diff line number Diff line change 1+ Feature : A commit with an identified GitHub nickname should be sent to the right user if he exists
2+ Scenario :
3+ Given a project "a"
4+ And our fee is "0"
5+ And a deposit of "500"
6+ And an user "yugo"
7+ And the email of "yugo" is "yugo1@example.com"
8+ And the last known commit is "A"
9+ And a new commit "B" with parent "A"
10+ And the author of commit "B" is "yugo"
11+ And the email of commit "B" is "yugo2@example.com"
12+
13+ When the new commits are read
14+ Then there should be a tip of "5" for commit "B"
15+ And the tip for commit "B" is for user "yugo"
16+ And there should be no user with email "yugo2@example.com"
Original file line number Diff line number Diff line change 1+ Given ( /^an user "(.*?)"$/ ) do |arg1 |
2+ create ( :user , nickname : arg1 , email : "#{ arg1 } @example.com" )
3+ end
4+
5+ Given ( /^the email of "(.*?)" is "(.*?)"$/ ) do |arg1 , arg2 |
6+ User . find_by_nickname! ( arg1 ) . update ( email : arg2 )
7+ end
8+
9+ Then ( /^the tip for commit "(.*?)" is for user "(.*?)"$/ ) do |arg1 , arg2 |
10+ Tip . find_by_commit! ( arg1 ) . user . nickname . should eq ( arg2 )
11+ end
12+
13+ Then ( /^there should be no user with email "(.*?)"$/ ) do |arg1 |
14+ User . where ( email : arg1 ) . size . should eq ( 0 )
15+ end
16+
Original file line number Diff line number Diff line change @@ -78,6 +78,10 @@ def find_new_commit(id)
7878 find_new_commit ( arg1 ) . deep_merge! ( commit : { message : arg2 } )
7979end
8080
81+ Given ( /^the email of commit "(.*?)" is "(.*?)"$/ ) do |arg1 , arg2 |
82+ find_new_commit ( arg1 ) . deep_merge! ( commit : { author : { email : arg2 } } )
83+ end
84+
8185When ( /^the new commits are read$/ ) do
8286 @project . reload
8387 @project . should_receive ( :new_commits ) . and_return ( @new_commits . values . map ( &:to_ostruct ) )
You can’t perform that action at this time.
0 commit comments