From 132c1fdd7870b4d62882d2f318a48e1103216205 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 27 Dec 2007 18:46:42 +0000 Subject: [PATCH] ActionItem24: yet implementing support for different types of articles --- app/controllers/my_profile/cms_controller.rb | 4 +++- app/models/textile_article.rb | 15 +++++++++++++++ app/models/tiny_mce_article.rb | 8 ++++++++ app/views/cms/_textile_article.rhtml | 11 +++++++++++ app/views/cms/_tiny_mce_article.rhtml | 2 ++ app/views/cms/edit.rhtml | 1 - test/functional/cms_controller_test.rb | 4 ++-- test/unit/textile_article_test.rb | 26 ++++++++++++++++++++++++++ 8 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 app/models/textile_article.rb create mode 100644 app/views/cms/_textile_article.rhtml create mode 100644 test/unit/textile_article_test.rb diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 0c07255..51946df 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -7,7 +7,9 @@ class CmsController < MyProfileController include CmsHelper ARTICLE_TYPES = [ - TinyMceArticle + TinyMceArticle, + TextileArticle, + RssFeed ] def view diff --git a/app/models/textile_article.rb b/app/models/textile_article.rb new file mode 100644 index 0000000..3da4bf0 --- /dev/null +++ b/app/models/textile_article.rb @@ -0,0 +1,15 @@ +class TextileArticle < Article + + def self.short_description + _('Text article with Textile markup language') + end + + def self.description + _('Accessible alternative for visually impaired users.') + end + + def to_html + RedCloth.new(self.body).to_html + end + +end diff --git a/app/models/tiny_mce_article.rb b/app/models/tiny_mce_article.rb index 46168f6..68af130 100644 --- a/app/models/tiny_mce_article.rb +++ b/app/models/tiny_mce_article.rb @@ -1,2 +1,10 @@ class TinyMceArticle < Article + + def self.short_description + _('Text article with visual editor.') + end + + def self.description + _('Not accessible for visually impaired users.') + end end diff --git a/app/views/cms/_textile_article.rhtml b/app/views/cms/_textile_article.rhtml new file mode 100644 index 0000000..6424f25 --- /dev/null +++ b/app/views/cms/_textile_article.rhtml @@ -0,0 +1,11 @@ + +<%# TODO add Textile help here %> + +<%= f.text_field('name', :size => '64') %> + +<%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> + +<%= f.text_area('abstract', :cols => 64, :rows => 5) %> + +<%= f.text_area('body', :cols => 64) %> + diff --git a/app/views/cms/_tiny_mce_article.rhtml b/app/views/cms/_tiny_mce_article.rhtml index 2a2f9d6..3e362c0 100644 --- a/app/views/cms/_tiny_mce_article.rhtml +++ b/app/views/cms/_tiny_mce_article.rhtml @@ -1,4 +1,6 @@ +<%= render :file => 'shared/tiny_mce' %> + <%= f.text_field('name', :size => '64') %> <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> diff --git a/app/views/cms/edit.rhtml b/app/views/cms/edit.rhtml index b016899..a3f20b9 100644 --- a/app/views/cms/edit.rhtml +++ b/app/views/cms/edit.rhtml @@ -1,6 +1,5 @@ -<%= render :file => 'shared/tiny_mce' %> <%= error_messages_for 'article' %> diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 077c5ff..f4098d2 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -56,8 +56,8 @@ class CmsControllerTest < Test::Unit::TestCase assert_template 'select_article_type' # TODO add more types here !! - [ 'TinyMceArticle' ].each do |item| - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=#{item}" } + [ TinyMceArticle, TextileArticle ].each do |item| + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/cms/new?type=#{item.name}" } end end diff --git a/test/unit/textile_article_test.rb b/test/unit/textile_article_test.rb new file mode 100644 index 0000000..b0525d9 --- /dev/null +++ b/test/unit/textile_article_test.rb @@ -0,0 +1,26 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class TextileArticleTest < Test::Unit::TestCase + + def setup + @profile = create_user('testing').person + end + attr_reader :profile + + should 'provide a proper short description' do + # not test the actual text, though + TextileArticle.stubs(:==).with(Article).returns(true) + assert_not_equal Article.short_description, TextileArticle.short_description + end + + should 'provide a proper description' do + # not test the actual text, though + TextileArticle.stubs(:==).with(Article).returns(true) + assert_not_equal Article.description, TextileArticle.description + end + + should 'convert Textile to HTML' do + assert_equal '

my text

', TextileArticle.new(:body => '*my text*').to_html + end + +end -- libgit2 0.21.2