Commit 502073f7bf28d64ec2227db1496c4381d12b103e

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent d27a79ec

Articles published from external_feeds copy the source

(ActionItem1620)
app/models/approve_article.rb
... ... @@ -64,7 +64,7 @@ class ApproveArticle < Task
64 64 end
65 65  
66 66 def perform
67   - PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted)
  67 + PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source)
68 68 end
69 69  
70 70 def target_notification_message
... ...
db/migrate/20100811211216_set_published_articles_source.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class SetPublishedArticlesSource < ActiveRecord::Migration
  2 + def self.up
  3 + update("update articles set source = (select source from articles origin where origin.id = articles.reference_article_id) where articles.type = 'PublishedArticle';")
  4 + end
  5 +
  6 + def self.down
  7 + say "this migration can't be reverted"
  8 + end
  9 +end
... ...
test/unit/approve_article_test.rb
... ... @@ -97,4 +97,14 @@ class ApproveArticleTest &lt; ActiveSupport::TestCase
97 97 assert ActionMailer::Base.deliveries.empty?
98 98 end
99 99  
  100 + should 'copy the source from the original article' do
  101 + article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article', :source => "sample-feed.com")
  102 + community = fast_create(Community, :name => 'test comm')
  103 +
  104 + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile)
  105 + a.finish
  106 +
  107 + assert_equal PublishedArticle.last.source, article.source
  108 + end
  109 +
100 110 end
... ...