Sha256: 58e4f2cf5ee47501069b65eb15aa03426ae44555103241297b6f9b8c07da82ed

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe "remote on-the-fly urls" do

  before(:each) do
    @thumbs = thumbs = {}
    @app = test_app.configure do
      generator :test do |content|
        content.update("TEST")
      end
      before_serve do |job, env|
        uid = job.store(:path => 'yay.txt')
        thumbs[job.serialize] = uid
      end
      define_url do |app, job, opts|
        uid = thumbs[job.serialize]
        if uid
          app.datastore.url_for(uid)
        else
          app.server.url_for(job)
        end
      end
      datastore :file,
        :root_path => 'tmp/dragonfly_test_urls',
        :server_root => 'tmp'
    end
    @job = @app.generate(:test)
  end

  after(:each) do
    FileUtils.rm_f('tmp/dragonfly_test_urls/yay.txt')
  end

  it "should give the url for the server" do
    @job.url.should == "/#{@job.serialize}?sha=#{@job.sha}"
  end

  it "should store the content when first called" do
    File.exist?('tmp/dragonfly_test_urls/yay.txt').should be_falsey
    request(@app, @job.url)
    File.read('tmp/dragonfly_test_urls/yay.txt').should == 'TEST'
  end

  it "should point to the external url the second time" do
    request(@app, @job.url)
    @job.url.should == '/dragonfly_test_urls/yay.txt'
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
dragonfly-1.4.1 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.4.0 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.3.0 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.2.1 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.2.0 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.5 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.4 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.3 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.2 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.1 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.1.0 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.0.12 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.0.11 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.0.10 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.0.9 spec/functional/remote_on_the_fly_spec.rb
dragonfly-1.0.8 spec/functional/remote_on_the_fly_spec.rb