Skip to content

Commit

Permalink
fix specs for memoiazed participants_submissions method
Browse files Browse the repository at this point in the history
  • Loading branch information
alhajrahmoun committed Oct 7, 2023
1 parent 2c06c24 commit 02591fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/duel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initial_state
end

def participants_submissions
@participants_submissions ||= submissions.where(user: users)
@participants_submissions ||= submissions
end

def user_state(user)
Expand Down
6 changes: 5 additions & 1 deletion spec/models/duel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
end

describe '#user_state' do
let!(:user) { create(:user) }
let!(:duel) { create(:duel) }
let(:users) { duel.users }
let(:user) { users.first }
let!(:submissions) { create_list(:submission, 3, user: user, duel: duel) }

before { duel.submissions.reload }

it 'returns the current state for a given user' do
state = duel.user_state(user)

expect(state.points).to eq(30)
expect(state.submissions).to eq(3)
expect(state.correct_answers).to eq(3)
Expand Down

0 comments on commit 02591fa

Please sign in to comment.