Commit a766ba55880a7f9765c770936b4c1cc2a746b4f4

Authored by Caio Almeida
1 parent 54bc457e

Ticket #85: Adding plugin that allows people to have tags (aka interests) - API pending

plugins/person_tags/features/person_tags.feature 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +Feature: person tags
  2 +
  3 +Background:
  4 + Given the following users
  5 + | login |
  6 + | joao |
  7 + And I am logged in as "joao"
  8 + And "PersonTags" plugin is enabled
  9 +
  10 +Scenario: add tags to person
  11 + Given I am on joao's control panel
  12 + And I follow "Edit Profile"
  13 + When I fill in "profile_data_interest_list" with "linux,debian"
  14 + And I press "Save"
  15 + And I go to joao's control panel
  16 + And I follow "Edit Profile"
  17 + Then the "profile_data_interest_list" field should contain "linux"
  18 + And the "profile_data_interest_list" field should contain "debian"
... ...
plugins/person_tags/lib/ext/person.rb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +require_dependency 'person'
  2 +
  3 +class Person
  4 + attr_accessible :interest_list
  5 +
  6 + acts_as_taggable_on :interests
  7 + N_('Fields of interest')
  8 +end
... ...
plugins/person_tags/lib/person_tags_plugin.rb 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +class PersonTagsPlugin < Noosfero::Plugin
  2 +
  3 + include ActionView::Helpers::TagHelper
  4 + include ActionView::Helpers::FormTagHelper
  5 + include FormsHelper
  6 +
  7 + def self.plugin_name
  8 + "PersonTagsPlugin"
  9 + end
  10 +
  11 + def self.plugin_description
  12 + _("People can define tags that describe their interests.")
  13 + end
  14 +
  15 + def profile_editor_extras
  16 + expanded_template('profile-editor-extras.html.erb').html_safe
  17 + end
  18 +end
... ...
plugins/person_tags/test/test_helper.rb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +require_relative '../../../test/test_helper'
... ...
plugins/person_tags/test/unit/person_tags_test.rb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +require 'test_helper'
  2 +
  3 +class PersonTagsPluginTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @environment = Environment.default
  7 + @environment.enable_plugin(PersonTagsPlugin)
  8 + end
  9 +
  10 + should 'have interests' do
  11 + person = create_user('person').person
  12 + assert_equal [], person.interests
  13 + person.interest_list.add('linux')
  14 + assert_equal ['linux'], person.interest_list
  15 + end
  16 +end
... ...
plugins/person_tags/views/profile-editor-extras.html.erb 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +<h2><%= _('Select your fields of interest') %></h2>
  2 +<%= text_field_tag('profile_data[interest_list]', context.profile.interest_list.join(','), size: 64) %>
  3 +<br />
  4 +<%= content_tag( 'small', _('Separate tags with commas') ) %>
  5 +
  6 +<script>
  7 + jQuery('#profile_data_interest_list').inputosaurus();
  8 +</script>
... ...