diff --git a/app/models/rss_feed.rb b/app/models/rss_feed.rb index 38e3b34..046fd1a 100644 --- a/app/models/rss_feed.rb +++ b/app/models/rss_feed.rb @@ -1,7 +1,7 @@ class RssFeed < Article # store setting in body - serialize Hash, :body + serialize :body, Hash def body self[:body] ||= {} diff --git a/app/views/cms/_rss_feed.rhtml b/app/views/cms/_rss_feed.rhtml new file mode 100644 index 0000000..5996afd --- /dev/null +++ b/app/views/cms/_rss_feed.rhtml @@ -0,0 +1,7 @@ +<%= f.text_field :name %> + +<%= 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(_('Include:'), f.select(:include, [ [ _('All articles'), 'all' ], [ _('Only articles child of the same article as the feed'), 'parent_and_children']] )) %> diff --git a/test/functional/cms_controller_test.rb b/test/functional/cms_controller_test.rb index f4098d2..a6bb627 100644 --- a/test/functional/cms_controller_test.rb +++ b/test/functional/cms_controller_test.rb @@ -142,4 +142,24 @@ class CmsControllerTest < Test::Unit::TestCase end end + should 'be able to create a RSS feed' do + login_as('ze') + assert_difference RssFeed, :count do + post :new, :type => RssFeed.name, :profile => profile.identifier, :article => { :name => 'feed', :limit => 15, :include => 'all', :feed_item_description => 'body' } + assert_response :redirect + end + end + + should 'be able to update a RSS feed' do + login_as('ze') + feed = RssFeed.create!(:name => 'myfeed', :limit => 5, :feed_item_description => 'body', :include => 'all', :profile_id => profile.id) + post :edit, :profile => profile.identifier, :id => feed.id, :article => { :limit => 77, :feed_item_description => 'abstract', :include => 'parent_and_children' } + assert_response :redirect + + updated = RssFeed.find(feed.id) + assert_equal 77, updated.limit + assert_equal 'abstract', updated.feed_item_description + assert_equal 'parent_and_children', updated.include + end + end diff --git a/test/unit/rss_feed_test.rb b/test/unit/rss_feed_test.rb index 2bebdf6..95709b4 100644 --- a/test/unit/rss_feed_test.rb +++ b/test/unit/rss_feed_test.rb @@ -165,12 +165,12 @@ class RssFeedTest < Test::Unit::TestCase end should 'provide proper short description' do - RssFeed.expects(:==).with(Article).returns(true).at_least_once + RssFeed.stubs(:==).with(Article).returns(true) assert_not_equal Article.short_description, RssFeed.short_description end should 'provide proper description' do - RssFeed.expects(:==).with(Article).returns(true).at_least_once + RssFeed.stubs(:==).with(Article).returns(true) assert_not_equal Article.description, RssFeed.description end -- libgit2 0.21.2