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

react_component outside of view #636

Merged
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
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]

## [Unreleased]

## [6.3.1]
## [6.3.2] - 2016-12-5
##### Fixed
- The `react_component` method was raising a `NameError` when `ReactOnRailsHelper` was included in a plain object. [#636](https://github.com/shakacode/react_on_rails/pull/636) by [jtibbertsma](https://github.com/jtibbertsma).

## [6.3.1] - 2016-11-30
##### Changed
- Improved generator post-install help messages. [#631](https://github.com/shakacode/react_on_rails/pull/631) by [justin808](https://github.com/justin808).

## [6.3.0]
## [6.3.0] - 2016-11-30
##### Changed
- Modified register API to allow registration of renderers, allowing a user to manually render their app to the DOM. This allows for code splitting and deferred loading. [#581](https://github.com/shakacode/react_on_rails/pull/581) by [jtibbertsma](https://github.com/jtibbertsma).

Expand Down Expand Up @@ -397,7 +401,8 @@ Best done with Object destructing:
##### Fixed
- Fix several generator related issues.

[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.3.1...master
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.3.2...master
[6.3.2]: https://github.com/shakacode/react_on_rails/compare/6.3.0...6.3.1
[6.3.1]: https://github.com/shakacode/react_on_rails/compare/6.3.0...6.3.1
[6.3.0]: https://github.com/shakacode/react_on_rails/compare/6.2.1...6.3.0
[6.2.1]: https://github.com/shakacode/react_on_rails/compare/6.2.0...6.2.1
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def rails_context(server_side:)
i18nLocale: I18n.locale,
i18nDefaultLocale: I18n.default_locale
}
if request.present?
if defined?(request) && request.present?
# Check for encoding of the request's original_url and try to force-encoding the
# URLs as UTF-8. This situation can occur in browsers that do not encode the
# entire URL as UTF-8 already, mostly on the Windows platform (IE11 and lower).
Expand Down Expand Up @@ -402,7 +402,7 @@ def send_tag_method(tag_method_name, args)
end

def in_mailer?
return false unless controller.present?
return false unless defined?(controller)
return false unless defined?(ActionMailer::Base)

controller.is_a?(ActionMailer::Base)
Expand Down
19 changes: 19 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 @@ -183,4 +183,23 @@
it { is_expected.to be_an_instance_of ActiveSupport::SafeBuffer }
it { is_expected.to eq hello_world }
end

describe "#rails_context" do
before do
@rendering_extension = ReactOnRails.configuration.rendering_extension
ReactOnRails.configuration.rendering_extension = nil
end

it "should not throw an error if not in a view" do
class PlainClass
include ReactOnRailsHelper
end

ob = PlainClass.new
expect { ob.send(:rails_context, server_side: true) }.to_not raise_error
expect { ob.send(:rails_context, server_side: false) }.to_not raise_error
end

after { ReactOnRails.configuration.rendering_extension = @rendering_extension }
end
end