Sha256: 20b17e99a1d82e1d8fbfdbca89c18ddf4df57331b19156b2cc529a003ecfc174

Contents?: true

Size: 1.36 KB

Versions: 53

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe "remote on-the-fly urls" do
  
  THUMBS = {}
  
  before(:each) do
    @app = test_app.configure do |c|
      c.generator.add :test do
        "TEST"
      end
      c.server.before_serve do |job, env|
        uid = job.store(:path => 'yay.txt')
        THUMBS[job.serialize] = uid
      end
      c.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
      c.datastore = Dragonfly::DataStorage::FileDataStore.new
      c.datastore.root_path = 'tmp/dragonfly_test_urls'
      c.datastore.server_root = 'tmp'
    end
    @job = @app.generate(:test)
  end

  after(:each) do
    THUMBS.delete_if{true}
    FileUtils.rm_f('tmp/dragonfly_test_urls/yay.txt')
  end
  
  it "should give the url for the server" do
    @job.url.should == "/#{@job.serialize}"
  end
  
  it "should store the content when first called" do
    File.exist?('tmp/dragonfly_test_urls/yay.txt').should be_false
    @app.server.call('PATH_INFO' => @job.url, 'REQUEST_METHOD' => 'GET')
    File.read('tmp/dragonfly_test_urls/yay.txt').should == 'TEST'
  end

  it "should point to the external url the second time" do
    @app.server.call('PATH_INFO' => @job.url, 'REQUEST_METHOD' => 'GET')
    @job.url.should == '/dragonfly_test_urls/yay.txt'
  end

end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.7.4 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.7.3 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.7.2 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.7.1 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.7.0 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
dragonfly-0.9.15 spec/functional/remote_on_the_fly_spec.rb
dragonfly-0.9.14 spec/functional/remote_on_the_fly_spec.rb
dragonfly-0.9.13 spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.9 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.8 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.7 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.6 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.5 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.4 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.3 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.2 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.1 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.6.0 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb
classiccms-0.5.17 vendor/bundle/gems/dragonfly-0.9.12/spec/functional/remote_on_the_fly_spec.rb