Commit 693f200171eda6f2fc3ab36c264795bf1d4a6f50
1 parent
0075cead
Exists in
master
and in
29 other branches
rails3: fix profile_controller
Showing
4 changed files
with
16 additions
and
24 deletions
Show diff stats
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.html.erb
@@ -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.html.erb
@@ -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
@@ -173,7 +173,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -173,7 +173,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
173 | should 'not show Leave This Community button for non-registered users' do | 173 | should 'not show Leave This Community button for non-registered users' do |
174 | community = Community.create!(:name => 'my test community') | 174 | community = Community.create!(:name => 'my test community') |
175 | community.boxes.first.blocks << block = ProfileInfoBlock.create! | 175 | community.boxes.first.blocks << block = ProfileInfoBlock.create! |
176 | - get :profile_info, :profile => community.identifier, :block_id => block.id | 176 | + get :index, :profile => community.identifier |
177 | assert_no_match /\/profile\/#{@profile.identifier}\/leave/, @response.body | 177 | assert_no_match /\/profile\/#{@profile.identifier}\/leave/, @response.body |
178 | end | 178 | end |
179 | 179 | ||
@@ -203,7 +203,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -203,7 +203,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
203 | friend = create_user_full('friendtestuser').person | 203 | friend = create_user_full('friendtestuser').person |
204 | friend.user.activate | 204 | friend.user.activate |
205 | friend.boxes.first.blocks << block = ProfileInfoBlock.create! | 205 | friend.boxes.first.blocks << block = ProfileInfoBlock.create! |
206 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 206 | + get :index, :profile => friend.identifier |
207 | assert_match /Add friend/, @response.body | 207 | assert_match /Add friend/, @response.body |
208 | end | 208 | end |
209 | 209 | ||
@@ -212,7 +212,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -212,7 +212,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
212 | friend = create_user_full('friendtestuser').person | 212 | friend = create_user_full('friendtestuser').person |
213 | friend.boxes.first.blocks << block = ProfileInfoBlock.create! | 213 | friend.boxes.first.blocks << block = ProfileInfoBlock.create! |
214 | AddFriend.create!(:person => @profile, :friend => friend) | 214 | AddFriend.create!(:person => @profile, :friend => friend) |
215 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 215 | + get :index, :profile => friend.identifier |
216 | assert_no_match /Add friend/, @response.body | 216 | assert_no_match /Add friend/, @response.body |
217 | end | 217 | end |
218 | 218 | ||
@@ -223,7 +223,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -223,7 +223,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
223 | @profile.add_friend(friend) | 223 | @profile.add_friend(friend) |
224 | @profile.friends.reload | 224 | @profile.friends.reload |
225 | assert @profile.is_a_friend?(friend) | 225 | assert @profile.is_a_friend?(friend) |
226 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 226 | + get :index, :profile => friend.identifier |
227 | assert_no_match /Add friend/, @response.body | 227 | assert_no_match /Add friend/, @response.body |
228 | end | 228 | end |
229 | 229 | ||
@@ -298,13 +298,13 @@ class ProfileControllerTest < ActionController::TestCase | @@ -298,13 +298,13 @@ class ProfileControllerTest < ActionController::TestCase | ||
298 | should 'display contact us for enterprises' do | 298 | should 'display contact us for enterprises' do |
299 | ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise') | 299 | ent = Enterprise.create!(:name => 'my test enterprise', :identifier => 'my-test-enterprise') |
300 | ent.boxes.first.blocks << block = ProfileInfoBlock.create! | 300 | ent.boxes.first.blocks << block = ProfileInfoBlock.create! |
301 | - get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id | 301 | + get :index, :profile => 'my-test-enterprise' |
302 | assert_match /\/contact\/my-test-enterprise\/new/, @response.body | 302 | assert_match /\/contact\/my-test-enterprise\/new/, @response.body |
303 | end | 303 | end |
304 | 304 | ||
305 | should 'not display contact us for non-enterprises' do | 305 | should 'not display contact us for non-enterprises' do |
306 | @profile.boxes.first.blocks << block = ProfileInfoBlock.create! | 306 | @profile.boxes.first.blocks << block = ProfileInfoBlock.create! |
307 | - get :profile_info, :profile => @profile.identifier, :block_id => block.id | 307 | + get :index, :profile => @profile.identifier |
308 | assert_no_match /\/contact\/#{@profile.identifier}\/new/, @response.body | 308 | assert_no_match /\/contact\/#{@profile.identifier}\/new/, @response.body |
309 | end | 309 | end |
310 | 310 | ||
@@ -312,7 +312,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -312,7 +312,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
312 | ent = Enterprise.create! :name => 'my test enterprise', :identifier => 'my-test-enterprise' | 312 | ent = Enterprise.create! :name => 'my test enterprise', :identifier => 'my-test-enterprise' |
313 | ent.boxes.first.blocks << block = ProfileInfoBlock.create! | 313 | ent.boxes.first.blocks << block = ProfileInfoBlock.create! |
314 | ent.update_attribute(:enable_contact_us, false) | 314 | ent.update_attribute(:enable_contact_us, false) |
315 | - get :profile_info, :profile => 'my-test-enterprise', :block_id => block.id | 315 | + get :index, :profile => 'my-test-enterprise' |
316 | assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body | 316 | assert_no_match /\/contact\/my-test-enterprise\/new/, @response.body |
317 | end | 317 | end |
318 | 318 | ||
@@ -325,7 +325,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -325,7 +325,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
325 | env.disable('disable_contact_person') | 325 | env.disable('disable_contact_person') |
326 | env.save! | 326 | env.save! |
327 | login_as(@profile.identifier) | 327 | login_as(@profile.identifier) |
328 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 328 | + get :index, :profile => friend.identifier |
329 | assert_match /\/contact\/#{friend.identifier}\/new/, @response.body | 329 | assert_match /\/contact\/#{friend.identifier}\/new/, @response.body |
330 | end | 330 | end |
331 | 331 | ||
@@ -333,7 +333,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -333,7 +333,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
333 | nofriend = create_user_full('no_friend').person | 333 | nofriend = create_user_full('no_friend').person |
334 | nofriend.boxes.first.blocks << block = ProfileInfoBlock.create! | 334 | nofriend.boxes.first.blocks << block = ProfileInfoBlock.create! |
335 | login_as(@profile.identifier) | 335 | login_as(@profile.identifier) |
336 | - get :profile_info, :profile => nofriend.identifier, :block_id => block.id | 336 | + get :index, :profile => nofriend.identifier |
337 | assert_no_match /\/contact\/#{nofriend.identifier}\/new/, @response.body | 337 | assert_no_match /\/contact\/#{nofriend.identifier}\/new/, @response.body |
338 | end | 338 | end |
339 | 339 | ||
@@ -346,7 +346,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -346,7 +346,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
346 | env.save! | 346 | env.save! |
347 | @profile.add_friend(friend) | 347 | @profile.add_friend(friend) |
348 | login_as(@profile.identifier) | 348 | login_as(@profile.identifier) |
349 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 349 | + get :index, :profile => friend.identifier |
350 | assert_match /\/contact\/#{friend.identifier}\/new/, @response.body | 350 | assert_match /\/contact\/#{friend.identifier}\/new/, @response.body |
351 | end | 351 | end |
352 | 352 | ||
@@ -358,7 +358,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -358,7 +358,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
358 | env.save! | 358 | env.save! |
359 | @profile.add_friend(friend) | 359 | @profile.add_friend(friend) |
360 | login_as(@profile.identifier) | 360 | login_as(@profile.identifier) |
361 | - get :profile_info, :profile => friend.identifier, :block_id => block.id | 361 | + get :index, :profile => friend.identifier |
362 | assert_no_match /\/contact\/#{friend.identifier}\/new/, @response.body | 362 | assert_no_match /\/contact\/#{friend.identifier}\/new/, @response.body |
363 | end | 363 | end |
364 | 364 | ||
@@ -370,7 +370,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -370,7 +370,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
370 | env.save! | 370 | env.save! |
371 | community.add_member(@profile) | 371 | community.add_member(@profile) |
372 | login_as(@profile.identifier) | 372 | login_as(@profile.identifier) |
373 | - get :profile_info, :profile => community.identifier, :block_id => block.id | 373 | + get :index, :profile => community.identifier |
374 | assert_match /\/contact\/#{community.identifier}\/new/, @response.body | 374 | assert_match /\/contact\/#{community.identifier}\/new/, @response.body |
375 | end | 375 | end |
376 | 376 | ||
@@ -382,7 +382,7 @@ class ProfileControllerTest < ActionController::TestCase | @@ -382,7 +382,7 @@ class ProfileControllerTest < ActionController::TestCase | ||
382 | env.save! | 382 | env.save! |
383 | community.add_member(@profile) | 383 | community.add_member(@profile) |
384 | login_as(@profile.identifier) | 384 | login_as(@profile.identifier) |
385 | - get :profile_info, :profile => community.identifier, :block_id => block.id | 385 | + get :index, :profile => community.identifier |
386 | assert_no_match /\/contact\/#{community.identifier}\/new/, @response.body | 386 | assert_no_match /\/contact\/#{community.identifier}\/new/, @response.body |
387 | end | 387 | end |
388 | 388 |