diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb
index d92a574f..8a3b01fe 100644
--- a/app/controllers/dmsf_controller.rb
+++ b/app/controllers/dmsf_controller.rb
@@ -718,7 +718,6 @@ class DmsfController < ApplicationController
@url_links = @folder.url_links.visible
@locked_for_user = @folder.locked_for_user?
else
- Rails.logger.info ">>> #{@project.dmsf_folders.visible.to_sql}"
@subfolders = @project.dmsf_folders.visible.to_a
@files = @project.dmsf_files.visible
@dir_links = @project.folder_links.visible
diff --git a/app/controllers/dmsf_upload_controller.rb b/app/controllers/dmsf_upload_controller.rb
index 243d83b2..d2ec6dca 100644
--- a/app/controllers/dmsf_upload_controller.rb
+++ b/app/controllers/dmsf_upload_controller.rb
@@ -110,7 +110,10 @@ class DmsfUploadController < ApplicationController
uploaded_files = attachments.select { |key, value| key == 'uploaded_file'}
uploaded_files.each_value do |uploaded_file|
upload = DmsfUpload.create_from_uploaded_attachment(@project, @folder, uploaded_file)
- uploaded_file[:disk_filename] = upload.disk_filename if upload
+ if upload
+ uploaded_file[:disk_filename] = upload.disk_filename
+ uploaded_file[:tempfile_path] = upload.tempfile_path
+ end
end
commit_files_internal uploaded_files
end
diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb
index 113b058f..952f39f6 100644
--- a/app/models/dmsf_file.rb
+++ b/app/models/dmsf_file.rb
@@ -119,7 +119,7 @@ class DmsfFile < ActiveRecord::Base
rescue Exception => e
Rails.logger.error e.message
end
- @@storage_path = path
+ @@storage_path = Pathname.new(path)
end
def self.find_file_by_name(project, folder, name)
diff --git a/lib/redmine_dmsf/webdav/base_resource.rb b/lib/redmine_dmsf/webdav/base_resource.rb
index fbd67438..5b34b613 100644
--- a/lib/redmine_dmsf/webdav/base_resource.rb
+++ b/lib/redmine_dmsf/webdav/base_resource.rb
@@ -164,20 +164,12 @@ module RedmineDmsf
# Return instance of Project based on the path
def project
unless @project
- use_project_names = Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
pinfo = @path.split('/').drop(1)
if pinfo.length > 0
- if use_project_names
- unless pinfo.first.match('(\[([0-9]+)\])$').nil?
- pid = $2
- begin
- @project = Project.find_by_id(pid)
- rescue Exception => e
- Rails.logger.error e.message
- end
- end
- if @project.nil?
- Rails.logger.warn {"WebDAV ERROR: No project found on path '#{@path}'"}
+ if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names']
+ if pinfo.first =~ /(\d)$/
+ @project = Project.find_by_id($1)
+ Rails.logger.warn {"WebDAV ERROR: No project found on path '#{@path}'"} unless @project
end
else
begin
diff --git a/lib/redmine_dmsf/webdav/controller.rb b/lib/redmine_dmsf/webdav/controller.rb
index f2fa8f8e..f9f8e709 100644
--- a/lib/redmine_dmsf/webdav/controller.rb
+++ b/lib/redmine_dmsf/webdav/controller.rb
@@ -107,7 +107,7 @@ module RedmineDmsf
raise BadRequest
end
end
-
+
if depth != 0
# Only use cache for requests with a depth>0, depth=0 responses are already fast.
pinfo = resource.path.split('/').drop(1)
@@ -123,7 +123,7 @@ module RedmineDmsf
end
end
end
-
+
if propfind_key.nil?
# This PROPFIND is never cached so always create a new response
create_propfind_response(properties)
@@ -131,8 +131,8 @@ module RedmineDmsf
response.body = RedmineDmsf::Webdav::Cache.read(propfind_key)
if !response.body.nil?
# Found cached PROPFIND, fill in Content-Type and Content-Length
- response["Content-Type"] = 'text/xml; charset="utf-8"'
- response["Content-Length"] = response.body.size.to_s
+ response['Content-Type'] = 'text/xml; charset="utf-8"'
+ response['Content-Length'] = response.body.size.to_s
else
# No cached PROPFIND found
# Remove .invalid entry for this propfind since we are now creating a new valid propfind
@@ -223,7 +223,7 @@ module RedmineDmsf
xml2.response do
unless(resource.propstat_relative_path)
- xml2.href "#{scheme}://#{host}:#{port}#{url_format(resource)}"
+ xml2.href "#{scheme}://#{host}:#{port}#{url_format(resource)}"
else
xml2.href url_format(resource)
end
diff --git a/lib/redmine_dmsf/webdav/dmsf_resource.rb b/lib/redmine_dmsf/webdav/dmsf_resource.rb
index 50099e7f..85097fb1 100644
--- a/lib/redmine_dmsf/webdav/dmsf_resource.rb
+++ b/lib/redmine_dmsf/webdav/dmsf_resource.rb
@@ -72,7 +72,7 @@ module RedmineDmsf
# - 2012-06-15: Only if you're allowed to browse the project
# - 2012-06-18: Issue #5, ensure item is only listed if project is enabled for dmsf
def exist?
- return project && project.module_enabled?('dmsf') && (folder || file) &&
+ project && project.module_enabled?('dmsf') && (folder || file) &&
(User.current.admin? || User.current.allowed_to?(:view_dmsf_folders, project))
end
@@ -96,13 +96,11 @@ module RedmineDmsf
@folder
end
- # Check if current entity exists as a file (DmsfFile), and returns corresponding object if found (nil otherwise)
+ # Check if the current entity exists as a file (DmsfFile), and returns corresponding object if found (nil otherwise)
def file
unless @file
return nil unless project # Again if entity project is nil, it cannot exist in context of this object
- @file = DmsfFile.visible.joins('JOIN dmsf_file_revisions ON dmsf_files.id = dmsf_file_revisions.dmsf_file_id').where(
- ["dmsf_files.project_id = ? AND dmsf_files.dmsf_folder_id #{parent.folder ? '=' : 'IS'} ? AND dmsf_file_revisions.name = ?",
- project.id, parent.folder ? parent.folder.id : nil, basename]).first
+ @file = DmsfFile.find_file_by_name(project, parent.folder, basename)
end
@file
end
@@ -238,7 +236,7 @@ module RedmineDmsf
# Behavioural differences between collection and single entity
# TODO: Support overwrite between both types of entity, and implement better checking
def move(dest, overwrite)
- # All of this should carry accrross the ResourceProxy frontend, we ensure this to
+ # All of this should carry across the ResourceProxy frontend, we ensure this to
# prevent unexpected errors
resource = dest.is_a?(ResourceProxy) ? dest.resource : dest
diff --git a/lib/tasks/dmsf_convert_documents.rake b/lib/tasks/dmsf_convert_documents.rake
index 4a5e6673..a4613f40 100644
--- a/lib/tasks/dmsf_convert_documents.rake
+++ b/lib/tasks/dmsf_convert_documents.rake
@@ -111,8 +111,7 @@ class DmsfConvertDocuments
document.attachments.each do |attachment|
begin
file = DmsfFile.new
- file.container_type = 'Project'
- file.container_id = project.id
+ file.project_id = project.id
file.dmsf_folder = folder
file.name = attachment.filename
diff --git a/test/integration/webdav/dmsf_webdav_delete_test.rb b/test/integration/webdav/dmsf_webdav_delete_test.rb
index d68275db..1e00aa8b 100644
--- a/test/integration/webdav/dmsf_webdav_delete_test.rb
+++ b/test/integration/webdav/dmsf_webdav_delete_test.rb
@@ -45,12 +45,12 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
User.current = nil
end
- def test_truth
+ def test_truth
assert_kind_of Project, @project1
assert_kind_of Project, @project2
assert_kind_of DmsfFolder, @folder1
assert_kind_of DmsfFolder, @folder6
- assert_kind_of DmsfFile, @file1
+ assert_kind_of DmsfFile, @file1
assert_kind_of Role, @role
end
@@ -58,7 +58,7 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
delete '/dmsf/webdav'
assert_response 401
end
-
+
def test_not_authenticated_project
delete "/dmsf/webdav/#{@project1.identifier}"
assert_response 401
@@ -68,32 +68,32 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
delete '/dmsf/webdav', nil, credentials('admin', 'badpassword')
assert_response 401
end
-
+
def test_failed_authentication
delete "/dmsf/webdav/#{@project1.identifier}", nil, credentials('admin', 'badpassword')
assert_response 401
end
- def test_root_folder
+ def test_root_folder
delete '/dmsf/webdav', nil, @admin
assert_response :error # 501
end
- def test_delete_not_empty_folder
+ def test_delete_not_empty_folder
put "/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}", nil, @admin
assert_response :forbidden
end
- def test_not_existed_project
+ def test_not_existed_project
delete '/dmsf/webdav/not_a_project/file.txt', nil, @admin
assert_response :missing # Item does not exist.
end
-
- def test_dmsf_not_enabled
+
+ def test_dmsf_not_enabled
delete "/dmsf/webdav/#{@project1.identifier}/test.txt", nil, @jsmith
assert_response :missing # Item does not exist, as project is not enabled.
end
-
+
def test_delete_when_ro
Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] = 'WEBDAV_READ_ONLY'
delete "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil, @admin
@@ -109,14 +109,14 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
end
end
- def test_unathorized_user
+ def test_unathorized_user
@project1.enable_module! :dmsf # Flag module enabled
delete "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil, @jsmith
assert_response :missing # Without folder_view permission, he will not even be aware of its existence.
@file1.reload
assert !@file1.deleted?, "File #{@file1.name} is expected to exist"
end
-
+
def test_unathorized_user_forbidden
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
@project1.enable_module! :dmsf # Flag module enabled
@@ -128,9 +128,9 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
end
end
- def test_view_folder_not_allowed
+ def test_view_folder_not_allowed
@project1.enable_module! :dmsf # Flag module enabled
- @role.add_permission! :file_manipulation
+ @role.add_permission! :file_manipulation
delete "/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}", nil, @jsmith
assert_response :missing # Without folder_view permission, he will not even be aware of its existence.
@folder1.reload
@@ -227,21 +227,21 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
def test_locked_folder
@project1.enable_module! :dmsf # Flag module enabled
@role.add_permission! :view_dmsf_folders
- @role.add_permission! :folder_manipulation
+ @role.add_permission! :folder_manipulation
@folder6.lock!
delete "/dmsf/webdav/#{@project1.identifier}/#{@folder6.title}", nil, @jsmith
- assert_response 423 # Locked
+ assert_response 423 # Locked
@folder6.reload
- assert !@folder6.deleted?, "Folder #{@folder6.title} is expected to exist"
+ assert !@folder6.deleted?, "Folder #{@folder6.title} is expected to exist"
end
-
+
def test_locked_file
@project1.enable_module! :dmsf
- @role.add_permission! :view_dmsf_folders
- @role.add_permission! :file_delete
+ @role.add_permission! :view_dmsf_folders
+ @role.add_permission! :file_delete
@file1.lock!
delete "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil, @jsmith
- assert_response 423 # Locked
+ assert_response 423 # Locked
@file1.reload
assert !@file1.deleted?, "File #{@file1.name} is expected to exist"
end
@@ -252,10 +252,10 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
@project1.enable_module! :dmsf
@role.add_permission! :view_dmsf_folders
@role.add_permission! :file_delete
- @file1.copy_to_filename(@project1, nil, "delete_test.tmp")
- delete "/dmsf/webdav/#{@project1.identifier}/delete_test.tmp", nil, @jsmith
+ delete "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil, @jsmith
+ assert_response :success
# The file should be destroyed
- assert_nil DmsfFile.find_file_by_name(@project1, nil, 'delete_test.tmp')
+ assert_nil DmsfFile.visible.find_by_id @file1.id
end
end
diff --git a/test/integration/webdav/dmsf_webdav_mkcol_test.rb b/test/integration/webdav/dmsf_webdav_mkcol_test.rb
index 0f2e1685..f1329d2e 100644
--- a/test/integration/webdav/dmsf_webdav_mkcol_test.rb
+++ b/test/integration/webdav/dmsf_webdav_mkcol_test.rb
@@ -39,14 +39,14 @@ class DmsfWebdavMkcolTest < RedmineDmsf::Test::IntegrationTest
DmsfFile.storage_path = File.expand_path '../../../fixtures/files', __FILE__
User.current = nil
end
-
- def test_truth
+
+ def test_truth
assert_kind_of Project, @project1
assert_kind_of Project, @project2
assert_kind_of Role, @role
assert_kind_of DmsfFolder, @folder6
end
-
+
def test_mkcol_requires_authentication
xml_http_request :mkcol, '/dmsf/webdav/test1'
assert_response 401
diff --git a/test/integration/webdav/dmsf_webdav_move_test.rb b/test/integration/webdav/dmsf_webdav_move_test.rb
index 92d3ceba..d69ce42b 100644
--- a/test/integration/webdav/dmsf_webdav_move_test.rb
+++ b/test/integration/webdav/dmsf_webdav_move_test.rb
@@ -33,12 +33,15 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
DmsfFile.storage_path = File.expand_path("./dmsf_test-#{timestamp}", DmsfHelper.temp_dir)
Dir.mkdir(DmsfFile.storage_path) unless File.directory?(DmsfFile.storage_path)
# Copy the physical files to the temporary storage
- files = File.expand_path('../../../fixtures/files/.', __FILE__)
+ files = File.expand_path('../../../fixtures/files', __FILE__) + '/.'
FileUtils.cp_r files, DmsfFile.storage_path
@admin = credentials 'admin'
@jsmith = credentials 'jsmith'
@project1 = Project.find_by_id 1
+ @file1 = DmsfFile.find_by_id 1
+ @file10 = DmsfFile.find_by_id 10
+ @folder1 = DmsfFolder.find_by_id 1
# Fix permissions for jsmith's role
@role = Role.find 1 #
@@ -64,39 +67,38 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
def test_truth
assert_kind_of Project, @project1
assert_kind_of Role, @role
+ assert_kind_of DmsfFile, @file1
+ assert_kind_of DmsfFile, @file10
+ assert_kind_of DmsfFolder, @folder1
end
-
- def test_move_denied_for_anonymous
- file = DmsfFile.find_by_id 1
- new_name = "#{file.name}.moved"
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ def test_move_denied_for_anonymous
+ new_name = "#{@file1.name}.moved"
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
{:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"}
assert_response 401
end
end
-
+
def test_move_to_new_filename_without_folder_manipulation_permission
@role.remove_permission! :folder_manipulation
- file = DmsfFile.find_by_id 1
- new_name = "#{file.name}.moved"
+ new_name = "#{@file1.name}.moved"
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 403
end
end
end
-
+
def test_move_to_new_filename_without_folder_manipulation_permission_as_admin
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
@role.remove_permission! :folder_manipulation
- file = DmsfFile.find_by_id 1
- new_name = "#{file.name}.moved"
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ new_name = "#{@file1.name}.moved"
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@admin.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 201 # Created
f = DmsfFile.find_file_by_name @project1, nil, "#{new_name}"
@@ -104,30 +106,27 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
end
end
end
-
+
def test_move_non_existent_file
xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/not_a_file.txt", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/moved_file.txt"})
assert_response 404 # NotFound
end
-
- def test_move_wrong_destination
- file = DmsfFile.find_by_id 1
- new_name = "#{file.name}.moved"
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ def test_move_wrong_destination
+ new_name = "#{@file1.name}.moved"
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.wrong-url.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 502 # BadGateway
end
end
-
+
def test_move_to_new_filename
- file = DmsfFile.find_by_id 1
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- new_name = "#{file.name}.moved"
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ new_name = "#{@file1.name}.moved"
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 201 # Created
f = DmsfFile.find_file_by_name @project1, nil, "#{new_name}"
@@ -137,13 +136,12 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
end
def test_move_to_new_filename_with_project_names
- file = DmsfFile.find_by_id 1
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = true
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] == true
project1_uri = Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
- new_name = "#{file.name}.moved"
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{project1_uri}/#{file.name}", nil,
+ new_name = "#{@file1.name}.moved"
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{project1_uri}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{project1_uri}/#{new_name}"})
assert_response 201 # Created
f = DmsfFile.find_file_by_name @project1, nil, "#{new_name}"
@@ -151,13 +149,12 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
end
end
end
-
+
def test_move_zero_sized_to_new_filename
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- file = DmsfFile.find_by_id 10
- new_name = "#{file.name}.moved"
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ new_name = "#{@file10.name}.moved"
+ assert_no_difference '@file10.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file10.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 201 # Created
f = DmsfFile.find_file_by_name @project1, nil, "#{new_name}"
@@ -165,122 +162,100 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
end
end
end
-
- def test_move_to_new_folder
- file = DmsfFile.find_by_id 1
- folder = DmsfFolder.find_by_id 1
- assert_kind_of DmsfFile, file
- assert_kind_of DmsfFolder, folder
+ def test_move_to_new_folder
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
- @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{folder.title}/#{file.name}"})
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
+ @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file1.name}"})
assert_response 201 # Created
- file2 = DmsfFile.find_by_id 1
- assert_equal folder.id, file2.dmsf_folder_id
+ @file1.reload
+ assert_equal @folder1.id, @file1.dmsf_folder_id
end
end
end
def test_move_to_new_folder_with_project_names
- file = DmsfFile.find_by_id 1
- folder = DmsfFolder.find_by_id 1
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = true
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] == true
project1_uri = Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
- assert_kind_of DmsfFile, file
- assert_kind_of DmsfFolder, folder
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{project1_uri}/#{@file1.name}", nil,
+ @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{project1_uri}/#{@folder1.title}/#{@file1.name}"})
+ assert_response 201 # Created
+ @file1.reload
+ assert_equal @folder1.id, @file1.dmsf_folder_id
+ end
+ end
+ end
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{project1_uri}/#{file.name}", nil,
- @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{project1_uri}/#{folder.title}/#{file.name}"})
- assert_response 201 # Created
- file2 = DmsfFile.find_by_id 1
- assert_equal folder.id, file2.dmsf_folder_id
- end
- end
- end
-
def test_move_zero_sized_to_new_folder
- file = DmsfFile.find_by_id 10
- folder = DmsfFolder.find_by_id 1
- assert_kind_of DmsfFile, file
- assert_kind_of DmsfFolder, folder
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
- @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{folder.title}/#{file.name}"})
+ assert_no_difference '@file10.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file10.name}", nil,
+ @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/#{@file10.name}"})
assert_response 201 # Created
- file2 = DmsfFile.find_by_id 10
- assert_equal folder.id, file2.dmsf_folder_id
+ @file10.reload
+ assert_equal @folder1.id, @file10.dmsf_folder_id
end
end
end
-
+
def test_move_to_existing_filename
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- file = DmsfFile.find_by_id 1
file2 = DmsfFile.find_by_id 9
new_name = "#{file2.name}"
assert_no_difference 'file2.dmsf_file_revisions.count' do
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 405 # MethodNotAllowed
end
end
end
end
-
+
def test_move_when_file_is_locked_by_other
- file = DmsfFile.find_by_id 1
-
log_user 'admin', 'admin' # login as admin
assert !User.current.anonymous?, 'Current user is anonymous'
- assert file.lock!, "File failed to be locked by #{User.current.name}"
-
- new_name = "#{file.name}.moved"
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ assert @file1.lock!, "File failed to be locked by #{User.current.name}"
+ new_name = "#{@file1.name}.moved"
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 423 # Locked
end
end
-
+
def test_move_when_file_is_locked_by_other_and_user_is_admin
- file = DmsfFile.find_by_id 1
-
log_user 'jsmith', 'jsmith' # login as jsmith
assert !User.current.anonymous?, 'Current user is anonymous'
- assert file.lock!, "File failed to be locked by #{User.current.name}"
+ assert @file1.lock!, "File failed to be locked by #{User.current.name}"
- new_name = "#{file.name}.moved"
- assert_no_difference 'file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ new_name = "#{@file1.name}.moved"
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@admin.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 423 # Locked
end
end
-
+
def test_move_when_file_is_locked_by_user
- file = DmsfFile.find_by_id 1
-
log_user 'jsmith', 'jsmith' # login as jsmith
assert !User.current.anonymous?, 'Current user is anonymous'
- assert file.lock!, "File failed to be locked by #{User.current.name}"
+ assert @file1.lock!, "File failed to be locked by #{User.current.name}"
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
# Move once
- new_name = "#{file.name}.m1"
- assert_difference 'file.dmsf_file_revisions.count', +1 do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{file.name}", nil,
+ new_name = "#{@file1.name}.m1"
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name}"})
assert_response 201 # Created
end
# Move twice, make sure that the MsOffice store sequence is not disrupting normal move
new_name2 = "#{new_name}.m2"
- assert_difference 'file.dmsf_file_revisions.count', +1 do
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{new_name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{new_name2}"})
assert_response 201 # Created
@@ -290,70 +265,67 @@ class DmsfWebdavMoveTest < RedmineDmsf::Test::IntegrationTest
def test_move_msoffice_save_locked_file
if Setting.plugin_redmine_dmsf['dmsf_webdav_strategy'] == 'WEBDAV_READ_WRITE'
- # When some versions of MsOffice saves a file it use the following sequence:
+ # When some versions of MsOffice save a file they use the following sequence:
# 1. Save changes to a new temporary document, XXX.tmp
- # 2. Rename (MOVE) document to YYY.tmp. History is lost here if original document is moved.
- # 3. Rename (MOVE) XXX.tmp to document name. XXX.tmp must be merged to original document or else the history is lost.
+ # 2. Rename (MOVE) document to YYY.tmp. History is lost here if the original document is moved.
+ # 3. Rename (MOVE) XXX.tmp to document's name. XXX.tmp must be merged to the original document otherwise the history is lost.
# 4. Delete YYY.tmp.
- # Verify that steps 2 and 3 works.
-
- original_file = DmsfFile.find_by_id 1
-
+ # Verify that steps 2 and 3 work.
log_user 'jsmith', 'jsmith' # login as jsmith
assert !User.current.anonymous?, 'Current user is anonymous'
- assert original_file.lock!, "File failed to be locked by #{User.current.name}"
+ assert @file1.lock!, "File failed to be locked by #{User.current.name}"
- # First save while file is locked, should create new revision
+ # First save while the file is locked, should create new revision
temp_file_name = 'AAAAAAAA.tmp'
# Make sure that the temp-file does not exist.
temp_file = DmsfFile.find_file_by_name @project1, nil, "#{temp_file_name}"
assert !temp_file, "File '#{temp_file_name}' should not exist yet."
- # Move the original file to AAAAAAAA.tmp. The original file should not change but a new file should be created.
- assert_no_difference 'original_file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{original_file.name}", nil,
+ # Move the original file to AAAAAAAA.tmp. The original file should not changed but a new file should be created.
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}"})
assert_response 201 # Created
end
- # Verify that a new file acutally has been created
+ # Verify that a new file has been created
temp_file = DmsfFile.find_file_by_name @project1, nil, "#{temp_file_name}"
assert temp_file, "File '#{temp_file_name}' not found, move failed."
assert_equal temp_file.dmsf_file_revisions.count,1
- assert_not_equal temp_file.id, original_file.id
+ assert_not_equal temp_file.id, @file1.id
# Move a temporary file (use AAAAAAAA.tmp) to the original file.
- assert_difference 'original_file.dmsf_file_revisions.count', +1 do
+ assert_difference '@file1.dmsf_file_revisions.count', +1 do
xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}", nil,
- @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{original_file.name}"})
+ @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}"})
assert_response 201 # Created
end
# Second save while file is locked, should NOT create new revision
- temp_file_name = "BBBBBBBB.tmp"
+ temp_file_name = 'BBBBBBBB.tmp'
# Make sure that the temp-file does not exist.
temp_file = DmsfFile.find_file_by_name @project1, nil, "#{temp_file_name}"
assert !temp_file, "File '#{temp_file_name}' should not exist yet."
# Move the original file to BBBBBBBB.tmp. The original file should not change but a new file should be created.
- assert_no_difference 'original_file.dmsf_file_revisions.count' do
- xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{original_file.name}", nil,
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
+ xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{@file1.name}", nil,
@jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}"})
assert_response 201 # Created
end
- # Verify that a new file acutally has been created
+ # Verify that a new file has been created
temp_file = DmsfFile.find_file_by_name @project1, nil, "#{temp_file_name}"
assert temp_file, "File '#{temp_file_name}' not found, move failed."
assert_equal temp_file.dmsf_file_revisions.count,1
- assert_not_equal temp_file.id, original_file.id
+ assert_not_equal temp_file.id, @file1.id
# Move a temporary file (use BBBBBBBB.tmp) to the original file.
- assert_no_difference 'original_file.dmsf_file_revisions.count' do
+ assert_no_difference '@file1.dmsf_file_revisions.count' do
xml_http_request :move, "/dmsf/webdav/#{@project1.identifier}/#{temp_file_name}", nil,
- @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{original_file.name}"})
+ @jsmith.merge!({:destination => "http://www.example.com/dmsf/webdav/#{@project1.identifier}/#{@file1.name}"})
assert_response 201 # Created
end
end
diff --git a/test/integration/webdav/dmsf_webdav_propfind_test.rb b/test/integration/webdav/dmsf_webdav_propfind_test.rb
index 7dd48100..e21fd702 100644
--- a/test/integration/webdav/dmsf_webdav_propfind_test.rb
+++ b/test/integration/webdav/dmsf_webdav_propfind_test.rb
@@ -46,7 +46,8 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
# Temporarily enable project names to generate names for project1
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = true
- @project1_uri = Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
+ @project1_name = RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1)
+ @project1_uri = Addressable::URI.escape(@project1_name)
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = false
RedmineDmsf::Webdav::Cache.init_nullcache
end
@@ -55,13 +56,13 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_kind_of Project, @project1
assert_kind_of Project, @project2
end
-
+
def test_propfind_denied_for_anonymous
xml_http_request :propfind, '/dmsf/webdav/', nil,
{:HTTP_DEPTH => '0'}
assert_response 401
end
-
+
def test_propfind_depth0_on_root_for_non_member
xml_http_request :propfind, '/dmsf/webdav/', nil,
@jsmith.merge!({:HTTP_DEPTH => '0'})
@@ -77,7 +78,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
def test_propfind_depth1_on_root_for_non_member
xml_http_request :propfind, '/dmsf/webdav/', nil,
@jsmith.merge!({:HTTP_DEPTH => '1'})
-
+
assert_response 207 # MultiStatus
assert_match 'http://www.example.com:80/dmsf/webdav/', response.body
assert_match '/', response.body
@@ -86,11 +87,11 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_no_match "http://www.example.com:80/dmsf/webdav/#{@project2.identifier}/", response.body
assert_no_match "#{@project2.identifier}", response.body
end
-
+
def test_propfind_depth0_on_root_for_admin
xml_http_request :propfind, '/dmsf/webdav/', nil,
@admin.merge!({:HTTP_DEPTH => '0'})
-
+
assert_response 207 # MultiStatus
assert_match 'http://www.example.com:80/dmsf/webdav/', response.body
assert_match '/', response.body
@@ -112,7 +113,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_no_match "http://www.example.com:80/dmsf/webdav/#{@project2.identifier}/", response.body
assert_no_match "#{@project2.identifier}", response.body
end
-
+
def test_propfind_depth1_on_root_for_admin_with_project_names
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = true
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] == true
@@ -126,10 +127,10 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_no_match "#{@project1.identifier}", response.body
# but the project name should match
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1_uri}/", response.body
- assert_match "#{@project1_uri}", response.body
+ assert_match "#{@project1_name}", response.body
end
end
-
+
def test_propfind_depth0_on_project1_for_non_member
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@jsmith.merge!({:HTTP_DEPTH => '0'})
@@ -174,7 +175,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_no_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", response.body
assert_no_match "#{@project1.identifier}", response.body
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1_uri}/", response.body
- assert_match "#{@project1_uri}", response.body
+ assert_match "#{@project1_name}", response.body
end
end
@@ -200,7 +201,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/#{@file10.name}", response.body
assert_match "#{@file10.name}", response.body
end
-
+
def test_propfind_depth1_on_project1_for_admin_with_project_names
Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] = true
if Setting.plugin_redmine_dmsf['dmsf_webdav_use_project_names'] == true
@@ -219,7 +220,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_no_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", response.body
assert_no_match "#{@project1.identifier}", response.body
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1_uri}/", response.body
- assert_match "#{@project1_uri}", response.body
+ assert_match "#{@project1_name}", response.body
# Folders
assert_no_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/#{@folder1.title}/", response.body
@@ -262,12 +263,13 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
# but the project name should match
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1_uri}/", response.body
- assert_match "#{@project1_uri}", response.body
+ assert_match "#{@project1_name}", response.body
# Rename project1
@project1.name = 'Online Cookbook'
@project1.save!
- project1_new_uri = Addressable::URI.escape(RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1))
+ project1_new_name = RedmineDmsf::Webdav::ProjectResource.create_project_name(@project1)
+ project1_new_uri = Addressable::URI.escape(project1_new_name)
# PROPSTATS for / is already cached, but a new PROPSTATS should be cached for project1
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
@@ -289,28 +291,28 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
# but new project name should match
assert_match "http://www.example.com:80/dmsf/webdav/#{project1_new_uri}/", response.body
- assert_match "#{project1_new_uri}", response.body
+ assert_match "#{project1_new_name}", response.body
end
end
-
+
def test_propfind_depth0_on_project1_for_admin_with_cache
RedmineDmsf::Webdav::Cache.init_testcache
-
+
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '0'})
assert_response 207 # MultiStatus
end
-
+
# Response should be correct
# Project
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", response.body
# A new PROPSTATS entry should have been created for project1
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", RedmineDmsf::Webdav::Cache.read("PROPSTATS/#{@project1.identifier}")
-
+
# Replace the PROPSTATS cache entry and make sure that it is used
RedmineDmsf::Webdav::Cache.write("PROPSTATS/#{@project1.identifier}", "Cached PROPSTATS/#{@project1.identifier}")
-
+
assert_no_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count' do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '0'})
@@ -318,16 +320,16 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
end
assert_match "Cached PROPSTATS/#{@project1.identifier}", response.body
end
-
+
def test_propfind_depth1_on_project1_for_admin_with_cache
RedmineDmsf::Webdav::Cache.init_testcache
-
- assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +9 do
+
+ assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +10 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
assert_response 207 # MultiStatus
end
-
+
# Project, a new PROPFIND and PROPSTATS should have been created for project1
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", response.body
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/", RedmineDmsf::Webdav::Cache.read("PROPFIND/#{@project1.id}")
@@ -344,7 +346,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/#{@file9.name}", RedmineDmsf::Webdav::Cache.read("PROPSTATS/#{@file9.id}-#{@file9.last_revision.id}")
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/#{@file10.name}", response.body
assert_match "http://www.example.com:80/dmsf/webdav/#{@project1.identifier}/#{@file10.name}", RedmineDmsf::Webdav::Cache.read("PROPSTATS/#{@file10.id}-#{@file10.last_revision.id}")
-
+
# Replace PROPFIND and verify that cached entry is used.
RedmineDmsf::Webdav::Cache.write("PROPFIND/#{@project1.id}", "Cached PROPFIND/#{@project1.id}")
assert_no_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count' do
@@ -353,7 +355,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_response 207 # MultiStatus
assert_match "Cached PROPFIND/#{@project1.id}", response.body
end
-
+
# Delete PROPFIND, replace PROPSTATS for one entry and verify that it is used when creating the response and new cache
RedmineDmsf::Webdav::Cache.invalidate_item("PROPFIND/#{@project1.id}")
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
@@ -369,19 +371,19 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert_match "Cached PROPSTATS/#{@project1.identifier}", RedmineDmsf::Webdav::Cache.read("PROPFIND/#{@project1.id}")
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}.invalid")
end
-
+
def test_propfind_depth1_on_project1_for_admin_with_cache_and_locks
RedmineDmsf::Webdav::Cache.init_testcache
-
+
log_user 'admin', 'admin' # login as admin
assert !User.current.anonymous?, 'Current user is anonymous'
-
- assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +9 do
+
+ assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +10 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
assert_response 207 # MultiStatus
end
-
+
# Verify that everything exists in the cache as it should
assert RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@project1.identifier}")
@@ -401,7 +403,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert !RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file9.id}-#{@file9.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file10.id}-#{@file10.last_revision.id}")
-
+
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
@@ -410,7 +412,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}.invalid")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
-
+
# Unlock a file and verify that the PROPSTATS for the file and the PROPFIND were deleted
assert @file1.unlock!, "File failed to be unlocked by #{User.current.name}"
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
@@ -421,7 +423,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert !RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file9.id}-#{@file9.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file10.id}-#{@file10.last_revision.id}")
-
+
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
@@ -430,7 +432,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}.invalid")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
-
+
# Lock a folder and verify that the PROPSTATS for the file and the PROPFIND were deleted
assert @folder1.lock!, "File failed to be locked by #{User.current.name}"
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
@@ -441,7 +443,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file9.id}-#{@file9.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file10.id}-#{@file10.last_revision.id}")
-
+
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
@@ -450,7 +452,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}.invalid")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@project1.identifier}/#{@folder1.title}")
-
+
# Unlock a folder and verify that the PROPSTATS for the file and the PROPFIND were deleted
assert @folder1.unlock!, "File failed to be unlocked by #{User.current.name}"
assert !RedmineDmsf::Webdav::Cache.exist?("PROPFIND/#{@project1.id}")
@@ -461,7 +463,7 @@ class DmsfWebdavPropfindTest < RedmineDmsf::Test::IntegrationTest
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file1.id}-#{@file1.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file9.id}-#{@file9.last_revision.id}")
assert RedmineDmsf::Webdav::Cache.exist?("PROPSTATS/#{@file10.id}-#{@file10.last_revision.id}")
-
+
assert_difference 'RedmineDmsf::Webdav::Cache.cache.instance_variable_get(:@data).count', +1 do
xml_http_request :propfind, "/dmsf/webdav/#{@project1.identifier}", nil,
@admin.merge!({:HTTP_DEPTH => '1'})
diff --git a/test/unit/dmsf_folder_test.rb b/test/unit/dmsf_folder_test.rb
index 2dd826bc..1bf34777 100644
--- a/test/unit/dmsf_folder_test.rb
+++ b/test/unit/dmsf_folder_test.rb
@@ -54,13 +54,13 @@ class DmsfFolderTest < RedmineDmsf::Test::UnitTest
# The role has got permissions
User.current = @manager
assert_equal 6, DmsfFolder.where(:project_id => 1).count
- assert_equal 5, DmsfFolder.visible.where(:project_id => 1).count
+ assert_equal 6, DmsfFolder.visible.where(:project_id => 1).count
# The user has got permissions
User.current = @developer
- assert_equal 5, DmsfFolder.visible.where(:project_id => 1).count
+ assert_equal 6, DmsfFolder.visible.where(:project_id => 1).count
# Hasn't got permissions for @folder7
@folder7.dmsf_folder_permissions.where(:object_type => 'User').delete_all
- assert_equal 4, DmsfFolder.visible.where(:project_id => 1).count
+ assert_equal 5, DmsfFolder.visible.where(:project_id => 1).count
end
def test_permissions
diff --git a/test/unit/project_patch_test.rb b/test/unit/project_patch_test.rb
index e8bdc419..5fb5ef5b 100644
--- a/test/unit/project_patch_test.rb
+++ b/test/unit/project_patch_test.rb
@@ -67,8 +67,8 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
def test_dmsf_count
hash = @project1.dmsf_count
- assert_equal 8, hash[:files]
- assert_equal 6, hash[:folders]
+ assert_equal 9, hash[:files]
+ assert_equal 7, hash[:folders]
end
def test_copy_approval_workflows
@@ -80,7 +80,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
def test_copy_dmsf
assert_equal 4, @project1.dmsf_files.visible.count
- assert_equal 3, @project1.dmsf_folders.visible.count
+ assert_equal 4, @project1.dmsf_folders.visible.count
assert_equal 1, @project1.file_links.visible.count
assert_equal 1, @project1.folder_links.visible.count
assert_equal 1, @project1.url_links.visible.count
@@ -91,7 +91,7 @@ class ProjectPatchTest < RedmineDmsf::Test::UnitTest
assert_equal 0, @project3.url_links.visible.count
@project3.copy_dmsf(@project1)
assert_equal 4, @project3.dmsf_files.visible.count
- assert_equal 3, @project3.dmsf_folders.count
+ assert_equal 4, @project3.dmsf_folders.count
assert_equal 1, @project3.file_links.visible.count
assert_equal 1, @project3.folder_links.visible.count
assert_equal 1, @project3.url_links.visible.count