From d568d8b7572e89e5dcea26d9cbfc71ebc8881330 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 19 Sep 2013 14:56:28 -0300 Subject: [PATCH] [otw] Fixing external feed --- app/models/external_feed.rb | 9 ++++++++- test/unit/external_feed_test.rb | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/external_feed.rb b/app/models/external_feed.rb index 3af3247..f7916db 100644 --- a/app/models/external_feed.rb +++ b/app/models/external_feed.rb @@ -20,7 +20,14 @@ class ExternalFeed < ActiveRecord::Base end content = doc.to_s - article = TinyMceArticle.new(:name => title, :profile => blog.profile, :body => content, :published_at => date, :source => link, :profile => blog.profile, :parent => blog) + article = TinyMceArticle.new + article.name = title + article.profile = blog.profile + article.body = content + article.published_at = date + article.source = link + article.profile = blog.profile + article.parent = blog unless blog.children.exists?(:slug => article.slug) article.save! article.delay.create_activity diff --git a/test/unit/external_feed_test.rb b/test/unit/external_feed_test.rb index 5462ea8..836f4b6 100644 --- a/test/unit/external_feed_test.rb +++ b/test/unit/external_feed_test.rb @@ -58,13 +58,13 @@ class ExternalFeedTest < ActiveSupport::TestCase end should 'require address if enabled' do - e = ExternalFeed.new(:enabled => true) + e = build(ExternalFeed, :enabled => true) assert !e.valid? assert e.errors[:address] end should 'not require address if disabled' do - e = ExternalFeed.new(:enabled => false, :address => nil) + e = build(ExternalFeed, :enabled => false, :address => nil) e.valid? assert !e.errors[:address] end @@ -132,7 +132,7 @@ class ExternalFeedTest < ActiveSupport::TestCase end should 'have an update errors counter' do - assert_equal 3, ExternalFeed.new(:update_errors => 3).update_errors + assert_equal 3, build(ExternalFeed, :update_errors => 3).update_errors end should 'have 0 update errors by default' do -- libgit2 0.21.2