diff --git a/app/views/manage_tags/_a_tag.rhtml b/app/views/manage_tags/_a_tag.rhtml index b81ce6d..3863875 100644 --- a/app/views/manage_tags/_a_tag.rhtml +++ b/app/views/manage_tags/_a_tag.rhtml @@ -1,9 +1,16 @@
  • <%= 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} %> -<%= link_to _('Approve tag'), {:action => 'approve', :id => a_tag} if a_tag.pending? %> +<%= 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/test/functional/manage_tags_controller_test.rb b/test/functional/manage_tags_controller_test.rb index effbf93..db2d021 100644 --- a/test/functional/manage_tags_controller_test.rb +++ b/test/functional/manage_tags_controller_test.rb @@ -6,7 +6,7 @@ class ManageTagsController; def rescue_action(e) raise e end; end class ManageTagsControllerTest < Test::Unit::TestCase - fixtures :tags + fixtures :profiles, :boxes, :blocks, :domains def setup @controller = ManageTagsController.new @@ -30,13 +30,18 @@ class ManageTagsControllerTest < Test::Unit::TestCase end def test_scoped_list - assert_nothing_raised { Tag.find(1) } - get :list, :parent => Tag.find(1) + 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 @@ -61,43 +66,44 @@ class ManageTagsControllerTest < Test::Unit::TestCase end def test_edit - assert_nothing_raised { Tag.find(1) } - get :edit, :id => 1 + 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 - assert_nothing_raised { Tag.find(1) } - post :update, :id => 1, :tag => {:name => 'altered_tag'} + 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 - assert_nothing_raised { Tag.find(1) } - post :update, :id => 1, :tag => {:name => ''} + 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 - assert_nothing_raised { Tag.find(1) } - post :destroy, :id => 1 + 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(1) } + assert_raise(ActiveRecord::RecordNotFound) { Tag.find(destroyed_tag.id) } end def test_approve - assert_nothing_raised { Tag.find_with_pendings(4) } - assert Tag.find_with_pendings(4).pending? - post :approve, :id => 4 + pending_tag = Tag.create(:name => 'pending_tag', :pending => true) + assert pending_tag.pending? + post :approve, :id => pending_tag.id assert_response :redirect assert_redirected_to :action => 'list' - assert ( not Tag.find_with_pendings(4).pending? ) + assert ( not Tag.find_with_pendings(pending_tag.id).pending? ) end end diff --git a/test/integration/manage_tags_test.rb b/test/integration/manage_tags_test.rb index ca0aa97..cea6371 100644 --- a/test/integration/manage_tags_test.rb +++ b/test/integration/manage_tags_test.rb @@ -1,7 +1,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" class ManageTagsTest < ActionController::IntegrationTest - fixtures :tags, :profiles, :users, :virtual_communities, :domains, :boxes, :blocks + fixtures :tags, :profiles, :boxes, :blocks def test_tags_create_edit_destroy get '/admin/manage_tags' @@ -24,6 +24,41 @@ class ManageTagsTest < ActionController::IntegrationTest 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 -- libgit2 0.21.2