overriding a crappy paperclip default

Oleg committed Feb 08, 2012
commit 7652ba76955241cdd38ddac425831250f2c83221
Showing 6 changed files with 14 additions and 12 deletions
config/initializers/comfortable_mexican_sofa.rb +1 -1
@@ @@ -31,7 +31,7 @@ ComfortableMexicanSofa.configure do |config|
# the upload method and appropriate settings based on Paperclip. For S3 see:
# http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Storage/S3, and for
# filesystem see: http://rdoc.info/gems/paperclip/2.3.8/Paperclip/Storage/S3
- # config.upload_file_options = {:storage => :filesystem}
+ # config.upload_file_options = {:url => '/system/:class/:id/:attachment/:style/:filename'}
# Sofa allows you to setup entire site from files. Database is updated with each
# request (if necessary). Please note that database entries are destroyed if there's
comfortable_mexican_sofa/configuration.rb b/lib/comfortable_mexican_sofa/configuration.rb +1 -1
@@ @@ -58,7 +58,7 @@ class ComfortableMexicanSofa::Configuration
@admin_route_prefix = 'cms-admin'
@admin_route_redirect = ''
@allow_irb = false
- @upload_file_options = {}
+ @upload_file_options = { :url => '/system/:class/:id/:attachment/:style/:filename' }
@enable_fixtures = false
@fixtures_path = File.expand_path('db/cms_fixtures', Rails.root)
@revisions_limit = 25
test/test_helper.rb +1 -1
@@ @@ -34,7 +34,7 @@ class ActiveSupport::TestCase
'zh-CN' => '简体中文'
}
config.admin_locale = nil
- config.upload_file_options = { }
+ config.upload_file_options = { :url => '/system/:class/:id/:attachment/:style/:filename' }
end
ComfortableMexicanSofa::HttpAuth.username = 'username'
ComfortableMexicanSofa::HttpAuth.password = 'password'
test/unit/configuration_test.rb +3 -1
@@ @@ -23,7 +23,9 @@ class ConfigurationTest < ActiveSupport::TestCase
}), config.locales
assert_equal nil, config.admin_locale
assert_equal nil, config.database_config
- assert_equal ({}), config.upload_file_options
+ assert_equal ({
+ :url => '/system/:class/:id/:attachment/:style/:filename'
+ }), config.upload_file_options
end
def test_initialization_overrides
test/unit/tags/page_file_test.rb +5 -5
@@ @@ -54,22 +54,22 @@ class PageFileTagTest < ActiveSupport::TestCase
file = tag.block.files.first
assert_equal file, tag.content
- assert_equal "/system/files/#{file.id}/original/image.jpg", tag.render
+ assert_equal "/system/cms/files/#{file.id}/files/original/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/image.jpg' target='_blank'>file</a>",
+ assert_equal "<a href='/system/cms/files/#{file.id}/files/original/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/image.jpg' target='_blank'>link label</a>",
+ assert_equal "<a href='/system/cms/files/#{file.id}/files/original/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/image.jpg' alt='file' />",
+ assert_equal "<img src='/system/cms/files/#{file.id}/files/original/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/image.jpg' alt='image alt' />",
+ assert_equal "<img src='/system/cms/files/#{file.id}/files/original/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 +3 -3
@@ @@ -55,14 +55,14 @@ class PageFilesTagTest < ActiveSupport::TestCase
file_a, file_b = files
assert_equal files, tag.content
- assert_equal "/system/files/#{file_a.id}/original/image.jpg, /system/files/#{file_b.id}/original/image.gif", tag.render
+ assert_equal "/system/cms/files/#{file_a.id}/files/original/image.jpg, /system/cms/files/#{file_b.id}/files/original/image.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/image.jpg' target='_blank'>Image</a> <a href='/system/files/#{file_b.id}/original/image.gif' target='_blank'>Image</a>",
+ assert_equal "<a href='/system/cms/files/#{file_a.id}/files/original/image.jpg' target='_blank'>Image</a> <a href='/system/cms/files/#{file_b.id}/files/original/image.gif' target='_blank'>Image</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/image.jpg' alt='Image' /> <img src='/system/files/#{file_b.id}/original/image.gif' alt='Image' />",
+ assert_equal "<img src='/system/cms/files/#{file_a.id}/files/original/image.jpg' alt='Image' /> <img src='/system/cms/files/#{file_b.id}/files/original/image.gif' alt='Image' />",
tag.render
assert tag = ComfortableMexicanSofa::Tag::PageFiles.initialize_tag(page, '{{ cms:page_files:files:partial }}')