alphagov/govuk_admin_template — pull request #42 by rgarner (2014-10-17 15:47:22+00:00)
Title: Fingerprint urls

From Rails 4, pipelined assets must be referenced by their MD5 digest name - e.g. `header-crown-6f74a12779850d13e364d480bab3b90d.png` - rather than their unadorned name. `govuk_admin_template` referenced the unadorned name in two places:

* `_navbar.css.scss` had an unguarded use of `url(...)` (now `image-url(...)`)
* The bootstrap gem on which our use of the glyphicons font relies now requires the use of `@import bootstrap-sprockets` *before* `@import bootstrap` in order to generate digest references in the compiled CSS.

**Neither of these changes is tested by `spec`**. It's a terrible rabbit hole making this gem demonstrably compatible with both Rails 3 and Rails 4, because of the following:

* `spec/dummy` is a completely self-contained test Rails 3 app
* We'd need a completely self-contained Rails 4 app too, or we'd need to wrap `spec/dummy' in a ton of conditionals to make it behave in the correct way at the correct time
* It's hard to test *either* of these in a production scenario, i.e. running `rake assets:precompile` and ensuring that the correct digest-named assets are generated while also somehow getting capybara to talk to an internally-hosted production environment
* We need this to work in transition yesterday, and we've already spent a lot of time down this hole up to our elbows in rabbit droppings

The way this *has* been tested is manually :sadface: :

* Adding an `:assets` group containing `uglifier`, `bootstrap-sass` and `sass-rails` to `Gemfile`
* Running `RAILS_ENV=production rake assets:precompile`
* Setting `config.serve_static_assets` to `true` in `environments/production.rb`
* adding ` ` to `app/views/welcome/index.html.erb`
* Running `RAILS_ENV=production bundle exec rails server` and checking that said `index.html.erb` didn't 404 any of its assets.

I want the testing story here to be better. Some suggestions exist in [this StackOverflow question](http://stackoverflow.com/questions/15752774/strategies-for-gem-tests-to-ensure-the-gem-works-with-rails-3-x-and-4-0). Suggestions or pointers to prior art are hugely welcome.