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