Commit 68daacb6ce92f6ed11ceafbf060286927f9c85db
1 parent
2636b292
Exists in
master
and in
28 other branches
ActionItem514: category is now updating categorization of parents of categories …
…to non virtual properly git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2205 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
app/models/categorization.rb
... | ... | @@ -9,6 +9,8 @@ module Categorization |
9 | 9 | connection.execute("insert into #{table_name} (category_id, #{object_id_column}, virtual) values(#{c.id}, #{object.id}, 1>0)") |
10 | 10 | c = c.parent |
11 | 11 | end |
12 | + else | |
13 | + connection.execute "update #{table_name} set virtual = (1!=1) where #{object_id_column} = #{object.id} and category_id = #{category.id}" | |
12 | 14 | end |
13 | 15 | end |
14 | 16 | ... | ... |
test/unit/article_categorization_test.rb
... | ... | @@ -74,4 +74,15 @@ class ArticleCategorizationTest < Test::Unit::TestCase |
74 | 74 | end |
75 | 75 | end |
76 | 76 | |
77 | + should 'make parent real when categorized after child' do | |
78 | + c1 = Category.create!(:name => 'c1', :environment => Environment.default) | |
79 | + c2 = c1.children.create!(:name => 'c2', :environment => Environment.default) | |
80 | + | |
81 | + p = create_user('testuser').person | |
82 | + a = p.articles.create!(:name => 'test') | |
83 | + ArticleCategorization.add_category_to_article(c2, a) | |
84 | + ArticleCategorization.add_category_to_article(c1, a) | |
85 | + | |
86 | + assert ArticleCategorization.find(:first, :conditions => [ 'category_id = ? and article_id = ? and not virtual', c1.id, a.id ]), 'categorization must be promoted to not virtual' | |
87 | + end | |
77 | 88 | end | ... | ... |