Change organisation sources for lib apicarto quartiersprioritaires

This commit is contained in:
Xavier J 2015-12-08 16:02:35 +01:00
parent 9f9e8ca176
commit e9145b031f
6 changed files with 8 additions and 8 deletions

View file

@ -67,7 +67,7 @@ class Users::CarteController < UsersController
coordinates.each_with_index do |coordinate, index|
coordinate = coordinates[index].map { |latlng| [latlng['lng'], latlng['lat']] }
qp = qp.merge CARTO::SGMAP::QuartierPrioritaireAdapter.new(coordinate).to_params
qp = qp.merge CARTO::SGMAP::QuartiersPrioritaires::Adapter.new(coordinate).to_params
end
qp

View file

@ -1,10 +1,10 @@
class CARTO::SGMAP::QuartierPrioritaireAdapter
class CARTO::SGMAP::QuartiersPrioritaires::Adapter
def initialize(coordinates)
@coordinates = GeojsonService.to_json_polygon(coordinates)
end
def data_source
@data_source ||= JSON.parse(CARTO::SGMAP::API.search_qp(@coordinates), symbolize_names: true)
@data_source ||= JSON.parse(CARTO::SGMAP::QuartiersPrioritaires::API.search_qp(@coordinates), symbolize_names: true)
end
def to_params

View file

@ -1,4 +1,4 @@
class CARTO::SGMAP::API
class CARTO::SGMAP::QuartiersPrioritaires::API
def initialize
end

View file

@ -87,7 +87,7 @@ RSpec.describe Users::CarteController, type: :controller do
describe 'Save quartier prioritaire' do
before do
allow_any_instance_of(CARTO::SGMAP::QuartierPrioritaireAdapter).
allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter).
to receive(:to_params).
and_return({"QPCODE1234" => {:code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})
@ -182,7 +182,7 @@ RSpec.describe Users::CarteController, type: :controller do
describe 'POST #get_qp' do
before do
allow_any_instance_of(CARTO::SGMAP::QuartierPrioritaireAdapter).
allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter).
to receive(:to_params).
and_return({"QPCODE1234" => {:code => "QPCODE1234", :geometry => {:type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]]}}})

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe CARTO::SGMAP::QuartierPrioritaireAdapter do
describe CARTO::SGMAP::QuartiersPrioritaires::Adapter do
subject { described_class.new(coordinates).to_params }
before do

View file

@ -1,6 +1,6 @@
require 'spec_helper'
describe CARTO::SGMAP::API do
describe CARTO::SGMAP::QuartiersPrioritaires::API do
describe '.search_qp' do
subject { described_class.search_qp(geojson) }