Updated PUT test for locked files. #615

This commit is contained in:
COLA@Redmine.local 2017-02-13 21:55:39 +01:00
parent 65b64ca799
commit b90e2983e8

View File

@ -196,10 +196,35 @@ class DmsfWebdavPutTest < RedmineDmsf::Test::IntegrationTest
@project1.enable_module! :dmsf # Flag module enabled
@role.add_permission! :view_dmsf_folders
@role.add_permission! :file_manipulation
log_user 'jsmith', 'jsmith' # login as jsmith
assert !User.current.anonymous?, 'Current user is not anonymous'
file = DmsfFile.find_file_by_name @project1, nil, 'test.txt'
assert file.lock!, "File failed to be locked by #{User.current.name}"
assert l=file.lock!, "File failed to be locked by #{User.current.name}"
assert_equal file.last_revision.id, l.revision
# First PUT should always create new revision.
assert_difference 'file.dmsf_file_revisions.count', +1 do
put "/dmsf/webdav/#{@project1.identifier}/test.txt", '1234', @jsmith.merge!({:content_type => :text})
assert_response :success # 201 - Created
end
# Second PUT on a locked file should only update the revision that were created on the first PUT
assert_no_difference 'file.dmsf_file_revisions.count' do
put "/dmsf/webdav/#{@project1.identifier}/test.txt", '1234', @jsmith.merge!({:content_type => :text})
assert_response :success # 201 - Created
end
# Unlock
assert file.unlock!, "File failed to be unlocked by #{User.current.name}"
# 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
# Delete the last revision, the revision that were stored in the lock.
file.last_revision.delete(true)
# First PUT should always create new revision.
assert_difference 'file.dmsf_file_revisions.count', +1 do
put "/dmsf/webdav/#{@project1.identifier}/test.txt", '1234', @jsmith.merge!({:content_type => :text})
assert_response :success # 201 - Created