Commit 02223aae274f217f2f64948950606e43f2308889
1 parent
fb79fda0
Exists in
master
and in
28 other branches
stoa-api: include communities to api
Showing
3 changed files
with
30 additions
and
1 deletions
Show diff stats
plugins/stoa/lib/stoa_plugin/person_api.rb
plugins/stoa/lib/stoa_plugin/person_fields.rb
... | ... | @@ -4,7 +4,7 @@ module StoaPlugin::PersonFields |
4 | 4 | EXTRA = %w[tags] |
5 | 5 | |
6 | 6 | ESSENTIAL = %w[username email nusp] |
7 | - AVERAGE = ESSENTIAL + %w[name first_name surname address homepage] | |
7 | + AVERAGE = ESSENTIAL + %w[name first_name surname address homepage communities] | |
8 | 8 | FULL = (AVERAGE + Person.fields + HEAVY + EXTRA - FILTER).uniq |
9 | 9 | COMPLETE = FULL - HEAVY |
10 | 10 | ... | ... |
plugins/stoa/test/unit/person_api_test.rb
... | ... | @@ -101,6 +101,31 @@ class StoaPlugin::PersonApiTest < ActiveSupport::TestCase |
101 | 101 | assert !api.tags.has_key?('noosfero') |
102 | 102 | end |
103 | 103 | |
104 | + should 'provide communities' do | |
105 | + c1 = fast_create(Community) | |
106 | + c2 = fast_create(Community) | |
107 | + c3 = fast_create(Community) | |
108 | + c1.add_member(person) | |
109 | + c2.add_member(person) | |
110 | + communities = [{:id => c1.id, :name => c1.name}, {:id => c2.id, :name => c2.name}] | |
111 | + api = StoaPlugin::PersonApi.new(person, self) | |
112 | + | |
113 | + assert_equivalent communities, api.communities | |
114 | + end | |
115 | + | |
116 | + should 'not provide private communities' do | |
117 | + c1 = fast_create(Community) | |
118 | + c2 = fast_create(Community, :public_profile => false) | |
119 | + c3 = fast_create(Community, :visible => false) | |
120 | + c1.add_member(person) | |
121 | + c2.add_member(person) | |
122 | + c3.add_member(person) | |
123 | + communities = [{:id => c1.id, :name => c1.name}] | |
124 | + api = StoaPlugin::PersonApi.new(person, self) | |
125 | + | |
126 | + assert_equivalent communities, api.communities | |
127 | + end | |
128 | + | |
104 | 129 | private |
105 | 130 | |
106 | 131 | def create_article_with_tags(profile_id, tags = '', options = {}) | ... | ... |