Skip to content

Commit

Permalink
BUGFIX:MSF-22702 - Show error message if gd_encoded_params or gd_enco…
Browse files Browse the repository at this point in the history
…ded_hidden_params is not specified
  • Loading branch information
Sang Truong committed Jan 5, 2022
1 parent 0aba290 commit b9696df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/gooddata/helpers/global_helpers_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/helpers/global_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b9696df

Please sign in to comment.