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
This commit is contained in:
parent
dd9c2cafa7
commit
2cbf9c9cc4
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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]
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue