From b4462f80eaa4c70d4818d45faa5059c818123a6d Mon Sep 17 00:00:00 2001 From: Joenio Costa Date: Mon, 14 Jun 2010 19:08:31 -0300 Subject: [PATCH] Fixing routing tests; more tests; removing duplicated route --- app/controllers/public/profile_controller.rb | 2 +- app/views/profile/content_tagged.rhtml | 23 +++++++++++++++++++++++ app/views/profile/tag.rhtml | 23 ----------------------- app/views/profile/tags.rhtml | 2 +- config/routes.rb | 5 ++--- features/tags.feature | 9 +++++++++ test/functional/profile_controller_test.rb | 4 ++-- test/integration/routing_test.rb | 2 +- 8 files changed, 39 insertions(+), 31 deletions(-) create mode 100644 app/views/profile/content_tagged.rhtml delete mode 100644 app/views/profile/tag.rhtml diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index 9c591cd..316be4c 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -21,7 +21,7 @@ class ProfileController < PublicController end end - def tag + def content_tagged @tag = params[:id] @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_#{profile.id.to_s}_page_#{params[:npage]}" if is_cache_expired?(@tag_cache_key, true) diff --git a/app/views/profile/content_tagged.rhtml b/app/views/profile/content_tagged.rhtml new file mode 100644 index 0000000..a8d8427 --- /dev/null +++ b/app/views/profile/content_tagged.rhtml @@ -0,0 +1,23 @@ +<% add_rss_feed_to_head(_("%s's contents tagged with \"%s\"") % [profile.name, @tag], tag_feed_path) %> + +

<%= _('Content tagged with "%s"') % @tag %>

+ +

+<%= link_to image_tag('icons-mime/rss-feed.png', :alt => _('Feed for this tag'), :title => _('Feed for this tag')), tag_feed_path, :class => 'blog-feed-link'%> +

+ +<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> +
+ +
+ + <%= pagination_links @tagged, :param_name => 'npage' %> + +
+ <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> +
+<% end %> diff --git a/app/views/profile/tag.rhtml b/app/views/profile/tag.rhtml deleted file mode 100644 index a8d8427..0000000 --- a/app/views/profile/tag.rhtml +++ /dev/null @@ -1,23 +0,0 @@ -<% add_rss_feed_to_head(_("%s's contents tagged with \"%s\"") % [profile.name, @tag], tag_feed_path) %> - -

<%= _('Content tagged with "%s"') % @tag %>

- -

-<%= link_to image_tag('icons-mime/rss-feed.png', :alt => _('Feed for this tag'), :title => _('Feed for this tag')), tag_feed_path, :class => 'blog-feed-link'%> -

- -<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> -
- -
- - <%= pagination_links @tagged, :param_name => 'npage' %> - -
- <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> -
-<% end %> diff --git a/app/views/profile/tags.rhtml b/app/views/profile/tags.rhtml index ab023d5..9e4013c 100644 --- a/app/views/profile/tags.rhtml +++ b/app/views/profile/tags.rhtml @@ -2,6 +2,6 @@
<% cache_timeout(@tags_cache_key, 4.hour.from_now) do %> - <%= tag_cloud @tags, :id, { :action => :tag}, {:show_count => true} %> + <%= tag_cloud @tags, :id, { :action => :tags }, {:show_count => true} %> <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 5f1a6d6..8319c57 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -67,11 +67,10 @@ ActionController::Routing::Routes.draw do |map| # feeds per tag 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}/ + map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'content_tagged', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ + map.tag 'profile/:profile/tags', :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/features/tags.feature b/features/tags.feature index 7aa5233..ff92901 100644 --- a/features/tags.feature +++ b/features/tags.feature @@ -31,3 +31,12 @@ Feature: tags And I follow "whales" Then I should see "save the whales" And I should not see "the Amazon is being destroyed" + + Scenario: viewing profile's tag cloud + When I go to /profile/joaoaraujo/tags + Then I should see "amazon" + And I should not see "whales" + + Scenario: viewing profile's content tagged + When I go to /profile/joaoaraujo/tags/amazon + Then I should see "the Amazon is being destroyed" diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 3f84d21..efecf6e 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -142,13 +142,13 @@ class ProfileControllerTest < Test::Unit::TestCase should 'display tag for profile' do @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') - get :tag, :profile => @profile.identifier, :id => 'tag1' + get :content_tagged, :profile => @profile.identifier, :id => 'tag1' assert_tag :tag => 'a', :attributes => { :href => /testuser\/testarticle$/ } end should 'link to the same tag but for whole environment' do @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') - get :tag, :profile => @profile.identifier, :id => 'tag1' + get :content_tagged, :profile => @profile.identifier, :id => 'tag1' assert_tag :tag => 'a', :attributes => { :href => '/tag/tag1' }, :content => 'See content tagged with "tag1" in the entire site' end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 2625363..fa6e3bb 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/tags/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'tag', :id => 'tag.withdot') + assert_routing('/profile/ze/tags/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'content_tagged', :id => 'tag.withdot') end def test_profile_with_tilde_routing -- libgit2 0.21.2