diff --git a/app/models/article.rb b/app/models/article.rb index 6db4cd7..ec1f7e6 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -170,7 +170,7 @@ class Article < ActiveRecord::Base def copy(options) attrs = attributes.reject! { |key, value| article_attr_blacklist.include?(key) } attrs.merge!(options) - Article.create(attrs) + self.class.create(attrs) end def article_attr_blacklist diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 73e1a76..1c15c2c 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -433,4 +433,12 @@ class ArticleTest < Test::Unit::TestCase assert_equal 'some text', b.body end + should 'mantain the type in a copy' do + p = create_user('test_user').person + a = Folder.create!(:name => 'test folder', :profile => p) + b = a.copy(:parent => a, :profile => p) + + assert_kind_of Folder, b + end + end -- libgit2 0.21.2