33class  ContributorsControllerTest  < ActionController ::TestCase 
44  def  test_index_main_listing 
55    # Order by ncommits DESC, url_id ASC. 
6-     expected  =  [ [ :jeremy ,  3 ] ,  [ :david ,  2 ] ,  [ :jose ,  1 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] 
6+     expected  =  [ [ :jeremy ,  3 ] ,  [ :david ,  2 ] ,  [ :jose ,  2 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] 
77
88    get  :index 
99
@@ -13,13 +13,27 @@ def test_index_main_listing
1313    assert_equal  expected . size ,  actual . size 
1414
1515    expected . zip ( actual ) . each  do  |e ,  a |
16-       assert_equal  contributors ( e . first ) . name ,  a . name 
16+       contributor  =  contributors ( e . first ) 
17+ 
18+       assert_equal  contributor . name ,  a . name 
1719      assert_equal  e . second ,  a . ncommits 
20+ 
21+       assert_select  "tr##{ contributor . name . downcase . tr ( ' ' ,  '-' )  }   do  |elements |
22+         assert_select  'td.contributor-rank' ,  "##{ contributor . rank . to_s }  
23+         assert_select  'td.contributor-name' ,  /#{ contributor . name }  
24+         assert_select  'td.contributor-timestamp'  do  |elements |
25+           assert_equal  2 ,  elements . size 
26+           assert_equal  contributor . first_contribution_at . strftime ( "%d %b %Y" ) ,  elements [ 0 ] . text . strip 
27+           assert_equal  contributor . last_contribution_at . strftime ( "%d %b %Y" ) ,  elements [ 1 ] . text . strip 
28+         end 
29+         assert_select  "td.no-commits" ,  e . second . to_s 
30+       end 
1831    end 
1932  end 
2033
2134  def  test_index_by_release 
2235    releases  =  { 
36+       'v4.0.0'   =>  [ [ :jose ,  1 ] ] , 
2337      'v3.2.0'   =>  [ [ :jeremy ,  1 ] ,  [ :jose ,  1 ] ,  [ :vijay ,  1 ] ] , 
2438      'v0.14.4'  =>  [ [ :david ,  1 ] ] 
2539    } 
@@ -48,11 +62,11 @@ def test_in_time_window
4862    date_range  =  '20121201-20121231' 
4963
5064    time_windows  =  { 
51-       'all-time'    =>  [ [ :jeremy ,  3 ] ,  [ :david ,  2 ] ,  [ :jose ,  1 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] , 
65+       'all-time'    =>  [ [ :jeremy ,  3 ] ,  [ :david ,  2 ] ,  [ :jose ,  2 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] , 
5266      'today'       =>  [ [ :jeremy ,  1 ] ] , 
5367      'this-week'   =>  [ [ :jeremy ,  1 ] ,  [ :xavier ,  1 ] ] , 
5468      'this-month'  =>  [ [ :david ,  1 ] ,  [ :jeremy ,  1 ] ,  [ :xavier ,  1 ] ] , 
55-       'this-year'   =>  [ [ :jeremy ,  3 ] ,  [ :david  ,   1 ] ,  [ :jose  ,  1 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] , 
69+       'this-year'   =>  [ [ :jeremy ,  3 ] ,  [ :jose  ,   2 ] ,  [ :david  ,  1 ] ,  [ :vijay ,  1 ] ,  [ :xavier ,  1 ] ] , 
5670      since         =>  [ [ :jeremy ,  1 ] ,  [ :xavier ,  1 ] ] , 
5771      date_range    =>  [ [ :david ,  1 ] ,  [ :jeremy ,  1 ] ,  [ :xavier ,  1 ] ] , 
5872    } 
0 commit comments