Improve testing setup
This commit is contained in:
@@ -5,47 +5,47 @@ require 'support/request_helpers'
|
||||
require 'support/examples/ext_mkcol'
|
||||
|
||||
RSpec.describe 'mkcol', type: :request do
|
||||
before(:all) do
|
||||
tmp_dir = Rails.root.join('../../tmp').to_path
|
||||
Dir.mkdir tmp_dir unless File.exist? tmp_dir
|
||||
|
||||
webdav_dir = Rails.root.join('../../tmp/webdav').to_path
|
||||
FileUtils.rm_r webdav_dir if File.exist? webdav_dir
|
||||
Dir.mkdir webdav_dir
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
skip_authentication
|
||||
end
|
||||
|
||||
it 'creates a collection with additional properties' do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:valid_resourcetypes
|
||||
).and_return(%w[collection special-resource])
|
||||
|
||||
expect(Dir).to receive(:mkdir).and_call_original
|
||||
expect_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:proppatch
|
||||
)
|
||||
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.body.empty?).to eq(true)
|
||||
expect(response.status).to eq(201)
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
end
|
||||
|
||||
context 'with an invalid resource type' do
|
||||
it 'returns an error response' do
|
||||
context "for #{Calligraphy::FileResource}" do
|
||||
it 'creates a collection with additional properties' do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:valid_resourcetypes
|
||||
).and_return(%w[collection special-resource])
|
||||
|
||||
expect(Dir).to receive(:mkdir).and_call_original
|
||||
expect_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:proppatch
|
||||
)
|
||||
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.body).to include('mkcol-response')
|
||||
expect(response.body).to include('valid-resourcetype')
|
||||
expect(response.body.empty?).to eq(true)
|
||||
expect(response.status).to eq(201)
|
||||
end
|
||||
|
||||
context 'with an invalid resource type' do
|
||||
it 'returns an error response' do
|
||||
mkcol '/webdav/special', headers: {
|
||||
RAW_POST_DATA: Support::Examples::ExtMkcol.rfc5689_3_4
|
||||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
expect(response.body).to include('mkcol-response')
|
||||
expect(response.body).to include('valid-resourcetype')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,48 +4,57 @@ require 'rails_helper'
|
||||
require 'support/request_helpers'
|
||||
|
||||
RSpec.describe 'OPTIONS', type: :request do
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
skip_authentication
|
||||
end
|
||||
|
||||
context 'when not using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(false)
|
||||
end
|
||||
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
|
||||
it 'does not advertise support for extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to_not include('extended-mkcol')
|
||||
end
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
end
|
||||
|
||||
context 'when using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(true)
|
||||
context "for #{Calligraphy::FileResource}" do
|
||||
context 'when not using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(false)
|
||||
end
|
||||
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
|
||||
it 'does not advertise support for extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to_not include('extended-mkcol')
|
||||
end
|
||||
end
|
||||
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
context 'when using extended MKCOL support' do
|
||||
before(:each) do
|
||||
allow_any_instance_of(Calligraphy::FileResource).to receive(
|
||||
:enable_extended_mkcol?
|
||||
).and_return(true)
|
||||
end
|
||||
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
it 'advertises support for all 3 WebDAV classes' do
|
||||
options '/webdav/special'
|
||||
|
||||
it 'advertises support for extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
%w[1 2 3].each { |c| expect(response.headers['DAV']).to include(c) }
|
||||
end
|
||||
|
||||
expect(response.headers['DAV']).to include('extended-mkcol')
|
||||
it 'advertises support for extended-mkcol' do
|
||||
options '/webdav/special'
|
||||
|
||||
expect(response.headers['DAV']).to include('extended-mkcol')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,25 +6,22 @@ require 'support/examples/propfind'
|
||||
require 'support/examples/proppatch'
|
||||
|
||||
RSpec.describe 'PROPFIND', type: :request do
|
||||
before(:all) do
|
||||
tmp_dir = Rails.root.join('../../tmp').to_path
|
||||
Dir.mkdir tmp_dir unless File.exist? tmp_dir
|
||||
|
||||
webdav_dir = Rails.root.join('../../tmp/webdav').to_path
|
||||
FileUtils.rm_r webdav_dir if File.exist? webdav_dir
|
||||
Dir.mkdir webdav_dir
|
||||
before(:context) do
|
||||
Calligraphy::FileResource.setup
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
allow(Calligraphy).to receive(:enable_digest_authentication)
|
||||
.and_return(false)
|
||||
skip_authentication
|
||||
end
|
||||
|
||||
after(:context) do
|
||||
Calligraphy::FileResource.cleanup
|
||||
end
|
||||
|
||||
context 'with xml defintiion' do
|
||||
before(:each) do
|
||||
put '/webdav/bar.html', headers: {
|
||||
RAW_POST_DATA: 'hello world'
|
||||
}
|
||||
Calligraphy::FileResource.create resource: 'bar.html'
|
||||
|
||||
proppatch '/webdav/bar.html', headers: {
|
||||
RAW_POST_DATA: Support::Examples::Proppatch.rfc4918_9_2_2
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user