Commit 09d0a1d6c190512c96cdde21a56f19f8d07854f5
1 parent
6848dff6
Exists in
master
and in
29 other branches
ActionItem591: preserve type of article on copy
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2419 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
9 additions
and
1 deletions
Show diff stats
app/models/article.rb
... | ... | @@ -170,7 +170,7 @@ class Article < ActiveRecord::Base |
170 | 170 | def copy(options) |
171 | 171 | attrs = attributes.reject! { |key, value| article_attr_blacklist.include?(key) } |
172 | 172 | attrs.merge!(options) |
173 | - Article.create(attrs) | |
173 | + self.class.create(attrs) | |
174 | 174 | end |
175 | 175 | |
176 | 176 | def article_attr_blacklist | ... | ... |
test/unit/article_test.rb
... | ... | @@ -433,4 +433,12 @@ class ArticleTest < Test::Unit::TestCase |
433 | 433 | assert_equal 'some text', b.body |
434 | 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 | 444 | end | ... | ... |