2018-04-03 18:05:29 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-08-14 13:39:49 +02:00
|
|
|
describe 'shared/dossiers/map.html.haml', type: :view do
|
2018-04-03 18:05:29 +02:00
|
|
|
subject do
|
2018-08-14 13:39:49 +02:00
|
|
|
render(partial: 'shared/dossiers/map.html.haml', locals: { dossier: dossier })
|
2018-04-03 18:05:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "javascript variables printing" do
|
|
|
|
let(:dossier) { create(:dossier, :with_entreprise, json_latlngs: json_latlngs) }
|
|
|
|
|
|
|
|
context 'with a correct json' do
|
|
|
|
let(:json_latlngs) { "[[{\"lat\":50.659255436656736,\"lng\":3.080635070800781},{\"lat\":50.659255436656736,\"lng\":3.079690933227539},{\"lat\":50.659962770886516,\"lng\":3.0800342559814453},{\"lat\":50.659962770886516,\"lng\":3.0811500549316406},{\"lat\":50.659255436656736,\"lng\":3.080635070800781}]]" }
|
|
|
|
|
|
|
|
before { subject }
|
|
|
|
|
2018-07-12 11:50:47 +02:00
|
|
|
it { expect(rendered).to have_content('dossierJsonLatLngs: [[{"lat":50.659255436656736,"lng":3.080635070800781},{"lat":50.659255436656736,"lng":3.079690933227539},{"lat":50.659962770886516,"lng":3.0800342559814453},{"lat":50.659962770886516,"lng":3.0811500549316406},{"lat":50.659255436656736,"lng":3.080635070800781}]],') }
|
2018-04-03 18:05:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'without a correct json' do
|
|
|
|
let(:json_latlngs) { "dossier" }
|
|
|
|
|
|
|
|
before { subject }
|
|
|
|
|
2018-07-12 11:50:47 +02:00
|
|
|
it { expect(rendered).to have_content('dossierJsonLatLngs: {},') }
|
2018-04-03 18:05:29 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|