Skip to content

Commit b9696df

Browse files
author
Sang Truong
committed
BUGFIX:MSF-22702 - Show error message if gd_encoded_params or gd_encoded_hidden_params is not specified
1 parent 0aba290 commit b9696df

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/gooddata/helpers/global_helpers_params.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def encode_hidden_params(params)
6161
def decode_params(params, options = {})
6262
key = ENCODED_PARAMS_KEY.to_s
6363
hidden_key = ENCODED_HIDDEN_PARAMS_KEY.to_s
64+
raise "Mandatory parameter '#{key}' or '#{hidden_key}' of type 'HashType' needs to be specified" if params[key].nil? && params[hidden_key].nil?
65+
6466
data_params = params[key] || '{}'
6567
hidden_data_params = if params.key?(hidden_key) && params[hidden_key].nil?
6668
"{\"#{hidden_key}\" : null}"

spec/unit/helpers/global_helpers_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
end
6363

6464
it 'should encode params and preserve the nil in hidden' do
65-
x = GoodData::Helpers.decode_params(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY.to_s => nil)
66-
expect(x).to eq("gd_encoded_hidden_params" => nil)
65+
x = GoodData::Helpers.decode_params(GoodData::Helpers::ENCODED_HIDDEN_PARAMS_KEY.to_s => nil, GoodData::Helpers::ENCODED_PARAMS_KEY.to_s => '{"d":{"b": "c"}}')
66+
expect(x).to eq({"d"=>{"b"=>"c"}, "gd_encoded_hidden_params"=>nil})
6767
end
6868

6969
it 'should encode params and preserve the nil in hidden' do

0 commit comments

Comments
 (0)