Sha256: 772a675e36a478234b70fafbea6a3f21145967656f7f71e1d711c791b5cb63a4

Contents?: true

Size: 1.78 KB

Versions: 6

Compression:

Stored size: 1.78 KB

Contents

require 'spec_helper'

describe "urls" do

  def job_should_match(array)
    Dragonfly::Response.should_receive(:new).with do |job, env|
      job.to_a.should == array
    end.and_return(double('response', :to_response => [200, {'Content-Type' => 'text/plain'}, ["OK"]]))
  end

  let (:app) {
    test_app.configure{
      processor(:thumb){}
      verify_urls false
    }
  }

  it "works with old marshalled urls (including with tildes in them)" do
    app.allow_legacy_urls = true
    url = "/BAhbBlsHOgZmSSIIPD4~BjoGRVQ"
    job_should_match [["f", "<>?"]]
    response = request(app, url)
  end

  it "blows up if it detects bad objects" do
    app.allow_legacy_urls = true
    url = "/BAhvOhpEcmFnb25mbHk6OlRlbXBPYmplY3QIOgpAZGF0YUkiCWJsYWgGOgZFVDoXQG9yaWdpbmFsX2ZpbGVuYW1lMDoKQG1ldGF7AA"
    Dragonfly::Job.should_not_receive(:from_a)
    response = request(app, url)
    response.status.should == 404
  end

  it "works with the '%2B' character" do
    url = "/W1siZiIsIjIwMTIvMTEvMDMvMTdfMzhfMDhfNTc4X19NR181ODk5Xy5qcGciXSxbInAiLCJ0aHVtYiIsIjQ1MHg0NTA%2BIl1d/_MG_5899+.jpg"
    job_should_match [["f", "2012/11/03/17_38_08_578__MG_5899_.jpg"], ["p", "thumb", "450x450>"]]
    response = request(app, url)
  end

  it "works when '%2B' has been converted to + (e.g. with nginx)" do
    url = "/W1siZiIsIjIwMTIvMTEvMDMvMTdfMzhfMDhfNTc4X19NR181ODk5Xy5qcGciXSxbInAiLCJ0aHVtYiIsIjQ1MHg0NTA+Il1d/_MG_5899+.jpg"
    job_should_match [["f", "2012/11/03/17_38_08_578__MG_5899_.jpg"], ["p", "thumb", "450x450>"]]
    response = request(app, url)
  end

  it "works with potentially tricky url characters for the url" do
    url = app.fetch('uid []=~/+').url(:name => 'name []=~/+')
    url.should =~ %r(^/[\w%]+/name%20%5B%5D%3D%7E%2F%2B$)
    job_should_match [["f", "uid []=~/+"]]
    response = request(app, url)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dragonfly-1.0.12 spec/functional/urls_spec.rb
dragonfly-1.0.11 spec/functional/urls_spec.rb
dragonfly-1.0.10 spec/functional/urls_spec.rb
dragonfly-1.0.9 spec/functional/urls_spec.rb
dragonfly-1.0.8 spec/functional/urls_spec.rb
dragonfly-1.0.7 spec/functional/urls_spec.rb