Commit a82864176c0536be6e3fcd39196fc4f275d70577
Committed by
Daniela Feitosa
1 parent
c51245ad
Exists in
master
and in
29 other branches
Fixing links to administration for profiles with own domain
(ActionItem1998)
Showing
8 changed files
with
29 additions
and
10 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -1107,7 +1107,7 @@ module ApplicationHelper |
1107 | 1107 | def manage_enterprises |
1108 | 1108 | if user && !user.enterprises.empty? |
1109 | 1109 | enterprises_link = user.enterprises.map do |enterprise| |
1110 | - link_to(content_tag('strong', [_('<span>Manage</span> %s') % enterprise.short_name(25)]), "/myprofile/#{enterprise.identifier}", :class => "icon-menu-enterprise", :title => [_('Manage %s') % enterprise.short_name]) | |
1110 | + link_to(content_tag('strong', [_('<span>Manage</span> %s') % enterprise.short_name(25)]), @environment.top_url + "/myprofile/#{enterprise.identifier}", :class => "icon-menu-enterprise", :title => [_('Manage %s') % enterprise.short_name]) | |
1111 | 1111 | end |
1112 | 1112 | render :partial => 'shared/manage_enterprises', :locals => {:enterprises_link => enterprises_link} |
1113 | 1113 | end |
... | ... | @@ -1116,12 +1116,12 @@ module ApplicationHelper |
1116 | 1116 | def usermenu_logged_in |
1117 | 1117 | pending_tasks_count = '' |
1118 | 1118 | if user && user.all_pending_tasks.count > 0 |
1119 | - pending_tasks_count = link_to(user.all_pending_tasks.count.to_s, '/myprofile/{login}/tasks', :id => 'pending-tasks-count', :title => _("Manage your pending tasks")) | |
1119 | + pending_tasks_count = link_to(user.all_pending_tasks.count.to_s, @environment.top_url + '/myprofile/{login}/tasks', :id => 'pending-tasks-count', :title => _("Manage your pending tasks")) | |
1120 | 1120 | end |
1121 | 1121 | |
1122 | 1122 | (_('Welcome, %s') % link_to('<i></i><strong>{login}</strong>', @environment.top_url + '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) + |
1123 | 1123 | render_environment_features(:usermenu) + |
1124 | - link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', { :controller => 'admin_panel', :action => 'index' }, :id => "controlpanel", :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') + | |
1124 | + link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', { :host => @environment.default_hostname, :controller => 'admin_panel', :action => 'index' }, :id => "controlpanel", :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') + | |
1125 | 1125 | manage_enterprises.to_s + |
1126 | 1126 | link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', @environment.top_url + '/myprofile/{login}', :id => "controlpanel", :title => _("Configure your personal account and content")) + |
1127 | 1127 | pending_tasks_count + | ... | ... |
app/models/environment.rb
... | ... | @@ -518,12 +518,15 @@ class Environment < ActiveRecord::Base |
518 | 518 | # If #force_www is true, adds 'www.' at the beginning of the hostname. If the |
519 | 519 | # environment has not associated domains, returns 'localhost'. |
520 | 520 | def default_hostname(email_hostname = false) |
521 | - if self.domains(true).empty? | |
522 | - 'localhost' | |
523 | - else | |
521 | + domain = 'localhost' | |
522 | + unless self.domains(true).empty? | |
524 | 523 | domain = (self.domains.find_by_is_default(true) || self.domains.find(:first, :order => 'id')).name |
525 | - email_hostname ? domain : (force_www ? ('www.' + domain) : domain) | |
524 | + domain = email_hostname ? domain : (force_www ? ('www.' + domain) : domain) | |
525 | + end | |
526 | + if Noosfero.url_options.has_key?(:port) | |
527 | + domain += ":#{Noosfero.url_options[:port]}" | |
526 | 528 | end |
529 | + domain | |
527 | 530 | end |
528 | 531 | |
529 | 532 | def top_url(ssl = false) | ... | ... |
app/views/admin_panel/site_info.rhtml
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | |
3 | 3 | <%= render :file => 'shared/tiny_mce' %> |
4 | 4 | |
5 | -<% labelled_form_for :environment, @environment do |f| %> | |
5 | +<% labelled_form_for :environment, @environment, :url => {:host => @environment.default_hostname} do |f| %> | |
6 | 6 | |
7 | 7 | <%= labelled_form_field(_('Site name'), text_field(:environment, :name)) %> |
8 | 8 | ... | ... |
app/views/users/send_mail.rhtml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 5 | <%= render :file => 'shared/tiny_mce' %> |
6 | 6 | |
7 | -<% form_for :mailing, :url => {:action => 'send_mail'} do |f| %> | |
7 | +<% form_for :mailing, :url => {:action => 'send_mail', :host => @environment.default_hostname} do |f| %> | |
8 | 8 | <%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> |
9 | 9 | <%= labelled_form_field(_('Body:'), f.text_area(:body, :class => 'mceEditor')) %> |
10 | 10 | <%= submit_button(:send, _('Send')) %> | ... | ... |
features/profile_domain.feature
... | ... | @@ -64,3 +64,9 @@ Feature: domain for profile |
64 | 64 | When I open /something-that-does-not-exist |
65 | 65 | And I follow "Go to the home page" |
66 | 66 | Then the page title should be "Colivre.net" |
67 | + | |
68 | + @selenium | |
69 | + Scenario: Compose link to administration with environment domain | |
70 | + Given I am logged in as "joaosilva" | |
71 | + When I visit "/" and wait | |
72 | + Then I should see "Administration" linking to "http://127.0.0.1:3001/admin" | ... | ... |
features/step_definitions/noosfero_steps.rb
... | ... | @@ -411,3 +411,7 @@ Given /^the environment domain is "([^\"]*)"$/ do |domain| |
411 | 411 | d = Domain.new :name => domain, :owner => Environment.default |
412 | 412 | d.save(false) |
413 | 413 | end |
414 | + | |
415 | +Given /^"([^\"]*)" is admin of environment$/ do |id| | |
416 | + Environment.default.add_admin(Person[id]) | |
417 | +end | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -1119,4 +1119,10 @@ class EnvironmentTest < Test::Unit::TestCase |
1119 | 1119 | assert_equal ["Meter", "Kilo", "Litre"], Environment.default.units.map(&:singular) |
1120 | 1120 | end |
1121 | 1121 | |
1122 | + should 'include port in default hostname for development environment' do | |
1123 | + env = Environment.new | |
1124 | + Noosfero.expects(:url_options).returns({ :port => 9999 }).at_least_once | |
1125 | + assert_equal 'localhost:9999', env.default_hostname | |
1126 | + end | |
1127 | + | |
1122 | 1128 | end | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -260,7 +260,7 @@ class ProfileTest < Test::Unit::TestCase |
260 | 260 | should 'help developers by adding a suitable port to url' do |
261 | 261 | profile = build(Profile) |
262 | 262 | |
263 | - Noosfero.expects(:url_options).returns({ :port => 9999 }) | |
263 | + Noosfero.stubs(:url_options).returns({ :port => 9999 }) | |
264 | 264 | |
265 | 265 | assert profile.url[:port] == 9999, 'Profile#url_options must include port option when running in development mode' |
266 | 266 | end | ... | ... |