Improve json conversion with tests and support for older Rails 3.x#787
Improve json conversion with tests and support for older Rails 3.x#787cheremukhin23 wants to merge 10 commits intoshakacode:masterfrom
Conversation
|
Looking great! Reviewed 1 of 2 files at r1, 1 of 1 files at r2. app/helpers/react_on_rails_helper.rb, line 223 at r2 (raw file):
Can we throw here if the value passed is not a hash or a string? What else could the value be? app/helpers/react_on_rails_helper.rb, line 231 at r2 (raw file):
Can we move this catch block around the JSON.parse above? we can do something like: hash_value = if hash_or_string.is_a?(String)
begin
JSON.parse(hash_or_string)
rescue JSON::ParserError => e
raise e, %(Cannot parse #{hash_or_string} \n Backtrace: #{e.backtrace.join("\n")})
else
hash_or_string
end app/helpers/react_on_rails_helper.rb, line 242 at r2 (raw file):
Can you provide a comment with a link on to the github source of this? spec/dummy/spec/helpers/react_on_rails_helper_spec.rb, line 40 at r2 (raw file):
Can we add a couple tests that confirm the exceptions:
Also, we're never testing the part where we check we're in development mode. I'd try to mock/stub out the Rails.env for that test. # RSpec version
it 'tests my code' do
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
# test code
endComments from Reviewable |
|
See note below. I might just release a temp patch on this. Review status: all files reviewed at latest revision, 5 unresolved discussions. app/helpers/react_on_rails_helper.rb, line 224 at r2 (raw file):
djudji [1:57 AM] [1:59] djudji [3:31 AM] djudji [3:53 AM] [3:55] [3:56] justin [8:16 AM] djudji [9:49 AM] OK, this is a bit strange.
Now everything is working fine in production, but in dev I still have the same error. This is the URL -> https://calendar-react-on-rails.herokuapp.com/ I can confirm that both of the apps work when pushed to production. This is the first URL -> https://calendar-railsreact.herokuapp.com/ (edited the error is in the conversion to the pretty JSON… for development mode. Before, we used to call: |
|
Note #789 is removing the pretty formatting. We can add it back in... |
|
@cheremukhin23 I thought more about the pretty formatting of json. Let's add a configuration flag for this, since it tends to break... Default is false. # Pretty printing props looks nice when you view the page source. However, if you have a large
# amount of props data, the page rendering can be a little slower.
config.pretty_print_props_in_development = false |
|
See #791. I fixed another critical bug... |
|
See #799 |
…into improve-json-safe-and-pretty # Conflicts: # app/helpers/react_on_rails_helper.rb
|
Review status: 0 of 2 files reviewed at latest revision, 5 unresolved discussions. app/helpers/react_on_rails_helper.rb, line 223 at r2 (raw file): Previously, justin808 (Justin Gordon) wrote…
We discard this code app/helpers/react_on_rails_helper.rb, line 224 at r2 (raw file): Previously, justin808 (Justin Gordon) wrote…
discarded code app/helpers/react_on_rails_helper.rb, line 242 at r2 (raw file): Previously, justin808 (Justin Gordon) wrote…
added link spec/dummy/spec/helpers/react_on_rails_helper_spec.rb, line 40 at r2 (raw file): Previously, justin808 (Justin Gordon) wrote…
added test for arguments Comments from Reviewable |
|
We need to fix this deprecation for React. |
|
Looking good:
Reviewed 2 of 2 files at r3. app/helpers/react_on_rails_helper.rb, line 234 at r3 (raw file):
I think this not right. What if the Rails version is "10.0". Please google for a proper version comparator. Something like this (you creating the Comments from Reviewable |
|
@cheremukhin23 See comment: #799 (comment) |
|
@cheremukhin23 @squadette Maybe I should merge this one and let's add the feature in a new PR? |
|
please rebase on master and that should fix the CI, @cheremukhin23 |
…into improve-json-safe-and-pretty # Conflicts: # app/helpers/react_on_rails_helper.rb
|
See #812. |
…ails older than 4.1 (#812) * Improve json_safe_and_pretty method to handle parse error * Add tests to json_safe_and_pretty method * Add old json escape method for Rails versions less than 4 * Add json safe and pretty argument class test * Add rails version less than method * Add tests for json encoding helper methods * Move rails_version_less_than method into Utils module * Extract json escaping logic into JsonOutput class * Remove "or equal" logic from rails_version_less_than util method * Use monkey patch json escape from Rails 4.2 instead of Rails 4 * Memoize result for static method rails_version_less_than * Update json escaping method into class methods
This change is