Commit b4462f80eaa4c70d4818d45faa5059c818123a6d
1 parent
c456c608
Exists in
master
and in
29 other branches
Fixing routing tests; more tests; removing duplicated route
(ActionItem1558)
Showing
8 changed files
with
39 additions
and
31 deletions
Show diff stats
app/controllers/public/profile_controller.rb
| @@ -21,7 +21,7 @@ class ProfileController < PublicController | @@ -21,7 +21,7 @@ class ProfileController < PublicController | ||
| 21 | end | 21 | end |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | - def tag | 24 | + def content_tagged |
| 25 | @tag = params[:id] | 25 | @tag = params[:id] |
| 26 | @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_#{profile.id.to_s}_page_#{params[:npage]}" | 26 | @tag_cache_key = "tag_#{CGI.escape(@tag.to_s)}_#{profile.id.to_s}_page_#{params[:npage]}" |
| 27 | if is_cache_expired?(@tag_cache_key, true) | 27 | if is_cache_expired?(@tag_cache_key, true) |
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +<% add_rss_feed_to_head(_("%s's contents tagged with \"%s\"") % [profile.name, @tag], tag_feed_path) %> | ||
| 2 | + | ||
| 3 | +<h1><%= _('Content tagged with "%s"') % @tag %></h1> | ||
| 4 | + | ||
| 5 | +<p> | ||
| 6 | +<%= 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'%> | ||
| 7 | +</p> | ||
| 8 | + | ||
| 9 | +<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> | ||
| 10 | + <div class='search-tagged-items'> | ||
| 11 | + <ul> | ||
| 12 | + <% for doc in @tagged %> | ||
| 13 | + <li><%= link_to doc.title, doc.url %></li> | ||
| 14 | + <% end %> | ||
| 15 | + </ul> | ||
| 16 | + </div> | ||
| 17 | + | ||
| 18 | + <%= pagination_links @tagged, :param_name => 'npage' %> | ||
| 19 | + | ||
| 20 | + <div> | ||
| 21 | + <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> | ||
| 22 | + </div> | ||
| 23 | +<% end %> |
app/views/profile/tag.rhtml
| @@ -1,23 +0,0 @@ | @@ -1,23 +0,0 @@ | ||
| 1 | -<% add_rss_feed_to_head(_("%s's contents tagged with \"%s\"") % [profile.name, @tag], tag_feed_path) %> | ||
| 2 | - | ||
| 3 | -<h1><%= _('Content tagged with "%s"') % @tag %></h1> | ||
| 4 | - | ||
| 5 | -<p> | ||
| 6 | -<%= 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'%> | ||
| 7 | -</p> | ||
| 8 | - | ||
| 9 | -<% cache_timeout(@tag_cache_key, 4.hour.from_now) do %> | ||
| 10 | - <div class='search-tagged-items'> | ||
| 11 | - <ul> | ||
| 12 | - <% for doc in @tagged %> | ||
| 13 | - <li><%= link_to doc.title, doc.url %></li> | ||
| 14 | - <% end %> | ||
| 15 | - </ul> | ||
| 16 | - </div> | ||
| 17 | - | ||
| 18 | - <%= pagination_links @tagged, :param_name => 'npage' %> | ||
| 19 | - | ||
| 20 | - <div> | ||
| 21 | - <%= link_to _('See content tagged with "%s" in the entire site') % @tag, :controller => 'search', :action => 'tag', :tag => @tag %> | ||
| 22 | - </div> | ||
| 23 | -<% end %> |
app/views/profile/tags.rhtml
| @@ -2,6 +2,6 @@ | @@ -2,6 +2,6 @@ | ||
| 2 | 2 | ||
| 3 | <div class='tag_cloud'> | 3 | <div class='tag_cloud'> |
| 4 | <% cache_timeout(@tags_cache_key, 4.hour.from_now) do %> | 4 | <% cache_timeout(@tags_cache_key, 4.hour.from_now) do %> |
| 5 | - <%= tag_cloud @tags, :id, { :action => :tag}, {:show_count => true} %> | 5 | + <%= tag_cloud @tags, :id, { :action => :tags }, {:show_count => true} %> |
| 6 | <% end %> | 6 | <% end %> |
| 7 | </div> | 7 | </div> |
config/routes.rb
| @@ -67,11 +67,10 @@ ActionController::Routing::Routes.draw do |map| | @@ -67,11 +67,10 @@ ActionController::Routing::Routes.draw do |map| | ||
| 67 | 67 | ||
| 68 | # feeds per tag | 68 | # feeds per tag |
| 69 | map.tag_feed 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ | 69 | map.tag_feed 'profile/:profile/tags/:id/feed', :controller => 'profile', :action =>'tag_feed', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ |
| 70 | - map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'tag', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ | ||
| 71 | 70 | ||
| 72 | # profile tags | 71 | # profile tags |
| 73 | - map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'tag', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ | ||
| 74 | - map.tag 'profile/:profile/tag', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format}/ | 72 | + map.tag 'profile/:profile/tags/:id', :controller => 'profile', :action => 'content_tagged', :id => /.+/, :profile => /#{Noosfero.identifier_format}/ |
| 73 | + map.tag 'profile/:profile/tags', :controller => 'profile', :action => 'tags', :profile => /#{Noosfero.identifier_format}/ | ||
| 75 | 74 | ||
| 76 | # public profile information | 75 | # public profile information |
| 77 | map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ | 76 | map.profile 'profile/:profile/:action/:id', :controller => 'profile', :action => 'index', :id => /.*/, :profile => /#{Noosfero.identifier_format}/ |
features/tags.feature
| @@ -31,3 +31,12 @@ Feature: tags | @@ -31,3 +31,12 @@ Feature: tags | ||
| 31 | And I follow "whales" | 31 | And I follow "whales" |
| 32 | Then I should see "save the whales" | 32 | Then I should see "save the whales" |
| 33 | And I should not see "the Amazon is being destroyed" | 33 | And I should not see "the Amazon is being destroyed" |
| 34 | + | ||
| 35 | + Scenario: viewing profile's tag cloud | ||
| 36 | + When I go to /profile/joaoaraujo/tags | ||
| 37 | + Then I should see "amazon" | ||
| 38 | + And I should not see "whales" | ||
| 39 | + | ||
| 40 | + Scenario: viewing profile's content tagged | ||
| 41 | + When I go to /profile/joaoaraujo/tags/amazon | ||
| 42 | + Then I should see "the Amazon is being destroyed" |
test/functional/profile_controller_test.rb
| @@ -142,13 +142,13 @@ class ProfileControllerTest < Test::Unit::TestCase | @@ -142,13 +142,13 @@ class ProfileControllerTest < Test::Unit::TestCase | ||
| 142 | should 'display tag for profile' do | 142 | should 'display tag for profile' do |
| 143 | @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') | 143 | @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') |
| 144 | 144 | ||
| 145 | - get :tag, :profile => @profile.identifier, :id => 'tag1' | 145 | + get :content_tagged, :profile => @profile.identifier, :id => 'tag1' |
| 146 | assert_tag :tag => 'a', :attributes => { :href => /testuser\/testarticle$/ } | 146 | assert_tag :tag => 'a', :attributes => { :href => /testuser\/testarticle$/ } |
| 147 | end | 147 | end |
| 148 | 148 | ||
| 149 | should 'link to the same tag but for whole environment' do | 149 | should 'link to the same tag but for whole environment' do |
| 150 | @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') | 150 | @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') |
| 151 | - get :tag, :profile => @profile.identifier, :id => 'tag1' | 151 | + get :content_tagged, :profile => @profile.identifier, :id => 'tag1' |
| 152 | 152 | ||
| 153 | assert_tag :tag => 'a', :attributes => { :href => '/tag/tag1' }, :content => 'See content tagged with "tag1" in the entire site' | 153 | assert_tag :tag => 'a', :attributes => { :href => '/tag/tag1' }, :content => 'See content tagged with "tag1" in the entire site' |
| 154 | end | 154 | end |
test/integration/routing_test.rb
| @@ -119,7 +119,7 @@ class RoutingTest < ActionController::IntegrationTest | @@ -119,7 +119,7 @@ class RoutingTest < ActionController::IntegrationTest | ||
| 119 | end | 119 | end |
| 120 | 120 | ||
| 121 | def test_profile_route_for_tags_with_dot | 121 | def test_profile_route_for_tags_with_dot |
| 122 | - assert_routing('/profile/ze/tags/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'tag', :id => 'tag.withdot') | 122 | + assert_routing('/profile/ze/tags/tag.withdot', :controller => 'profile', :profile => 'ze', :action => 'content_tagged', :id => 'tag.withdot') |
| 123 | end | 123 | end |
| 124 | 124 | ||
| 125 | def test_profile_with_tilde_routing | 125 | def test_profile_with_tilde_routing |