Skip to content

Commit

Permalink
Cleanup data setup for CreditNoteQuery tests
Browse files Browse the repository at this point in the history
  • Loading branch information
floganz committed Dec 19, 2024
1 parent cb458cc commit bd9043e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/queries/credit_notes_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ def call
credit_notes = paginate(credit_notes)
credit_notes = apply_consistent_ordering(credit_notes)

credit_notes = with_currency(credit_notes) if filters.currency
credit_notes = with_currency(credit_notes) if filters.currency.present?
credit_notes = with_customer_external_id(credit_notes) if filters.customer_external_id
credit_notes = with_customer_id(credit_notes) if filters.customer_id.present?
credit_notes = with_reason(credit_notes) if filters.reason.present?
credit_notes = with_credit_status(credit_notes) if filters.credit_status.present?
credit_notes = with_refund_status(credit_notes) if filters.refund_status.present?
credit_notes = with_invoice_number(credit_notes) unless filters.invoice_number.nil?
credit_notes = with_invoice_number(credit_notes) if filters.invoice_number.present?
credit_notes = with_issuing_date_range(credit_notes) if filters.issuing_date_from || filters.issuing_date_to
credit_notes = with_amount_range(credit_notes) if filters.amount_from || filters.amount_to
credit_notes = with_amount_range(credit_notes) if filters.amount_from.present? || filters.amount_to.present?

result.credit_notes = credit_notes
result
Expand Down
8 changes: 2 additions & 6 deletions spec/queries/credit_notes_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
described_class.call(organization:, search_term:, pagination:, filters:)
end

let(:membership) { create(:membership) }
let(:organization) { membership.organization }
let(:customer) { create(:customer, organization:) }
let(:organization) { customer.organization }
let(:customer) { create(:customer) }

let(:pagination) { nil }
let(:search_term) { nil }
Expand Down Expand Up @@ -307,7 +306,6 @@
let(:customer) do
create(
:customer,
organization:,
name: "Rick Sanchez",
firstname: "Rick Ramon",
lastname: "Sanchez Spencer"
Expand Down Expand Up @@ -344,7 +342,6 @@
let(:customer) do
create(
:customer,
organization:,
name: "Rick Sanchez",
firstname: "Rick Ramon",
lastname: "Sanchez Spencer"
Expand Down Expand Up @@ -383,7 +380,6 @@
let(:customer) do
create(
:customer,
organization:,
name: "Rick Sanchez",
firstname: "Rick Ramon",
lastname: "Sanchez Spencer"
Expand Down

0 comments on commit bd9043e

Please sign in to comment.