From c456c608bb2973d5d9ff9c80fa60971e6dbffebd Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Thu, 10 Jun 2010 14:27:11 -0300 Subject: [PATCH] Tag routes uses "tags" for single or group tags --- app/controllers/public/profile_controller.rb | 2 +- app/models/tags_block.rb | 2 +- app/views/content_viewer/view_page.rhtml | 2 +- app/views/profile/index.rhtml | 2 +- config/routes.rb | 7 ++++++- test/functional/content_viewer_controller_test.rb | 4 ++-- test/functional/profile_controller_test.rb | 4 ++-- test/integration/routing_test.rb | 2 +- test/unit/tags_block_test.rb | 8 ++++---- 9 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index a87f0f5..9c591cd 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -37,7 +37,7 @@ class ProfileController < PublicController tagged, :title => _("%s's contents tagged with \"%s\"") % [profile.name, @tag], :description => _("%s's contents tagged with \"%s\"") % [profile.name, @tag], - :link => url_for(:action => 'tag') + :link => url_for(:action => 'tags') ) render :text => data, :content_type => "text/xml" end diff --git a/app/models/tags_block.rb b/app/models/tags_block.rb index c37f454..ef4d093 100644 --- a/app/models/tags_block.rb +++ b/app/models/tags_block.rb @@ -32,7 +32,7 @@ class TagsBlock < Block block_title(title) + "\n
\n"+ tag_cloud( tags, :id, - owner.public_profile_url.merge(:controller => 'profile', :action => 'tag'), + owner.public_profile_url.merge(:controller => 'profile', :action => 'tags'), :max_size => 16, :min_size => 9 ) + "\n
\n"; end diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index 580b2bd..308039d 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -66,7 +66,7 @@ <% if !@page.tags.empty? %>
<%= _("This article's tags:") %> - <%= @page.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tag', :id => t.name ) }.join("\n") %> + <%= @page.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }.join("\n") %>
<% end %> diff --git a/app/views/profile/index.rhtml b/app/views/profile/index.rhtml index b0a6b3d..6e2fb94 100644 --- a/app/views/profile/index.rhtml +++ b/app/views/profile/index.rhtml @@ -51,7 +51,7 @@ <%= _('Tags:') %> - <%= tag_cloud @tags, :id, { :action => 'tag' }, :max_size => 18, :min_size => 10%> + <%= tag_cloud @tags, :id, { :action => 'tags' }, :max_size => 18, :min_size => 10%> diff --git a/config/routes.rb b/config/routes.rb index 2c42c82..5f1a6d6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -66,7 +66,12 @@ ActionController::Routing::Routes.draw do |map| map.invite 'profile/:profile/invite/:action', :controller => 'invite', :profile => /#{Noosfero.identifier_format}/ # feeds per tag - map.tag_feed 'profile/:profile/tag/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ + map.tag_feed 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ + map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'tag', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ + + # profile tags + map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'tag', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ + map.tag 'profile/:profile/tag', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format}/ # public profile information map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 719aade..1602194 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -251,11 +251,11 @@ class ContentViewerControllerTest < Test::Unit::TestCase get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ] assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :tag => 'a', - :attributes => { :href => "/profile/#{profile.identifier}/tag/tag1" } + :attributes => { :href => "/profile/#{profile.identifier}/tags/tag1" } } assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :tag => 'a', - :attributes => { :href => "/profile/#{profile.identifier}/tag/tag2" } + :attributes => { :href => "/profile/#{profile.identifier}/tags/tag2" } } assert_tag :tag => 'div', :attributes => { :id => 'article-tags' }, :descendant => { :content => /This article's tags:/ } diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index e935539..3f84d21 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -311,8 +311,8 @@ class ProfileControllerTest < Test::Unit::TestCase Person.any_instance.stubs(:article_tags).returns({ 'one' => 1, 'two' => 2}) get :tags, :profile => 'testuser' - assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => '/profile/testuser/tag/one'} } - assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => '/profile/testuser/tag/two'} } + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => '/profile/testuser/tags/one'} } + assert_tag :tag => 'div', :attributes => { :class => /main-block/ }, :descendant => { :tag => 'a', :attributes => { :href => '/profile/testuser/tags/two'} } end should 'show e-mail for friends on profile page' do diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 1d0185d..2625363 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -119,7 +119,7 @@ class RoutingTest < ActionController::IntegrationTest end def test_profile_route_for_tags_with_dot - assert_routing('/profile/ze/tag/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'tag', :id => 'tag.withdot') + assert_routing('/profile/ze/tags/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'tag', :id => 'tag.withdot') end def test_profile_with_tilde_routing diff --git a/test/unit/tags_block_test.rb b/test/unit/tags_block_test.rb index bc086f2..5b5863d 100644 --- a/test/unit/tags_block_test.rb +++ b/test/unit/tags_block_test.rb @@ -22,9 +22,9 @@ class TagsBlockTest < Test::Unit::TestCase end should 'generate links to tags' do - assert_match /profile\/testinguser\/tag\/first-tag/, block.content - assert_match /profile\/testinguser\/tag\/second-tag/, block.content - assert_match /profile\/testinguser\/tag\/third-tag/, block.content + assert_match /profile\/testinguser\/tags\/first-tag/, block.content + assert_match /profile\/testinguser\/tags\/second-tag/, block.content + assert_match /profile\/testinguser\/tags\/third-tag/, block.content end should 'return (none) when no tags to display' do @@ -34,7 +34,7 @@ class TagsBlockTest < Test::Unit::TestCase should 'generate links when profile has own hostname' do @user.domains << Domain.new(:name => 'testuser.net'); @user.save! - assert_match /profile\/testinguser\/tag\/first-tag/, block.content + assert_match /profile\/testinguser\/tags\/first-tag/, block.content end end -- libgit2 0.21.2