Commit b6ac3685767521da63b1fc04c271e860999976f2
1 parent
51455693
Exists in
master
and in
22 other branches
Fixing webmail link for old-style user menu
(ActionItem1608)
Showing
4 changed files
with
14 additions
and
18 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -238,7 +238,7 @@ class AccountController < ApplicationController | @@ -238,7 +238,7 @@ class AccountController < ApplicationController | ||
238 | def user_data | 238 | def user_data |
239 | user_data = | 239 | user_data = |
240 | if logged_in? | 240 | if logged_in? |
241 | - { "login" => current_user.login, "is_admin" => user.is_admin?(environment), 'since_month' => user.created_at.month, 'since_year' => user.created_at.year } | 241 | + { "login" => current_user.login, "is_admin" => user.is_admin?(environment), 'since_month' => user.created_at.month, 'since_year' => user.created_at.year, 'email_domain' => current_user.enable_email ? current_user.email_domain : nil } |
242 | else | 242 | else |
243 | { } | 243 | { } |
244 | end | 244 | end |
app/views/shared/user_menu.rhtml
@@ -29,11 +29,11 @@ | @@ -29,11 +29,11 @@ | ||
29 | 29 | ||
30 | <!-- li><a href="#"><span class="icon-menu-blog"></span> Meu Blog</a></li --> | 30 | <!-- li><a href="#"><span class="icon-menu-blog"></span> Meu Blog</a></li --> |
31 | 31 | ||
32 | - <%# if MailConf.enabled? && current_user.enable_email %> | ||
33 | - <li> | ||
34 | - <%# link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url(user.identifier, current_user.email_domain) %> | 32 | + <% if MailConf.enabled? %> |
33 | + <li class='webmail-link' style='display: none'> | ||
34 | + <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url('%{login}', '%{email_domain}') %> | ||
35 | </li> | 35 | </li> |
36 | - <%# end %> | 36 | + <% end %> |
37 | 37 | ||
38 | <li> | 38 | <li> |
39 | <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), '/myprofile/%{login}', :id => 'link_edit_profile') %> | 39 | <%= link_to('<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), '/myprofile/%{login}', :id => 'link_edit_profile') %> |
public/javascripts/application.js
@@ -442,13 +442,20 @@ jQuery(function($) { | @@ -442,13 +442,20 @@ jQuery(function($) { | ||
442 | // logged in | 442 | // logged in |
443 | $('#user .logged-in, .login-block .logged-user-info').each(function() { | 443 | $('#user .logged-in, .login-block .logged-user-info').each(function() { |
444 | $(this).find('a[href]').each(function() { | 444 | $(this).find('a[href]').each(function() { |
445 | - $(this).attr('href', $(this).attr('href').replace('%{login}', data.login)) | 445 | + var new_href = $(this).attr('href').replace('%{login}', data.login); |
446 | + if (data.email_domain) { | ||
447 | + new_href = new_href.replace('%{email_domain}', data.email_domain); | ||
448 | + } | ||
449 | + $(this).attr('href', new_href); | ||
446 | }); | 450 | }); |
447 | var html = $(this).html().replace(/%{login}/g, data.login).replace('%{month}', data.since_month).replace('%{year}', data.since_year); | 451 | var html = $(this).html().replace(/%{login}/g, data.login).replace('%{month}', data.since_month).replace('%{year}', data.since_year); |
448 | $(this).html(html).fadeIn(); | 452 | $(this).html(html).fadeIn(); |
449 | if (data.is_admin) { | 453 | if (data.is_admin) { |
450 | $('#user .admin-link').show(); | 454 | $('#user .admin-link').show(); |
451 | } | 455 | } |
456 | + if (data.email_domain) { | ||
457 | + $('#user .webmail-link').show(); | ||
458 | + } | ||
452 | }); | 459 | }); |
453 | } else { | 460 | } else { |
454 | // not logged in | 461 | // not logged in |
test/functional/application_controller_test.rb
@@ -201,12 +201,11 @@ class ApplicationControllerTest < Test::Unit::TestCase | @@ -201,12 +201,11 @@ class ApplicationControllerTest < Test::Unit::TestCase | ||
201 | assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' | 201 | assert_tag :tag => 'option', :attributes => { :value => 'it' }, :content => 'Italiano' |
202 | end | 202 | end |
203 | 203 | ||
204 | - should 'display link to webmail if enabled for system and for user' do | 204 | + should 'display link to webmail if enabled for system' do |
205 | @controller.stubs(:get_layout).returns('application') | 205 | @controller.stubs(:get_layout).returns('application') |
206 | login_as('ze') | 206 | login_as('ze') |
207 | MailConf.expects(:enabled?).returns(true) | 207 | MailConf.expects(:enabled?).returns(true) |
208 | MailConf.expects(:webmail_url).returns('http://web.mail/') | 208 | MailConf.expects(:webmail_url).returns('http://web.mail/') |
209 | - User.any_instance.expects(:enable_email).returns(true) | ||
210 | 209 | ||
211 | get :index | 210 | get :index |
212 | assert_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } } | 211 | assert_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } } |
@@ -221,16 +220,6 @@ class ApplicationControllerTest < Test::Unit::TestCase | @@ -221,16 +220,6 @@ class ApplicationControllerTest < Test::Unit::TestCase | ||
221 | assert_no_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } } | 220 | assert_no_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } } |
222 | end | 221 | end |
223 | 222 | ||
224 | - should 'not display link in menu to webmail if not enabled for user' do | ||
225 | - @controller.stubs(:get_layout).returns('application') | ||
226 | - login_as('ze') | ||
227 | - MailConf.expects(:enabled?).returns(true) | ||
228 | - User.any_instance.expects(:enable_email).returns(false) | ||
229 | - | ||
230 | - get :index | ||
231 | - assert_no_tag :tag => 'div', :attributes => { :id => 'user_box' }, :descendant => { :tag => 'a', :attributes => { :href => 'http://web.mail/' } } | ||
232 | - end | ||
233 | - | ||
234 | should 'display theme test panel when testing theme' do | 223 | should 'display theme test panel when testing theme' do |
235 | @request.session[:theme] = 'my-test-theme' | 224 | @request.session[:theme] = 'my-test-theme' |
236 | theme = mock | 225 | theme = mock |