uploads are now files
Oleg
committed Aug 05, 2011
commit b3feb59ac91fa392cdefaf87f07c3d4789089c89
Showing 45
changed files with
261 additions
and 255 deletions
app/assets/stylesheets/comfortable_mexican_sofa/structure.css
+1
-4
| @@ | @@ -1,8 +1,5 @@ |
| /* -- Containers --------------------------------------------------------- */ | |
| - | html { |
| - | height: 100%; |
| - | } |
| - | body#cms_body { |
| + | html, body#cms_body { |
| height: 100%; | |
| background-color: #252525; | |
| } | |
app/controllers/cms_admin/files_controller.rb
+29
-0
| @@ | @@ -0,0 +1,29 @@ |
| + | class CmsAdmin::FilesController < CmsAdmin::BaseController |
| + | |
| + | skip_before_filter :load_fixtures |
| + | |
| + | before_filter :load_file, :only => :destroy |
| + | |
| + | def index |
| + | render |
| + | end |
| + | |
| + | def create |
| + | @file = @site.files.create!(:file => params[:file]) |
| + | render :partial => 'file', :object => @file |
| + | rescue ActiveRecord::RecordInvalid |
| + | render :nothing => true, :status => :bad_request |
| + | end |
| + | |
| + | def destroy |
| + | @file.destroy |
| + | end |
| + | |
| + | protected |
| + | |
| + | def load_file |
| + | @file = @site.files.find(params[:id]) |
| + | rescue ActiveRecord::RecordNotFound |
| + | render :nothing => true |
| + | end |
| + | end |
app/controllers/cms_admin/pages_controller.rb
+3
-3
| @@ | @@ -4,7 +4,7 @@ class CmsAdmin::PagesController < CmsAdmin::BaseController |
| before_filter :build_cms_page, :only => [:new, :create] | |
| before_filter :load_cms_page, :only => [:edit, :update, :destroy] | |
| before_filter :preview_cms_page, :only => [:create, :update] | |
| - | before_filter :build_upload_file, :only => [:new, :edit] |
| + | before_filter :build_file, :only => [:new, :edit] |
| def index | |
| return redirect_to :action => :new if @site.pages.count == 0 | |
| @@ | @@ -81,8 +81,8 @@ protected |
| @page.layout ||= (@page.parent && @page.parent.layout || @site.layouts.first) | |
| end | |
| - | def build_upload_file |
| - | @upload = Cms::Upload.new |
| + | def build_file |
| + | @file = Cms::File.new |
| end | |
| def load_cms_page | |
app/controllers/cms_admin/uploads_controller.rb
+0
-29
| @@ | @@ -1,29 +0,0 @@ |
| - | class CmsAdmin::UploadsController < CmsAdmin::BaseController |
| - | |
| - | skip_before_filter :load_fixtures |
| - | |
| - | before_filter :load_upload, :only => :destroy |
| - | |
| - | def index |
| - | render |
| - | end |
| - | |
| - | def create |
| - | @upload = @site.uploads.create!(:file => params[:file]) |
| - | render :partial => 'file', :object => @upload |
| - | rescue ActiveRecord::RecordInvalid |
| - | render :nothing => true, :status => :bad_request |
| - | end |
| - | |
| - | def destroy |
| - | @upload.destroy |
| - | end |
| - | |
| - | protected |
| - | |
| - | def load_upload |
| - | @upload = @site.uploads.find(params[:id]) |
| - | rescue ActiveRecord::RecordNotFound |
| - | render :nothing => true |
| - | end |
| - | end |
app/models/cms/file.rb
+15
-0
| @@ | @@ -0,0 +1,15 @@ |
| + | class Cms::File < ActiveRecord::Base |
| + | |
| + | set_table_name :cms_files |
| + | |
| + | # -- AR Extensions -------------------------------------------------------- |
| + | has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options |
| + | |
| + | # -- Relationships -------------------------------------------------------- |
| + | belongs_to :site |
| + | |
| + | # -- Validations ---------------------------------------------------------- |
| + | validates :site_id, :presence => true |
| + | validates_attachment_presence :file |
| + | |
| + | end |
app/models/cms/site.rb
+1
-1
| @@ | @@ -6,7 +6,7 @@ class Cms::Site < ActiveRecord::Base |
| has_many :layouts, :dependent => :destroy | |
| has_many :pages, :dependent => :destroy | |
| has_many :snippets, :dependent => :destroy | |
| - | has_many :uploads, :dependent => :destroy |
| + | has_many :files, :dependent => :destroy |
| # -- Callbacks ------------------------------------------------------------ | |
| before_validation :assign_label | |
app/models/cms/upload.rb
+0
-15
| @@ | @@ -1,15 +0,0 @@ |
| - | class Cms::Upload < ActiveRecord::Base |
| - | |
| - | set_table_name :cms_uploads |
| - | |
| - | # -- AR Extensions -------------------------------------------------------- |
| - | has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options |
| - | |
| - | # -- Relationships -------------------------------------------------------- |
| - | belongs_to :site |
| - | |
| - | # -- Validations ---------------------------------------------------------- |
| - | validates :site_id, :presence => true |
| - | validates_attachment_presence :file |
| - | |
| - | end |
app/views/cms_admin/files/_file.html.erb
+10
-0
| @@ | @@ -0,0 +1,10 @@ |
| + | <div class='file' id='<%= dom_id(file) %>'> |
| + | <% file_name = file.file_file_name |
| + | file_ext = file.file_file_name.split('.').last |
| + | if (file_name.size - file_ext.size) > 30 |
| + | file_name = file_name.truncate(30) + file_ext |
| + | end |
| + | %> |
| + | <%= link_to file_name, file.file.url, :target => '_blank', :class => 'filename' %> |
| + | <%= link_to span_tag('x'), cms_admin_site_file_path(@site, file), :method => :delete, :remote => true, :class => 'delete' %> |
| + | </div> |
| \ No newline at end of file | |
app/views/cms_admin/files/_index.html.erb
+10
-0
| @@ | @@ -0,0 +1,10 @@ |
| + | <div id='file_uploads' class='box' data-path='<%= cms_admin_site_files_path(@site) %>'> |
| + | <div class='actions'> |
| + | <a id='uploader_button' href='#' class='big button'><%= t('.button') %></a> |
| + | </div> |
| + | <div id='uploaded_files'> |
| + | <% Cms::File.order('file_file_name').all.each do |file| %> |
| + | <%= render :partial => 'cms_admin/files/file', :object => file %> |
| + | <% end %> |
| + | </div> |
| + | </div> |
app/views/cms_admin/files/destroy.js.erb
+3
-0
| @@ | @@ -0,0 +1,3 @@ |
| + | $(".file#<%= dom_id(@file) %>").fadeOut('slow', function(){ |
| + | $(this).remove() |
| + | }) |
| \ No newline at end of file | |
app/views/cms_admin/layouts/_form.html.erb
+1
-1
| @@ | @@ -1,5 +1,5 @@ |
| <% content_for :right_column do %> | |
| - | <%= render :partial => 'cms_admin/uploads/index' %> |
| + | <%= render :partial => 'cms_admin/files/index' %> |
| <% end %> | |
| <%= form.text_field :label, :id => (@layout.new_record?? 'slugify' : nil)%> | |
app/views/cms_admin/pages/_form.html.erb
+1
-1
| @@ | @@ -6,7 +6,7 @@ |
| </label> | |
| <button></button> | |
| </div> | |
| - | <%= render :partial => 'cms_admin/uploads/index' %> |
| + | <%= render :partial => 'cms_admin/files/index' %> |
| <% end %> | |
| <%= form.text_field :label, :id => (@page.new_record?? 'slugify' : nil) %> | |
app/views/cms_admin/snippets/_form.html.erb
+1
-1
| @@ | @@ -1,5 +1,5 @@ |
| <% content_for :right_column do %> | |
| - | <%= render :partial => 'cms_admin/uploads/index' %> |
| + | <%= render :partial => 'cms_admin/files/index' %> |
| <% end %> | |
| <%= form.text_field :label, :id => (@snippet.new_record?? 'slugify' : nil) %> | |
app/views/cms_admin/uploads/_file.html.erb
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | <div class='file' id='<%= dom_id(file) %>'> |
| - | <% file_name = file.file_file_name |
| - | file_ext = file.file_file_name.split('.').last |
| - | if (file_name.size - file_ext.size) > 30 |
| - | file_name = file_name.truncate(30) + file_ext |
| - | end |
| - | %> |
| - | <%= link_to file_name, file.file.url, :target => '_blank', :class => 'filename' %> |
| - | <%= link_to span_tag('x'), cms_admin_site_upload_path(@site, file), :method => :delete, :remote => true, :class => 'delete' %> |
| - | </div> |
| \ No newline at end of file | |
app/views/cms_admin/uploads/_index.html.erb
+0
-10
| @@ | @@ -1,10 +0,0 @@ |
| - | <div id='file_uploads' class='box' data-path='<%= cms_admin_site_uploads_path(@site) %>'> |
| - | <div class='actions'> |
| - | <a id='uploader_button' href='#' class='big button'><%= t('.button') %></a> |
| - | </div> |
| - | <div id='uploaded_files'> |
| - | <% Cms::Upload.order('file_file_name').all.each do |file| %> |
| - | <%= render :partial => 'cms_admin/uploads/file', :object => file %> |
| - | <% end %> |
| - | </div> |
| - | </div> |
app/views/cms_admin/uploads/destroy.js.erb
+0
-3
| @@ | @@ -1,3 +0,0 @@ |
| - | $(".file#<%= dom_id(@upload) %>").fadeOut('slow', function(){ |
| - | $(this).remove() |
| - | }) |
| \ No newline at end of file | |
config/locales/en.yml
+2
-2
| @@ | @@ -75,7 +75,7 @@ en: |
| record_not_found: Record Not Found | |
| not_found: Revision Not Found | |
| - | uploads: |
| + | files: |
| content: | |
| site_not_found: Site Not Found | |
| @@ | @@ -174,7 +174,7 @@ en: |
| slug: Slug | |
| update: Update to this Revision | |
| - | uploads: |
| + | files: |
| index: | |
| button: Upload Files | |
| \ No newline at end of file | |
config/locales/es.yml
+2
-2
| @@ | @@ -75,7 +75,7 @@ es: |
| record_not_found: Registro no encontrado | |
| not_found: Revisión no encontrada | |
| - | uploads: |
| + | files: |
| content: | |
| site_not_found: Sitio no encontrado | |
| @@ | @@ -174,6 +174,6 @@ es: |
| slug: Identificador | |
| update: Actualizar a esta versión | |
| - | uploads: |
| + | files: |
| index: | |
| button: Cargar Archivos | |
config/routes.rb
+1
-1
| @@ | @@ -15,7 +15,7 @@ Rails.application.routes.draw do |
| put :revert, :on => :member | |
| end | |
| end | |
| - | resources :uploads, :only => [:create, :destroy] |
| + | resources :files |
| resources :layouts do | |
| resources :revisions, :only => [:index, :show, :revert] do | |
| put :revert, :on => :member | |
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb
+3
-3
| @@ | @@ -68,15 +68,15 @@ class CreateCms < ActiveRecord::Migration |
| end | |
| add_index :cms_snippets, [:site_id, :slug], :unique => true | |
| - | # -- Assets ------------------------------------------------------------- |
| - | create_table :cms_uploads do |t| |
| + | # -- Files -------------------------------------------------------------- |
| + | create_table :cms_files do |t| |
| t.integer :site_id | |
| t.string :file_file_name | |
| t.string :file_content_type | |
| t.integer :file_file_size | |
| t.timestamps | |
| end | |
| - | add_index :cms_uploads, [:site_id, :file_file_name] |
| + | add_index :cms_files, [:site_id, :file_file_name] |
| # -- Revisions ----------------------------------------------------------- | |
| create_table :cms_revisions, :force => true do |t| | |
migrate/upgrades/05_upgrade_to_1_4_0.rb b/db/migrate/upgrades/05_upgrade_to_1_4_0.rb
+9
-0
| @@ | @@ -0,0 +1,9 @@ |
| + | class UpgradeTo130 < ActiveRecord::Migration |
| + | def self.up |
| + | rename_table :cms_uploads, :cms_files |
| + | end |
| + | |
| + | def self.down |
| + | rename_table :cms_files, :cms_uploads |
| + | end |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tag.rb b/lib/comfortable_mexican_sofa/tag.rb
+2
-2
| @@ | @@ -85,8 +85,8 @@ module ComfortableMexicanSofa::Tag |
| end | |
| # Initializing Cms::Upload object | |
| - | def upload |
| - | page.site.uploads.detect{|s| s.file_file_name == self.label.to_s} |
| + | def file |
| + | page.site.files.detect{|f| f.file_file_name == self.label.to_s} |
| end | |
| # Checks if this tag is using Cms::Block | |
comfortable_mexican_sofa/tags/file.rb b/lib/comfortable_mexican_sofa/tags/file.rb
+24
-0
| @@ | @@ -0,0 +1,24 @@ |
| + | class ComfortableMexicanSofa::Tag::File |
| + | include ComfortableMexicanSofa::Tag |
| + | |
| + | def self.regex_tag_signature(label = nil) |
| + | label ||= /[\w\-\.]+/ |
| + | /\{\{\s*cms:file:(#{label}):?(.*?)\s*\}\}/ |
| + | end |
| + | |
| + | def content |
| + | return unless file |
| + | |
| + | format = params[0] |
| + | text = params[1] || label |
| + | |
| + | case format |
| + | when 'link' |
| + | "<a href='#{file.file.url}' target='_blank'>#{text}</a>" |
| + | when 'image' |
| + | "<img src='#{file.file.url}' alt='#{text}' />" |
| + | else |
| + | file.file.url |
| + | end |
| + | end |
| + | end |
| \ No newline at end of file | |
comfortable_mexican_sofa/tags/upload.rb b/lib/comfortable_mexican_sofa/tags/upload.rb
+0
-24
| @@ | @@ -1,24 +0,0 @@ |
| - | class ComfortableMexicanSofa::Tag::Upload |
| - | include ComfortableMexicanSofa::Tag |
| - | |
| - | def self.regex_tag_signature(label = nil) |
| - | label ||= /[\w\-\.]+/ |
| - | /\{\{\s*cms:upload:(#{label}):?(.*?)\s*\}\}/ |
| - | end |
| - | |
| - | def content |
| - | return unless upload |
| - | |
| - | format = params[0] |
| - | text = params[1] || label |
| - | |
| - | case format |
| - | when 'link' |
| - | "<a href='#{upload.file.url}' target='_blank'>#{text}</a>" |
| - | when 'image' |
| - | "<img src='#{upload.file.url}' alt='#{text}' />" |
| - | else |
| - | upload.file.url |
| - | end |
| - | end |
| - | end |
| \ No newline at end of file | |
test/fixtures/cms/files.yml
+5
-0
| @@ | @@ -0,0 +1,5 @@ |
| + | default: |
| + | site: default |
| + | file_file_name: sample.jpg |
| + | file_content_type: image/jpeg |
| + | file_file_size: 20099 |
| \ No newline at end of file | |
test/fixtures/cms/uploads.yml
+0
-5
| @@ | @@ -1,5 +0,0 @@ |
| - | default: |
| - | site: default |
| - | file_file_name: sample.jpg |
| - | file_content_type: image/jpeg |
| - | file_file_size: 20099 |
| \ No newline at end of file | |
test/functional/cms_admin/files_controller_test.rb
+26
-0
| @@ | @@ -0,0 +1,26 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class CmsAdmin::FilesControllerTest < ActionController::TestCase |
| + | |
| + | def test_create |
| + | assert_difference 'Cms::File.count', 1 do |
| + | xhr :post, :create, :site_id => cms_sites(:default), :file => fixture_file_upload('files/valid_image.jpg') |
| + | assert_response :success |
| + | end |
| + | end |
| + | |
| + | def test_create_failure |
| + | assert_no_difference 'Cms::File.count' do |
| + | xhr :post, :create, :site_id => cms_sites(:default), :file => nil |
| + | assert_response :bad_request |
| + | end |
| + | end |
| + | |
| + | def test_destroy |
| + | assert_difference 'Cms::File.count', -1 do |
| + | xhr :delete, :destroy, :site_id => cms_sites(:default), :id => cms_files(:default) |
| + | assert_response :success |
| + | end |
| + | end |
| + | |
| + | end |
test/functional/cms_admin/uploads_controller_test.rb
+0
-26
| @@ | @@ -1,26 +0,0 @@ |
| - | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| - | |
| - | class CmsAdmin::UploadsControllerTest < ActionController::TestCase |
| - | |
| - | def test_create |
| - | assert_difference 'Cms::Upload.count', 1 do |
| - | xhr :post, :create, :site_id => cms_sites(:default), :file => fixture_file_upload('files/valid_image.jpg') |
| - | assert_response :success |
| - | end |
| - | end |
| - | |
| - | def test_create_failure |
| - | assert_no_difference 'Cms::Upload.count' do |
| - | xhr :post, :create, :site_id => cms_sites(:default), :file => nil |
| - | assert_response :bad_request |
| - | end |
| - | end |
| - | |
| - | def test_destroy |
| - | assert_difference 'Cms::Upload.count', -1 do |
| - | xhr :delete, :destroy, :site_id => cms_sites(:default), :id => cms_uploads(:default) |
| - | assert_response :success |
| - | end |
| - | end |
| - | |
| - | end |
test/unit/models/file_test.rb
+32
-0
| @@ | @@ -0,0 +1,32 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class CmsFileTest < ActiveSupport::TestCase |
| + | |
| + | def test_fixtures_validity |
| + | Cms::File.all.each do |file| |
| + | assert file.valid?, file.errors.full_messages.to_s |
| + | end |
| + | end |
| + | |
| + | def test_validations |
| + | assert_no_difference 'Cms::File.count' do |
| + | file = Cms::File.create |
| + | assert file.errors.present? |
| + | assert_has_errors_on file, [:file_file_name] |
| + | end |
| + | end |
| + | |
| + | def test_create |
| + | assert_difference 'Cms::File.count' do |
| + | cms_sites(:default).files.create( |
| + | :file => fixture_file_upload('files/valid_image.jpg') |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_create_failure |
| + | assert_no_difference 'Cms::File.count' do |
| + | cms_sites(:default).files.create(:file => '') |
| + | end |
| + | end |
| + | end |
test/unit/models/upload_test.rb
+0
-32
| @@ | @@ -1,32 +0,0 @@ |
| - | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| - | |
| - | class CmsUploadTest < ActiveSupport::TestCase |
| - | |
| - | def test_fixtures_validity |
| - | Cms::Upload.all.each do |upload| |
| - | assert upload.valid?, upload.errors.full_messages.to_s |
| - | end |
| - | end |
| - | |
| - | def test_validations |
| - | assert_no_difference 'Cms::Upload.count' do |
| - | upload = Cms::Upload.create |
| - | assert upload.errors.present? |
| - | assert_has_errors_on upload, [:file_file_name] |
| - | end |
| - | end |
| - | |
| - | def test_create |
| - | assert_difference 'Cms::Upload.count' do |
| - | cms_sites(:default).uploads.create( |
| - | :file => fixture_file_upload('files/valid_image.jpg') |
| - | ) |
| - | end |
| - | end |
| - | |
| - | def test_create_failure |
| - | assert_no_difference 'Cms::Upload.count' do |
| - | cms_sites(:default).uploads.create(:file => '') |
| - | end |
| - | end |
| - | end |
test/unit/tags/asset_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class AssetTest < ActiveSupport::TestCase |
| + | class AssetTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::Asset.initialize_tag( | |
test/unit/tags/field_datetime_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class FieldDateTimeTest < ActiveSupport::TestCase |
| + | class FieldDateTimeTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::FieldDateTime.initialize_tag( | |
test/unit/tags/field_integer_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class FieldIntegerTest < ActiveSupport::TestCase |
| + | class FieldIntegerTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::FieldInteger.initialize_tag( | |
test/unit/tags/field_string_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class FieldStringTest < ActiveSupport::TestCase |
| + | class FieldStringTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::FieldString.initialize_tag( | |
test/unit/tags/field_text_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class FieldTextTest < ActiveSupport::TestCase |
| + | class FieldTextTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::FieldText.initialize_tag( | |
test/unit/tags/file_test.rb
+67
-0
| @@ | @@ -0,0 +1,67 @@ |
| + | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| + | |
| + | class FileTagTest < ActiveSupport::TestCase |
| + | |
| + | def test_initialize_tag |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg:image:alt text }}' |
| + | ) |
| + | assert_equal cms_files(:default), tag.file |
| + | assert_equal 'sample.jpg', tag.label |
| + | assert_equal ['image', 'alt text'], tag.params |
| + | end |
| + | |
| + | def test_initialize_tag_failure |
| + | [ |
| + | '{{cms:file}}', |
| + | '{{cms:not_file:label}}', |
| + | '{not_a_tag}' |
| + | ].each do |tag_signature| |
| + | assert_nil ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), tag_signature |
| + | ) |
| + | end |
| + | end |
| + | |
| + | def test_render_for_invalid |
| + | tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{cms:file:invalid.jpg}}' |
| + | ) |
| + | assert_nil tag.file |
| + | assert_equal '', tag.render |
| + | end |
| + | |
| + | def test_render |
| + | file = cms_files(:default) |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg }}' |
| + | ) |
| + | assert_equal file.file.url, tag.render |
| + | end |
| + | |
| + | def test_render_for_link |
| + | file = cms_files(:default) |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg:link }}' |
| + | ) |
| + | assert_equal "<a href='#{file.file.url}' target='_blank'>sample.jpg</a>", tag.render |
| + | |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg:link:link text }}' |
| + | ) |
| + | assert_equal "<a href='#{file.file.url}' target='_blank'>link text</a>", tag.render |
| + | end |
| + | |
| + | def test_render_for_image |
| + | file = cms_files(:default) |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg:image }}' |
| + | ) |
| + | assert_equal "<img src='#{file.file.url}' alt='sample.jpg' />", tag.render |
| + | |
| + | assert tag = ComfortableMexicanSofa::Tag::File.initialize_tag( |
| + | cms_pages(:default), '{{ cms:file:sample.jpg:image:alt text }}' |
| + | ) |
| + | assert_equal "<img src='#{file.file.url}' alt='alt text' />", tag.render |
| + | end |
| + | end |
| \ No newline at end of file | |
test/unit/tags/helper_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class HelperTest < ActiveSupport::TestCase |
| + | class HelperTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::Helper.initialize_tag( | |
test/unit/tags/page_datetime_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PageDateTimeTest < ActiveSupport::TestCase |
| + | class PageDateTimeTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::PageDateTime.initialize_tag( | |
test/unit/tags/page_integer_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PageIntegerTest < ActiveSupport::TestCase |
| + | class PageIntegerTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::PageInteger.initialize_tag( | |
test/unit/tags/page_rich_text.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PageRichTextTest < ActiveSupport::TestCase |
| + | class PageRichTextTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::PageRichText.initialize_tag( | |
test/unit/tags/page_string_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PageStringTest < ActiveSupport::TestCase |
| + | class PageStringTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::PageString.initialize_tag( | |
test/unit/tags/page_text_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PageTextTest < ActiveSupport::TestCase |
| + | class PageTextTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::PageText.initialize_tag( | |
test/unit/tags/partial_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class PartialTest < ActiveSupport::TestCase |
| + | class PartialTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::Partial.initialize_tag( | |
test/unit/tags/snippet_test.rb
+1
-1
| @@ | @@ -1,6 +1,6 @@ |
| require File.expand_path('../../test_helper', File.dirname(__FILE__)) | |
| - | class SnippetTest < ActiveSupport::TestCase |
| + | class SnippetTagTest < ActiveSupport::TestCase |
| def test_initialize_tag | |
| assert tag = ComfortableMexicanSofa::Tag::Snippet.initialize_tag( | |
test/unit/tags/upload_test.rb
+0
-67
| @@ | @@ -1,67 +0,0 @@ |
| - | require File.expand_path('../../test_helper', File.dirname(__FILE__)) |
| - | |
| - | class UploadTest < ActiveSupport::TestCase |
| - | |
| - | def test_initialize_tag |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg:image:alt text }}' |
| - | ) |
| - | assert_equal cms_uploads(:default), tag.upload |
| - | assert_equal 'sample.jpg', tag.label |
| - | assert_equal ['image', 'alt text'], tag.params |
| - | end |
| - | |
| - | def test_initialize_tag_failure |
| - | [ |
| - | '{{cms:upload}}', |
| - | '{{cms:not_upload:label}}', |
| - | '{not_a_tag}' |
| - | ].each do |tag_signature| |
| - | assert_nil ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), tag_signature |
| - | ) |
| - | end |
| - | end |
| - | |
| - | def test_render_for_invalid |
| - | tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{cms:upload:invalid.jpg}}' |
| - | ) |
| - | assert_nil tag.upload |
| - | assert_equal '', tag.render |
| - | end |
| - | |
| - | def test_render |
| - | upload = cms_uploads(:default) |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg }}' |
| - | ) |
| - | assert_equal upload.file.url, tag.render |
| - | end |
| - | |
| - | def test_render_for_link |
| - | upload = cms_uploads(:default) |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg:link }}' |
| - | ) |
| - | assert_equal "<a href='#{upload.file.url}' target='_blank'>sample.jpg</a>", tag.render |
| - | |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg:link:link text }}' |
| - | ) |
| - | assert_equal "<a href='#{upload.file.url}' target='_blank'>link text</a>", tag.render |
| - | end |
| - | |
| - | def test_render_for_image |
| - | upload = cms_uploads(:default) |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg:image }}' |
| - | ) |
| - | assert_equal "<img src='#{upload.file.url}' alt='sample.jpg' />", tag.render |
| - | |
| - | assert tag = ComfortableMexicanSofa::Tag::Upload.initialize_tag( |
| - | cms_pages(:default), '{{ cms:upload:sample.jpg:image:alt text }}' |
| - | ) |
| - | assert_equal "<img src='#{upload.file.url}' alt='alt text' />", tag.render |
| - | end |
| - | end |
| \ No newline at end of file | |