Commit 35e6a9494644b066d327b5f344b5e1ceba26805c
1 parent
bdd8a4d0
Exists in
master
and in
29 other branches
stoa-api: make communities return name and url
Showing
2 changed files
with
11 additions
and
3 deletions
Show diff stats
plugins/stoa/lib/stoa_plugin/person_api.rb
... | ... | @@ -31,6 +31,6 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator |
31 | 31 | end |
32 | 32 | |
33 | 33 | def communities |
34 | - object.communities.public.map {|community| {:id => community.id, :name => community.name}} | |
34 | + object.communities.public.map {|community| {:url => context.url_for(community.url), :name => community.name}} | |
35 | 35 | end |
36 | 36 | end | ... | ... |
plugins/stoa/test/unit/person_api_test.rb
... | ... | @@ -107,7 +107,11 @@ class StoaPlugin::PersonApiTest < ActiveSupport::TestCase |
107 | 107 | c3 = fast_create(Community) |
108 | 108 | c1.add_member(person) |
109 | 109 | c2.add_member(person) |
110 | - communities = [{:id => c1.id, :name => c1.name}, {:id => c2.id, :name => c2.name}] | |
110 | + c1_homepage = 'c1.org' | |
111 | + c2_homepage = 'c2.org' | |
112 | + self.stubs(:url_for).with(c1.url).returns(c1_homepage) | |
113 | + self.stubs(:url_for).with(c2.url).returns(c2_homepage) | |
114 | + communities = [{:url => c1_homepage, :name => c1.name}, {:url => c2_homepage, :name => c2.name}] | |
111 | 115 | api = StoaPlugin::PersonApi.new(person, self) |
112 | 116 | |
113 | 117 | assert_equivalent communities, api.communities |
... | ... | @@ -120,7 +124,11 @@ class StoaPlugin::PersonApiTest < ActiveSupport::TestCase |
120 | 124 | c1.add_member(person) |
121 | 125 | c2.add_member(person) |
122 | 126 | c3.add_member(person) |
123 | - communities = [{:id => c1.id, :name => c1.name}] | |
127 | + c1_homepage = 'c1.org' | |
128 | + c2_homepage = 'c2.org' | |
129 | + self.stubs(:url_for).with(c1.url).returns(c1_homepage) | |
130 | + self.stubs(:url_for).with(c2.url).returns(c2_homepage) | |
131 | + communities = [{:url => c1_homepage, :name => c1.name}] | |
124 | 132 | api = StoaPlugin::PersonApi.new(person, self) |
125 | 133 | |
126 | 134 | assert_equivalent communities, api.communities | ... | ... |