Commit 0f01bf0921305739e6cc0c59a44a6829d36fe339

Authored by Daniela Feitosa
1 parent 9dcfa5de

Added article tags list on profiles

app/helpers/profile_helper.rb
1 module ProfileHelper 1 module ProfileHelper
2 2
3 COMMON_CATEGORIES = ActiveSupport::OrderedHash.new 3 COMMON_CATEGORIES = ActiveSupport::OrderedHash.new
4 - COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :tags] 4 + COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :article_tags]
5 COMMON_CATEGORIES[:interests] = [:interests] 5 COMMON_CATEGORIES[:interests] = [:interests]
6 COMMON_CATEGORIES[:general] = nil 6 COMMON_CATEGORIES[:general] = nil
7 7
@@ -41,6 +41,7 @@ module ProfileHelper @@ -41,6 +41,7 @@ module ProfileHelper
41 :birth_date => _('Date of birth'), 41 :birth_date => _('Date of birth'),
42 :created_at => _('Profile created at'), 42 :created_at => _('Profile created at'),
43 :members_count => _('Members'), 43 :members_count => _('Members'),
  44 + :article_tags => _('Tags')
44 } 45 }
45 46
46 EXCEPTION = { 47 EXCEPTION = {
@@ -73,7 +74,11 @@ module ProfileHelper @@ -73,7 +74,11 @@ module ProfileHelper
73 return '' 74 return ''
74 end 75 end
75 value = begin profile.send(field) rescue nil end 76 value = begin profile.send(field) rescue nil end
76 - if !value.blank? 77 + return '' if value.blank?
  78 + if value.kind_of?(Hash)
  79 + content = self.send("treat_#{field}", value)
  80 + content_tag('tr', content_tag('td', title(field), :class => 'field-name') + content_tag('td', content))
  81 + else
77 entries = multiple ? value : [] << value 82 entries = multiple ? value : [] << value
78 entries.map do |entry| 83 entries.map do |entry|
79 content = self.send("treat_#{field}", entry) 84 content = self.send("treat_#{field}", entry)
@@ -81,8 +86,6 @@ module ProfileHelper @@ -81,8 +86,6 @@ module ProfileHelper
81 content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) 86 content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content))
82 end 87 end
83 end.join("\n") 88 end.join("\n")
84 - else  
85 - ''  
86 end 89 end
87 end 90 end
88 91
@@ -144,7 +147,7 @@ module ProfileHelper @@ -144,7 +147,7 @@ module ProfileHelper
144 link_to events.published.count, :controller => 'events', :action => 'events' 147 link_to events.published.count, :controller => 'events', :action => 'events'
145 end 148 end
146 149
147 - def treat_tags(tags) 150 + def treat_article_tags(tags)
148 tag_cloud @tags, :id, { :action => 'tags' }, :max_size => 18, :min_size => 10 151 tag_cloud @tags, :id, { :action => 'tags' }, :max_size => 18, :min_size => 10
149 end 152 end
150 153
features/profile_tags.feature
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -Feature: profile tags  
2 - As a Noosfero user  
3 - I want to to view content tagged  
4 - So that I can follow the subjects I care about  
5 -  
6 - Background:  
7 - Given the following users  
8 - | login |  
9 - | terceiro |  
10 - And the following articles  
11 - | owner | name | body | tag_list |  
12 - | terceiro | text 1 | text 1 content | tag1, tag2 |  
13 - | terceiro | text 2 | text 2 content | tag1, tag3 |  
14 -  
15 - Scenario: tag feed  
16 - When I go to terceiro's profile  
17 - And I follow "tag1"  
18 - And I follow "Feed for this tag"  
19 - Then I should see "text 1"  
20 - And I should see "text 2"  
test/functional/profile_controller_test.rb
@@ -495,6 +495,14 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -495,6 +495,14 @@ class ProfileControllerTest &lt; ActionController::TestCase
495 assert_tag :tag => 'a', :content => 'One picture', :attributes => { :href => /\/testuser\/gallery/ } 495 assert_tag :tag => 'a', :content => 'One picture', :attributes => { :href => /\/testuser\/gallery/ }
496 end 496 end
497 497
  498 + should 'show tags in index' do
  499 + article = create(Article, :name => 'Published at', :profile_id => profile.id, :tag_list => ['tag1'])
  500 +
  501 + get :index, :profile => profile.identifier
  502 +
  503 + assert_tag :tag => 'a', :content => 'tag1', :attributes => { :href => /profile\/#{profile.identifier}\/tags\/tag1$/ }
  504 + end
  505 +
498 should 'show description of orgarnization' do 506 should 'show description of orgarnization' do
499 login_as(@profile.identifier) 507 login_as(@profile.identifier)
500 ent = fast_create(Enterprise) 508 ent = fast_create(Enterprise)