demarches-normaliennes/spec/models/champ_spec.rb
2016-06-09 12:08:18 +02:00

40 lines
No EOL
1 KiB
Ruby

require 'spec_helper'
describe Champ do
describe 'database columns' do
it { is_expected.to have_db_column(:value) }
end
describe 'associations' do
it { is_expected.to belong_to(:dossier) }
it { is_expected.to belong_to(:type_de_champ) }
end
describe 'delegation' do
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
it { is_expected.to delegate_method(:type_champ).to(:type_de_champ) }
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
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
end