From 3d6e53c7d761c69192959756ed32230909180008 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 28 Dec 2007 14:22:22 +0000 Subject: [PATCH] ActionItem24: checkpoint --- app/controllers/my_profile/cms_controller.rb | 3 ++- app/controllers/public/content_viewer_controller.rb | 9 ++++++++- app/models/rss_feed.rb | 4 +++- app/models/uploaded_file.rb | 12 +++++++++++- app/views/cms/_rss_feed.rhtml | 2 +- app/views/cms/_textile_article.rhtml | 2 -- app/views/cms/_tiny_mce_article.rhtml | 2 -- app/views/cms/edit.rhtml | 5 ++++- test/fixtures/files/test.txt | 1 + test/functional/cms_controller_test.rb | 8 +++++++- test/unit/article_test.rb | 8 ++++++++ test/unit/profile_test.rb | 4 ++++ test/unit/rss_feed_test.rb | 8 ++++++++ test/unit/uploaded_file_test.rb | 13 +++++++++++++ 14 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 test/fixtures/files/test.txt diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 51946df..5b1d6b1 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -9,7 +9,8 @@ class CmsController < MyProfileController ARTICLE_TYPES = [ TinyMceArticle, TextileArticle, - RssFeed + RssFeed, + UploadedFile, ] def view diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index e97dcdb..ce88259 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -21,7 +21,14 @@ class ContentViewerController < PublicController if @page.mime_type != 'text/html' headers['Content-Type'] = @page.mime_type - render :text => @page.data, :layout => false + data = @page.data + + # TODO test the condition + if data.nil? + raise "No data for file" + end + + render :text => data, :layout => false return end diff --git a/app/models/rss_feed.rb b/app/models/rss_feed.rb index 86b0b99..cd6499d 100644 --- a/app/models/rss_feed.rb +++ b/app/models/rss_feed.rb @@ -69,8 +69,9 @@ class RssFeed < Article xml.rss(:version=>"2.0") do xml.channel do xml.title(_("%s's RSS feed") % (self.profile.name)) + # FIXME link to profile xml.link("http://www.yourDomain.com") - xml.description('Description here') + xml.description(_("%s's content published at %s") % [self.profile.name, self.profile.environment.name]) xml.language("pt_BR") for article in articles unless self == article @@ -83,6 +84,7 @@ class RssFeed < Article end # rfc822 xml.pubDate(article.created_on.rfc2822) + # FIXME link to article xml.link("http://www.yourDomain.com/linkToYourPost") xml.guid("http://www.yourDomain.com/linkToYourPost") end diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 6132067..ac2907b 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -1,7 +1,7 @@ class UploadedFile < Article # FIXME need to define min/max file size - has_attachment :thumbnails => { :icon => [24,24] } + has_attachment :thumbnails => { :icon => [24,24] }, :storage => :file_system def icon_name self.image? ? public_filename(:icon) : self.content_type.gsub('/', '-') @@ -19,4 +19,14 @@ class UploadedFile < Article _('Upload any kind of file you want.') end + alias :orig_set_filename :filename= + def filename=(value) + orig_set_filename(value) + self.name = self.filename + end + + def data + File.read(self.full_filename) + end + end diff --git a/app/views/cms/_rss_feed.rhtml b/app/views/cms/_rss_feed.rhtml index 5996afd..0378fd7 100644 --- a/app/views/cms/_rss_feed.rhtml +++ b/app/views/cms/_rss_feed.rhtml @@ -2,6 +2,6 @@ <%= labelled_form_field(_('Limit of articles'), f.text_field(:limit)) %> -<%= labelled_form_field(_('Use as item description:'), f.select(:feed_item_description, [ [ _('Article body'), 'body'], [ _('Article abstract'), 'abstract']])) %> +<%= labelled_form_field(_('Use as item description:'), f.select(:feed_item_description, [ [ _('Article abstract'), 'abstract'], [ _('Article body'), 'body']])) %> <%= labelled_form_field(_('Include:'), f.select(:include, [ [ _('All articles'), 'all' ], [ _('Only articles child of the same article as the feed'), 'parent_and_children']] )) %> diff --git a/app/views/cms/_textile_article.rhtml b/app/views/cms/_textile_article.rhtml index 6424f25..e7abb62 100644 --- a/app/views/cms/_textile_article.rhtml +++ b/app/views/cms/_textile_article.rhtml @@ -3,8 +3,6 @@ <%= 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 3e362c0..0a0a855 100644 --- a/app/views/cms/_tiny_mce_article.rhtml +++ b/app/views/cms/_tiny_mce_article.rhtml @@ -3,8 +3,6 @@ <%= 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/edit.rhtml b/app/views/cms/edit.rhtml index a3f20b9..f4fbd8a 100644 --- a/app/views/cms/edit.rhtml +++ b/app/views/cms/edit.rhtml @@ -3,7 +3,7 @@ <%= error_messages_for 'article' %> -<% labelled_form_for 'article', @article do |f| %> +<% labelled_form_for 'article', @article, :html => { :multipart => true } do |f| %> <%= hidden_field_tag("type", params[:type]) if params[:type] %> @@ -11,6 +11,9 @@ <%= render :partial => partial_for_class(@article.class), :locals => { :f => f } %> + <%# TODO display the tooltip (title below) in a directly visible way %> + <%= f.text_field('tag_list', :size => 64, :title => _('Separate tags with commas')) %> + <%= design_display_button_submit('save', _('Save')) %> <%= design_display_button('cancel', _('Cancel'), :action => (@article.parent ? 'view' : 'index'), :id => @article.parent) %> <% end %> diff --git a/test/fixtures/files/test.txt b/test/fixtures/files/test.txt new file mode 100644 index 0000000..1f38c8d --- /dev/null +++ b/test/fixtures/files/test.txt @@ -0,0 +1 @@ +this is a sample text file diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index 6abff63..90f33ff 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -163,11 +163,17 @@ class CmsControllerTest < Test::Unit::TestCase end should 'be able to upload a file' do - flunk 'pending' + assert_difference UploadedFile, :count do + post :new, :type => UploadedFile.name, :profile => profile.identifier, :article => { :uploaded_data => fixture_file_upload('/files/test.txt', 'text/plain')} + end end should 'be able to update an uploaded file' do flunk 'pending' end + should 'not offer to create children if article does not accept them' do + flunk 'pending' + end + end diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 5cd0b4b..f6087ff 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -158,4 +158,12 @@ class ArticleTest < Test::Unit::TestCase assert_equal 'An article of type "MyClass"', klass.description end + should 'indicate wheter children articles are allowed or not' do + flunk 'pending' + end + + should 'provide a url to itself' do + flunk 'pending' + end + end diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index d8782fb..80c5c67 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -217,6 +217,10 @@ class ProfileTest < Test::Unit::TestCase assert_equal blocks - profile_blocks, Design::Block.count end + should 'provide url to itself' do + flunk 'pending' + end + private def assert_invalid_identifier(id) diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb index 67b42cd..c83ba39 100644 --- a/test/unit/rss_feed_test.rb +++ b/test/unit/rss_feed_test.rb @@ -106,6 +106,14 @@ class RssFeedTest < Test::Unit::TestCase assert_no_match /article 2<\/title>/, rss end + should 'provide link to profile' do + flunk 'pending' + end + + should 'provide link to each article' do + flunk 'pending' + end + should 'be able to indicate maximum number of items' do profile = create_user('testuser').person a1 = profile.articles.build(:name => 'article 1'); a1.save! diff --git a/test/unit/uploaded_file_test.rb b/test/unit/uploaded_file_test.rb index 305cfca..ff6eedb 100644 --- a/test/unit/uploaded_file_test.rb +++ b/test/unit/uploaded_file_test.rb @@ -32,4 +32,17 @@ class UploadedFileTest < Test::Unit::TestCase assert_not_equal Article.short_description, UploadedFile.short_description end + should 'set name from uploaded filename' do + file = UploadedFile.new + file.filename = 'test.txt' + assert_equal 'test.txt', file.name + end + + should 'provide file content as data' do + file = UploadedFile.new + file.expects(:full_filename).returns('myfilename') + File.expects(:read).with('myfilename').returns('my data') + assert_equal 'my data', file.data + end + end -- libgit2 0.21.2