Commit d568d8b7572e89e5dcea26d9cbfc71ebc8881330

Authored by Rodrigo Souto
1 parent f300fee3

[otw] Fixing external feed

app/models/external_feed.rb
... ... @@ -20,7 +20,14 @@ class ExternalFeed < ActiveRecord::Base
20 20 end
21 21 content = doc.to_s
22 22  
23   - article = TinyMceArticle.new(:name => title, :profile => blog.profile, :body => content, :published_at => date, :source => link, :profile => blog.profile, :parent => blog)
  23 + article = TinyMceArticle.new
  24 + article.name = title
  25 + article.profile = blog.profile
  26 + article.body = content
  27 + article.published_at = date
  28 + article.source = link
  29 + article.profile = blog.profile
  30 + article.parent = blog
24 31 unless blog.children.exists?(:slug => article.slug)
25 32 article.save!
26 33 article.delay.create_activity
... ...
test/unit/external_feed_test.rb
... ... @@ -58,13 +58,13 @@ class ExternalFeedTest < ActiveSupport::TestCase
58 58 end
59 59  
60 60 should 'require address if enabled' do
61   - e = ExternalFeed.new(:enabled => true)
  61 + e = build(ExternalFeed, :enabled => true)
62 62 assert !e.valid?
63 63 assert e.errors[:address]
64 64 end
65 65  
66 66 should 'not require address if disabled' do
67   - e = ExternalFeed.new(:enabled => false, :address => nil)
  67 + e = build(ExternalFeed, :enabled => false, :address => nil)
68 68 e.valid?
69 69 assert !e.errors[:address]
70 70 end
... ... @@ -132,7 +132,7 @@ class ExternalFeedTest < ActiveSupport::TestCase
132 132 end
133 133  
134 134 should 'have an update errors counter' do
135   - assert_equal 3, ExternalFeed.new(:update_errors => 3).update_errors
  135 + assert_equal 3, build(ExternalFeed, :update_errors => 3).update_errors
136 136 end
137 137  
138 138 should 'have 0 update errors by default' do
... ...