|
|
|
|
@ -24,4 +24,55 @@ RSpec.describe TermsOfService do
|
|
|
|
|
expect(subject.pluck(:id)).to match_array(user_before.id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe '::current' do
|
|
|
|
|
context 'when no terms exist' do
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(described_class.current).to be_nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when only unpublished terms exist' do
|
|
|
|
|
before do
|
|
|
|
|
yesterday = Date.yesterday
|
|
|
|
|
travel_to yesterday do
|
|
|
|
|
Fabricate(:terms_of_service, published_at: nil, effective_date: yesterday)
|
|
|
|
|
end
|
|
|
|
|
Fabricate(:terms_of_service, published_at: nil, effective_date: Date.tomorrow)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
|
expect(described_class.current).to be_nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when both effective and future terms exist' do
|
|
|
|
|
let!(:effective_terms) do
|
|
|
|
|
yesterday = Date.yesterday
|
|
|
|
|
travel_to yesterday do
|
|
|
|
|
Fabricate(:terms_of_service, effective_date: yesterday)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
Fabricate(:terms_of_service, effective_date: Date.tomorrow)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the effective terms' do
|
|
|
|
|
expect(described_class.current).to eq effective_terms
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when only future terms exist' do
|
|
|
|
|
let!(:upcoming_terms) { Fabricate(:terms_of_service, effective_date: Date.tomorrow) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
Fabricate(:terms_of_service, effective_date: 10.days.since)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns the terms that are upcoming next' do
|
|
|
|
|
expect(described_class.current).to eq upcoming_terms
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|