Skip to content

Commit

Permalink
Ensure credit_spec fails
Browse files Browse the repository at this point in the history
For the tests to fail as expected, the user and organisation test subjects
need to be created after their related credits. To ensure this, I have used
the eager loading `let!`.
  • Loading branch information
codeandclay committed Feb 22, 2024
1 parent 0d64806 commit c93f6c2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/models/credit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
it { is_expected.to belong_to(:purchase).optional }

context "when caching counters" do
let(:user_credits) { create_list(:credit, 2, user: user) }
let(:org_credits) { create_list(:credit, 1, organization: organization) }
let!(:user_credits) { create_list(:credit, 2, user: user) }
let!(:org_credits) { create_list(:credit, 1, organization: organization) }

describe "#credits_count" do
it "counts credits for user" do
Expand Down

0 comments on commit c93f6c2

Please sign in to comment.