3
3
class ContributorsControllerTest < ActionController ::TestCase
4
4
def test_index_main_listing
5
5
# 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 ] ]
7
7
8
8
get :index
9
9
@@ -13,13 +13,27 @@ def test_index_main_listing
13
13
assert_equal expected . size , actual . size
14
14
15
15
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
17
19
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
18
31
end
19
32
end
20
33
21
34
def test_index_by_release
22
35
releases = {
36
+ 'v4.0.0' => [ [ :jose , 1 ] ] ,
23
37
'v3.2.0' => [ [ :jeremy , 1 ] , [ :jose , 1 ] , [ :vijay , 1 ] ] ,
24
38
'v0.14.4' => [ [ :david , 1 ] ]
25
39
}
@@ -48,11 +62,11 @@ def test_in_time_window
48
62
date_range = '20121201-20121231'
49
63
50
64
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 ] ] ,
52
66
'today' => [ [ :jeremy , 1 ] ] ,
53
67
'this-week' => [ [ :jeremy , 1 ] , [ :xavier , 1 ] ] ,
54
68
'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 ] ] ,
56
70
since => [ [ :jeremy , 1 ] , [ :xavier , 1 ] ] ,
57
71
date_range => [ [ :david , 1 ] , [ :jeremy , 1 ] , [ :xavier , 1 ] ] ,
58
72
}
0 commit comments