Commit c2cbd96f68db04171fdac3a53fdb35b37e0dbd20
1 parent
25b98859
Exists in
master
and in
28 other branches
Fixed text on user menu links to manage groups
On languages that "My" is not translated the same way when used with "enterprises" and "communities", the translations were wrong. (ActionItem3190)
Showing
3 changed files
with
77 additions
and
5 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1075,7 +1075,7 @@ module ApplicationHelper |
1075 | 1075 | result |
1076 | 1076 | end |
1077 | 1077 | |
1078 | - def manage_link(list, kind) | |
1078 | + def manage_link(list, kind, title) | |
1079 | 1079 | if list.present? |
1080 | 1080 | link_to_all = nil |
1081 | 1081 | if list.count > 5 |
... | ... | @@ -1088,19 +1088,19 @@ module ApplicationHelper |
1088 | 1088 | if link_to_all |
1089 | 1089 | link << link_to_all |
1090 | 1090 | end |
1091 | - render :partial => "shared/manage_link", :locals => {:link => link, :kind => kind.to_s} | |
1091 | + render :partial => "shared/manage_link", :locals => {:link => link, :kind => kind.to_s, :title => title} | |
1092 | 1092 | end |
1093 | 1093 | end |
1094 | 1094 | |
1095 | 1095 | def manage_enterprises |
1096 | 1096 | return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu) |
1097 | - manage_link(user.enterprises.visible, :enterprises) | |
1097 | + manage_link(user.enterprises.visible, :enterprises, _('My enterprises')) | |
1098 | 1098 | end |
1099 | 1099 | |
1100 | 1100 | def manage_communities |
1101 | 1101 | return unless user && user.environment.enabled?(:display_my_communities_on_user_menu) |
1102 | 1102 | administered_communities = user.communities.visible.more_popular.select {|c| c.admins.include? user} |
1103 | - manage_link(administered_communities, :communities) | |
1103 | + manage_link(administered_communities, :communities, _('My communities')) | |
1104 | 1104 | end |
1105 | 1105 | |
1106 | 1106 | def usermenu_logged_in | ... | ... |
app/views/shared/_manage_link.html.erb
1 | 1 | <div id=<%= "manage-#{kind}" %> class="manage-groups"> |
2 | - <a href="#" id=<%= "manage-#{kind}-link" %> class="simplemenu-trigger" title="<%= _('Manage %s') % kind %>"><i class=<%= "icon-menu-#{kind.singularize}" %>></i><strong><%= ui_icon('ui-icon-triangle-1-s') + _('My %s') % kind %></strong></a> | |
2 | + <a href="#" id=<%= "manage-#{kind}-link" %> class="simplemenu-trigger" title="<%= _('Manage %s') % _(kind) %>"><i class=<%= "icon-menu-#{kind.singularize}" %>></i><strong><%= ui_icon('ui-icon-triangle-1-s') + title %></strong></a> | |
3 | 3 | <ul class="simplemenu-submenu"> |
4 | 4 | <% link.each do |link| %> |
5 | 5 | <li class="simplemenu-item"><%= link %></li> | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -846,6 +846,78 @@ class ApplicationHelperTest < ActiveSupport::TestCase |
846 | 846 | filter_html(article.body, article) |
847 | 847 | end |
848 | 848 | |
849 | + should 'not display enterprises if not logged' do | |
850 | + @controller = ApplicationController.new | |
851 | + profile = create_user('testuser').person | |
852 | + profile.environment.enable('display_my_enterprises_on_user_menu') | |
853 | + enterprise = fast_create(Enterprise) | |
854 | + enterprise.add_admin(profile) | |
855 | + | |
856 | + stubs(:user).returns(nil) | |
857 | + expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never | |
858 | + assert_nil manage_enterprises | |
859 | + end | |
860 | + | |
861 | + should 'display enterprises if logged and enabled on environment' do | |
862 | + @controller = ApplicationController.new | |
863 | + profile = create_user('testuser').person | |
864 | + profile.environment.enable('display_my_enterprises_on_user_menu') | |
865 | + enterprise = fast_create(Enterprise) | |
866 | + enterprise.add_admin(profile) | |
867 | + | |
868 | + stubs(:user).returns(profile) | |
869 | + expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).returns('enterprises list') | |
870 | + assert_equal 'enterprises list', manage_enterprises | |
871 | + end | |
872 | + | |
873 | + should 'not display enterprises if logged and disabled on environment' do | |
874 | + @controller = ApplicationController.new | |
875 | + profile = create_user('testuser').person | |
876 | + profile.environment.disable('display_my_enterprises_on_user_menu') | |
877 | + enterprise = fast_create(Enterprise) | |
878 | + enterprise.add_admin(profile) | |
879 | + | |
880 | + stubs(:user).returns(profile) | |
881 | + expects(:manage_link).with(profile.enterprises, :enterprises, _('My enterprises')).never | |
882 | + assert_nil manage_enterprises | |
883 | + end | |
884 | + | |
885 | + should 'not display communities if not logged' do | |
886 | + @controller = ApplicationController.new | |
887 | + profile = create_user('testuser').person | |
888 | + profile.environment.enable('display_my_communities_on_user_menu') | |
889 | + community = fast_create(Community) | |
890 | + community.add_admin(profile) | |
891 | + | |
892 | + stubs(:user).returns(nil) | |
893 | + expects(:manage_link).with(profile.communities, :communities, _('My communities')).never | |
894 | + assert_nil manage_communities | |
895 | + end | |
896 | + | |
897 | + should 'display communities if logged and enabled on environment' do | |
898 | + @controller = ApplicationController.new | |
899 | + profile = create_user('testuser').person | |
900 | + profile.environment.enable('display_my_communities_on_user_menu') | |
901 | + community = fast_create(Community) | |
902 | + community.add_admin(profile) | |
903 | + | |
904 | + stubs(:user).returns(profile) | |
905 | + expects(:manage_link).with(profile.communities, :communities, _('My communities')).returns('communities list') | |
906 | + assert_equal 'communities list', manage_communities | |
907 | + end | |
908 | + | |
909 | + should 'not display communities if logged and disabled on environment' do | |
910 | + @controller = ApplicationController.new | |
911 | + profile = create_user('testuser').person | |
912 | + profile.environment.disable('display_my_communities_on_user_menu') | |
913 | + community = fast_create(Community) | |
914 | + community.add_admin(profile) | |
915 | + | |
916 | + stubs(:user).returns(profile) | |
917 | + expects(:manage_link).with(profile.communities, :communities, _('My communities')).never | |
918 | + assert_nil manage_communities | |
919 | + end | |
920 | + | |
849 | 921 | protected |
850 | 922 | include NoosferoTestHelper |
851 | 923 | ... | ... |