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

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.

@@ -0,0 +1,8 @@
exit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tadeusrox Thanks!

@st0012
Copy link
Contributor Author

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

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 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 [WIP] Cache mailer view Cache mailer view Dec 31, 2015
@st0012
Copy link
Contributor Author

st0012 commented Jan 6, 2016

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

@rafaelfranca
Copy link
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.


module ActionMailer
module Caching
extend ActiveSupport::Autoload
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need this.

@st0012 st0012 force-pushed the cache-mailer-view branch 2 times, most recently from 2204218 to e5ae5a8 Compare January 7, 2016 07:29
@st0012
Copy link
Contributor Author

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
Copy link
Contributor Author

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 cache-mailer-view branch February 24, 2016 04:07
@st0012
Copy link
Contributor Author

st0012 commented Feb 24, 2016

@rafaelfranca Thanks for merging!

@st0012
Copy link
Contributor Author

st0012 commented Feb 24, 2016

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

@rafaelfranca
Copy link
Member

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

@st0012
Copy link
Contributor Author

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
Development

Successfully merging this pull request may close these issues.

5 participants