Skip to content

Commit

Permalink
added fixes to allow actionmailer test to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
eacaps committed Jul 21, 2016
1 parent 05d3144 commit d99fc36
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
14 changes: 7 additions & 7 deletions app/helpers/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ def initialize_redux_stores
# second parameter passed to both component and store generator functions.
def rails_context(server_side:)
@rails_context ||= begin
# result = {}
# unless request.nil?
result = {}
unless request.nil?
# Using Addressable instead of standard URI to better deal with
# non-ASCII characters (see https://github.com/shakacode/react_on_rails/pull/405)
uri = Addressable::URI.parse(request.original_url)
Expand All @@ -365,11 +365,11 @@ def rails_context(server_side:)
i18nDefaultLocale: I18n.default_locale,
httpAcceptLanguage: request.env["HTTP_ACCEPT_LANGUAGE"]
}
# end
# if ReactOnRails.configuration.rendering_extension
# custom_context = ReactOnRails.configuration.rendering_extension.custom_context(self)
# result.merge!(custom_context) if custom_context
# end
end
if ReactOnRails.configuration.rendering_extension
custom_context = ReactOnRails.configuration.rendering_extension.custom_context(self)
result.merge!(custom_context) if custom_context
end
result
end

Expand Down
6 changes: 5 additions & 1 deletion spec/dummy/app/views/dummy_mailer/hello_email.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Someone emailed this to you:

<%= react_component("HelloWorld", props: {}, prerender: true) %>
<%= react_component("HelloWorld", props: {
helloWorldData: {
name: "Mr. Mailing Server Side Rendering"
}
}, prerender: true) %>
11 changes: 8 additions & 3 deletions spec/dummy/config/initializers/react_on_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ module RenderingExtension
# Return a Hash that contains custom values from the view context that will get passed to
# all calls to react_component and redux_store for rendering
def self.custom_context(view_context)
{
somethingUseful: view_context.session[:something_useful]
}
result = {}
begin
result = {
somethingUseful: view_context.session[:something_useful]
}
rescue
end
result
end
end

Expand Down
1 change: 1 addition & 0 deletions spec/dummy/spec/requests/server_render_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
it 'sends email okay' do
mail = DummyMailer.hello_email
expect(mail.subject).to match 'mail'
expect(mail.body).to match 'Mr. Mailing Server Side Rendering'
end
end

Expand Down

0 comments on commit d99fc36

Please sign in to comment.