@@ -35,83 +35,88 class RepositoriesMercurialControllerTest < Test::Unit::TestCase | |||||
35 | Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH) |
|
35 | Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH) | |
36 | end |
|
36 | end | |
37 |
|
37 | |||
38 | def test_show |
|
38 | if File.directory?(REPOSITORY_PATH) | |
39 | get :show, :id => 3 |
|
39 | def test_show | |
40 | assert_response :success |
|
40 | get :show, :id => 3 | |
41 | assert_template 'show' |
|
41 | assert_response :success | |
42 | assert_not_nil assigns(:entries) |
|
42 | assert_template 'show' | |
43 |
assert_not_nil assigns(: |
|
43 | assert_not_nil assigns(:entries) | |
44 | end |
|
44 | assert_not_nil assigns(:changesets) | |
45 |
|
45 | end | ||
46 | def test_browse_root |
|
46 | ||
47 | get :browse, :id => 3 |
|
47 | def test_browse_root | |
48 | assert_response :success |
|
48 | get :browse, :id => 3 | |
49 | assert_template 'browse' |
|
49 | assert_response :success | |
50 | assert_not_nil assigns(:entries) |
|
50 | assert_template 'browse' | |
51 |
assert_ |
|
51 | assert_not_nil assigns(:entries) | |
52 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
52 | assert_equal 3, assigns(:entries).size | |
53 |
assert assigns(:entries).detect {|e| e.name == ' |
|
53 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
54 |
assert assigns(:entries).detect {|e| e.name == ' |
|
54 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
55 | end |
|
55 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
56 |
|
56 | end | ||
57 | def test_browse_directory |
|
57 | ||
58 | get :browse, :id => 3, :path => ['images'] |
|
58 | def test_browse_directory | |
59 | assert_response :success |
|
59 | get :browse, :id => 3, :path => ['images'] | |
60 | assert_template 'browse' |
|
60 | assert_response :success | |
61 | assert_not_nil assigns(:entries) |
|
61 | assert_template 'browse' | |
62 |
assert_ |
|
62 | assert_not_nil assigns(:entries) | |
63 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
63 | assert_equal 2, assigns(:entries).size | |
64 | assert_not_nil entry |
|
64 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
65 |
assert_ |
|
65 | assert_not_nil entry | |
66 |
assert_equal ' |
|
66 | assert_equal 'file', entry.kind | |
67 | end |
|
67 | assert_equal 'images/edit.png', entry.path | |
68 |
|
68 | end | ||
69 | def test_changes |
|
69 | ||
70 | get :changes, :id => 3, :path => ['images', 'edit.png'] |
|
70 | def test_changes | |
71 | assert_response :success |
|
71 | get :changes, :id => 3, :path => ['images', 'edit.png'] | |
72 |
assert_ |
|
72 | assert_response :success | |
73 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
73 | assert_template 'changes' | |
74 | end |
|
74 | assert_tag :tag => 'h2', :content => 'edit.png' | |
75 |
|
75 | end | ||
76 | def test_entry_show |
|
76 | ||
77 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'] |
|
77 | def test_entry_show | |
78 | assert_response :success |
|
78 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'] | |
79 | assert_template 'entry' |
|
79 | assert_response :success | |
80 | # Line 19 |
|
80 | assert_template 'entry' | |
81 | assert_tag :tag => 'th', |
|
81 | # Line 19 | |
82 | :content => /10/, |
|
82 | assert_tag :tag => 'th', | |
83 | :attributes => { :class => /line-num/ }, |
|
83 | :content => /10/, | |
84 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } |
|
84 | :attributes => { :class => /line-num/ }, | |
85 | end |
|
85 | :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ } | |
86 |
|
86 | end | ||
87 | def test_entry_download |
|
87 | ||
88 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' |
|
88 | def test_entry_download | |
89 | assert_response :success |
|
89 | get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw' | |
90 | # File content |
|
90 | assert_response :success | |
91 | assert @response.body.include?('WITHOUT ANY WARRANTY') |
|
91 | # File content | |
92 | end |
|
92 | assert @response.body.include?('WITHOUT ANY WARRANTY') | |
93 |
|
93 | end | ||
94 | def test_diff |
|
|||
95 | # Full diff of changeset 4 |
|
|||
96 | get :diff, :id => 3, :rev => 4 |
|
|||
97 | assert_response :success |
|
|||
98 | assert_template 'diff' |
|
|||
99 | # Line 22 removed |
|
|||
100 | assert_tag :tag => 'th', |
|
|||
101 | :content => /22/, |
|
|||
102 | :sibling => { :tag => 'td', |
|
|||
103 | :attributes => { :class => /diff_out/ }, |
|
|||
104 | :content => /def remove/ } |
|
|||
105 | end |
|
|||
106 |
|
94 | |||
107 |
def test_ |
|
95 | def test_diff | |
108 | get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] |
|
96 | # Full diff of changeset 4 | |
109 | assert_response :success |
|
97 | get :diff, :id => 3, :rev => 4 | |
110 | assert_template 'annotate' |
|
98 | assert_response :success | |
111 | # Line 23, revision 4 |
|
99 | assert_template 'diff' | |
112 | assert_tag :tag => 'th', :content => /23/, |
|
100 | # Line 22 removed | |
113 | :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } }, |
|
101 | assert_tag :tag => 'th', | |
114 |
|
|
102 | :content => /22/, | |
115 |
:sibling => { :tag => 'td', |
|
103 | :sibling => { :tag => 'td', | |
|
104 | :attributes => { :class => /diff_out/ }, | |||
|
105 | :content => /def remove/ } | |||
|
106 | end | |||
|
107 | ||||
|
108 | def test_annotate | |||
|
109 | get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] | |||
|
110 | assert_response :success | |||
|
111 | assert_template 'annotate' | |||
|
112 | # Line 23, revision 4 | |||
|
113 | assert_tag :tag => 'th', :content => /23/, | |||
|
114 | :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } }, | |||
|
115 | :sibling => { :tag => 'td', :content => /jsmith/ }, | |||
|
116 | :sibling => { :tag => 'td', :content => /watcher =/ } | |||
|
117 | end | |||
|
118 | else | |||
|
119 | puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" | |||
|
120 | def test_fake; assert true end | |||
116 | end |
|
121 | end | |
117 | end |
|
122 | end |
General Comments 0
You need to be logged in to leave comments.
Login now