A lot of warnings in WebDAV unit tests #584

This commit is contained in:
Karel Picman 2016-11-02 14:33:24 +01:00
parent de2ad3f1a6
commit 538371e316
6 changed files with 22 additions and 13 deletions

View File

@ -121,7 +121,7 @@ class DmsfFile < ActiveRecord::Base
end
def last_revision
unless @last_revision
unless defined?(@last_revision)
@last_revision = self.deleted? ? self.dmsf_file_revisions.first : self.dmsf_file_revisions.visible.first
end
@last_revision

View File

@ -20,6 +20,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'dav4rack'
require 'addressable/uri'
module RedmineDmsf
module Webdav
@ -117,15 +118,15 @@ module RedmineDmsf
# Escape URL string
def url_format(resource)
# Additionally escape square brackets, otherwise files with
# file names like file[1].pdf are not visible in some WebDAV clients
# TODO: The method is obsolete
URI.encode(super, '[]')
ret = resource.public_path
if resource.collection? && (ret[-1,1] != '/')
ret += '/'
end
Addressable::URI.escape ret
end
def url_unescape(str)
# TODO: The method is obsolete
super str
Addressable::URI.unescape str
end
end

View File

@ -20,6 +20,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 'uuidtools'
require 'addressable/uri'
module RedmineDmsf
module Webdav
@ -413,9 +414,6 @@ module RedmineDmsf
l.save!
@response['Lock-Token'] = l.uuid
return [1.hours.to_i, l.uuid]
# Unfortunately if we're here, then it's updating a lock we can't find
return Conflict
end
scope = "scope_#{(args[:scope] || 'exclusive')}".to_sym
@ -610,8 +608,8 @@ module RedmineDmsf
doc.timeout "Second-#{(lock.expires_at.to_i - Time.now.to_i)}"
end
lock_entity = lock.folder || lock.file
lock_path = "#{request.scheme}://#{request.host}:#{request.port}#{path_prefix}#{URI.escape(lock_entity.project.identifier)}/"
lock_path << lock_entity.dmsf_path.map {|x| URI.escape(x.respond_to?('name') ? x.name : x.title) }.join('/')
lock_path = "#{request.scheme}://#{request.host}:#{request.port}#{path_prefix}#{Addressable::URI.escape(lock_entity.project.identifier)}/"
lock_path << lock_entity.dmsf_path.map { |e| Addressable::URI.escape(e.respond_to?('name') ? e.name : e.title) }.join('/')
lock_path << '/' if lock_entity.is_a?(DmsfFolder) && lock_path[-1,1] != '/'
doc.lockroot { doc.href lock_path }
if ((lock.user.id == User.current.id) || User.current.allowed_to?(:force_file_unlock, self.project))

View File

@ -22,6 +22,11 @@
module RedmineDmsf
module Webdav
class IndexResource < BaseResource
def initialize(*args)
super(*args)
@projects = nil
end
def children
unless @projects

View File

@ -22,6 +22,11 @@
module RedmineDmsf
module Webdav
class ProjectResource < BaseResource
def initialize(*args)
super(*args)
@children = nil
end
def children
unless @children

View File

@ -64,7 +64,7 @@ class DmsfWebdavDeleteTest < RedmineDmsf::Test::IntegrationTest
assert_response 401
end
def test_failed_authentication
def test_failed_authentication_global
delete '/dmsf/webdav', nil, credentials('admin', 'badpassword')
assert_response 401
end