http_get: fix retries on broken connections
[omgdav.git] / test / test_readonly.rb
blobb0922fac3df3d53cf99f6c52a4ed3663a32957cb
1 # -*- encoding: binary -*-
2 # Copyright (C) 2012-2017 all contributors <omgdav-public@bogomips.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 require './test/integration'
5 class Test_ReadOnly < Minitest::Test
6   include TestMogileFSIntegration
8   def test_readonly
9     resp = @req.put("/foo", input: StringIO.new("HELLO"))
10     assert_equal 201, resp.status.to_i
12     @app = OMGDAV::App.new(@db, @mogc, methods: :ro)
13     @req = Rack::MockRequest.new(@app)
14     resp = @req.put("/foo", input: StringIO.new("GOODBYE"))
15     assert_equal 405, resp.status.to_i
16     status, _, body = req("GET", "/foo")
17     assert_equal 200, status.to_i
18     assert_equal "HELLO", body_string(body)
20     assert_equal 405, req("DELETE", "/foo")[0].to_i
21   end
22 end