dav4rack 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -305,6 +305,7 @@ A big thanks to everyone contributing to help make this project better.
305
305
  * {clyfe}[http://github.com/clyfe]
306
306
  * {antiloopgmbh}[http://github.com/antiloopgmbh]
307
307
  * {krug}[http://github.com/krug]
308
+ * {teefax}[http://github.com/teefax]
308
309
 
309
310
  == License
310
311
 
@@ -71,7 +71,7 @@ module DAV4Rack
71
71
  status = resource.put(request, response)
72
72
  multistatus do |xml|
73
73
  xml.response do
74
- xml.href resource.path
74
+ xml.href "#{scheme}://#{host}:#{port}#{url_escape(resource.public_path)}"
75
75
  xml.status "#{http_version} #{status.status_line}"
76
76
  end
77
77
  end
@@ -95,7 +95,7 @@ module DAV4Rack
95
95
  status = resource.make_collection
96
96
  multistatus do |xml|
97
97
  xml.response do
98
- xml.href resource.path
98
+ xml.href "#{scheme}://#{host}:#{port}#{url_escape(resource.public_path)}"
99
99
  xml.status "#{http_version} #{status.status_line}"
100
100
  end
101
101
  end
@@ -468,19 +468,7 @@ module DAV4Rack
468
468
  # element:: Nokogiri::XML::Element
469
469
  # Converts element into proper text
470
470
  def xml_convert(xml, element)
471
- if element.children.empty?
472
- if element.text?
473
- xml.send(element.name, element.text, element.attributes)
474
- else
475
- xml.send(element.name, element.attributes)
476
- end
477
- else
478
- xml.send(element.name, element.attributes) do
479
- element.elements.each do |child|
480
- xml_convert(xml, child)
481
- end
482
- end
483
- end
471
+ xml.doc.root.add_child(element)
484
472
  end
485
473
 
486
474
  end
@@ -234,7 +234,7 @@ module DAV4Rack
234
234
  lock.scope = args[:scope]
235
235
  lock.kind = args[:type]
236
236
  lock.owner = args[:owner]
237
- lock.depth = args[:depth].to_i
237
+ lock.depth = args[:depth].is_a?(Symbol) ? args[:depth] : args[:depth].to_i
238
238
  if(args[:timeout])
239
239
  lock.timeout = args[:timeout] <= @max_timeout && args[:timeout] > 0 ? args[:timeout] : @max_timeout
240
240
  else
@@ -1,3 +1,3 @@
1
1
  module DAV4Rack
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
data/spec/handler_spec.rb CHANGED
@@ -120,6 +120,13 @@ describe DAV4Rack::Handler do
120
120
  get('/test').should be_ok
121
121
  response.body.should == 'body'
122
122
  end
123
+
124
+ it 'should return an absolute url after a put request' do
125
+ put('/test', :input => 'body')
126
+ multi_status_ok.should eq true
127
+ multistatus_response('/D:href').first.text.should =~ /http:\/\/localhost(:\d+)?\/test/
128
+ end
129
+
123
130
  it 'should create and find a url with escaped characters' do
124
131
  put(url_escape('/a b'), :input => 'body')
125
132
  multi_status_ok.should eq true
@@ -250,6 +257,14 @@ describe DAV4Rack::Handler do
250
257
  multistatus_response('/D:propstat/D:prop/D:resourcetype/D:collection').should_not be_empty
251
258
  end
252
259
 
260
+ it 'should return full urls after creating a collection' do
261
+ mkcol('/folder')
262
+ multi_status_created.should eq true
263
+ propfind('/folder', :input => propfind_xml(:resourcetype))
264
+ multistatus_response('/D:propstat/D:prop/D:resourcetype/D:collection').should_not be_empty
265
+ multistatus_response('/D:href').first.text.should =~ /http:\/\/localhost(:\d+)?\/folder/
266
+ end
267
+
253
268
  it 'should not find properties for nonexistent resources' do
254
269
  propfind('/non').should be_not_found
255
270
  end
@@ -305,4 +320,18 @@ describe DAV4Rack::Handler do
305
320
  match['/D:locktoken'].should_not be_empty
306
321
  match['/D:owner'].should_not be_empty
307
322
  end
323
+
324
+ context "when mapping a path" do
325
+
326
+ before do
327
+ @controller = DAV4Rack::Handler.new(:root => DOC_ROOT, :root_uri_path => '/webdav/')
328
+ end
329
+
330
+ it "should return correct urls" do
331
+ # FIXME: a put to '/test' works, too -- should it?
332
+ put('/webdav/test', :input => 'body')
333
+ multi_status_ok.should eq true
334
+ multistatus_response('/D:href').first.text.should =~ /http:\/\/localhost(:\d+)?\/webdav\/test/
335
+ end
336
+ end
308
337
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dav4rack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 3
10
- version: 0.2.3
5
+ version: 0.2.4
11
6
  platform: ruby
12
7
  authors:
13
8
  - Chris Roberts
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-03-31 00:00:00 -07:00
13
+ date: 2011-05-14 00:00:00 -07:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 1
32
- - 4
33
- - 2
34
24
  version: 1.4.2
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 9
46
- segments:
47
- - 2
48
- - 1
49
- - 1
50
35
  version: 2.1.1
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ">="
60
45
  - !ruby/object:Gem::Version
61
- hash: 19
62
- segments:
63
- - 1
64
- - 1
65
- - 0
66
46
  version: 1.1.0
67
47
  type: :runtime
68
48
  version_requirements: *id003
@@ -109,23 +89,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
89
  requirements:
110
90
  - - ">="
111
91
  - !ruby/object:Gem::Version
112
- hash: 3
113
- segments:
114
- - 0
115
92
  version: "0"
116
93
  required_rubygems_version: !ruby/object:Gem::Requirement
117
94
  none: false
118
95
  requirements:
119
96
  - - ">="
120
97
  - !ruby/object:Gem::Version
121
- hash: 3
122
- segments:
123
- - 0
124
98
  version: "0"
125
99
  requirements: []
126
100
 
127
101
  rubyforge_project:
128
- rubygems_version: 1.5.1
102
+ rubygems_version: 1.6.2
129
103
  signing_key:
130
104
  specification_version: 3
131
105
  summary: WebDAV handler for Rack