Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HashWithIndifferent access for props threw #1100

Merged
merged 1 commit into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ before_install:

install:
- travis_retry gem install bundler
- travis_retry nvm install 9.11.1
- travis_retry nvm install 8.11.3
- node -v
- travis_retry npm i -g yarn@0.27.5
- travis_retry npm i -g yarn
- travis_retry yarn global add babel-cli
- travis_retry bundle install
- travis_retry yarn
Expand Down
2 changes: 1 addition & 1 deletion lib/react_on_rails/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def server_render_js(js_expression, options = {})

def json_safe_and_pretty(hash_or_string)
return "{}" if hash_or_string.nil?
unless hash_or_string.class.in?([Hash, String])
unless hash_or_string.is_a?(String) || hash_or_string.is_a?(Hash)
raise ReactOnRails::Error, "#{__method__} only accepts String or Hash as argument "\
"(#{hash_or_string.class} given)."
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: ../..
specs:
react_on_rails (11.0.6)
react_on_rails (11.0.7)
addressable
connection_pool
execjs (~> 2.5)
Expand Down Expand Up @@ -350,4 +350,4 @@ DEPENDENCIES
webpacker

BUNDLED WITH
1.16.1
1.16.2
10 changes: 10 additions & 0 deletions spec/dummy/spec/helpers/react_on_rails_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@
expect { helper.json_safe_and_pretty(false) }.to raise_error
end

it "should return empty json when an empty Hash" do
escaped_json = helper.json_safe_and_pretty({})
expect(escaped_json).to eq("{}")
end

it "should return empty json when an empty HashWithIndifferentAccess" do
escaped_json = helper.json_safe_and_pretty(HashWithIndifferentAccess.new)
expect(escaped_json).to eq("{}")
end

it "should return empty json when nil" do
escaped_json = helper.json_safe_and_pretty(nil)
expect(escaped_json).to eq("{}")
Expand Down
Loading