From 0f01bf0921305739e6cc0c59a44a6829d36fe339 Mon Sep 17 00:00:00 2001 From: Daniela Feitosa Date: Wed, 22 Oct 2014 18:42:24 -0300 Subject: [PATCH] Added article tags list on profiles --- app/helpers/profile_helper.rb | 13 ++++++++----- features/profile_tags.feature | 20 -------------------- test/functional/profile_controller_test.rb | 8 ++++++++ 3 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 features/profile_tags.feature diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb index ac0b0fd..d23eabc 100644 --- a/app/helpers/profile_helper.rb +++ b/app/helpers/profile_helper.rb @@ -1,7 +1,7 @@ module ProfileHelper COMMON_CATEGORIES = ActiveSupport::OrderedHash.new - COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :tags] + COMMON_CATEGORIES[:content] = [:blogs, :image_galleries, :events, :article_tags] COMMON_CATEGORIES[:interests] = [:interests] COMMON_CATEGORIES[:general] = nil @@ -41,6 +41,7 @@ module ProfileHelper :birth_date => _('Date of birth'), :created_at => _('Profile created at'), :members_count => _('Members'), + :article_tags => _('Tags') } EXCEPTION = { @@ -73,7 +74,11 @@ module ProfileHelper return '' end value = begin profile.send(field) rescue nil end - if !value.blank? + return '' if value.blank? + if value.kind_of?(Hash) + content = self.send("treat_#{field}", value) + content_tag('tr', content_tag('td', title(field), :class => 'field-name') + content_tag('td', content)) + else entries = multiple ? value : [] << value entries.map do |entry| content = self.send("treat_#{field}", entry) @@ -81,8 +86,6 @@ module ProfileHelper content_tag('tr', content_tag('td', title(field, entry), :class => 'field-name') + content_tag('td', content)) end end.join("\n") - else - '' end end @@ -144,7 +147,7 @@ module ProfileHelper link_to events.published.count, :controller => 'events', :action => 'events' end - def treat_tags(tags) + def treat_article_tags(tags) tag_cloud @tags, :id, { :action => 'tags' }, :max_size => 18, :min_size => 10 end diff --git a/features/profile_tags.feature b/features/profile_tags.feature deleted file mode 100644 index 43fd80f..0000000 --- a/features/profile_tags.feature +++ /dev/null @@ -1,20 +0,0 @@ -Feature: profile tags - As a Noosfero user - I want to to view content tagged - So that I can follow the subjects I care about - - Background: - Given the following users - | login | - | terceiro | - And the following articles - | owner | name | body | tag_list | - | terceiro | text 1 | text 1 content | tag1, tag2 | - | terceiro | text 2 | text 2 content | tag1, tag3 | - - Scenario: tag feed - When I go to terceiro's profile - And I follow "tag1" - And I follow "Feed for this tag" - Then I should see "text 1" - And I should see "text 2" diff --git a/test/functional/profile_controller_test.rb b/test/functional/profile_controller_test.rb index 5737509..191b142 100644 --- a/test/functional/profile_controller_test.rb +++ b/test/functional/profile_controller_test.rb @@ -495,6 +495,14 @@ class ProfileControllerTest < ActionController::TestCase assert_tag :tag => 'a', :content => 'One picture', :attributes => { :href => /\/testuser\/gallery/ } end + should 'show tags in index' do + article = create(Article, :name => 'Published at', :profile_id => profile.id, :tag_list => ['tag1']) + + get :index, :profile => profile.identifier + + assert_tag :tag => 'a', :content => 'tag1', :attributes => { :href => /profile\/#{profile.identifier}\/tags\/tag1$/ } + end + should 'show description of orgarnization' do login_as(@profile.identifier) ent = fast_create(Enterprise) -- libgit2 0.21.2