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
base: master
from

Conversation

Projects
None yet
5 participants
@st0012
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot 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.

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

View changes

Show outdated Hide outdated actionmailer/.byebug_history
@st0012

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Dec 29, 2015

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Dec 29, 2015

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Dec 30, 2015

Contributor

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

Contributor

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 changed the title from [WIP] Cache mailer view to Cache mailer view Dec 31, 2015

@st0012

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Jan 6, 2016

Contributor

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

Contributor

st0012 commented Jan 6, 2016

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

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Jan 6, 2016

Member

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.

Member

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

View changes

Show outdated Hide outdated actionmailer/lib/action_mailer/caching.rb
@rafaelfranca

View changes

Show outdated Hide outdated actionmailer/lib/action_mailer/caching.rb
@@ -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.

@rafaelfranca

rafaelfranca Jan 6, 2016

Member

This line can be removed.

This comment has been minimized.

@st0012

st0012 Jan 7, 2016

Contributor

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

@st0012

st0012 Jan 7, 2016

Contributor

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

@rafaelfranca

View changes

Show outdated Hide outdated actionpack/lib/action_dispatch/caching.rb
@rafaelfranca

View changes

Show outdated Hide outdated actionpack/lib/action_dispatch/caching.rb
@st0012

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Jan 10, 2016

Contributor

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 😢 .

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Feb 20, 2016

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Feb 24, 2016

Contributor

@rafaelfranca Thanks for merging!

Contributor

st0012 commented Feb 24, 2016

@rafaelfranca Thanks for merging!

@st0012

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Feb 24, 2016

Contributor

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

Contributor

st0012 commented Feb 24, 2016

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

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Feb 24, 2016

Member

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

Member

rafaelfranca commented Feb 24, 2016

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

@st0012

This comment has been minimized.

Show comment
Hide comment
@st0012

st0012 Feb 24, 2016

Contributor

@rafaelfranca ok, thanks!

Contributor

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