2016-08-08 12:52:30 +02:00
|
|
|
shared_examples 'champ_spec' do
|
2022-10-17 10:38:23 +02:00
|
|
|
describe 'mandatory_blank?' do
|
2018-02-13 17:00:19 +01:00
|
|
|
let(:type_de_champ) { build(:type_de_champ, mandatory: mandatory) }
|
2020-07-20 17:18:44 +02:00
|
|
|
let(:champ) { build(:champ, type_de_champ: type_de_champ, value: value) }
|
2017-03-29 13:37:07 +02:00
|
|
|
let(:value) { '' }
|
|
|
|
let(:mandatory) { true }
|
|
|
|
|
|
|
|
context 'when mandatory and blank' do
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(true) }
|
2017-03-29 13:37:07 +02:00
|
|
|
end
|
|
|
|
|
2018-10-22 14:17:30 +02:00
|
|
|
context 'when carte mandatory and blank' do
|
|
|
|
let(:type_de_champ) { build(:type_de_champ_carte, mandatory: mandatory) }
|
2021-07-21 10:45:59 +02:00
|
|
|
let(:champ) { build(:champ_carte, type_de_champ: type_de_champ, value: value) }
|
|
|
|
let(:value) { nil }
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(true) }
|
2018-10-22 14:17:30 +02:00
|
|
|
end
|
2021-03-18 14:44:14 +01:00
|
|
|
|
|
|
|
context 'when multiple_drop_down_list mandatory and blank' do
|
|
|
|
let(:type_de_champ) { build(:type_de_champ_multiple_drop_down_list, mandatory: mandatory) }
|
2021-07-21 10:45:59 +02:00
|
|
|
let(:champ) { build(:champ_multiple_drop_down_list, type_de_champ: type_de_champ, value: value) }
|
2021-03-18 14:44:14 +01:00
|
|
|
let(:value) { '[]' }
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(true) }
|
2021-03-18 14:44:14 +01:00
|
|
|
end
|
2021-07-21 10:45:59 +02:00
|
|
|
|
|
|
|
context 'when repetition blank' do
|
|
|
|
let(:type_de_champ) { build(:type_de_champ_repetition) }
|
|
|
|
let(:champ) { build(:champ_repetition, type_de_champ: type_de_champ, rows: 0) }
|
|
|
|
|
|
|
|
it { expect(champ.blank?).to be(true) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when repetition not blank' do
|
2022-11-30 12:05:27 +01:00
|
|
|
let(:type_de_champ) { build(:type_de_champ_repetition, :with_types_de_champ, procedure: build(:procedure)) }
|
2021-07-21 10:45:59 +02:00
|
|
|
let(:champ) { build(:champ_repetition, type_de_champ: type_de_champ) }
|
|
|
|
|
|
|
|
it { expect(champ.blank?).to be(false) }
|
|
|
|
end
|
2018-10-22 14:17:30 +02:00
|
|
|
|
2017-03-29 13:37:07 +02:00
|
|
|
context 'when not blank' do
|
|
|
|
let(:value) { 'yop' }
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(false) }
|
2017-03-29 13:37:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not mandatory' do
|
|
|
|
let(:mandatory) { false }
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(false) }
|
2017-03-29 13:37:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not mandatory or blank' do
|
|
|
|
let(:value) { 'u' }
|
|
|
|
let(:mandatory) { false }
|
2022-10-17 10:38:23 +02:00
|
|
|
it { expect(champ.mandatory_blank?).to be(false) }
|
2017-03-29 13:37:07 +02:00
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|