Mange / roadie-rails

Making HTML emails comfortable for the Rails rockstars
MIT License
363 stars 65 forks source link

Fix sprockets-rails 3 integration #46

Closed rafaelfranca closed 9 years ago

rafaelfranca commented 9 years ago

In a few days I'm going to release sprockets-rails 3. This means that Rails 4 applications will use it by default. sprockets-rails 3 is a major version that aims to support sprockets 3 and sprockets 4 and because of that some things have changed. One thing is that now you don't have Rails.application.assets in initialize time so the app.assets check will fail.

To fix that I'm using the Rails.application.config.assets.configure block, that is also present in sprockets-rails 2.

There is still two tests failing but I don't know what do with those tests. They are expecting the background image to not have digest (see failures below) but since sprockets-rails 2 we don't generate undigested assets so that would never work out of box.

Here are the failures:

Failures:

  1) Integrations with Rails 4.2.x (with sprockets-rails 3) inlines styles for multipart emails
     Failure/Error: expect(document).to have_styling('background' => "url(#{expected_image_url})").at_selector('.image')
       expected styles at ".image" to be:
       [["background", "url(https://example.app.org/assets/rails.png)"]]
       but was:
       [["background", "url(https://example.app.org/assets/rails-322506f9917889126e81df2833a6eecdf2e394658d53dad347e9882dd4dbf28e.png)"]]
     # ./spec/integration_spec.rb:45:in `block (4 levels) in <top (required)>'

  2) Integrations with Rails 4.2.x (with sprockets-rails 3) automatically inlines styles with automatic mailer
     Failure/Error: expect(document).to have_styling('background' => "url(#{expected_image_url})").at_selector('.image')
       expected styles at ".image" to be:
       [["background", "url(https://example.app.org/assets/rails.png)"]]
       but was:
       [["background", "url(https://example.app.org/assets/rails-322506f9917889126e81df2833a6eecdf2e394658d53dad347e9882dd4dbf28e.png)"]]
     # ./spec/integration_spec.rb:73:in `block (4 levels) in <top (required)>'

Let me know how can I proceed with this broken tests.

Mange commented 9 years ago

Thank you for bringing this to my attention!

  1. The mailers, views and assets directories in the Rails apps are symlinks to their shared counterparts. Please use them for your new embedded app too.
  2. Test failures are interesting. I made Rails 4.0 (precompiled) a special case in the bottom of integration_spec.rb. With this new Sprockets integration where you always have digests, this needs to be folded into the rest of the tests.
    • You could add a new digests option to the RailsApp declarations.
    • Check this option when setting up expected file names.
    • Add the Rails 4.0.x (precompiled) at the top.
    • Remove the Rails 4.0.x (precompiled) block at the bottom; everything in there is already covered in the generic examples.
  3. Please add a line in Changelog.md (merge latest master first) and sign it with your GH user and name (if you want). There are examples in older versions. Also tag the line with this issue number.

I can do this myself if you don't feel like it, but please let me know in that case. I'd love to have this in the 1.1 release.

rafaelfranca commented 9 years ago

Done

Mange commented 9 years ago

Great one! Thank you very much.

rafaelfranca commented 9 years ago

Thanks!