From bcaed90744bf470504b883010f28c9f59bd33505 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 23 May 2015 15:25:05 +1000 Subject: [PATCH] fix missing rtl stylesheets --- app/controllers/stylesheets_controller.rb | 2 +- lib/sass/discourse_stylesheets.rb | 1 + .../stylesheets_controller_spec.rb | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/controllers/stylesheets_controller.rb b/app/controllers/stylesheets_controller.rb index eac320b5f..2d3df8b3a 100644 --- a/app/controllers/stylesheets_controller.rb +++ b/app/controllers/stylesheets_controller.rb @@ -5,7 +5,7 @@ class StylesheetsController < ApplicationController no_cookies - target,digest = params[:name].split("_") + target,digest = params[:name].split(/_([a-f0-9]{40})/) cache_time = request.env["HTTP_IF_MODIFIED_SINCE"] cache_time = Time.rfc2822(cache_time) rescue nil if cache_time diff --git a/lib/sass/discourse_stylesheets.rb b/lib/sass/discourse_stylesheets.rb index c37ed0791..ac4955dbd 100644 --- a/lib/sass/discourse_stylesheets.rb +++ b/lib/sass/discourse_stylesheets.rb @@ -15,6 +15,7 @@ class DiscourseStylesheets end def self.stylesheet_link_tag(target = :desktop) + tag = cache[target] return tag.dup.html_safe if tag diff --git a/spec/controllers/stylesheets_controller_spec.rb b/spec/controllers/stylesheets_controller_spec.rb index c37f6f292..99e427a3d 100644 --- a/spec/controllers/stylesheets_controller_spec.rb +++ b/spec/controllers/stylesheets_controller_spec.rb @@ -3,21 +3,36 @@ require 'spec_helper' describe StylesheetsController do it 'can survive cache miss' do - DiscourseStylesheets.cache.clear - DiscourseStylesheets.stylesheet_link_tag('desktop_rtl') StylesheetCache.destroy_all + builder = DiscourseStylesheets.new('desktop_rtl') + builder.compile + + digest = StylesheetCache.first.digest + StylesheetCache.destroy_all # digestless get :show, name: 'desktop_rtl' expect(response).to be_success + StylesheetCache.destroy_all + + get :show, name: "desktop_rtl_#{digest}" + expect(response).to be_success + + cached = StylesheetCache.first + expect(cached.target).to eq 'desktop_rtl' + expect(cached.digest).to eq digest + # tmp folder destruction and cached `rm #{DiscourseStylesheets.cache_fullpath}/*` get :show, name: 'desktop_rtl' expect(response).to be_success + get :show, name: "desktop_rtl_#{digest}" + expect(response).to be_success + # there is an edge case which is ... disk and db cache is nuked, very unlikely to happen end