diff options
-rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0c8544932..2108b9d45 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -180,7 +180,10 @@ class ApplicationController < ActionController::Base path = foi_fragment_cache_part_path(param) path = "/views" + path foi_cache_path = File.join(File.dirname(__FILE__), '../../cache') - return File.join(foi_cache_path, path) + max_file_length = 255 - 35 # we subtract 35 because tempfile + # adds on a variable number of + # characters + return File.join(foi_cache_path, path)[0...max_file_length] end def foi_fragment_cache_all_for_request(info_request) # return stub path so admin can expire it diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 1d6802940..0a1d57f0c 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -23,3 +23,12 @@ describe ApplicationController, "when accessing third party services" do end end +describe ApplicationController, "when caching fragments" do + it "should not fail with long filenames" do + long_name = "blahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblahblah.txt" + path = self.controller.send(:foi_fragment_cache_path, long_name) + self.controller.send(:foi_fragment_cache_write, path, "whassap") + end + +end + |