2018-04-23 11:57:54 +02:00
|
|
|
RSpec.describe EtablissementHelper, type: :helper do
|
2015-08-14 18:07:40 +02:00
|
|
|
let(:code_effectif) { '00' }
|
|
|
|
let(:raison_sociale) { 'GRTGaz' }
|
|
|
|
let(:nom) { 'mon nom' }
|
|
|
|
let(:prenom) { 'mon prenom' }
|
2015-08-20 17:30:17 +02:00
|
|
|
let(:entreprise_params) do
|
2015-08-14 18:07:40 +02:00
|
|
|
{
|
2018-04-23 11:57:54 +02:00
|
|
|
entreprise_capital_social: 123_000,
|
|
|
|
entreprise_code_effectif_entreprise: code_effectif,
|
|
|
|
entreprise_raison_sociale: raison_sociale,
|
|
|
|
entreprise_nom: nom,
|
|
|
|
entreprise_prenom: prenom
|
2015-08-14 18:07:40 +02:00
|
|
|
}
|
2015-08-20 17:30:17 +02:00
|
|
|
end
|
2018-04-23 11:57:54 +02:00
|
|
|
let(:etablissement) { create(:etablissement, entreprise_params) }
|
|
|
|
|
2015-08-14 18:07:40 +02:00
|
|
|
describe '#raison_sociale_or_name' do
|
2018-04-23 11:57:54 +02:00
|
|
|
subject { raison_sociale_or_name(etablissement) }
|
|
|
|
|
2015-08-14 18:07:40 +02:00
|
|
|
context 'when raison_sociale exist' do
|
|
|
|
let(:raison_sociale) { 'ma super raison_sociale' }
|
|
|
|
it 'display raison_sociale' do
|
|
|
|
expect(subject).to eq(raison_sociale)
|
|
|
|
end
|
|
|
|
end
|
2018-04-23 11:57:54 +02:00
|
|
|
|
2015-08-14 18:07:40 +02:00
|
|
|
context 'when raison_sociale is nil' do
|
|
|
|
let(:raison_sociale) { nil }
|
|
|
|
it 'display nom and prenom' do
|
2018-01-15 21:41:16 +01:00
|
|
|
expect(subject).to eq("#{nom} #{prenom}")
|
2015-08-14 18:07:40 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#effectif' do
|
2018-04-23 11:57:54 +02:00
|
|
|
subject { effectif(etablissement) }
|
|
|
|
|
2015-08-14 18:07:40 +02:00
|
|
|
context 'when code_effectif is 00' do
|
|
|
|
let(:code_effectif) { '01' }
|
|
|
|
it { is_expected.to eq('1 ou 2 salariés') }
|
|
|
|
end
|
2018-04-23 11:57:54 +02:00
|
|
|
|
2015-08-14 18:07:40 +02:00
|
|
|
context 'when code_effectif is 32' do
|
|
|
|
let(:code_effectif) { '32' }
|
|
|
|
it { is_expected.to eq('250 à 499 salariés') }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-23 11:57:54 +02:00
|
|
|
describe '#pretty_currency' do
|
|
|
|
subject { pretty_currency(etablissement.entreprise_capital_social) }
|
|
|
|
|
|
|
|
it { is_expected.to eq('123 000,00 €') }
|
2015-08-14 18:07:40 +02:00
|
|
|
end
|
2015-08-20 17:30:17 +02:00
|
|
|
end
|