end
def revision
- @changeset = @repository.changesets.find(:first, :conditions => ["revision LIKE ?", @rev + '%'])
+ @changeset = @repository.find_changeset_by_name(@rev)
raise ChangesetNotFound unless @changeset
respond_to do |format|
path
end
+ # Finds and returns a revision with a number or the beginning of a hash
+ def find_changeset_by_name(name)
+ changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name.to_i] : ["revision LIKE ?", name + '%']))
+ end
+
def latest_changeset
@latest_changeset ||= changesets.find(:first)
end
user_id: 3
repository_id: 10
committer: dlopper
+changesets_009:
+ commit_date: "2009-09-10"
+ comments: One file added.
+ committed_on: 2009-09-10 19:04:35
+ revision: "9"
+ id: 108
+ scmid:
+ user_id: 3
+ repository_id: 10
+ committer: dlopper
+changesets_010:
+ commit_date: "2009-09-10"
+ comments: Same file modified.
+ committed_on: 2009-09-10 19:04:35
+ revision: "10"
+ id: 109
+ scmid:
+ user_id: 3
+ repository_id: 10
+ committer: dlopper
\ No newline at end of file
)
end
+ def test_revision
+ get :revision, :id => 1, :rev => 1
+ assert_response :success
+ assert_not_nil assigns(:changeset)
+ assert_equal "1", assigns(:changeset).revision
+ end
+
def test_revision_with_before_nil_and_afer_normal
get :revision, {:id => 1, :rev => 1}
assert_response :success
changesets = assigns(:changesets)
assert_not_nil changesets
- assert_equal %w(7 6 5 2), changesets.collect(&:revision)
+ assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
end
def test_entry
end
def test_next_nil
- changeset = Changeset.find_by_revision('8')
+ changeset = Changeset.find_by_revision('10')
assert_nil changeset.next
end
end
@repository.fetch_changesets
@repository.reload
- assert_equal 8, @repository.changesets.count
- assert_equal 16, @repository.changes.count
+ assert_equal 10, @repository.changesets.count
+ assert_equal 18, @repository.changes.count
assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
end
assert_equal 5, @repository.changesets.count
@repository.fetch_changesets
- assert_equal 8, @repository.changesets.count
+ assert_equal 10, @repository.changesets.count
end
def test_latest_changesets_with_limit