From 3241a772680ee7cd4e72be6b15f392419a29e30b Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sun, 2 Dec 2007 04:26:46 +0000 Subject: [PATCH] ActionItem93: removing unused stuff --- app/controllers/admin/manage_tags_controller.rb | 74 -------------------------------------------------------------------------- app/views/manage_tags/_a_tag.rhtml | 16 ---------------- app/views/manage_tags/_form.rhtml | 3 --- app/views/manage_tags/_search_box.rhtml | 6 ------ app/views/manage_tags/edit.rhtml | 7 ------- app/views/manage_tags/list.rhtml | 20 -------------------- app/views/manage_tags/new.rhtml | 7 ------- app/views/manage_tags/search.rhtml | 12 ------------ test/functional/manage_tags_controller_test.rb | 117 --------------------------------------------------------------------------------------------------------------------- test/integration/manage_tags_test.rb | 64 ---------------------------------------------------------------- test/integration/routing_test.rb | 4 ---- 11 files changed, 0 insertions(+), 330 deletions(-) delete mode 100644 app/controllers/admin/manage_tags_controller.rb delete mode 100644 app/views/manage_tags/_a_tag.rhtml delete mode 100644 app/views/manage_tags/_form.rhtml delete mode 100644 app/views/manage_tags/_search_box.rhtml delete mode 100644 app/views/manage_tags/edit.rhtml delete mode 100644 app/views/manage_tags/list.rhtml delete mode 100644 app/views/manage_tags/new.rhtml delete mode 100644 app/views/manage_tags/search.rhtml delete mode 100644 test/functional/manage_tags_controller_test.rb delete mode 100644 test/integration/manage_tags_test.rb diff --git a/app/controllers/admin/manage_tags_controller.rb b/app/controllers/admin/manage_tags_controller.rb deleted file mode 100644 index 2fe0617..0000000 --- a/app/controllers/admin/manage_tags_controller.rb +++ /dev/null @@ -1,74 +0,0 @@ -# Manage tags stored by the acts-as_taggable_on_steroids plugin by providing an interface to create, destroy, update and list them -class ManageTagsController < AdminController - - # Index redirects to list action without modifing the url - def index - redirect_to :action => 'list' - end - - # Lists the tags starting with the top tags or with the chidren of @parent if its provided - def list - @parent = Tag.find(params[:parent]) if params[:parent] - @tags = @parent ? @parent.children : Tag.roots - @pending_tags = Tag.find_all_by_pending(true) - end - - # Prompt for data to a new tag - def new - @parent_tags = Tag.find_all_by_pending(false) - @tag = Tag.new - end - - # Collects the data and creates a new tag with it - def create - @tag = Tag.new(params[:tag]) - if @tag.save - flash[:notice] = _('Tag was successfully created.') - redirect_to :action => 'list' - else - @parent_tags = Tag.find_all_by_pending(false) - render :action => 'new' - end - end - - # Prompt for modifications on the attributes of a tag - def edit - @tag = Tag.find(params[:id]) - @parent_tags = @tag.parent_candidates - end - - # Do the modifications collected by edit - def update - @tag = Tag.find(params[:id]) - if @tag.update_attributes(params[:tag]) - flash[:notice] = _('Tag was successfully updated.') - redirect_to :action => 'list' - else - @parent_tags = @tag.parent_candidates - render :action => 'edit' - end - end - - # Destroy a tag and all its children - def destroy - @tag = Tag.find(params[:id]) - if @tag.destroy - flash[:notice] = _('Tag was successfuly destroyed') - end - redirect_to :action => 'list' - end - - # Approve a pending tag so now ita can be used to tag things - def approve - @tag = Tag.find(params[:id]) - if @tag.update_attribute(:pending, false) - flash[:notice] = _('Tag was successfuly approved') - redirect_to :action => 'list' - end - end - - # Full-text search for tags that have the query terms - def search - @tags_found = Tag.find_all_by_name_and_pending(params[:query], false) - end -end diff --git a/app/views/manage_tags/_a_tag.rhtml b/app/views/manage_tags/_a_tag.rhtml deleted file mode 100644 index 3863875..0000000 --- a/app/views/manage_tags/_a_tag.rhtml +++ /dev/null @@ -1,16 +0,0 @@ -
  • -<%= a_tag.name %> -<%= link_to _('Edit'), {:action => 'edit', :id => a_tag } %> -<%= help _('Edit the attributes of this tag (name, parent and pending status)') %> -<%= link_to _('Destroy'), {:action => 'destroy', :id => a_tag} %> -<%= help _('Erase the tag and all its subtags but not the tagged content') %> -<%= link_to _('Filter by this tag'), {:action => 'list', :parent => a_tag} %> -<%= help _('List only the tags that are subtags of this tag') %> -<% if a_tag.pending? %> - <%= link_to _('Approve tag'), {:action => 'approve', :id => a_tag} %> - <%= help _('Approve this tag so content can be tagged with it and subtags of it can br created') %> -<% end %> - -
  • diff --git a/app/views/manage_tags/_form.rhtml b/app/views/manage_tags/_form.rhtml deleted file mode 100644 index fc8b309..0000000 --- a/app/views/manage_tags/_form.rhtml +++ /dev/null @@ -1,3 +0,0 @@ -<%= _('Name') %>: <%= text_field 'tag', 'name' %>
    -<%= _('Parent tag') %>: <%= select('tag', 'parent_id', @parent_tags.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) %>
    -<%= _('Pending') %>: <%= check_box 'tag', 'pending' %>
    diff --git a/app/views/manage_tags/_search_box.rhtml b/app/views/manage_tags/_search_box.rhtml deleted file mode 100644 index 895590d..0000000 --- a/app/views/manage_tags/_search_box.rhtml +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/app/views/manage_tags/edit.rhtml b/app/views/manage_tags/edit.rhtml deleted file mode 100644 index 4bc8e04..0000000 --- a/app/views/manage_tags/edit.rhtml +++ /dev/null @@ -1,7 +0,0 @@ -

    <%= _('Editing Tag') %>

    - -<% form_tag :action => 'update', :id => @tag do %> - <%= render :partial => 'form' %> - <%= submit_tag _('Update') %> - <%= link_to _('Cancel'), {:action => 'list'} %> -<% end %> diff --git a/app/views/manage_tags/list.rhtml b/app/views/manage_tags/list.rhtml deleted file mode 100644 index 0235e0e..0000000 --- a/app/views/manage_tags/list.rhtml +++ /dev/null @@ -1,20 +0,0 @@ -<%= render :partial => 'search_box' %> - -

    <%= _("Listing tags") %>

    - - - -

    <%= _('Pending Tags') %>

    - - - -<%= link_to _('Top'), {:action => 'list'} if @parent %> -<%= help _('Go to the top view of the tags') %> -<%= link_to _('Up'), {:action => 'list', :parent => @parent.parent} if @parent %> -<% help _('Filter by the parent of the actual tag') %> -<%= link_to _('New tag'), {:action => 'new'} %> -<%= help _('Create a new tag') %> diff --git a/app/views/manage_tags/new.rhtml b/app/views/manage_tags/new.rhtml deleted file mode 100644 index 4271eff..0000000 --- a/app/views/manage_tags/new.rhtml +++ /dev/null @@ -1,7 +0,0 @@ -

    <%= _('New tag') %>

    - -<% form_tag :action =>'create' do%> - <%= render :partial => 'form' %> - <%= submit_tag _('Create') %> - <%= link_to _('Cancel'), {:action => 'list'} %> -<% end %> diff --git a/app/views/manage_tags/search.rhtml b/app/views/manage_tags/search.rhtml deleted file mode 100644 index 1ef7950..0000000 --- a/app/views/manage_tags/search.rhtml +++ /dev/null @@ -1,12 +0,0 @@ -<%= render :partial => 'search_box' %> - -

    <%= _('Matching tags') %>

    - -<% if not @tags_found.empty? %> - <%= @tags_found.size.to_s + (@tags_found.size > 1 ? ' tags' : ' tag') + _(' was found') %> - <%= render :partial => 'a_tag', :collection => @tags_found %> -<% else %> - <%= _('No tags found matching criteria') %> -<% end %> - -<%= link_to _('Back'), :action => 'list' %> diff --git a/test/functional/manage_tags_controller_test.rb b/test/functional/manage_tags_controller_test.rb deleted file mode 100644 index 54f06d5..0000000 --- a/test/functional/manage_tags_controller_test.rb +++ /dev/null @@ -1,117 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'manage_tags_controller' - -# Re-raise errors caught by the controller. -class ManageTagsController; def rescue_action(e) raise e end; end - -class ManageTagsControllerTest < Test::Unit::TestCase - -# all_fixtures:profiles, :design_boxes, :design_blocks, :domains -all_fixtures - def setup - @controller = ManageTagsController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_get_index - get :index - assert_response :redirect - assert_redirected_to :action => 'list' - end - - def test_list - get :list - assert_response :success - assert_template 'list' - assert_not_nil assigns(:tags) - assert_not_nil assigns(:pending_tags) - assert_nil assigns(:parent), 'the list should not scoped' - end - - def test_scoped_list - parent_tag = Tag.create(:name => 'parent_tag') - child_tag = Tag.create(:name => 'child_tag', :parent => parent_tag) - orphan_tag = Tag.create(:name => 'orphan_tag') - get :list, :parent => parent_tag - assert_response :success - assert_template 'list' - assert_not_nil assigns(:parent), 'the list should be scoped' - assert_not_nil assigns(:tags) - assert_not_nil assigns(:pending_tags) - assert assigns(:tags).include?(child_tag) - assert (not assigns(:tags).include?(orphan_tag)) - - end - - def test_new - get :new - assert_response :success - assert_template 'new' - assert_not_nil assigns(:parent_tags) - assert_not_nil assigns(:tag) - end - - def test_create - post :create, :tag => {:name => 'test_tag'} - assert_response :redirect - assert_redirected_to :action => 'list' - assert_not_nil assigns(:tag) - end - - def test_create_wrong - post :create, :tag => {:name => ''} - assert_response :success - assert_template 'new' - end - - def test_edit - tag_to_edit = Tag.create(:name => 'tag_to_edit') - get :edit, :id => tag_to_edit.id - assert assigns(:tag) - assert assigns(:parent_tags) - end - - def test_update - tag_to_update = Tag.create(:name => 'tag_to_update') - post :update, :id => tag_to_update.id, :tag => {:name => 'altered_tag'} - assert_response :redirect - assert_redirected_to :action => 'list' - assert assigns(:tag) - assert_equal 'altered_tag', assigns(:tag).name - end - - def test_update_wrong - wrong_tag = Tag.create(:name => 'wrong_tag') - post :update, :id => wrong_tag, :tag => {:name => ''} - assert_response :success - assert_template 'edit' - assert assigns(:parent_tags) - end - - def test_destroy - destroyed_tag = Tag.create(:name => 'tag_to_destroy') - post :destroy, :id => destroyed_tag.id - assert_response :redirect - assert_redirected_to :action => 'list' - assert_not_nil flash[:notice] - assert_raise(ActiveRecord::RecordNotFound) { Tag.find(destroyed_tag.id) } - end - - def test_approve - pending_tag = Tag.create(:name => 'pending_tag', :pending => true) - post :approve, :id => pending_tag.id - assert_response :redirect - assert_redirected_to :action => 'list' - assert ( not Tag.find(pending_tag.id).pending? ) - end - - def test_search - found_tag = Tag.create(:name => 'found_tag') - lost_tag = Tag.create(:name => 'lost_tag') - post :search, :query => 'found_tag' - assert_not_nil assigns(:tags_found) - assert assigns(:tags_found).include?(found_tag) - assert (not assigns(:tags_found).include?(lost_tag)) - end -end diff --git a/test/integration/manage_tags_test.rb b/test/integration/manage_tags_test.rb deleted file mode 100644 index 62f4db6..0000000 --- a/test/integration/manage_tags_test.rb +++ /dev/null @@ -1,64 +0,0 @@ -require "#{File.dirname(__FILE__)}/../test_helper" - -class ManageTagsTest < ActionController::IntegrationTest - fixtures :tags, :profiles, :design_boxes, :design_blocks - - def test_tags_create_edit_destroy - get '/admin/manage_tags' - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/admin/manage_tags/list', path - assert_tag :tag => 'a', :attributes => {:href => '/admin/manage_tags/new'} - - get '/admin/manage_tags/new' - assert_response :success - assert_tag :tag => 'input', :attributes => {:name => 'tag[name]'} - assert_tag :tag => 'select', :attributes => {:name => 'tag[parent_id]'} - assert_tag :tag => 'input', :attributes => {:name => 'tag[pending]'} - - post '/admin/manage_tags/create', :tag => { 'name' => 'new_tag', 'pending' => 'false', 'parent_id' => '0'} - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/admin/manage_tags/list', path - assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/edit]} - - get '/admin/manage_tags/edit', :id => 1 - assert_response :success - assert_tag :tag => 'input', :attributes => {:name => 'tag[name]'} - assert_tag :tag => 'select', :attributes => {:name => 'tag[parent_id]'} - assert_tag :tag => 'input', :attributes => {:name => 'tag[pending]'} - - post '/admin/manage_tags/update', :id => 1, :tag => {:name => 'bla_tag'} - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/admin/manage_tags/list', path - assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/destroy]} - - post '/admin/manage_tags/destroy', :id => 1 - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/admin/manage_tags/list', path - end - - def test_approve_tag - get '/admin/manage_tags/list' - assert_response :success - assert_tag :tag => 'a', :attributes => {:href => %r[/admin/manage_tags/approve]} - - post '/admin/manage_tags/approve', :id => 5 - assert_response :redirect - - follow_redirect! - assert_response :success - assert_equal '/admin/manage_tags/list', path - end - -end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 61bc30f..0209658 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -55,10 +55,6 @@ class RoutingTest < ActionController::IntegrationTest assert_routing('/admin/features/update', :controller => 'features', :action => 'update') end - def test_manage_tags_controller - assert_routing('/admin/manage_tags', :controller => 'manage_tags', :action => 'index') - end - def test_categories_management assert_routing('/admin/categories', :controller => 'categories', :action => 'index') assert_routing('/admin/categories/new', :controller => 'categories', :action => 'new') -- libgit2 0.21.2