diff --git a/app/models/approve_article.rb b/app/models/approve_article.rb index 853c523..e242252 100644 --- a/app/models/approve_article.rb +++ b/app/models/approve_article.rb @@ -64,7 +64,7 @@ class ApproveArticle < Task end def perform - PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted) + PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted, :source => article.source) end def target_notification_message diff --git a/db/migrate/20100811211216_set_published_articles_source.rb b/db/migrate/20100811211216_set_published_articles_source.rb new file mode 100644 index 0000000..d07a9d5 --- /dev/null +++ b/db/migrate/20100811211216_set_published_articles_source.rb @@ -0,0 +1,9 @@ +class SetPublishedArticlesSource < ActiveRecord::Migration + def self.up + update("update articles set source = (select source from articles origin where origin.id = articles.reference_article_id) where articles.type = 'PublishedArticle';") + end + + def self.down + say "this migration can't be reverted" + end +end diff --git a/test/unit/approve_article_test.rb b/test/unit/approve_article_test.rb index 2aab15d..c10ba92 100644 --- a/test/unit/approve_article_test.rb +++ b/test/unit/approve_article_test.rb @@ -97,4 +97,14 @@ class ApproveArticleTest < ActiveSupport::TestCase assert ActionMailer::Base.deliveries.empty? end + should 'copy the source from the original article' do + article = fast_create(TextArticle, :profile_id => profile.id, :name => 'test article', :source => "sample-feed.com") + community = fast_create(Community, :name => 'test comm') + + a = ApproveArticle.create!(:name => 'test name', :article => article, :target => community, :requestor => profile) + a.finish + + assert_equal PublishedArticle.last.source, article.source + end + end -- libgit2 0.21.2