How can I test a scope of my Subscription model.
class Subscription < ApplicationRecord
has_many invoices, as invoiceable
scope :total, -> { joins(:invoices).where(invoices: Invoice.month(2.month.ago)).where.not(invoices: Invoice.month(1.month.ago)) }
end
These are the fields of invoice
t.string "invoiceable_type"
t.bigint "invoiceable_id"
t.string "status", default: "draft"
t.string "number"
t.string "period"
The scope takes the subcriptions that has invoices two month ago, but has not invoice last month.
Aucun commentaire:
Enregistrer un commentaire