disabling paperclip timestamps in tests
Oleg
committed Sep 28, 2011
commit ddfb2b67b1c7d2a931e6b00de832e7d84fafc0fc
Showing 8
changed files with
39 additions
and 15 deletions
app/controllers/cms_admin/files_controller.rb
+1
-1
| @@ | @@ -6,7 +6,7 @@ class CmsAdmin::FilesController < CmsAdmin::BaseController |
| def index | |
| return redirect_to :action => :new if @site.files.count == 0 | |
| - | @files = @site.files.for_category(params[:category]).all(:order => 'cms_files.label') |
| + | @files = @site.files.includes(:categories).for_category(params[:category]).all(:order => 'cms_files.label') |
| end | |
| def new | |
app/controllers/cms_admin/pages_controller.rb
+1
-1
| @@ | @@ -9,7 +9,7 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController |
| def index | |
| return redirect_to :action => :new if @site.pages.count == 0 | |
| if params[:category].present? | |
| - | @pages = @site.pages.for_category(params[:category]).all(:order => 'label') |
| + | @pages = @site.pages.includes(:categories).for_category(params[:category]).all(:order => 'label') |
| else | |
| @pages = [@site.pages.root].compact | |
| end | |
app/controllers/cms_admin/snippets_controller.rb
+1
-1
| @@ | @@ -5,7 +5,7 @@ class CmsAdmin::SnippetsController < CmsAdmin::BaseController |
| def index | |
| return redirect_to :action => :new if @site.snippets.count == 0 | |
| - | @snippets = @site.snippets.for_category(params[:category]) |
| + | @snippets = @site.snippets.includes(:categories).for_category(params[:category]) |
| end | |
| def new | |
config/initializers/paperclip.rb
+25
-0
| @@ | @@ -1,3 +1,28 @@ |
| Paperclip.options[:command_path] = case Rails.env | |
| when 'development' then "/usr/local/bin" | |
| + | end |
| + | |
| + | if Rails.env.test? |
| + | class Paperclip::Attachment |
| + | def self.default_options |
| + | @default_options = { |
| + | :url => "/system/:attachment/:id/:style/:filename", |
| + | :path => ":rails_root/public:url", |
| + | :styles => {}, |
| + | :only_process => [], |
| + | :processors => [:thumbnail], |
| + | :convert_options => {}, |
| + | :source_file_options => {}, |
| + | :default_url => "/:attachment/:style/missing.png", |
| + | :default_style => :original, |
| + | :storage => :filesystem, |
| + | :use_timestamp => false, |
| + | :whiny => Paperclip.options[:whiny] || Paperclip.options[:whiny_thumbnails], |
| + | :use_default_time_zone => true, |
| + | :hash_digest => "SHA1", |
| + | :hash_data => ":class/:attachment/:id/:style/:updated_at", |
| + | :preserve_files => false |
| + | } |
| + | end |
| + | end |
| end | |
| \ No newline at end of file | |
test/test_helper.rb
+1
-0
| @@ | @@ -33,6 +33,7 @@ class ActiveSupport::TestCase |
| config.revisions_limit = 25 | |
| config.locales = { :en => 'English', :es => 'Español' } | |
| config.admin_locale = nil | |
| + | config.upload_file_options = { } |
| end | |
| ComfortableMexicanSofa::HttpAuth.username = 'username' | |
| ComfortableMexicanSofa::HttpAuth.password = 'password' | |
test/unit/configuration_test.rb
+1
-0
| @@ | @@ -18,6 +18,7 @@ class ConfigurationTest < ActiveSupport::TestCase |
| assert_equal ({:en => 'English', :es => 'Español'}), config.locales | |
| assert_equal nil, config.admin_locale | |
| assert_equal nil, config.database_config | |
| + | assert_equal ({}), config.upload_file_options |
| end | |
| def test_initialization_overrides | |
test/unit/tags/page_file_test.rb
+5
-6
| @@ | @@ -43,25 +43,24 @@ class PageFileTagTest < ActiveSupport::TestCase |
| ] | |
| ) | |
| file = tag.block.files.first | |
| - | time = file.updated_at.to_f.to_i |
| assert_equal file, tag.content | |
| - | assert_equal "/system/files/#{file.id}/original/valid_image.jpg?#{time}", tag.render |
| + | assert_equal "/system/files/#{file.id}/original/valid_image.jpg", tag.render |
| assert tag = ComfortableMexicanSofa::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:link }}') | |
| - | assert_equal "<a href='/system/files/#{file.id}/original/valid_image.jpg?#{time}' target='_blank'>file</a>", |
| + | assert_equal "<a href='/system/files/#{file.id}/original/valid_image.jpg' target='_blank'>file</a>", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:link:link label }}') | |
| - | assert_equal "<a href='/system/files/#{file.id}/original/valid_image.jpg?#{time}' target='_blank'>link label</a>", |
| + | assert_equal "<a href='/system/files/#{file.id}/original/valid_image.jpg' target='_blank'>link label</a>", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:image }}') | |
| - | assert_equal "<img src='/system/files/#{file.id}/original/valid_image.jpg?#{time}' alt='file' />", |
| + | assert_equal "<img src='/system/files/#{file.id}/original/valid_image.jpg' alt='file' />", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:image:image alt }}') | |
| - | assert_equal "<img src='/system/files/#{file.id}/original/valid_image.jpg?#{time}' alt='image alt' />", |
| + | assert_equal "<img src='/system/files/#{file.id}/original/valid_image.jpg' alt='image alt' />", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFile.initialize_tag(page, '{{ cms:page_file:file:partial }}') | |
test/unit/tags/page_files_test.rb
+4
-6
| @@ | @@ -43,19 +43,17 @@ class PageFilesTagTest < ActiveSupport::TestCase |
| ] | |
| ) | |
| files = tag.block.files | |
| - | file_a, file_b = files |
| - | time_a = file_a.updated_at.to_f.to_i |
| - | time_b = file_b.updated_at.to_f.to_i |
| + | file_a, file_b = files |
| assert_equal files, tag.content | |
| - | assert_equal "/system/files/#{file_a.id}/original/valid_image.jpg?#{time_a}, /system/files/#{file_b.id}/original/invalid_file.gif?#{time_b}", tag.render |
| + | assert_equal "/system/files/#{file_a.id}/original/valid_image.jpg, /system/files/#{file_b.id}/original/invalid_file.gif", tag.render |
| assert tag = ComfortableMexicanSofa::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:link }}') | |
| - | assert_equal "<a href='/system/files/#{file_a.id}/original/valid_image.jpg?#{time_a}' target='_blank'>Valid Image</a> <a href='/system/files/#{file_b.id}/original/invalid_file.gif?#{time_b}' target='_blank'>Invalid File</a>", |
| + | assert_equal "<a href='/system/files/#{file_a.id}/original/valid_image.jpg' target='_blank'>Valid Image</a> <a href='/system/files/#{file_b.id}/original/invalid_file.gif' target='_blank'>Invalid File</a>", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:image }}') | |
| - | assert_equal "<img src='/system/files/#{file_a.id}/original/valid_image.jpg?#{time_a}' alt='Valid Image' /> <img src='/system/files/#{file_b.id}/original/invalid_file.gif?#{time_b}' alt='Invalid File' />", |
| + | assert_equal "<img src='/system/files/#{file_a.id}/original/valid_image.jpg' alt='Valid Image' /> <img src='/system/files/#{file_b.id}/original/invalid_file.gif' alt='Invalid File' />", |
| tag.render | |
| assert tag = ComfortableMexicanSofa::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial }}') | |