Sha256: 4d2733b36f686e1a58093de95731b26be7dfb342ce46463ba53bb7f0ba274190

Contents?: true

Size: 1.34 KB

Versions: 18

Compression:

Stored size: 1.34 KB

Contents

require "rails_helper"

describe ::Dorsale::BillingMachine::QuotationSingleVatPdf, pdfs: true do
  before :each do
    ::Dorsale::BillingMachine.vat_mode = :single
  end

  let(:quotation) {
    q = create(:billing_machine_quotation)

    create(:billing_machine_quotation_line,
      :quotation => q,
      :vat_rate  => 19.6,
    )

    q
  }

  let(:pdf) {
    quotation.pdf
  }

  let(:content) {
    tempfile = Tempfile.new("pdf")
    tempfile.binmode
    tempfile.write(pdf.render)
    tempfile.flush
    Yomu.new(tempfile.path).text
  }

  it "should display global vat rate" do
    expect(content).to include "TVA 19,60 %"
    expect(content).to_not include "MONTANT TVA"
    expect(content).to_not include "TVA %"
  end

  it "should work with empty quotation" do
    id_card = Dorsale::BillingMachine::IdCard.new
    quotation = ::Dorsale::BillingMachine::Quotation.new(id_card: id_card)

    expect {
      quotation.pdf.render
    }.to_not raise_error
  end

  describe "attachment" do
    it "should build attachments" do
      quotation  = create(:billing_machine_quotation)
      attachment = create(:alexandrie_attachment, attachable: quotation)
      pdf = quotation.pdf
      pdf.build

      text = Yomu.read(:text, pdf.render_with_attachments).split("\n")
      expect(text).to include "page 1"
      expect(text).to include "page 2"
    end
  end

end



Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dorsale-3.0.3 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.0.2 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.0.1 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.0.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.7.3 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.7.2 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.7.1 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.7.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.8 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.7 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.6 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.5 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.4 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.3 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.2 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.1 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.6.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-2.5.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb