Commit 09d0a1d6c190512c96cdde21a56f19f8d07854f5

Authored by MoisesMachado
1 parent 6848dff6

ActionItem591: preserve type of article on copy

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2419 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/article.rb
@@ -170,7 +170,7 @@ class Article < ActiveRecord::Base @@ -170,7 +170,7 @@ class Article < ActiveRecord::Base
170 def copy(options) 170 def copy(options)
171 attrs = attributes.reject! { |key, value| article_attr_blacklist.include?(key) } 171 attrs = attributes.reject! { |key, value| article_attr_blacklist.include?(key) }
172 attrs.merge!(options) 172 attrs.merge!(options)
173 - Article.create(attrs) 173 + self.class.create(attrs)
174 end 174 end
175 175
176 def article_attr_blacklist 176 def article_attr_blacklist
test/unit/article_test.rb
@@ -433,4 +433,12 @@ class ArticleTest < Test::Unit::TestCase @@ -433,4 +433,12 @@ class ArticleTest < Test::Unit::TestCase
433 assert_equal 'some text', b.body 433 assert_equal 'some text', b.body
434 end 434 end
435 435
  436 + should 'mantain the type in a copy' do
  437 + p = create_user('test_user').person
  438 + a = Folder.create!(:name => 'test folder', :profile => p)
  439 + b = a.copy(:parent => a, :profile => p)
  440 +
  441 + assert_kind_of Folder, b
  442 + end
  443 +
436 end 444 end