Commit a3a6896450b9c77d41c013ee40943df7df749b53

Authored by Daniela Feitosa
2 parents 031e5bd1 f099dfa6

Merge branch 'AI3015-fix_profile_controller' of https://gitlab.com/participa/noo…

…sfero into AI3015-fix_profile_controller
app/controllers/public/profile_controller.rb
@@ -304,14 +304,6 @@ class ProfileController < PublicController @@ -304,14 +304,6 @@ class ProfileController < PublicController
304 end 304 end
305 end 305 end
306 306
307 - def profile_info  
308 - begin  
309 - @block = profile.blocks.find(params[:block_id])  
310 - rescue  
311 - render :text => _('Profile information could not be loaded')  
312 - end  
313 - end  
314 -  
315 def report_abuse 307 def report_abuse
316 @abuse_report = AbuseReport.new 308 @abuse_report = AbuseReport.new
317 render :layout => false 309 render :layout => false
app/views/blocks/profile_image.rhtml
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 16
17 <% if !user.nil? and user.has_permission?('edit_profile', profile) %> 17 <% if !user.nil? and user.has_permission?('edit_profile', profile) %>
18 <div class='admin-link'> 18 <div class='admin-link'>
19 - <%= link_to _('Control panel'), :controller => 'profile_editor' %> 19 + <%= link_to _('Control panel'), block.owner.admin_url %>
20 </div> 20 </div>
21 <% end %> 21 <% end %>
22 22
app/views/blocks/profile_info.rhtml
@@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
21 <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li> 21 <li><%= link_to(_('Products/Services'), :controller => 'catalog', :profile => block.owner.identifier) %></li>
22 <% end %> 22 <% end %>
23 <% if !user.nil? and user.has_permission?('edit_profile', profile) %> 23 <% if !user.nil? and user.has_permission?('edit_profile', profile) %>
24 - <li><%= link_to _('Control panel'), :controller => 'profile_editor' %></li> 24 + <li><%= link_to _('Control panel'), block.owner.admin_url %></li>
25 <% end %> 25 <% end %>
26 <% if profile.person? %> 26 <% if profile.person? %>
27 <li><%= _('Since %{year}/%{month}') % { :year => block.owner.created_at.year, :month => block.owner.created_at.month } %></li> 27 <li><%= _('Since %{year}/%{month}') % { :year => block.owner.created_at.year, :month => block.owner.created_at.month } %></li>
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 <% end %> 40 <% end %>
41 41
42 <div class="profile-info-options"> 42 <div class="profile-info-options">
43 - <%= render :file => view_for_profile_actions(@block.owner.class) %> 43 + <%= render :file => view_for_profile_actions(block.owner.class) %>
44 </div> 44 </div>
45 45
46 </div><!-- end class="vcard" --> 46 </div><!-- end class="vcard" -->
test/functional/profile_controller_test.rb
@@ -176,7 +176,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -176,7 +176,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
176 should 'not show Leave This Community button for non-registered users' do 176 should 'not show Leave This Community button for non-registered users' do
177 community = Community.create!(:name => 'my test community') 177 community = Community.create!(:name => 'my test community')
178 community.boxes.first.blocks << block = ProfileInfoBlock.create! 178 community.boxes.first.blocks << block = ProfileInfoBlock.create!
179 - get :profile_info, :profile => community.identifier, :block_id => block.id 179 + get :index, :profile => community.identifier
180 assert_no_match /\/profile\/#{@profile.identifier}\/leave/, @response.body 180 assert_no_match /\/profile\/#{@profile.identifier}\/leave/, @response.body
181 end 181 end
182 182
@@ -206,7 +206,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -206,7 +206,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
206 friend = create_user_full('friendtestuser').person 206 friend = create_user_full('friendtestuser').person
207 friend.user.activate 207 friend.user.activate
208 friend.boxes.first.blocks << block = ProfileInfoBlock.create! 208 friend.boxes.first.blocks << block = ProfileInfoBlock.create!
209 - get :profile_info, :profile => friend.identifier, :block_id => block.id 209 + get :index, :profile => friend.identifier
210 assert_match /Add friend/, @response.body 210 assert_match /Add friend/, @response.body
211 end 211 end
212 212
@@ -215,7 +215,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -215,7 +215,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
215 friend = create_user_full('friendtestuser').person 215 friend = create_user_full('friendtestuser').person
216 friend.boxes.first.blocks << block = ProfileInfoBlock.create! 216 friend.boxes.first.blocks << block = ProfileInfoBlock.create!
217 AddFriend.create!(:person => @profile, :friend => friend) 217 AddFriend.create!(:person => @profile, :friend => friend)
218 - get :profile_info, :profile => friend.identifier, :block_id => block.id 218 + get :index, :profile => friend.identifier
219 assert_no_match /Add friend/, @response.body 219 assert_no_match /Add friend/, @response.body
220 end 220 end
221 221
@@ -226,7 +226,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -226,7 +226,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
226 @profile.add_friend(friend) 226 @profile.add_friend(friend)
227 @profile.friends.reload 227 @profile.friends.reload
228 assert @profile.is_a_friend?(friend) 228 assert @profile.is_a_friend?(friend)
229 - get :profile_info, :profile => friend.identifier, :block_id => block.id 229 + get :index, :profile => friend.identifier
230 assert_no_match /Add friend/, @response.body 230 assert_no_match /Add friend/, @response.body
231 end 231 end
232 232
@@ -301,13 +301,13 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -301,13 +301,13 @@ class ProfileControllerTest &lt; ActionController::TestCase
301 should 'display contact us for enterprises' do 301 should 'display contact us for enterprises' do
302 ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise') 302 ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise')
303 ent.boxes.first.blocks << block = ProfileInfoBlock.create! 303 ent.boxes.first.blocks << block = ProfileInfoBlock.create!
304 - get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id 304 + get :index, :profile => 'my-test-enterprise'
305 assert_match /\/contact\/my-test-enterprise\/new/, @response.body 305 assert_match /\/contact\/my-test-enterprise\/new/, @response.body
306 end 306 end
307 307
308 should 'not display contact us for non-enterprises' do 308 should 'not display contact us for non-enterprises' do
309 @profile.boxes.first.blocks << block = ProfileInfoBlock.create! 309 @profile.boxes.first.blocks << block = ProfileInfoBlock.create!
310 - get :profile_info, :profile => @profile.identifier, :block_id => block.id 310 + get :index, :profile => @profile.identifier
311 assert_no_match /\/contact\/#{@profile.identifier}\/new/, @response.body 311 assert_no_match /\/contact\/#{@profile.identifier}\/new/, @response.body
312 end 312 end
313 313
@@ -315,7 +315,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -315,7 +315,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
315 ent = Enterprise.create! :name => 'my test enterprise', :identifier => 'my-test-enterprise' 315 ent = Enterprise.create! :name => 'my test enterprise', :identifier => 'my-test-enterprise'
316 ent.boxes.first.blocks << block = ProfileInfoBlock.create! 316 ent.boxes.first.blocks << block = ProfileInfoBlock.create!
317 ent.update_attribute(:enable_contact_us, false) 317 ent.update_attribute(:enable_contact_us, false)
318 - get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id 318 + get :index, :profile => 'my-test-enterprise'
319 assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body 319 assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body
320 end 320 end
321 321
@@ -328,7 +328,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -328,7 +328,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
328 env.disable('disable_contact_person') 328 env.disable('disable_contact_person')
329 env.save! 329 env.save!
330 login_as(@profile.identifier) 330 login_as(@profile.identifier)
331 - get :profile_info, :profile => friend.identifier, :block_id => block.id 331 + get :index, :profile => friend.identifier
332 assert_match /\/contact\/#{friend.identifier}\/new/, @response.body 332 assert_match /\/contact\/#{friend.identifier}\/new/, @response.body
333 end 333 end
334 334
@@ -336,7 +336,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -336,7 +336,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
336 nofriend = create_user_full('no_friend').person 336 nofriend = create_user_full('no_friend').person
337 nofriend.boxes.first.blocks << block = ProfileInfoBlock.create! 337 nofriend.boxes.first.blocks << block = ProfileInfoBlock.create!
338 login_as(@profile.identifier) 338 login_as(@profile.identifier)
339 - get :profile_info, :profile => nofriend.identifier, :block_id => block.id 339 + get :index, :profile => nofriend.identifier
340 assert_no_match /\/contact\/#{nofriend.identifier}\/new/, @response.body 340 assert_no_match /\/contact\/#{nofriend.identifier}\/new/, @response.body
341 end 341 end
342 342
@@ -349,7 +349,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -349,7 +349,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
349 env.save! 349 env.save!
350 @profile.add_friend(friend) 350 @profile.add_friend(friend)
351 login_as(@profile.identifier) 351 login_as(@profile.identifier)
352 - get :profile_info, :profile => friend.identifier, :block_id => block.id 352 + get :index, :profile => friend.identifier
353 assert_match /\/contact\/#{friend.identifier}\/new/, @response.body 353 assert_match /\/contact\/#{friend.identifier}\/new/, @response.body
354 end 354 end
355 355
@@ -361,7 +361,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -361,7 +361,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
361 env.save! 361 env.save!
362 @profile.add_friend(friend) 362 @profile.add_friend(friend)
363 login_as(@profile.identifier) 363 login_as(@profile.identifier)
364 - get :profile_info, :profile => friend.identifier, :block_id => block.id 364 + get :index, :profile => friend.identifier
365 assert_no_match /\/contact\/#{friend.identifier}\/new/, @response.body 365 assert_no_match /\/contact\/#{friend.identifier}\/new/, @response.body
366 end 366 end
367 367
@@ -373,7 +373,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -373,7 +373,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
373 env.save! 373 env.save!
374 community.add_member(@profile) 374 community.add_member(@profile)
375 login_as(@profile.identifier) 375 login_as(@profile.identifier)
376 - get :profile_info, :profile => community.identifier, :block_id => block.id 376 + get :index, :profile => community.identifier
377 assert_match /\/contact\/#{community.identifier}\/new/, @response.body 377 assert_match /\/contact\/#{community.identifier}\/new/, @response.body
378 end 378 end
379 379
@@ -385,7 +385,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -385,7 +385,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
385 env.save! 385 env.save!
386 community.add_member(@profile) 386 community.add_member(@profile)
387 login_as(@profile.identifier) 387 login_as(@profile.identifier)
388 - get :profile_info, :profile => community.identifier, :block_id => block.id 388 + get :index, :profile => community.identifier
389 assert_no_match /\/contact\/#{community.identifier}\/new/, @response.body 389 assert_no_match /\/contact\/#{community.identifier}\/new/, @response.body
390 end 390 end
391 391