RfCs: Allow filtering for any states

We want to differentiate between those RfCs explicitly marked as solved, those potentially solved since the author reached the maximum score, and those being unsolved where the author has not yet reached the full score yet.
This commit is contained in:
Sebastian Serth
2024-04-18 10:00:19 +02:00
committed by Dominic Sauer
parent d72139cf04
commit 7cc4fb00c6
6 changed files with 51 additions and 8 deletions

View File

@ -3,9 +3,8 @@
require 'rails_helper'
RSpec.describe RequestForComment do
let!(:rfc) { create(:rfc) }
describe 'scope with_comments' do
let!(:rfc) { create(:rfc) }
let!(:rfc2) { create(:rfc_with_comment) }
it 'includes all RfCs with comments' do
@ -16,4 +15,26 @@ RSpec.describe RequestForComment do
expect(described_class.with_comments).not_to include(rfc)
end
end
describe 'state' do
let!(:rfc_solved) { create(:rfc, solved: true) }
let!(:rfc_soft_solved) { create(:rfc, solved: false, full_score_reached: true) }
let!(:rfc_ongoing) { create(:rfc, solved: false, full_score_reached: false) }
it 'returns solved RfCs when solved state is requested' do
expect(described_class.state(RequestForComment::SOLVED)).to contain_exactly(rfc_solved)
end
it 'returns soft solved RfCs when soft solved state is requested' do
expect(described_class.state(RequestForComment::SOFT_SOLVED)).to contain_exactly(rfc_soft_solved)
end
it 'returns ongoing RfCs when ongoing state is requested' do
expect(described_class.state(RequestForComment::ONGOING)).to contain_exactly(rfc_ongoing)
end
it 'returns all RfCs when all state is requested' do
expect(described_class.state(RequestForComment::ALL)).to contain_exactly(rfc_solved, rfc_soft_solved, rfc_ongoing)
end
end
end