[#2741] Expand unit tests for sorted_ids just to be sure
This commit is contained in:
parent
37fb358bd5
commit
c652cf3ae5
1 changed files with 25 additions and 7 deletions
|
@ -257,18 +257,36 @@ describe ProcedurePresentation do
|
|||
|
||||
context 'for self table' do
|
||||
let(:table) { 'self' }
|
||||
let(:column) { 'updated_at' } # All other columns work the same, no extra test required
|
||||
let(:order) { 'asc' } # Desc works the same, no extra test required
|
||||
|
||||
let(:recent_dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:older_dossier) { create(:dossier, procedure: procedure) }
|
||||
context 'for created_at column' do
|
||||
let(:column) { 'created_at' }
|
||||
let!(:recent_dossier) { Timecop.freeze(DateTime.new(2018, 10, 17)) { create(:dossier, procedure: procedure) } }
|
||||
let!(:older_dossier) { Timecop.freeze(DateTime.new(2003, 11, 11)) { create(:dossier, procedure: procedure) } }
|
||||
|
||||
before do
|
||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
end
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
context 'for en_construction_at column' do
|
||||
let(:column) { 'en_construction_at' }
|
||||
let!(:recent_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2018, 10, 17)) }
|
||||
let!(:older_dossier) { create(:dossier, :en_construction, procedure: procedure, en_construction_at: DateTime.new(2013, 1, 1)) }
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
end
|
||||
|
||||
context 'for updated_at column' do
|
||||
let(:column) { 'updated_at' }
|
||||
let(:recent_dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:older_dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
before do
|
||||
recent_dossier.touch(time: DateTime.new(2018, 9, 25))
|
||||
older_dossier.touch(time: DateTime.new(2018, 5, 13))
|
||||
end
|
||||
|
||||
it { is_expected.to eq([older_dossier, recent_dossier].map(&:id)) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'for type_de_champ table' do
|
||||
|
|
Loading…
Reference in a new issue