Sha256: 0cf232dde91e11822247223a0528e11657b30975e6137e8e7ad49bbf6036cee9

Contents?: true

Size: 1.64 KB

Versions: 90

Compression:

Stored size: 1.64 KB

Contents

require 'test/test_helper'
require 'rest-client'

class PostTest < Test::Unit::TestCase
  # Make sure you have a posttest.localhost in your /etc/hosts/
  def setup
    @url='http://posttest.localhost:10453/'
  end

  def teardown
  end

  def test_options
    RestClient.options(@url) do |response|
      assert_equal(response.code, 200)
      assert_equal(response.headers[:access_control_allow_origin],"*")
      assert_equal(response.headers[:access_control_allow_methods], "PUT, POST, HEAD, GET, OPTIONS")
      assert_equal(response.headers[:access_control_allow_headers], "Accept, Content-Type, Authorization, Content-Length, ETag, X-CSRF-Token")
      assert_equal(response.headers[:access_control_expose_headers], "ETag")
    end
  end

  def test_redirect
    res = RestClient.post(
      @url,
      'key'=>'uploads/12345/${filename}',
      'success_action_redirect'=>'http://somewhere.else.com/',
      'file'=>File.new(__FILE__,"rb")
    ) { |response|
      assert_equal(response.code, 307)
      assert_equal(response.headers[:location], 'http://somewhere.else.com/')
    }
  end

  def test_status_200
    res = RestClient.post(
      @url,
      'key'=>'uploads/12345/${filename}',
      'success_action_status'=>'200',
      'file'=>File.new(__FILE__,"rb")
    ) { |response|
      assert_equal(response.code, 200)
    }
  end

  def test_status_201
    res = RestClient.post(
      @url,
      'key'=>'uploads/12345/${filename}',
      'success_action_status'=>'201',
      'file'=>File.new(__FILE__,"rb")
    ) { |response|
      assert_equal(response.code, 201)
      assert_match(%r{^\<\?xml.*uploads/12345/post_test\.rb}m, response.body)
    }
  end

end

Version data entries

90 entries across 90 versions & 2 rubygems

Version Path
plntr-fakes3-1.0.0.pre.11alpha2 test/post_test.rb
plntr-fakes3-1.0.0.pre.11alpha1 test/post_test.rb
plntr-fakes3-1.0.0.pre.10 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha51 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha50 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha49 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha48 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha47 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha46 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha45 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha44 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha43 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha42 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha41 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha40 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha39 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha38 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha37 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha36 test/post_test.rb
plntr-fakes3-1.0.0.pre.10alpha35 test/post_test.rb