Commit 9e9bd5c87b398ddb43f782d540f1875b76a9d9b7
1 parent
83e70c2f
Exists in
master
and in
29 other branches
ActionItem4: integration tests and user documentation added
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@140 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
5 changed files
with
71 additions
and
19 deletions
Show diff stats
app/views/manage_tags/_a_tag.rhtml
1 | 1 | <li> |
2 | 2 | <%= a_tag.name %> |
3 | 3 | <%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %> |
4 | +<%= help _('Edit the attributes of this tag (name, parent and pending status)') %> | |
4 | 5 | <%= link_to _('Destroy'), {:action => 'destroy', :id => a_tag} %> |
6 | +<%= help _('Erase the tag and all its subtags but not the tagged content') %> | |
5 | 7 | <%= link_to _('Filter by this tag'), {:action => 'list', :parent => a_tag} %> |
6 | -<%= link_to _('Approve tag'), {:action => 'approve', :id => a_tag} if a_tag.pending? %> <ul> | |
8 | +<%= help _('List only the tags that are subtags of this tag') %> | |
9 | +<% if a_tag.pending? %> | |
10 | + <%= link_to _('Approve tag'), {:action => 'approve', :id => a_tag} %> | |
11 | + <%= help _('Approve this tag so content can be tagged with it and subtags of it can br created') %> | |
12 | +<% end %> | |
13 | +<ul> | |
7 | 14 | <%= render :partial => 'a_tag', :collection => a_tag.children.select{|t|!t.pending?} %> |
8 | 15 | </ul> |
9 | 16 | </li> | ... | ... |
app/views/manage_tags/_form.rhtml
1 | 1 | Name: <%= text_field 'tag', 'name' %> <br> |
2 | -Parent tag: <%= select("tag", "parent_id", @parent_tags.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) %> <br> | |
2 | +Parent tag: <%= select('tag', 'parent_id', @parent_tags.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) %> <br> | |
3 | 3 | Pending: <%= check_box 'tag', 'pending' %> <br> | ... | ... |
app/views/manage_tags/list.rhtml
... | ... | @@ -10,5 +10,9 @@ |
10 | 10 | <%= render :partial => 'a_tag', :collection => @pending_tags %> |
11 | 11 | </ul> |
12 | 12 | |
13 | +<%= link_to _('Top'), {:action => 'list'} if @parent %> | |
14 | +<%= help _('Go to the top view of the tags') %> | |
13 | 15 | <%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> |
16 | +<% help _('Filter by the parent of the actual tag') %> | |
14 | 17 | <%= link_to _('New tag'), {:action => 'new'} %> |
18 | +<%= help _('Create a new tag') %> | ... | ... |
test/functional/manage_tags_controller_test.rb
... | ... | @@ -6,7 +6,7 @@ class ManageTagsController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class ManageTagsControllerTest < Test::Unit::TestCase |
8 | 8 | |
9 | - fixtures :tags | |
9 | + fixtures :profiles, :boxes, :blocks, :domains | |
10 | 10 | |
11 | 11 | def setup |
12 | 12 | @controller = ManageTagsController.new |
... | ... | @@ -30,13 +30,18 @@ class ManageTagsControllerTest < Test::Unit::TestCase |
30 | 30 | end |
31 | 31 | |
32 | 32 | def test_scoped_list |
33 | - assert_nothing_raised { Tag.find(1) } | |
34 | - get :list, :parent => Tag.find(1) | |
33 | + parent_tag = Tag.create(:name => 'parent_tag') | |
34 | + child_tag = Tag.create(:name => 'child_tag', :parent => parent_tag) | |
35 | + orphan_tag = Tag.create(:name => 'orphan_tag') | |
36 | + get :list, :parent => parent_tag | |
35 | 37 | assert_response :success |
36 | 38 | assert_template 'list' |
37 | 39 | assert_not_nil assigns(:parent), 'the list should be scoped' |
38 | 40 | assert_not_nil assigns(:tags) |
39 | 41 | assert_not_nil assigns(:pending_tags) |
42 | + assert assigns(:tags).include?(child_tag) | |
43 | + assert (not assigns(:tags).include?(orphan_tag)) | |
44 | + | |
40 | 45 | end |
41 | 46 | |
42 | 47 | def test_new |
... | ... | @@ -61,43 +66,44 @@ class ManageTagsControllerTest < Test::Unit::TestCase |
61 | 66 | end |
62 | 67 | |
63 | 68 | def test_edit |
64 | - assert_nothing_raised { Tag.find(1) } | |
65 | - get :edit, :id => 1 | |
69 | + tag_to_edit = Tag.create(:name => 'tag_to_edit') | |
70 | + get :edit, :id => tag_to_edit.id | |
66 | 71 | assert assigns(:tag) |
67 | 72 | assert assigns(:parent_tags) |
68 | 73 | end |
69 | 74 | |
70 | 75 | def test_update |
71 | - assert_nothing_raised { Tag.find(1) } | |
72 | - post :update, :id => 1, :tag => {:name => 'altered_tag'} | |
76 | + tag_to_update = Tag.create(:name => 'tag_to_update') | |
77 | + post :update, :id => tag_to_update.id, :tag => {:name => 'altered_tag'} | |
73 | 78 | assert_response :redirect |
74 | 79 | assert_redirected_to :action => 'list' |
75 | 80 | assert assigns(:tag) |
81 | + assert_equal 'altered_tag', assigns(:tag).name | |
76 | 82 | end |
77 | 83 | |
78 | 84 | def test_update_wrong |
79 | - assert_nothing_raised { Tag.find(1) } | |
80 | - post :update, :id => 1, :tag => {:name => ''} | |
85 | + wrong_tag = Tag.create(:name => 'wrong_tag') | |
86 | + post :update, :id => wrong_tag, :tag => {:name => ''} | |
81 | 87 | assert_response :success |
82 | 88 | assert_template 'edit' |
83 | 89 | assert assigns(:parent_tags) |
84 | 90 | end |
85 | 91 | |
86 | 92 | def test_destroy |
87 | - assert_nothing_raised { Tag.find(1) } | |
88 | - post :destroy, :id => 1 | |
93 | + destroyed_tag = Tag.create(:name => 'tag_to_destroy') | |
94 | + post :destroy, :id => destroyed_tag.id | |
89 | 95 | assert_response :redirect |
90 | 96 | assert_redirected_to :action => 'list' |
91 | 97 | assert_not_nil flash[:notice] |
92 | - assert_raise(ActiveRecord::RecordNotFound) { Tag.find(1) } | |
98 | + assert_raise(ActiveRecord::RecordNotFound) { Tag.find(destroyed_tag.id) } | |
93 | 99 | end |
94 | 100 | |
95 | 101 | def test_approve |
96 | - assert_nothing_raised { Tag.find_with_pendings(4) } | |
97 | - assert Tag.find_with_pendings(4).pending? | |
98 | - post :approve, :id => 4 | |
102 | + pending_tag = Tag.create(:name => 'pending_tag', :pending => true) | |
103 | + assert pending_tag.pending? | |
104 | + post :approve, :id => pending_tag.id | |
99 | 105 | assert_response :redirect |
100 | 106 | assert_redirected_to :action => 'list' |
101 | - assert ( not Tag.find_with_pendings(4).pending? ) | |
107 | + assert ( not Tag.find_with_pendings(pending_tag.id).pending? ) | |
102 | 108 | end |
103 | 109 | end | ... | ... |
test/integration/manage_tags_test.rb
1 | 1 | require "#{File.dirname(__FILE__)}/../test_helper" |
2 | 2 | |
3 | 3 | class ManageTagsTest < ActionController::IntegrationTest |
4 | - fixtures :tags, :profiles, :users, :virtual_communities, :domains, :boxes, :blocks | |
4 | + fixtures :tags, :profiles, :boxes, :blocks | |
5 | 5 | |
6 | 6 | def test_tags_create_edit_destroy |
7 | 7 | get '/admin/manage_tags' |
... | ... | @@ -24,6 +24,41 @@ class ManageTagsTest < ActionController::IntegrationTest |
24 | 24 | follow_redirect! |
25 | 25 | assert_response :success |
26 | 26 | assert_equal '/admin/manage_tags/list', path |
27 | + assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/edit]} | |
28 | + | |
29 | + get '/admin/manage_tags/edit', :id => 1 | |
30 | + assert_response :success | |
31 | + assert_tag :tag => 'input', :attributes => {:name => 'tag[name]'} | |
32 | + assert_tag :tag => 'select', :attributes => {:name => 'tag[parent_id]'} | |
33 | + assert_tag :tag => 'input', :attributes => {:name => 'tag[pending]'} | |
34 | + | |
35 | + post '/admin/manage_tags/update', :id => 1, :tag => {:name => 'bla_tag'} | |
36 | + assert_response :redirect | |
37 | + | |
38 | + follow_redirect! | |
39 | + assert_response :success | |
40 | + assert_equal '/admin/manage_tags/list', path | |
41 | + assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/destroy]} | |
42 | + | |
43 | + post '/admin/manage_tags/destroy', :id => 1 | |
44 | + assert_response :redirect | |
45 | + | |
46 | + follow_redirect! | |
47 | + assert_response :success | |
48 | + assert_equal '/admin/manage_tags/list', path | |
49 | + end | |
50 | + | |
51 | + def test_approve_tag | |
52 | + get '/admin/manage_tags/list' | |
53 | + assert_response :success | |
54 | + assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/approve]} | |
55 | + | |
56 | + post '/admin/manage_tags/approve', :id => 5 | |
57 | + assert_response :redirect | |
58 | + | |
59 | + follow_redirect! | |
60 | + assert_response :success | |
61 | + assert_equal '/admin/manage_tags/list', path | |
27 | 62 | end |
28 | 63 | |
29 | 64 | end | ... | ... |