diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-03 11:46:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-06-03 11:46:58 +0000 |
commit | 2cbf9c9cc48135019dae50ccc5d9b07a44af8325 (patch) | |
tree | a191f37eca9f1cd62ad15c8fa04af319d8068d6b | |
parent | dd9c2cafa795ec00875981dcedd3287d2d005457 (diff) | |
download | redmine-2cbf9c9cc48135019dae50ccc5d9b07a44af8325.tar.gz redmine-2cbf9c9cc48135019dae50ccc5d9b07a44af8325.zip |
Renamed #changes association to #filechanges (clash with AR::Base.changes that triggers errors with Rails 3.2.5).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9759 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/helpers/repositories_helper.rb | 6 | ||||
-rw-r--r-- | app/models/changeset.rb | 2 | ||||
-rw-r--r-- | app/models/repository.rb | 4 | ||||
-rw-r--r-- | app/models/repository/cvs.rb | 8 | ||||
-rw-r--r-- | app/models/repository/darcs.rb | 2 | ||||
-rw-r--r-- | app/views/repositories/revision.html.erb | 2 | ||||
-rw-r--r-- | test/unit/repository_bazaar_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_cvs_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_darcs_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_filesystem_test.rb | 4 | ||||
-rw-r--r-- | test/unit/repository_git_test.rb | 6 | ||||
-rw-r--r-- | test/unit/repository_mercurial_test.rb | 8 | ||||
-rw-r--r-- | test/unit/repository_subversion_test.rb | 4 | ||||
-rw-r--r-- | test/unit/repository_test.rb | 6 |
14 files changed, 30 insertions, 28 deletions
diff --git a/app/helpers/repositories_helper.rb b/app/helpers/repositories_helper.rb index 0c0a39563..ccc606642 100644 --- a/app/helpers/repositories_helper.rb +++ b/app/helpers/repositories_helper.rb @@ -46,17 +46,17 @@ module RepositoriesHelper end def render_changeset_changes - changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change| + changes = @changeset.filechanges.find(:all, :limit => 1000, :order => 'path').collect do |change| case change.action when 'A' # Detects moved/copied files if !change.from_path.blank? change.action = - @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C' + @changeset.filechanges.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C' end change when 'D' - @changeset.changes.detect {|c| c.from_path == change.path} ? nil : change + @changeset.filechanges.detect {|c| c.from_path == change.path} ? nil : change else change end diff --git a/app/models/changeset.rb b/app/models/changeset.rb index d795524a8..dbab9feac 100644 --- a/app/models/changeset.rb +++ b/app/models/changeset.rb @@ -20,7 +20,7 @@ require 'iconv' class Changeset < ActiveRecord::Base belongs_to :repository belongs_to :user - has_many :changes, :dependent => :delete_all + has_many :filechanges, :class_name => 'Change', :dependent => :delete_all has_and_belongs_to_many :issues has_and_belongs_to_many :parents, :class_name => "Changeset", diff --git a/app/models/repository.rb b/app/models/repository.rb index 945615968..592729d22 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -22,7 +22,7 @@ class Repository < ActiveRecord::Base belongs_to :project has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC" - has_many :changes, :through => :changesets + has_many :filechanges, :class_name => 'Change', :through => :changesets serialize :extra_info @@ -228,7 +228,7 @@ class Repository < ActiveRecord::Base :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC", :limit => limit) else - changes.find( + filechanges.find( :all, :include => {:changeset => :user}, :conditions => ["path = ?", path.with_leading_slash], diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb index d8ab59e21..1ad7fb65d 100644 --- a/app/models/repository/cvs.rb +++ b/app/models/repository/cvs.rb @@ -54,7 +54,7 @@ class Repository::Cvs < Repository if entries entries.each() do |entry| if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? ) - change=changes.find_by_revision_and_path( + change = filechanges.find_by_revision_and_path( entry.lastrev.revision, scm.with_leading_slash(entry.path) ) if change @@ -94,7 +94,7 @@ class Repository::Cvs < Repository if rev_to.to_i > 0 changeset_to = changesets.find_by_revision(rev_to) end - changeset_from.changes.each() do |change_from| + changeset_from.filechanges.each() do |change_from| revision_from = nil revision_to = nil if path.nil? || (change_from.path.starts_with? scm.with_leading_slash(path)) @@ -102,7 +102,7 @@ class Repository::Cvs < Repository end if revision_from if changeset_to - changeset_to.changes.each() do |change_to| + changeset_to.filechanges.each() do |change_to| revision_to = change_to.revision if change_to.path == change_from.path end end @@ -133,7 +133,7 @@ class Repository::Cvs < Repository # only add the change to the database, if it doen't exists. the cvs log # is not exclusive at all. tmp_time = revision.time.clone - unless changes.find_by_path_and_revision( + unless filechanges.find_by_path_and_revision( scm.with_leading_slash(revision.paths[0][:path]), revision.paths[0][:revision] ) diff --git a/app/models/repository/darcs.rb b/app/models/repository/darcs.rb index 220121153..18eb3a2f7 100644 --- a/app/models/repository/darcs.rb +++ b/app/models/repository/darcs.rb @@ -79,7 +79,7 @@ class Repository::Darcs < Repository return nil if patch_from.nil? patch_to = changesets.find_by_revision(rev_to) if rev_to if path.blank? - path = patch_from.changes.collect{|change| change.path}.join(' ') + path = patch_from.filechanges.collect{|change| change.path}.join(' ') end patch_from ? scm.diff(path, patch_from.scmid, patch_to ? patch_to.scmid : nil) : nil end diff --git a/app/views/repositories/revision.html.erb b/app/views/repositories/revision.html.erb index c1e2413e1..b9293d9d5 100644 --- a/app/views/repositories/revision.html.erb +++ b/app/views/repositories/revision.html.erb @@ -83,7 +83,7 @@ :id => @project, :repository_id => @repository.identifier_param, :path => "", - :rev => @changeset.identifier) if @changeset.changes.any? %></p> + :rev => @changeset.identifier) if @changeset.filechanges.any? %></p> <div class="changeset-changes"> <%= render_changeset_changes %> diff --git a/test/unit/repository_bazaar_test.rb b/test/unit/repository_bazaar_test.rb index 6e92aa33e..2713f9473 100644 --- a/test/unit/repository_bazaar_test.rb +++ b/test/unit/repository_bazaar_test.rb @@ -67,7 +67,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - assert_equal 9, @repository.changes.count + assert_equal 9, @repository.filechanges.count assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments end diff --git a/test/unit/repository_cvs_test.rb b/test/unit/repository_cvs_test.rb index 1f303a9fd..0fc1873c7 100644 --- a/test/unit/repository_cvs_test.rb +++ b/test/unit/repository_cvs_test.rb @@ -102,7 +102,7 @@ class RepositoryCvsTest < ActiveSupport::TestCase @project.reload assert_equal CHANGESETS_NUM, @repository.changesets.count - assert_equal 16, @repository.changes.count + assert_equal 16, @repository.filechanges.count assert_not_nil @repository.changesets.find_by_comments('Two files changed') r2 = @repository.changesets.find_by_revision('2') diff --git a/test/unit/repository_darcs_test.rb b/test/unit/repository_darcs_test.rb index 06d0bff5e..9923e0cbd 100644 --- a/test/unit/repository_darcs_test.rb +++ b/test/unit/repository_darcs_test.rb @@ -68,7 +68,7 @@ class RepositoryDarcsTest < ActiveSupport::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - assert_equal 13, @repository.changes.count + assert_equal 13, @repository.filechanges.count assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments end diff --git a/test/unit/repository_filesystem_test.rb b/test/unit/repository_filesystem_test.rb index b0604c689..25e7c88a9 100644 --- a/test/unit/repository_filesystem_test.rb +++ b/test/unit/repository_filesystem_test.rb @@ -62,11 +62,11 @@ class RepositoryFilesystemTest < ActiveSupport::TestCase if File.directory?(REPOSITORY_PATH) def test_fetch_changesets assert_equal 0, @repository.changesets.count - assert_equal 0, @repository.changes.count + assert_equal 0, @repository.filechanges.count @repository.fetch_changesets @project.reload assert_equal 0, @repository.changesets.count - assert_equal 0, @repository.changes.count + assert_equal 0, @repository.filechanges.count end def test_entries diff --git a/test/unit/repository_git_test.rb b/test/unit/repository_git_test.rb index d4d0e8c1a..9f053df57 100644 --- a/test/unit/repository_git_test.rb +++ b/test/unit/repository_git_test.rb @@ -105,7 +105,7 @@ class RepositoryGitTest < ActiveSupport::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - assert_equal 39, @repository.changes.count + assert_equal 39, @repository.filechanges.count commit = @repository.changesets.find_by_revision("7234cb2750b63f47bff735edc50a1c0a433c2518") assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid @@ -115,8 +115,8 @@ class RepositoryGitTest < ActiveSupport::TestCase # TODO: add a commit with commit time <> author time to the test repository assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on assert_equal "2007-12-14".to_date, commit.commit_date - assert_equal 3, commit.changes.count - change = commit.changes.sort_by(&:path).first + assert_equal 3, commit.filechanges.count + change = commit.filechanges.sort_by(&:path).first assert_equal "README", change.path assert_equal nil, change.from_path assert_equal "A", change.action diff --git a/test/unit/repository_mercurial_test.rb b/test/unit/repository_mercurial_test.rb index 0b6c4fa71..8d6e076d1 100644 --- a/test/unit/repository_mercurial_test.rb +++ b/test/unit/repository_mercurial_test.rb @@ -86,7 +86,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase @repository.fetch_changesets @project.reload assert_equal NUM_REV, @repository.changesets.count - assert_equal 46, @repository.changes.count + assert_equal 46, @repository.filechanges.count assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments end @@ -214,7 +214,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase cs1 = @repository.changesets.find_by_revision('13') assert_not_nil cs1 - c1 = cs1.changes.sort_by(&:path) + c1 = cs1.filechanges.sort_by(&:path) assert_equal 2, c1.size assert_equal 'A', c1[0].action @@ -227,7 +227,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase assert_equal '/sql_escape/underscore_dir/understrike_file.txt', c1[1].from_path cs2 = @repository.changesets.find_by_revision('15') - c2 = cs2.changes + c2 = cs2.filechanges assert_equal 1, c2.size assert_equal 'A', c2[0].action @@ -236,7 +236,7 @@ class RepositoryMercurialTest < ActiveSupport::TestCase assert_equal '933ca60293d7', c2[0].from_revision cs3 = @repository.changesets.find_by_revision('19') - c3 = cs3.changes + c3 = cs3.filechanges assert_equal 1, c3.size assert_equal 'A', c3[0].action assert_equal "/latin-1-dir/test-#{@char_1}-1.txt", c3[0].path diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb index c952cf8e5..8ea8ce0c5 100644 --- a/test/unit/repository_subversion_test.rb +++ b/test/unit/repository_subversion_test.rb @@ -36,7 +36,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase @project.reload assert_equal NUM_REV, @repository.changesets.count - assert_equal 20, @repository.changes.count + assert_equal 20, @repository.filechanges.count assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments end @@ -99,7 +99,7 @@ class RepositorySubversionTest < ActiveSupport::TestCase @project.reload assert_equal 1, @repository.changesets.count, 'Expected to see 1 revision' - assert_equal 2, @repository.changes.count, 'Expected to see 2 changes, dir add and file add' + assert_equal 2, @repository.filechanges.count, 'Expected to see 2 changes, dir add and file add' entries = @repository.entries('') assert_not_nil entries, 'Expect to find entries' diff --git a/test/unit/repository_test.rb b/test/unit/repository_test.rb index b96503662..0bd9af4b5 100644 --- a/test/unit/repository_test.rb +++ b/test/unit/repository_test.rb @@ -98,8 +98,10 @@ class RepositoryTest < ActiveSupport::TestCase end def test_destroy - changesets = Changeset.where("repository_id = 10").all.count - changes = Changeset.joins([:changes]).where("repository_id = 10").all.count + repository = Repository.find(10) + changesets = repository.changesets.count + changes = repository.filechanges.count + assert_difference 'Changeset.count', -changesets do assert_difference 'Change.count', -changes do Repository.find(10).destroy |