Commit 3241a772680ee7cd4e72be6b15f392419a29e30b
1 parent
11ecf28c
Exists in
staging
and in
42 other branches
ActionItem93: removing unused stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1060 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
11 changed files
with
0 additions
and
330 deletions
Show diff stats
app/controllers/admin/manage_tags_controller.rb
... | ... | @@ -1,74 +0,0 @@ |
1 | -# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them | |
2 | -class ManageTagsController < AdminController | |
3 | - | |
4 | - # Index redirects to list action without modifing the url | |
5 | - def index | |
6 | - redirect_to :action => 'list' | |
7 | - end | |
8 | - | |
9 | - # Lists the tags starting with the top tags or with the chidren of @parent if its provided | |
10 | - def list | |
11 | - @parent = Tag.find(params[:parent]) if params[:parent] | |
12 | - @tags = @parent ? @parent.children : Tag.roots | |
13 | - @pending_tags = Tag.find_all_by_pending(true) | |
14 | - end | |
15 | - | |
16 | - # Prompt for data to a new tag | |
17 | - def new | |
18 | - @parent_tags = Tag.find_all_by_pending(false) | |
19 | - @tag = Tag.new | |
20 | - end | |
21 | - | |
22 | - # Collects the data and creates a new tag with it | |
23 | - def create | |
24 | - @tag = Tag.new(params[:tag]) | |
25 | - if @tag.save | |
26 | - flash[:notice] = _('Tag was successfully created.') | |
27 | - redirect_to :action => 'list' | |
28 | - else | |
29 | - @parent_tags = Tag.find_all_by_pending(false) | |
30 | - render :action => 'new' | |
31 | - end | |
32 | - end | |
33 | - | |
34 | - # Prompt for modifications on the attributes of a tag | |
35 | - def edit | |
36 | - @tag = Tag.find(params[:id]) | |
37 | - @parent_tags = @tag.parent_candidates | |
38 | - end | |
39 | - | |
40 | - # Do the modifications collected by edit | |
41 | - def update | |
42 | - @tag = Tag.find(params[:id]) | |
43 | - if @tag.update_attributes(params[:tag]) | |
44 | - flash[:notice] = _('Tag was successfully updated.') | |
45 | - redirect_to :action => 'list' | |
46 | - else | |
47 | - @parent_tags = @tag.parent_candidates | |
48 | - render :action => 'edit' | |
49 | - end | |
50 | - end | |
51 | - | |
52 | - # Destroy a tag and all its children | |
53 | - def destroy | |
54 | - @tag = Tag.find(params[:id]) | |
55 | - if @tag.destroy | |
56 | - flash[:notice] = _('Tag was successfuly destroyed') | |
57 | - end | |
58 | - redirect_to :action => 'list' | |
59 | - end | |
60 | - | |
61 | - # Approve a pending tag so now ita can be used to tag things | |
62 | - def approve | |
63 | - @tag = Tag.find(params[:id]) | |
64 | - if @tag.update_attribute(:pending, false) | |
65 | - flash[:notice] = _('Tag was successfuly approved') | |
66 | - redirect_to :action => 'list' | |
67 | - end | |
68 | - end | |
69 | - | |
70 | - # Full-text search for tags that have the query terms | |
71 | - def search | |
72 | - @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) | |
73 | - end | |
74 | -end |
app/views/manage_tags/_a_tag.rhtml
... | ... | @@ -1,16 +0,0 @@ |
1 | -<li> | |
2 | -<%= a_tag.name %> | |
3 | -<%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %> | |
4 | -<%= help _('Edit the attributes of this tag (name, parent and pending status)') %> | |
5 | -<%= link_to _('Destroy'), {:action => 'destroy', :id => a_tag} %> | |
6 | -<%= help _('Erase the tag and all its subtags but not the tagged content') %> | |
7 | -<%= link_to _('Filter by this tag'), {:action => 'list', :parent => a_tag} %> | |
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> | |
14 | - <%= render :partial => 'a_tag', :collection => a_tag.children.select{|t|!t.pending?} %> | |
15 | -</ul> | |
16 | -</li> |
app/views/manage_tags/_form.rhtml
app/views/manage_tags/_search_box.rhtml
app/views/manage_tags/edit.rhtml
app/views/manage_tags/list.rhtml
... | ... | @@ -1,20 +0,0 @@ |
1 | -<%= render :partial => 'search_box' %> | |
2 | - | |
3 | -<h2> <%= _("Listing tags") %> </h2> | |
4 | - | |
5 | -<ul> | |
6 | - <%= render :partial => 'a_tag', :collection => @tags %> | |
7 | -</ul> | |
8 | - | |
9 | -<h3> <%= _('Pending Tags') %> </h3> | |
10 | - | |
11 | -<ul> | |
12 | - <%= render :partial => 'a_tag', :collection => @pending_tags %> | |
13 | -</ul> | |
14 | - | |
15 | -<%= link_to _('Top'), {:action => 'list'} if @parent %> | |
16 | -<%= help _('Go to the top view of the tags') %> | |
17 | -<%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> | |
18 | -<% help _('Filter by the parent of the actual tag') %> | |
19 | -<%= link_to _('New tag'), {:action => 'new'} %> | |
20 | -<%= help _('Create a new tag') %> |
app/views/manage_tags/new.rhtml
app/views/manage_tags/search.rhtml
... | ... | @@ -1,12 +0,0 @@ |
1 | -<%= render :partial => 'search_box' %> | |
2 | - | |
3 | -<h2> <%= _('Matching tags') %></h2> | |
4 | - | |
5 | -<% if not @tags_found.empty? %> | |
6 | - <%= @tags_found.size.to_s + (@tags_found.size > 1 ? ' tags' : ' tag') + _(' was found') %> | |
7 | - <%= render :partial => 'a_tag', :collection => @tags_found %> | |
8 | -<% else %> | |
9 | - <%= _('No tags found matching criteria') %> | |
10 | -<% end %> | |
11 | - | |
12 | -<%= link_to _('Back'), :action => 'list' %> |
test/functional/manage_tags_controller_test.rb
... | ... | @@ -1,117 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | -require 'manage_tags_controller' | |
3 | - | |
4 | -# Re-raise errors caught by the controller. | |
5 | -class ManageTagsController; def rescue_action(e) raise e end; end | |
6 | - | |
7 | -class ManageTagsControllerTest < Test::Unit::TestCase | |
8 | - | |
9 | -# all_fixtures:profiles, :design_boxes, :design_blocks, :domains | |
10 | -all_fixtures | |
11 | - def setup | |
12 | - @controller = ManageTagsController.new | |
13 | - @request = ActionController::TestRequest.new | |
14 | - @response = ActionController::TestResponse.new | |
15 | - end | |
16 | - | |
17 | - def test_get_index | |
18 | - get :index | |
19 | - assert_response :redirect | |
20 | - assert_redirected_to :action => 'list' | |
21 | - end | |
22 | - | |
23 | - def test_list | |
24 | - get :list | |
25 | - assert_response :success | |
26 | - assert_template 'list' | |
27 | - assert_not_nil assigns(:tags) | |
28 | - assert_not_nil assigns(:pending_tags) | |
29 | - assert_nil assigns(:parent), 'the list should not scoped' | |
30 | - end | |
31 | - | |
32 | - def test_scoped_list | |
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 | |
37 | - assert_response :success | |
38 | - assert_template 'list' | |
39 | - assert_not_nil assigns(:parent), 'the list should be scoped' | |
40 | - assert_not_nil assigns(:tags) | |
41 | - assert_not_nil assigns(:pending_tags) | |
42 | - assert assigns(:tags).include?(child_tag) | |
43 | - assert (not assigns(:tags).include?(orphan_tag)) | |
44 | - | |
45 | - end | |
46 | - | |
47 | - def test_new | |
48 | - get :new | |
49 | - assert_response :success | |
50 | - assert_template 'new' | |
51 | - assert_not_nil assigns(:parent_tags) | |
52 | - assert_not_nil assigns(:tag) | |
53 | - end | |
54 | - | |
55 | - def test_create | |
56 | - post :create, :tag => {:name => 'test_tag'} | |
57 | - assert_response :redirect | |
58 | - assert_redirected_to :action => 'list' | |
59 | - assert_not_nil assigns(:tag) | |
60 | - end | |
61 | - | |
62 | - def test_create_wrong | |
63 | - post :create, :tag => {:name => ''} | |
64 | - assert_response :success | |
65 | - assert_template 'new' | |
66 | - end | |
67 | - | |
68 | - def test_edit | |
69 | - tag_to_edit = Tag.create(:name => 'tag_to_edit') | |
70 | - get :edit, :id => tag_to_edit.id | |
71 | - assert assigns(:tag) | |
72 | - assert assigns(:parent_tags) | |
73 | - end | |
74 | - | |
75 | - def test_update | |
76 | - tag_to_update = Tag.create(:name => 'tag_to_update') | |
77 | - post :update, :id => tag_to_update.id, :tag => {:name => 'altered_tag'} | |
78 | - assert_response :redirect | |
79 | - assert_redirected_to :action => 'list' | |
80 | - assert assigns(:tag) | |
81 | - assert_equal 'altered_tag', assigns(:tag).name | |
82 | - end | |
83 | - | |
84 | - def test_update_wrong | |
85 | - wrong_tag = Tag.create(:name => 'wrong_tag') | |
86 | - post :update, :id => wrong_tag, :tag => {:name => ''} | |
87 | - assert_response :success | |
88 | - assert_template 'edit' | |
89 | - assert assigns(:parent_tags) | |
90 | - end | |
91 | - | |
92 | - def test_destroy | |
93 | - destroyed_tag = Tag.create(:name => 'tag_to_destroy') | |
94 | - post :destroy, :id => destroyed_tag.id | |
95 | - assert_response :redirect | |
96 | - assert_redirected_to :action => 'list' | |
97 | - assert_not_nil flash[:notice] | |
98 | - assert_raise(ActiveRecord::RecordNotFound) { Tag.find(destroyed_tag.id) } | |
99 | - end | |
100 | - | |
101 | - def test_approve | |
102 | - pending_tag = Tag.create(:name => 'pending_tag', :pending => true) | |
103 | - post :approve, :id => pending_tag.id | |
104 | - assert_response :redirect | |
105 | - assert_redirected_to :action => 'list' | |
106 | - assert ( not Tag.find(pending_tag.id).pending? ) | |
107 | - end | |
108 | - | |
109 | - def test_search | |
110 | - found_tag = Tag.create(:name => 'found_tag') | |
111 | - lost_tag = Tag.create(:name => 'lost_tag') | |
112 | - post :search, :query => 'found_tag' | |
113 | - assert_not_nil assigns(:tags_found) | |
114 | - assert assigns(:tags_found).include?(found_tag) | |
115 | - assert (not assigns(:tags_found).include?(lost_tag)) | |
116 | - end | |
117 | -end |
test/integration/manage_tags_test.rb
... | ... | @@ -1,64 +0,0 @@ |
1 | -require "#{File.dirname(__FILE__)}/../test_helper" | |
2 | - | |
3 | -class ManageTagsTest < ActionController::IntegrationTest | |
4 | - fixtures :tags, :profiles, :design_boxes, :design_blocks | |
5 | - | |
6 | - def test_tags_create_edit_destroy | |
7 | - get '/admin/manage_tags' | |
8 | - assert_response :redirect | |
9 | - | |
10 | - follow_redirect! | |
11 | - assert_response :success | |
12 | - assert_equal '/admin/manage_tags/list', path | |
13 | - assert_tag :tag => 'a', :attributes => {:href => '/admin/manage_tags/new'} | |
14 | - | |
15 | - get '/admin/manage_tags/new' | |
16 | - assert_response :success | |
17 | - assert_tag :tag => 'input', :attributes => {:name => 'tag[name]'} | |
18 | - assert_tag :tag => 'select', :attributes => {:name => 'tag[parent_id]'} | |
19 | - assert_tag :tag => 'input', :attributes => {:name => 'tag[pending]'} | |
20 | - | |
21 | - post '/admin/manage_tags/create', :tag => { 'name' => 'new_tag', 'pending' => 'false', 'parent_id' => '0'} | |
22 | - assert_response :redirect | |
23 | - | |
24 | - follow_redirect! | |
25 | - assert_response :success | |
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 | |
62 | - end | |
63 | - | |
64 | -end |
test/integration/routing_test.rb
... | ... | @@ -55,10 +55,6 @@ class RoutingTest < ActionController::IntegrationTest |
55 | 55 | assert_routing('/admin/features/update', :controller => 'features', :action => 'update') |
56 | 56 | end |
57 | 57 | |
58 | - def test_manage_tags_controller | |
59 | - assert_routing('/admin/manage_tags', :controller => 'manage_tags', :action => 'index') | |
60 | - end | |
61 | - | |
62 | 58 | def test_categories_management |
63 | 59 | assert_routing('/admin/categories', :controller => 'categories', :action => 'index') |
64 | 60 | assert_routing('/admin/categories/new', :controller => 'categories', :action => 'new') | ... | ... |