demarches-normaliennes/spec/models/champ_spec.rb

40 lines
1 KiB
Ruby
Raw Normal View History

2015-11-03 10:48:40 +01:00
require 'spec_helper'
describe Champ do
2015-11-03 10:48:40 +01:00
describe 'database columns' do
it { is_expected.to have_db_column(:value) }
end
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
2015-11-05 11:21:44 +01:00
it { is_expected.to belong_to(:type_de_champ) }
2015-11-03 10:48:40 +01:00
end
describe 'delegation' do
2015-11-05 11:21:44 +01:00
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
it { is_expected.to delegate_method(:type_champ).to(:type_de_champ) }
2015-11-05 11:21:44 +01:00
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
2015-11-03 10:48:40 +01:00
end
describe 'data_provide' do
let(:champ) { create :champ }
subject { champ.data_provide }
context 'when type_champ is datetime' do
before do
champ.type_de_champ = create :type_de_champ, type_champ: 'datetime'
end
it { is_expected.to eq 'datepicker' }
end
context 'when type_champ is address' do
before do
champ.type_de_champ = create :type_de_champ, type_champ: 'address'
end
it { is_expected.to eq 'typeahead' }
end
end
2015-11-03 10:48:40 +01:00
end