# No '..' in the repository path
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
+ PRJ_ID = 3
def setup
@controller = RepositoriesController.new
def test_browse_root
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
def test_browse_branch
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3, :rev => 'test_branch'
+ get :show, :id => PRJ_ID, :rev => 'test_branch'
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
"tag00.lightweight",
"tag01.annotated",
].each do |t1|
- get :show, :id => 3, :rev => t1
+ get :show, :id => PRJ_ID, :rev => t1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
def test_browse_directory
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3, :path => ['images']
+ get :show, :id => PRJ_ID, :path => ['images']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
def test_browse_at_given_revision
@repository.fetch_changesets
@repository.reload
- get :show, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
+ get :show, :id => PRJ_ID, :path => ['images'],
+ :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_changes
- get :changes, :id => 3, :path => ['images', 'edit.png']
+ get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
assert_response :success
assert_template 'changes'
assert_tag :tag => 'h2', :content => 'edit.png'
end
def test_entry_show
- get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'entry'
# Line 19
end
def test_entry_download
- get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'],
+ :format => 'raw'
assert_response :success
# File content
assert @response.body.include?('WITHOUT ANY WARRANTY')
end
def test_directory_entry
- get :entry, :id => 3, :path => ['sources']
+ get :entry, :id => PRJ_ID, :path => ['sources']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entry)
def test_diff
@repository.fetch_changesets
@repository.reload
-
# Full diff of changeset 2f9c0091
- get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
+ get :diff, :id => PRJ_ID, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
assert_response :success
assert_template 'diff'
# Line 22 removed
def test_diff_two_revs
@repository.fetch_changesets
@repository.reload
-
- get :diff, :id => 3, :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
- :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
+ get :diff, :id => PRJ_ID,
+ :rev => '61b685fbe55ab05b5ac68402d5720c1a6ac973d1',
+ :rev_to => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
assert_response :success
assert_template 'diff'
-
diff = assigns(:diff)
assert_not_nil diff
assert_tag :tag => 'h2', :content => /2f9c0091:61b685fb/
end
def test_annotate
- get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
+ get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'annotate'
# Line 23, changeset 2f9c0091
def test_annotate_at_given_revision
@repository.fetch_changesets
@repository.reload
- get :annotate, :id => 3, :rev => 'deff7', :path => ['sources', 'watchers_controller.rb']
+ get :annotate, :id => PRJ_ID, :rev => 'deff7',
+ :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'annotate'
assert_tag :tag => 'h2', :content => /@ deff712f/
end
def test_annotate_binary_file
- get :annotate, :id => 3, :path => ['images', 'edit.png']
+ get :annotate, :id => PRJ_ID, :path => ['images', 'edit.png']
assert_response 500
assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
:content => /cannot be annotated/
@repository.fetch_changesets
@repository.reload
['61b685fbe55ab05b5ac68402d5720c1a6ac973d1', '61b685f'].each do |r|
- get :revision, :id => 3, :rev => r
+ get :revision, :id => PRJ_ID, :rev => r
assert_response :success
assert_template 'revision'
end
@repository.fetch_changesets
@repository.reload
['', ' ', nil].each do |r|
- get :revision, :id => 3, :rev => r
+ get :revision, :id => PRJ_ID, :rev => r
assert_response 404
assert_error_tag :content => /was not found/
end