REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
# CVS module
MODULE_NAME = 'test'
-
+ PRJ_ID = 3
+
def setup
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
Setting.default_language = 'en'
User.current = nil
- @project = Project.find(1)
- @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
- :url => MODULE_NAME)
+ @project = Project.find(PRJ_ID)
+ @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID),
+ :root_url => REPOSITORY_PATH,
+ :url => MODULE_NAME)
+ assert @repository
end
if File.directory?(REPOSITORY_PATH)
def test_show
- get :show, :id => 1
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_browse_root
- get :show, :id => 1
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_browse_directory
- get :show, :id => 1, :path => ['images']
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID, :path => ['images']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_browse_at_given_revision
- Project.find(1).repository.fetch_changesets
- get :show, :id => 1, :path => ['images'], :rev => 1
+ @repository.fetch_changesets
+ @repository.reload
+ get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entries)
end
def test_entry
- get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
+ @repository.fetch_changesets
+ @repository.reload
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'entry'
assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
def test_entry_at_given_revision
# changesets must be loaded
- Project.find(1).repository.fetch_changesets
- get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
+ @repository.fetch_changesets
+ @repository.reload
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2
assert_response :success
assert_template 'entry'
# this line was removed in r3
end
def test_entry_not_found
- get :entry, :id => 1, :path => ['sources', 'zzz.c']
+ @repository.fetch_changesets
+ @repository.reload
+ get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c']
assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
:content => /The entry or revision was not found in the repository/
end
def test_entry_download
- get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
+ @repository.fetch_changesets
+ @repository.reload
+ get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
assert_response :success
end
def test_directory_entry
- get :entry, :id => 1, :path => ['sources']
+ @repository.fetch_changesets
+ @repository.reload
+ get :entry, :id => PRJ_ID, :path => ['sources']
assert_response :success
assert_template 'show'
assert_not_nil assigns(:entry)
end
def test_diff
- Project.find(1).repository.fetch_changesets
- get :diff, :id => 1, :rev => 3, :type => 'inline'
+ @repository.fetch_changesets
+ @repository.reload
+ get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline'
assert_response :success
assert_template 'diff'
assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
end
def test_annotate
- Project.find(1).repository.fetch_changesets
- get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
+ @repository.fetch_changesets
+ @repository.reload
+ get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
assert_response :success
assert_template 'annotate'
# 1.1 line