@@ -35,6 +35,10 class Changeset < ActiveRecord::Base | |||
|
35 | 35 | validates_uniqueness_of :revision, :scope => :repository_id |
|
36 | 36 | validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true |
|
37 | 37 | |
|
38 | def revision=(r) | |
|
39 | write_attribute :revision, (r.nil? ? nil : r.to_s) | |
|
40 | end | |
|
41 | ||
|
38 | 42 | def comments=(comment) |
|
39 | 43 | write_attribute(:comments, comment.strip) |
|
40 | 44 | end |
@@ -41,22 +41,22 class ChangesetTest < Test::Unit::TestCase | |||
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def test_previous |
|
44 | changeset = Changeset.find_by_revision(3) | |
|
45 | assert_equal Changeset.find_by_revision(2), changeset.previous | |
|
44 | changeset = Changeset.find_by_revision('3') | |
|
45 | assert_equal Changeset.find_by_revision('2'), changeset.previous | |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | def test_previous_nil |
|
49 | changeset = Changeset.find_by_revision(1) | |
|
49 | changeset = Changeset.find_by_revision('1') | |
|
50 | 50 | assert_nil changeset.previous |
|
51 | 51 | end |
|
52 | 52 | |
|
53 | 53 | def test_next |
|
54 | changeset = Changeset.find_by_revision(2) | |
|
55 | assert_equal Changeset.find_by_revision(3), changeset.next | |
|
54 | changeset = Changeset.find_by_revision('2') | |
|
55 | assert_equal Changeset.find_by_revision('3'), changeset.next | |
|
56 | 56 | end |
|
57 | 57 | |
|
58 | 58 | def test_next_nil |
|
59 | changeset = Changeset.find_by_revision(4) | |
|
59 | changeset = Changeset.find_by_revision('4') | |
|
60 | 60 | assert_nil changeset.next |
|
61 | 61 | end |
|
62 | 62 | end |
@@ -36,13 +36,13 class RepositoryBazaarTest < Test::Unit::TestCase | |||
|
36 | 36 | |
|
37 | 37 | assert_equal 4, @repository.changesets.count |
|
38 | 38 | assert_equal 9, @repository.changes.count |
|
39 | assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments | |
|
39 | assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments | |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | 42 | def test_fetch_changesets_incremental |
|
43 | 43 | @repository.fetch_changesets |
|
44 | 44 | # Remove changesets with revision > 5 |
|
45 |
@repository.changesets.find(:all |
|
|
45 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | |
|
46 | 46 | @repository.reload |
|
47 | 47 | assert_equal 2, @repository.changesets.count |
|
48 | 48 |
@@ -35,13 +35,13 class RepositoryDarcsTest < Test::Unit::TestCase | |||
|
35 | 35 | |
|
36 | 36 | assert_equal 6, @repository.changesets.count |
|
37 | 37 | assert_equal 13, @repository.changes.count |
|
38 | assert_equal "Initial commit.", @repository.changesets.find_by_revision(1).comments | |
|
38 | assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments | |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_fetch_changesets_incremental |
|
42 | 42 | @repository.fetch_changesets |
|
43 | 43 | # Remove changesets with revision > 3 |
|
44 |
@repository.changesets.find(:all |
|
|
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3} | |
|
45 | 45 | @repository.reload |
|
46 | 46 | assert_equal 3, @repository.changesets.count |
|
47 | 47 |
@@ -35,13 +35,13 class RepositoryMercurialTest < Test::Unit::TestCase | |||
|
35 | 35 | |
|
36 | 36 | assert_equal 6, @repository.changesets.count |
|
37 | 37 | assert_equal 11, @repository.changes.count |
|
38 | assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision(0).comments | |
|
38 | assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments | |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_fetch_changesets_incremental |
|
42 | 42 | @repository.fetch_changesets |
|
43 | 43 | # Remove changesets with revision > 2 |
|
44 |
@repository.changesets.find(:all |
|
|
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2} | |
|
45 | 45 | @repository.reload |
|
46 | 46 | assert_equal 3, @repository.changesets.count |
|
47 | 47 |
@@ -35,13 +35,13 class RepositorySubversionTest < Test::Unit::TestCase | |||
|
35 | 35 | |
|
36 | 36 | assert_equal 8, @repository.changesets.count |
|
37 | 37 | assert_equal 16, @repository.changes.count |
|
38 | assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments | |
|
38 | assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments | |
|
39 | 39 | end |
|
40 | 40 | |
|
41 | 41 | def test_fetch_changesets_incremental |
|
42 | 42 | @repository.fetch_changesets |
|
43 | 43 | # Remove changesets with revision > 5 |
|
44 |
@repository.changesets.find(:all |
|
|
44 | @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5} | |
|
45 | 45 | @repository.reload |
|
46 | 46 | assert_equal 5, @repository.changesets.count |
|
47 | 47 |
General Comments 0
You need to be logged in to leave comments.
Login now