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

Cache mailer view #22825

Closed
wants to merge 22 commits into from
Closed

Cache mailer view #22825

wants to merge 22 commits into from

Conversation

@st0012
Copy link
Contributor

@st0012 st0012 commented Dec 29, 2015

Hi, I'm adding cache feature to ActionMailer's templates. I think there two ways to accomplish this goal.
First is moving all the caching feature from ActionController to AbstractController since both ActionMailer and ActionController are inherited from it.
The second one is porting caching features to ActionMailer, which I think will break the DRY rule.
However, I'm working on this with the second approach. Because I think after I reimplemented it in ActionMailer, I can find some reusable parts in both ActionMailer and ActionController and put them into somewhere like ActiveSupport?
And I know this could be a huge work while I am not every familiar with Rails' codebase. So I am hoping someone can discuss this with me or give me some advice. Any suggestion will be very helpful, thanks!

@rails-bot
Copy link

@rails-bot rails-bot commented Dec 29, 2015

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @arthurnn (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@tadeusrox
tadeusrox reviewed Dec 29, 2015
View changes
actionmailer/.byebug_history Outdated
@@ -0,0 +1,8 @@
exit

This comment has been minimized.

@tadeusrox

tadeusrox Dec 29, 2015
Contributor

I think this file shouldn't be here

If you think it's usefull -> https://help.github.com/articles/ignoring-files/#create-a-global-gitignore

This comment has been minimized.

@st0012

st0012 Dec 29, 2015
Author Contributor

@tadeusrox Thanks!

@st0012
Copy link
Contributor Author

@st0012 st0012 commented Dec 29, 2015

And I think the main difference between ActionController and ActionMailer's caching implementation is how the cache key is generated and ActionMailer doesn't need to deal with requests.

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Dec 29, 2015

I can find some reusable parts in both ActionMailer and ActionController and put them into somewhere like ActiveSupport?

Yes. You can put in Action Dispatch like Abstract Controller already is.

@st0012
Copy link
Contributor Author

@st0012 st0012 commented Dec 30, 2015

Hi, I'm wondering if I need to copy all the caching test from ActionController, and change them to the ActionMailer version? I think most of them are testing the fragment cache itself, not testing fragment cache in ActionController. So make a copy of them in ActionMailer are basically unnecessary. What do you think? cc @rafaelfranca @arthurnn

@st0012 st0012 force-pushed the st0012:cache-mailer-view branch Dec 30, 2015
@st0012 st0012 changed the title [WIP] Cache mailer view Cache mailer view Dec 31, 2015
@st0012
Copy link
Contributor Author

@st0012 st0012 commented Jan 6, 2016

@arthurnn Hi, can you please give me some advice? thank you 😄

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Jan 6, 2016

Hi, I'm wondering if I need to copy all the caching test from ActionController, and change them to the ActionMailer version? I think most of them are testing the fragment cache itself, not testing fragment cache in ActionController. So make a copy of them in ActionMailer are basically unnecessary. What do you think?

Yes, agree. It is better to have a fresh start in the test suite, but it is good to use the ActionController tests as inspiration.

@rafaelfranca
rafaelfranca reviewed Jan 6, 2016
View changes
actionmailer/lib/action_mailer/caching.rb Outdated

module ActionMailer
module Caching
extend ActiveSupport::Autoload

This comment has been minimized.

@rafaelfranca

rafaelfranca Jan 6, 2016
Member

you don't need this.

@rafaelfranca
rafaelfranca reviewed Jan 6, 2016
View changes
actionmailer/lib/action_mailer/caching.rb Outdated
require 'action_dispatch/caching'

module ActionMailer
module Caching

This comment has been minimized.

@rafaelfranca

rafaelfranca Jan 6, 2016
Member

I think we can remove this module and just include its content directly in ActionMailer::Base

This comment has been minimized.

@st0012

st0012 Jan 6, 2016
Author Contributor

Should we also move ActionController::Caching into ActionController::Base?

@@ -23,65 +22,24 @@ module ActionController
# config.action_controller.cache_store = :mem_cache_store, Memcached::Rails.new('localhost:11211')
# config.action_controller.cache_store = MyOwnStore.new('parameter')
module Caching
extend ActiveSupport::Concern
extend ActiveSupport::Autoload

This comment has been minimized.

@rafaelfranca

rafaelfranca Jan 6, 2016
Member

This line can be removed.

This comment has been minimized.

@st0012

st0012 Jan 7, 2016
Author Contributor

Remove this line will cause undefined method eager_load! error in here.

@rafaelfranca
rafaelfranca reviewed Jan 6, 2016
View changes
actionpack/lib/action_dispatch/caching.rb Outdated

protected
# Convenience accessor.
def cache(key, options = {}, &block)

This comment has been minimized.

@rafaelfranca

rafaelfranca Jan 6, 2016
Member

The indentation here needs to be fixed

@rafaelfranca
rafaelfranca reviewed Jan 6, 2016
View changes
actionpack/lib/action_dispatch/caching.rb Outdated
end
end

include AbstractController::Helpers

This comment has been minimized.

@rafaelfranca

rafaelfranca Jan 6, 2016
Member

Why is this included here? It is being used here somewhere? I think it is fine to remove since both classes that include AD::Caching already include this module.

@st0012 st0012 force-pushed the st0012:cache-mailer-view branch 2 times, most recently Jan 7, 2016
@st0012
Copy link
Contributor Author

@st0012 st0012 commented Jan 10, 2016

Here's what I have done so far:

  1. I move the ActionController::Caching to ActionDispatch::Caching and include it in ActionMailer::Base and ActionController::Caching.
  2. I added some unit tests and functional test to make sure that ActionMailer has the caching ability.
  3. Finally, I changed the environment template files to add ActionMailer's caching configuration.

And I am wondering what I should do next? This is my first time contributing Rails, so I think I need some guide to finish this 😢 .

@rafaelfranca rafaelfranca added this to the 5.0.0 milestone Jan 16, 2016
@dhh dhh assigned rafaelfranca and unassigned arthurnn Feb 10, 2016
@st0012 st0012 force-pushed the st0012:cache-mailer-view branch to b166455 Feb 16, 2016
@st0012
Copy link
Contributor Author

@st0012 st0012 commented Feb 20, 2016

@rafaelfranca Hello ~ what can I do to merge this?

rafaelfranca added a commit that referenced this pull request Feb 23, 2016
rafaelfranca added a commit that referenced this pull request Feb 24, 2016
@st0012 st0012 deleted the st0012:cache-mailer-view branch Feb 24, 2016
@st0012
Copy link
Contributor Author

@st0012 st0012 commented Feb 24, 2016

@rafaelfranca Thanks for merging!

@st0012
Copy link
Contributor Author

@st0012 st0012 commented Feb 24, 2016

@rafaelfranca BTW, when should/can I edit the documentations?

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Feb 24, 2016

You can open a PR upgrading the documentation, and we really should.

@st0012
Copy link
Contributor Author

@st0012 st0012 commented Feb 24, 2016

@rafaelfranca ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.