2015-11-03 10:48:40 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-11-03 15:27:49 +01:00
|
|
|
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) }
|
2015-11-17 10:23:05 +01:00
|
|
|
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
|
2016-06-09 12:08:18 +02:00
|
|
|
|
|
|
|
describe 'data_provide' do
|
|
|
|
let(:champ) { create :champ }
|
|
|
|
|
|
|
|
subject { champ.data_provide }
|
|
|
|
|
|
|
|
context 'when type_champ is datetime' do
|
|
|
|
before do
|
2016-08-03 18:19:56 +02:00
|
|
|
champ.type_de_champ = create :type_de_champ_public, type_champ: 'datetime'
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to eq 'datepicker' }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when type_champ is address' do
|
|
|
|
before do
|
2016-08-03 18:19:56 +02:00
|
|
|
champ.type_de_champ = create :type_de_champ_public, type_champ: 'address'
|
2016-06-09 12:08:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to eq 'typeahead' }
|
|
|
|
end
|
|
|
|
end
|
2015-11-03 10:48:40 +01:00
|
|
|
end
|