Sha256: 168c38e280f0a995f1da66c048699839cc877fa7bf9554494b481586f049ccee

Contents?: true

Size: 1.53 KB

Versions: 7

Compression:

Stored size: 1.53 KB

Contents

require File.expand_path("../spec_helper.rb", File.dirname(__FILE__))

describe Prawnto::CompileSupport do
  
  before do
    @request = mock()
    @request.stubs(:ssl?).returns(false)
    @headers = mock()
    @controller = mock()
    @controller.stubs(:request).returns(@request)
    @controller.stubs(:headers).returns(@headers)
    @controller.stubs(:compute_prawnto_options).returns({:inline => true})
  end

  describe "#set_disposition" do
    before do
      Prawnto::CompileSupport.any_instance.stubs(:set_pragma).returns(true)
      Prawnto::CompileSupport.any_instance.stubs(:set_cache_control).returns(true)
      Prawnto::CompileSupport.any_instance.stubs(:set_content_type).returns(Mime::PDF)
    end
    
    it "default" do
      @headers.expects("[]=").with("Content-Disposition", "inline").once
      Prawnto::CompileSupport.new(@controller)
    end

    it "inline with filename" do
      @controller.stubs(:compute_prawnto_options).returns({:filename => "xxx.pdf", :inline => true})
      @headers.expects("[]=").with("Content-Disposition", "inline;filename=\"xxx.pdf\"").once
      Prawnto::CompileSupport.new(@controller)
    end
    
    it "attachment with filename" do
      @controller.stubs(:compute_prawnto_options).returns({:filename => "xxx.pdf", :inline => false})
      @headers.expects("[]=").with("Content-Disposition", "attachment;filename=\"xxx.pdf\"").once
      Prawnto::CompileSupport.new(@controller)
    end

  end
  
  describe "#set_pragma" do
    pending
  end
  
  describe "#set_cache_control" do
    pending
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
prawnto_2-0.2.3 spec/units/compile_support_spec.rb
prawnto_2-0.2.2 spec/units/compile_support_spec.rb
prawnto_2-0.2.1 spec/units/compile_support_spec.rb
prawnto_2-0.2.0 spec/units/compile_support_spec.rb
prawnto_2-0.2.0.beta6 spec/units/compile_support_spec.rb
prawnto_2-0.2.0.beta4 spec/units/compile_support_spec.rb
prawnto_2-0.2.0.beta3 spec/units/compile_support_spec.rb