models: require belong_to associations on champ
- Make `champ.dossier` a requirement; - Move the dossier_id assignation to `before_validation` (otherwise the record is invalid, and never gets saved); - Allow specs to only build the champ (instead of saving it to the database), which bypasses the requirement to have a dossier.
This commit is contained in:
parent
eb22dc9d8f
commit
6328011f60
13 changed files with 318 additions and 274 deletions
|
@ -1,7 +1,7 @@
|
|||
shared_examples 'champ_spec' do
|
||||
describe 'mandatory_and_blank?' do
|
||||
let(:type_de_champ) { build(:type_de_champ, mandatory: mandatory) }
|
||||
let(:champ) { type_de_champ.champ.build(value: value) }
|
||||
let(:champ) { build(:champ, type_de_champ: type_de_champ, value: value) }
|
||||
let(:value) { '' }
|
||||
let(:mandatory) { true }
|
||||
|
||||
|
@ -33,8 +33,7 @@ shared_examples 'champ_spec' do
|
|||
end
|
||||
|
||||
context "when type_champ=date" do
|
||||
let(:type_de_champ) { create(:type_de_champ_date) }
|
||||
let(:champ) { type_de_champ.champ.create }
|
||||
let(:champ) { build(:champ_date) }
|
||||
|
||||
it "should convert %d/%m/%Y format to ISO" do
|
||||
champ.value = "31/12/2017"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue