add types_de_champ_ordered in procedure

This commit is contained in:
Tanguy PATTE 2015-11-17 15:30:03 +01:00
parent 15033de455
commit e6136e17c3
2 changed files with 13 additions and 0 deletions

View file

@ -8,4 +8,8 @@ class Procedure < ActiveRecord::Base
validates :libelle, presence: true, allow_blank: false, allow_nil: false validates :libelle, presence: true, allow_blank: false, allow_nil: false
validates :description, presence: true, allow_blank: false, allow_nil: false validates :description, presence: true, allow_blank: false, allow_nil: false
def types_de_champ_ordered
types_de_champ.order(:order_place)
end
end end

View file

@ -36,4 +36,13 @@ describe Procedure do
it { is_expected.to allow_value('http://localhost').for(:lien_demarche) } it { is_expected.to allow_value('http://localhost').for(:lien_demarche) }
end end
end end
describe '#types_de_champ_ordered' do
let(:procedure) { create(:procedure) }
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 1) }
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 0) }
subject { procedure.types_de_champ_ordered }
it { expect(subject.first).to eq(type_de_champ_1) }
it { expect(subject.last).to eq(type_de_champ_0) }
end
end end