Implement atomic operations on MapEditor
This commit is contained in:
parent
d3ea20968e
commit
05e408225b
9 changed files with 258 additions and 101 deletions
|
@ -18,6 +18,105 @@ describe Champs::CarteController, type: :controller do
|
|||
cadastres: true
|
||||
}).champ.create(dossier: dossier)
|
||||
end
|
||||
describe 'features' do
|
||||
let(:feature) { attributes_for(:geo_area, :polygon) }
|
||||
let(:geo_area) { create(:geo_area, :selection_utilisateur, :polygon, champ: champ) }
|
||||
let(:params) do
|
||||
{
|
||||
champ_id: champ.id,
|
||||
feature: feature
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
sign_in user
|
||||
request.accept = "application/json"
|
||||
request.content_type = "application/json"
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
before do
|
||||
post :create, params: params
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq 201 }
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
let(:params) do
|
||||
{
|
||||
champ_id: champ.id,
|
||||
id: geo_area.id,
|
||||
feature: feature
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
patch :update, params: params
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq 204 }
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
let(:params) do
|
||||
{
|
||||
champ_id: champ.id,
|
||||
id: geo_area.id
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
delete :destroy, params: params
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq 204 }
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
render_views
|
||||
|
||||
before do
|
||||
request.accept = "application/javascript"
|
||||
request.content_type = "application/javascript"
|
||||
end
|
||||
|
||||
context 'with cadastres update' do
|
||||
let(:params) do
|
||||
{
|
||||
champ_id: champ.id,
|
||||
cadastres: 'update'
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
get :index, params: params
|
||||
end
|
||||
|
||||
it {
|
||||
expect(response.status).to eq 200
|
||||
expect(response.body).to include("DS.fire('cadastres:update'")
|
||||
}
|
||||
end
|
||||
|
||||
context 'without cadastres update' do
|
||||
let(:params) do
|
||||
{
|
||||
champ_id: champ.id
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
get :index, params: params
|
||||
end
|
||||
|
||||
it {
|
||||
expect(response.status).to eq 200
|
||||
expect(response.body).not_to include("DS.fire('cadastres:update'")
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #show' do
|
||||
render_views
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue