Skip to content

Commit

Permalink
fixed a bug where context_locals could be nil + spec
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperionel committed May 11, 2016
1 parent d4a8088 commit 15c1516
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/error_store/interfaces/frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def sanitize_data(data)
function = nil if function == '?'

context_locals = data[:vars]
context_locals = if context_locals.is_a?(Array)
Hash[context_locals]
elsif !context_locals.is_a?(Hash)
{}
end
if context_locals.is_a?(Array)
context_locals = Hash[context_locals]
elsif !context_locals.is_a?(Hash)
context_locals = {}
end

context_locals = trim_hash(context_locals) do |result|
handle_nan(result)
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/error_store/interfaces/frame_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
expect( subject._data[:vars] ).to eq({})
end

it 'does not change the value of context_locals if its already a Hash' do
post_data[:vars] = { value: 'zoro' }
expect( subject._data[:vars] ).to eq( { value: 'zoro' } )
end

it 'trimps hash of context_locals' do
post_data[:vars] = generate_array(100)
expect( subject._data[:vars].length ).to eq(ErrorStore::MAX_HASH_ITEMS)
Expand Down

0 comments on commit 15c1516

Please sign in to comment.