Renamed DmsfLock.revision to dmsf_file_last_revision_id. #615

This commit is contained in:
COLA@Redmine.local 2017-02-14 16:58:55 +01:00
parent c3ae2a35e6
commit 6d2b22c459
4 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,5 @@
class AddDmsfFileLastRevisionIdToDmsfLock < ActiveRecord::Migration
def change
rename_column :dmsf_locks, :revision, :dmsf_file_last_revision_id
end
end

View File

@ -69,7 +69,7 @@ module RedmineDmsf
l.lock_scope = scope
l.user = User.current
l.expires_at = expire
l.revision = self.last_revision.id if self.is_a?(DmsfFile)
l.dmsf_file_last_revision_id = self.last_revision.id if self.is_a?(DmsfFile)
l.save!
reload
locks.reload

View File

@ -745,7 +745,7 @@ private
next if lock.expired?
# lock should be exclusive but just in case make sure we find this users lock
next if lock.user != User.current
if lock.revision < file.last_revision.id
if lock.dmsf_file_last_revision_id < file.last_revision.id
# At least one new revision has been created since the lock was created, reuse that revision.
return true
end

View File

@ -201,7 +201,7 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
assert !User.current.anonymous?, 'Current user is not anonymous'
file = DmsfFile.find_file_by_name @project1, nil, 'test.txt'
assert l=file.lock!, "File failed to be locked by #{User.current.name}"
assert_equal file.last_revision.id, l.revision
assert_equal file.last_revision.id, l.dmsf_file_last_revision_id
# First PUT should always create new revision.
assert_difference 'file.dmsf_file_revisions.count', +1 do
@ -219,7 +219,7 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
# Lock file again, but this time delete the revision that were stored in the lock
file = DmsfFile.find_file_by_name @project1, nil, 'test.txt'
assert l=file.lock!, "File failed to be locked by #{User.current.name}"
assert_equal file.last_revision.id, l.revision
assert_equal file.last_revision.id, l.dmsf_file_last_revision_id
# Delete the last revision, the revision that were stored in the lock.
file.last_revision.delete(true)