Sha256: 958afe5b93454148bf32fb7d8bc96361f407c2f3d23f4699973048e254b2b5c5

Contents?: true

Size: 1.3 KB

Versions: 7

Compression:

Stored size: 1.3 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(:generate!) {
    Dorsale::BillingMachine::PdfFileGenerator.(quotation)
    quotation.reload
  }

  let(:content) {
    generate!
    PDF::Reader.new(quotation.pdf_file.path).pages.map(&:text).join("\n")
  }

  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
    quotation = ::Dorsale::BillingMachine::Quotation.new

    expect {
      described_class.new(quotation).tap(&:build).render_with_attachments
    }.to_not raise_error
  end

  describe "attachments" do
    let(:quotation) {
      quotation  = create(:billing_machine_quotation)
      attachment = create(:alexandrie_attachment, attachable: quotation)
      quotation
    }

    it "should build attachments" do
      expect(content).to include "page 1"
      expect(content).to include "page 2"
    end
  end # describe "attachments"
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dorsale-4.0.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.20.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.19.1 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.19.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.18.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.17.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb
dorsale-3.16.0 spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb