diff --git a/lib/ext/person.rb b/lib/ext/person.rb index 12510c6..5a7f078 100644 --- a/lib/ext/person.rb +++ b/lib/ext/person.rb @@ -32,4 +32,15 @@ class Person false end + def softwares + softwares = [] + self.communities.each do |community| + if community.software? + softwares << community + end + end + + softwares + end + end diff --git a/test/unit/mpog_person_test.rb b/test/unit/mpog_person_test.rb index a692a45..cf4e3eb 100644 --- a/test/unit/mpog_person_test.rb +++ b/test/unit/mpog_person_test.rb @@ -79,4 +79,17 @@ class MpogSoftwarePluginPersonTest < ActiveSupport::TestCase assert_equal(100, @plugin.calc_percentage_registration(@person)) end -end \ No newline at end of file + + should 'get a list of softwares of a person' do + software1 = create_software_info "noosfero" + software2 = create_software_info "colab" + community = create_community "simple_community" + + software1.community.add_member @person + software1.save! + community.add_member @person + community.save! + + assert_equal 1, @person.softwares.count + end +end -- libgit2 0.21.2