Commit ae14ca6cee7a6e61b28be5a69794e58d884e50c7

Authored by MoisesMachado
1 parent 0b2d24fc

ActionItem4: testing tags extensions

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@120 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/manage_tags_controller.rb
@@ -35,7 +35,7 @@ class ManageTagsController < ApplicationController @@ -35,7 +35,7 @@ class ManageTagsController < ApplicationController
35 # Prompt for modifications on the attributes of a tag 35 # Prompt for modifications on the attributes of a tag
36 def edit 36 def edit
37 @tag = Tag.find_with_pendings(params[:id]) 37 @tag = Tag.find_with_pendings(params[:id])
38 - @parent_tags = @tag.parents_candidates 38 + @parent_tags = @tag.parent_candidates
39 end 39 end
40 40
41 # Do the modifications collected by edit 41 # Do the modifications collected by edit
@@ -45,7 +45,7 @@ class ManageTagsController < ApplicationController @@ -45,7 +45,7 @@ class ManageTagsController < ApplicationController
45 flash[:notice] = _('Tag was successfully updated.') 45 flash[:notice] = _('Tag was successfully updated.')
46 redirect_to :action => 'list' 46 redirect_to :action => 'list'
47 else 47 else
48 - @parent_tags = @tag.parents_candidates 48 + @parent_tags = @tag.parent_candidates
49 render :action => 'edit' 49 render :action => 'edit'
50 end 50 end
51 end 51 end
db/migrate/004_acts_as_taggable_migration.rb
@@ -3,7 +3,7 @@ class ActsAsTaggableMigration < ActiveRecord::Migration @@ -3,7 +3,7 @@ class ActsAsTaggableMigration < ActiveRecord::Migration
3 create_table :tags do |t| 3 create_table :tags do |t|
4 t.column :name, :string 4 t.column :name, :string
5 t.column :parent_id, :integer 5 t.column :parent_id, :integer
6 - t.column :pending, :boolean 6 + t.column :pending, :boolean, :default => false
7 end 7 end
8 8
9 create_table :taggings do |t| 9 create_table :taggings do |t|
lib/extended_tag.rb
@@ -17,7 +17,7 @@ class Tag @@ -17,7 +17,7 @@ class Tag
17 end 17 end
18 18
19 # All the tags that can be a new parent for this tag, that is all but itself and its descendents to avoid loops 19 # All the tags that can be a new parent for this tag, that is all but itself and its descendents to avoid loops
20 - def parents_candidates 20 + def parent_candidates
21 Tag.find(:all) - descendents - [self] 21 Tag.find(:all) - descendents - [self]
22 end 22 end
23 23
@@ -26,9 +26,4 @@ class Tag @@ -26,9 +26,4 @@ class Tag
26 children.to_a.sum([], &:descendents) + children 26 children.to_a.sum([], &:descendents) + children
27 end 27 end
28 28
29 - # Test if this tag has been approved already  
30 - def aproved?  
31 - not pending?  
32 - end  
33 -  
34 end 29 end
test/functional/manage_tags_controller_test.rb
@@ -6,12 +6,8 @@ class ManageTagsController; def rescue_action(e) raise e end; end @@ -6,12 +6,8 @@ class ManageTagsController; def rescue_action(e) raise e end; end
6 6
7 class ManageTagsControllerTest < Test::Unit::TestCase 7 class ManageTagsControllerTest < Test::Unit::TestCase
8 8
9 - def test_truth  
10 - assert true  
11 - end 9 + fixtures :tags
12 10
13 -#TODO i comment it because the test were not passing  
14 - fixtures :tags, :users, :blocks, :profiles, :virtual_communities, :boxes, :domains  
15 def setup 11 def setup
16 @controller = ManageTagsController.new 12 @controller = ManageTagsController.new
17 @request = ActionController::TestRequest.new 13 @request = ActionController::TestRequest.new