diff --git a/lib/gooddata/helpers/global_helpers_params.rb b/lib/gooddata/helpers/global_helpers_params.rb index 6b977e351..ef084ee09 100644 --- a/lib/gooddata/helpers/global_helpers_params.rb +++ b/lib/gooddata/helpers/global_helpers_params.rb @@ -61,6 +61,8 @@ def encode_hidden_params(params) def decode_params(params, options = {}) key = ENCODED_PARAMS_KEY.to_s hidden_key = ENCODED_HIDDEN_PARAMS_KEY.to_s + raise "Mandatory parameter '#{key}' or '#{hidden_key}' of type 'HashType' needs to be specified" if params[key].nil? && params[hidden_key].nil? + data_params = params[key] || '{}' hidden_data_params = if params.key?(hidden_key) && params[hidden_key].nil? "{\"#{hidden_key}\" : null}" diff --git a/spec/unit/helpers/global_helpers_spec.rb b/spec/unit/helpers/global_helpers_spec.rb index 1118a487c..4866956cb 100644 --- a/spec/unit/helpers/global_helpers_spec.rb +++ b/spec/unit/helpers/global_helpers_spec.rb @@ -62,8 +62,8 @@ end it 'should encode params and preserve the nil in hidden' do - x = GoodData::Helpers.decode_params(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY.to_s => nil) - expect(x).to eq("gd_encoded_hidden_params" => nil) + x = GoodData::Helpers.decode_params(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY.to_s => nil, GoodData::Helpers::ENCODED_PARAMS_KEY.to_s => '{"d":{"b": "c"}}') + expect(x).to eq({"d"=>{"b"=>"c"}, "gd_encoded_hidden_params"=>nil}) end it 'should encode params and preserve the nil in hidden' do