diff --git a/spec/factories/widgets.rb b/spec/factories/widgets.rb index 1fc175fe5d..7808f626ab 100644 --- a/spec/factories/widgets.rb +++ b/spec/factories/widgets.rb @@ -8,6 +8,7 @@ FactoryGirl.define do order 1 type 'formula' title 'The Title' + source_id 'a0' options do { type: "formula", diff --git a/spec/requests/carto/api/widgets_controller_spec.rb b/spec/requests/carto/api/widgets_controller_spec.rb index 022a1fbd83..05370e3561 100644 --- a/spec/requests/carto/api/widgets_controller_spec.rb +++ b/spec/requests/carto/api/widgets_controller_spec.rb @@ -69,7 +69,7 @@ shared_context 'layer hierarchy' do title: 'the title', options: { 'a field' => 'first', 'another field' => 'second' }, order: nil, - source: nil, + source: { id: 'a0' }, style: { 'widget_style': { 'fill': 'wadus' } }) payload = { @@ -230,6 +230,12 @@ describe Carto::Api::WidgetsController do other_map.destroy end + it 'returns 422 if missing source' do + post_json widgets_url(user_domain: @user1.username, map_id: @map.id, map_layer_id: @widget.layer_id, api_key: @user1.api_key), widget_payload(source: nil), http_json_headers do |response| + response.status.should == 422 + end + end + it 'returns 403 if visualization is private and current user is not the owner' do post_json widgets_url(user_domain: @user2.username, map_id: @map.id, map_layer_id: @widget.layer_id, api_key: @user2.api_key), widget_payload, http_json_headers do |response| response.status.should == 403