Commit 2fc43667e59fba1a28a92721b80602b2f5baa021

Authored by Evandro Junior
Committed by Leandro Santos
1 parent 99bf0aae

Renamed visitor to anonymous

test/api/categories_test.rb
... ... @@ -97,26 +97,24 @@ class CategoriesTest < ActiveSupport::TestCase
97 97 end
98 98 end
99 99  
100   - ############## Visitors' tests #######################################################################33
101   -
102   - should 'visitor list categories' do
103   - visitor_setup
  100 + should 'anonymous list categories' do
  101 + anonymous_setup
104 102 category = fast_create(Category, :environment_id => environment.id)
105 103 get "/api/v1/categories/?#{params.to_query}"
106 104 json = JSON.parse(last_response.body)
107 105 assert_includes json["categories"].map { |c| c["name"] }, category.name
108 106 end
109 107  
110   - should 'visitor get category by id' do
111   - visitor_setup
  108 + should 'anonymous get category by id' do
  109 + anonymous_setup
112 110 category = fast_create(Category, :environment_id => environment.id)
113 111 get "/api/v1/categories/#{category.id}/?#{params.to_query}"
114 112 json = JSON.parse(last_response.body)
115 113 assert_equal category.name, json["category"]["name"]
116 114 end
117 115  
118   - should 'visitor list parent and children when get category by id' do
119   - visitor_setup
  116 + should 'anonymous list parent and children when get category by id' do
  117 + anonymous_setup
120 118 parent = fast_create(Category, :environment_id => environment.id)
121 119 child_1 = fast_create(Category, :environment_id => environment.id)
122 120 child_2 = fast_create(Category, :environment_id => environment.id)
... ... @@ -133,8 +131,8 @@ class CategoriesTest < ActiveSupport::TestCase
133 131 assert_equivalent [child_1.id, child_2.id], json['category']['children'].map { |c| c['id'] }
134 132 end
135 133  
136   - should 'visitor include parent in categories list if params is true' do
137   - visitor_setup
  134 + should 'anonymous include parent in categories list if params is true' do
  135 + anonymous_setup
138 136 parent_1 = fast_create(Category, :environment_id => environment.id) # parent_1 has no parent category
139 137 child_1 = fast_create(Category, :environment_id => environment.id)
140 138 child_2 = fast_create(Category, :environment_id => environment.id)
... ... @@ -156,8 +154,8 @@ class CategoriesTest < ActiveSupport::TestCase
156 154 json["categories"].map { |c| c['parent'] && c['parent']['id'] }
157 155 end
158 156  
159   - should 'visitor include children in categories list if params is true' do
160   - visitor_setup
  157 + should 'anonymous include children in categories list if params is true' do
  158 + anonymous_setup
161 159 category = fast_create(Category, :environment_id => environment.id)
162 160 child_1 = fast_create(Category, :environment_id => environment.id)
163 161 child_2 = fast_create(Category, :environment_id => environment.id)
... ... @@ -182,8 +180,8 @@ class CategoriesTest < ActiveSupport::TestCase
182 180 end
183 181  
184 182 expose_attributes.each do |attr|
185   - should "visitor expose category #{attr} attribute by default" do
186   - visitor_setup
  183 + should "anonymous expose category #{attr} attribute by default" do
  184 + anonymous_setup
187 185 category = fast_create(Category, :environment_id => environment.id)
188 186 get "/api/v1/categories/?#{params.to_query}"
189 187 json = JSON.parse(last_response.body)
... ... @@ -191,6 +189,6 @@ class CategoriesTest < ActiveSupport::TestCase
191 189 end
192 190 end
193 191  
194   - ################################# End visitors' test ####################################################################################
  192 +
195 193  
196 194 end
... ...
test/api/communities_test.rb
... ... @@ -171,10 +171,8 @@ class CommunitiesTest < ActiveSupport::TestCase
171 171 assert_not_includes json["communities"].map { |a| a["id"] }, community2.id
172 172 end
173 173  
174   - ################### Visitor's tests ######################################3
175   -
176   - should 'visitor list only communities' do
177   - visitor_setup
  174 + should 'anonymous list only communities' do
  175 + anonymous_setup
178 176 community = fast_create(Community, :environment_id => environment.id)
179 177 enterprise = fast_create(Enterprise, :environment_id => environment.id) # should not list this enterprise
180 178 get "/api/v1/communities?#{params.to_query}"
... ... @@ -183,8 +181,8 @@ class CommunitiesTest < ActiveSupport::TestCase
183 181 assert_includes json['communities'].map {|c| c['id']}, community.id
184 182 end
185 183  
186   - should 'visitor list all communities' do
187   - visitor_setup
  184 + should 'anonymous list all communities' do
  185 + anonymous_setup
188 186 community1 = fast_create(Community, :environment_id => environment.id, :public_profile => true)
189 187 community2 = fast_create(Community, :environment_id => environment.id)
190 188 get "/api/v1/communities?#{params.to_query}"
... ... @@ -192,8 +190,8 @@ class CommunitiesTest < ActiveSupport::TestCase
192 190 assert_equivalent [community1.id, community2.id], json['communities'].map {|c| c['id']}
193 191 end
194 192  
195   - should 'not visitor list invisible communities' do
196   - visitor_setup
  193 + should 'not anonymous list invisible communities' do
  194 + anonymous_setup
