diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5c5cf39a5..37ab18da8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,11 +49,6 @@ module ApplicationHelper end end - # Displays a link to user's account page if active - def link_to_user(user, options={}) - user.is_a?(User) ? link_to_principal(user, options) : h(user.to_s) - end - # Displays a link to user's account page or group page def link_to_principal(principal, options={}) only_path = options[:only_path].nil? ? true : options[:only_path] @@ -77,20 +72,8 @@ module ApplicationHelper css_classes += " #{options[:class]}" if css_classes && options[:class].present? url ? link_to(name, url, :class => css_classes) : name end - - # Displays a link to edit group page if current user is admin - # Otherwise display only the group name - def link_to_group(group, options={}) - if group.is_a?(Group) - name = h(group.name) - if User.current.admin? - only_path = options[:only_path].nil? ? true : options[:only_path] - link_to name, edit_group_path(group, :only_path => only_path) - else - name - end - end - end + alias link_to_user link_to_principal + alias link_to_group link_to_principal # Displays a link to +issue+ with its subject. # Examples: diff --git a/test/functional/groups_controller_test.rb b/test/functional/groups_controller_test.rb index e335e9918..c0273c3f4 100644 --- a/test/functional/groups_controller_test.rb +++ b/test/functional/groups_controller_test.rb @@ -289,4 +289,12 @@ class GroupsControllerTest < Redmine::ControllerTest assert_response :success assert_include 'John Smith', response.body end + + def test_show_should_display_edit_link_for_admin + @request.session[:user_id] = 1 + get :show, :params => {:id => 10} + assert_response :success + + assert_select '.contextual > .icon-edit' + end end diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 40d842607..0274fe936 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -301,8 +301,8 @@ class UsersControllerTest < Redmine::ControllerTest assert_select 'div#groups', 1 do assert_select 'h3', :text => 'Groups' assert_select 'li', 2 - assert_select 'a[href=?]', '/groups/10/edit', :text => 'A Team' - assert_select 'a[href=?]', '/groups/11/edit', :text => 'B Team' + assert_select 'a[href=?]', '/groups/10', :text => 'A Team' + assert_select 'a[href=?]', '/groups/11', :text => 'B Team' end end diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index c68f7495c..1ca076826 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -1851,19 +1851,6 @@ class ApplicationHelperTest < Redmine::HelperTest assert_include "<>'&", link_to_principal("<>'&") end - def test_link_to_group_should_return_only_group_name_for_non_admin_users - User.current = nil - group = Group.find(10) - assert_equal "A Team", link_to_group(group) - end - - def test_link_to_group_should_link_to_group_edit_page_for_admin_users - User.current = User.find(1) - group = Group.find(10) - result = link_to("A Team", "/groups/10/edit") - assert_equal result, link_to_group(group) - end - def test_link_to_user_should_not_link_to_anonymous user = User.anonymous assert user.anonymous?