##// END OF EJS Templates
Fixed: RepositoriesController#revision may show wrong revision (#3779)....
Jean-Philippe Lang -
r2784:30ad78e57da3
parent child
Show More
@@ -130,7 +130,7 class RepositoriesController < ApplicationController
130 end
130 end
131
131
132 def revision
132 def revision
133 @changeset = @repository.changesets.find(:first, :conditions => ["revision LIKE ?", @rev + '%'])
133 @changeset = @repository.find_changeset_by_name(@rev)
134 raise ChangesetNotFound unless @changeset
134 raise ChangesetNotFound unless @changeset
135
135
136 respond_to do |format|
136 respond_to do |format|
@@ -92,6 +92,11 class Repository < ActiveRecord::Base
92 path
92 path
93 end
93 end
94
94
95 # Finds and returns a revision with a number or the beginning of a hash
96 def find_changeset_by_name(name)
97 changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name.to_i] : ["revision LIKE ?", name + '%']))
98 end
99
95 def latest_changeset
100 def latest_changeset
96 @latest_changeset ||= changesets.find(:first)
101 @latest_changeset ||= changesets.find(:first)
97 end
102 end
@@ -81,4 +81,24 changesets_008:
81 user_id: 3
81 user_id: 3
82 repository_id: 10
82 repository_id: 10
83 committer: dlopper
83 committer: dlopper
84 changesets_009:
85 commit_date: "2009-09-10"
86 comments: One file added.
87 committed_on: 2009-09-10 19:04:35
88 revision: "9"
89 id: 108
90 scmid:
91 user_id: 3
92 repository_id: 10
93 committer: dlopper
94 changesets_010:
95 commit_date: "2009-09-10"
96 comments: Same file modified.
97 committed_on: 2009-09-10 19:04:35
98 revision: "10"
99 id: 109
100 scmid:
101 user_id: 3
102 repository_id: 10
103 committer: dlopper
84 No newline at end of file
104
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -77,6 +77,13 class RepositoriesControllerTest < ActionController::TestCase
77 )
77 )
78 end
78 end
79
79
80 def test_revision
81 get :revision, :id => 1, :rev => 1
82 assert_response :success
83 assert_not_nil assigns(:changeset)
84 assert_equal "1", assigns(:changeset).revision
85 end
86
80 def test_revision_with_before_nil_and_afer_normal
87 def test_revision_with_before_nil_and_afer_normal
81 get :revision, {:id => 1, :rev => 1}
88 get :revision, {:id => 1, :rev => 1}
82 assert_response :success
89 assert_response :success
@@ -102,7 +102,7 class RepositoriesSubversionControllerTest < ActionController::TestCase
102
102
103 changesets = assigns(:changesets)
103 changesets = assigns(:changesets)
104 assert_not_nil changesets
104 assert_not_nil changesets
105 assert_equal %w(7 6 5 2), changesets.collect(&:revision)
105 assert_equal %w(10 9 7 6 5 2), changesets.collect(&:revision)
106 end
106 end
107
107
108 def test_entry
108 def test_entry
@@ -91,7 +91,7 class ChangesetTest < ActiveSupport::TestCase
91 end
91 end
92
92
93 def test_next_nil
93 def test_next_nil
94 changeset = Changeset.find_by_revision('8')
94 changeset = Changeset.find_by_revision('10')
95 assert_nil changeset.next
95 assert_nil changeset.next
96 end
96 end
97 end
97 end
@@ -33,8 +33,8 class RepositorySubversionTest < ActiveSupport::TestCase
33 @repository.fetch_changesets
33 @repository.fetch_changesets
34 @repository.reload
34 @repository.reload
35
35
36 assert_equal 8, @repository.changesets.count
36 assert_equal 10, @repository.changesets.count
37 assert_equal 16, @repository.changes.count
37 assert_equal 18, @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 end
39 end
40
40
@@ -46,7 +46,7 class RepositorySubversionTest < ActiveSupport::TestCase
46 assert_equal 5, @repository.changesets.count
46 assert_equal 5, @repository.changesets.count
47
47
48 @repository.fetch_changesets
48 @repository.fetch_changesets
49 assert_equal 8, @repository.changesets.count
49 assert_equal 10, @repository.changesets.count
50 end
50 end
51
51
52 def test_latest_changesets_with_limit
52 def test_latest_changesets_with_limit
General Comments 0
You need to be logged in to leave comments. Login now