197 195 community1 = fast_create(Community, :environment_id => environment.id)
198 196 fast_create(Community, :environment_id => environment.id, :visible => false)
199 197  
... ... @@ -202,8 +200,8 @@ class CommunitiesTest < ActiveSupport::TestCase
202 200 assert_equal [community1.id], json['communities'].map {|c| c['id']}
203 201 end
204 202  
205   - should 'visitor list private communities' do
206   - visitor_setup
  203 + should 'anonymous list private communities' do
  204 + anonymous_setup
207 205 community1 = fast_create(Community, :environment_id => environment.id)
208 206 community2 = fast_create(Community, :environment_id => environment.id, :public_profile => false)
209 207  
... ... @@ -214,32 +212,32 @@ class CommunitiesTest < ActiveSupport::TestCase
214 212  
215 213  
216 214  
217   - should 'not visitor create a community' do
218   - visitor_setup
  215 + should 'not anonymous create a community' do
  216 + anonymous_setup
219 217 params[:community] = {:name => 'some'}
220 218 post "/api/v1/communities?#{params.to_query}"
221 219 json = JSON.parse(last_response.body)
222 220 assert_equal 401, last_response.status
223 221 end
224 222  
225   - should 'visitor get community' do
226   - visitor_setup
  223 + should 'anonymous get community' do
  224 + anonymous_setup
227 225 community = fast_create(Community, :environment_id => environment.id)
228 226 get "/api/v1/communities/#{community.id}"
229 227 json = JSON.parse(last_response.body)
230 228 assert_equal community.id, json['community']['id']
231 229 end
232 230  
233   - should 'not visitor get invisible community' do
234   - visitor_setup
  231 + should 'not anonymous get invisible community' do
  232 + anonymous_setup
235 233 community = fast_create(Community, :environment_id => environment.id, :visible => false)
236 234 get "/api/v1/communities/#{community.id}"
237 235 json = JSON.parse(last_response.body)
238 236 assert json['community'].blank?
239 237 end
240 238  
241   - should 'visitor not get private communities' do
242   - visitor_setup
  239 + should 'anonymous not get private communities' do
  240 + anonymous_setup
243 241 community = fast_create(Community, :environment_id => environment.id)
244 242 fast_create(Community, :environment_id => environment.id, :public_profile => false)
245 243 get "/api/v1/communities/#{community.id}"
... ... @@ -247,8 +245,8 @@ class CommunitiesTest < ActiveSupport::TestCase
247 245 assert_equal community.id, json['community']['id']
248 246 end
249 247  
250   - should 'visitor list communities with pagination' do
251   - visitor_setup
  248 + should 'anonymous list communities with pagination' do
  249 + anonymous_setup
252 250 community1 = fast_create(Community, :public_profile => true, :created_at => 1.day.ago)
253 251 community2 = fast_create(Community, :created_at => 2.days.ago)
254 252  
... ... @@ -269,8 +267,8 @@ class CommunitiesTest < ActiveSupport::TestCase
269 267 assert_not_includes json_page_two["communities"].map { |a| a["id"] }, community1.id
270 268 end
271 269  
272   - should 'visitor list communities with timestamp' do
273   - visitor_setup
  270 + should 'anonymous list communities with timestamp' do
  271 + anonymous_setup
274 272 community1 = fast_create(Community, :public_profile => true)
275 273 community2 = fast_create(Community)
276 274  
... ... @@ -285,6 +283,4 @@ class CommunitiesTest < ActiveSupport::TestCase
285 283 assert_not_includes json["communities"].map { |a| a["id"] }, community2.id
286 284 end
287 285  
288   - ###################End Visitor's tests ######################################3
289   -
290 286 end
... ...
test/api/profiles_test.rb
... ... @@ -80,7 +80,7 @@ class ProfilesTest < ActiveSupport::TestCase
80 80  
81 81 end
82 82  
83   - should 'visitor list all profiles' do
  83 + should 'anonymous list all profiles' do
84 84 person1 = fast_create(Person)
85 85 person2 = fast_create(Person)
86 86 community = fast_create(Community)
... ... @@ -89,14 +89,14 @@ class ProfilesTest < ActiveSupport::TestCase
89 89 assert_equivalent [person1.id, person2.id, community.id], json.map {|p| p['id']}
90 90 end
91 91  
92   - should 'visitor get person from profile id' do
  92 + should 'anonymous get person from profile id' do
93 93 some_person = fast_create(Person)
94 94 get "/api/v1/profiles/#{some_person.id}"
95 95 json = JSON.parse(last_response.body)
96 96 assert_equal some_person.id, json['id']
97 97 end
98 98  
99   - should 'visitor get community from profile id' do
  99 + should 'anonymous get community from profile id' do
100 100 community = fast_create(Community)
101 101 get "/api/v1/profiles/#{community.id}"
102 102 json = JSON.parse(last_response.body)
... ...
test/api/test_helper.rb
... ... @@ -25,7 +25,7 @@ class ActiveSupport::TestCase
25 25 @params = {:private_token => @private_token}
26 26 end
27 27  
28   - def visitor_setup
  28 + def anonymous_setup
29 29 @environment = Environment.default
30 30 @params = {}
31 31 end
... ...