demarches-normaliennes/spec/models/etablissement_spec.rb
2019-02-13 19:22:38 +01:00

60 lines
1.8 KiB
Ruby

require 'spec_helper'
describe Etablissement do
describe '#geo_adresse' do
let(:etablissement) { create(:etablissement) }
subject { etablissement.geo_adresse }
it { is_expected.to eq '6 RUE RAOUL NORDLING IMMEUBLE BORA 92270 BOIS COLOMBES' }
end
describe '#inline_adresse' do
let(:etablissement) { create(:etablissement, nom_voie: 'green moon') }
it { expect(etablissement.inline_adresse).to eq '6 RUE green moon, IMMEUBLE BORA, 92270 BOIS COLOMBES' }
context 'with missing complement adresse' do
let(:expected_adresse) { '6 RUE RAOUL NORDLING, 92270 BOIS COLOMBES' }
subject { etablissement.inline_adresse }
context 'when blank' do
let(:etablissement) { create(:etablissement, complement_adresse: '') }
it { is_expected.to eq expected_adresse }
end
context 'when whitespace' do
let(:etablissement) { create(:etablissement, complement_adresse: ' ') }
it { is_expected.to eq expected_adresse }
end
context 'when nil' do
let(:etablissement) { create(:etablissement, complement_adresse: nil) }
it { is_expected.to eq expected_adresse }
end
end
end
describe '#verify' do
let(:etablissement) { create(:etablissement) }
let(:etablissement2) { create(:etablissement) }
it 'should verify signed etablissement' do
etablissement.signature = etablissement.sign
expect(etablissement.verify).to eq(true)
end
it 'should reject etablissement with other etablissement signature' do
etablissement.signature = etablissement2.sign
expect(etablissement.verify).to eq(false)
end
it 'should reject etablissement with wrong signature' do
etablissement.signature = "fd7687fdsgdf6gd7f8g"
expect(etablissement.verify).to eq(false)
end
end
end