From 4954dc688b61284563547362a1b149b6564aeb1d Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 7 Jun 2015 15:58:00 -0400 Subject: [PATCH] Add permanent URLs for JS and CSS asset bundles --- lib/app.rb | 8 ++++++-- test/app_test.rb | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/app.rb b/lib/app.rb index 61cba919..9bbb463d 100644 --- a/lib/app.rb +++ b/lib/app.rb @@ -172,8 +172,12 @@ class App < Sinatra::Application 200 end - get '/docs.json' do - redirect asset_path('docs.json', protocol: 'http') + %w(docs.json application.js application.css).each do |asset| + class_eval <<-CODE, __FILE__, __LINE__ + 1 + get '/#{asset}' do + redirect asset_path('#{asset}', protocol: 'http') + end + CODE end get '/s/maxcdn' do diff --git a/test/app_test.rb b/test/app_test.rb index 81240d11..74dd01ce 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -181,6 +181,22 @@ class AppTest < MiniTest::Spec end end + describe "/application.js" do + it "returns to the asset path" do + get '/application.js' + assert last_response.redirect? + assert_equal 'http://example.org/assets/application.js', last_response['Location'] + end + end + + describe "/application.css" do + it "returns to the asset path" do + get '/application.css' + assert last_response.redirect? + assert_equal 'http://example.org/assets/application.css', last_response['Location'] + end + end + describe "/feed" do it "returns an atom feed" do get '/feed'