Sha256: f046525b0fa3e92ece012dd6431ce995885e3d8fe2a87d0028531e15e09e5226

Contents?: true

Size: 989 Bytes

Versions: 3

Compression:

Stored size: 989 Bytes

Contents

require 'test_helper'
require 'rack/mock'
require File.expand_path(File.dirname(__FILE__)) + '/../lib/app/middleware/plupload_params_renamer'

class PluploadRails3Test < ActiveSupport::TestCase
  #include Rack::Test::Methods
  setup do
    app = lambda { |env|
          req = Rack::Request.new(env)
          [200, {'Content-Type' => 'text/plain'}, [req.params.inspect]]
        }
    @app = PluploadParamsRenamer.new(app)
  end
  
  test "should not modify params on post without _plupload_upload" do
    params = {'some_param' => 'somevalue'}
    response = Rack::MockRequest.new(@app).post('/', :params=>params)
    
    assert_equal response.body, params.inspect
  end
  
  test "should create new param based on value of _plupload_upload" do
    params = {'_plupload_upload' => 'method[object]', 'file' => 'original_value'}
    response = Rack::MockRequest.new(@app).post('/', :params=>params)
    
    assert_match /"method"=>{"object"=>"original_value"}/, response.body
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
plupload-rails3-0.0.7 test/plupload_rails3_test.rb
plupload-rails3-0.0.5 test/plupload_rails3_test.rb
plupload-rails3-0.0.4 test/plupload_rails3_test.rb