Commit 657084436e1a031727581d7b1b12fc06a93af67a

Authored by Rodrigo Souto
2 parents 81ca0e3a 3149f725

Merge commit 'refs/merge-requests/285' of git://gitorious.org/noosfero/noosfero …

…into merge-requests/285
app/controllers/application_controller.rb
... ... @@ -98,6 +98,12 @@ class ApplicationController < ActionController::Base
98 98 else
99 99 @environment = @domain.environment
100 100 @profile = @domain.profile
  101 +
  102 + # Check if the requested profile belongs to another domain
  103 + if @profile && !params[:profile].blank? && params[:profile] != @profile.identifier
  104 + @profile = @environment.profiles.find_by_identifier params[:profile]
  105 + redirect_to params.merge(:host => @profile.default_hostname)
  106 + end
101 107 end
102 108 end
103 109  
... ...
test/functional/profile_controller_test.rb
... ... @@ -1218,6 +1218,23 @@ class ProfileControllerTest < ActionController::TestCase
1218 1218 end
1219 1219 end
1220 1220  
  1221 + should 'check different profile from the domain profile' do
  1222 + default = Environment.default
  1223 + default.domains.create!(:name => 'environment.com')
  1224 + profile = create_user('another_user').person
  1225 + domain_profile = create_user('domain_user').person
  1226 + domain_profile.domains.create!(:name => 'profiledomain.com')
  1227 +
  1228 + @request.expects(:host).returns('profiledomain.com').at_least_once
  1229 + get :index, :profile => profile.identifier
  1230 + assert_response :redirect
  1231 + assert_redirected_to @request.params.merge(:host => profile.default_hostname)
  1232 +
  1233 + @request.expects(:host).returns(profile.default_hostname).at_least_once
  1234 + get :index, :profile => profile.identifier
  1235 + assert_response :success
  1236 + end
  1237 +
1221 1238 should 'redirect to profile domain if it has one' do
1222 1239 community = fast_create(Community, :name => 'community with domain')
1223 1240 community.domains << Domain.new(:name => 'community.example.net')
... ...