diff --git a/lib/needs_profile.rb b/lib/needs_profile.rb index 86ffaa1..5410ce5 100644 --- a/lib/needs_profile.rb +++ b/lib/needs_profile.rb @@ -24,7 +24,7 @@ module NeedsProfile @profile ||= environment.profiles.find_by_identifier(params[:profile]) if @profile profile_hostname = @profile.hostname - if profile_hostname && request.host == @environment.default_hostname + if profile_hostname && profile_hostname != request.host params.delete(:profile) redirect_to(Noosfero.url_options.merge(params).merge(:host => profile_hostname)) end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 1bd38dc..e32f2dc 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -624,6 +624,7 @@ class ProfileEditorControllerTest < ActionController::TestCase profile.domains << Domain.new(:name => 'myowndomain.net') profile.environment.domains << Domain.new(:name => 'myenv.net') + ActionController::TestRequest.any_instance.stubs(:host).returns(profile.hostname) get :edit, :profile => profile.identifier assert_tag :tag => 'select', :attributes => { :name => 'profile_data[preferred_domain_id]' }, :descendant => { :tag => "option", :content => 'myowndomain.net' } @@ -639,6 +640,7 @@ class ProfileEditorControllerTest < ActionController::TestCase profile.domains << Domain.new(:name => 'myowndomain.net') profile.environment.domains << Domain.new(:name => 'myenv.net') + ActionController::TestRequest.any_instance.stubs(:host).returns(profile.hostname) get :edit, :profile => profile.identifier assert_tag :tag => "select", :attributes => { :name => 'profile_data[preferred_domain_id]'}, :descendant => { :tag => 'option', :content => '<Select domain>', :attributes => { :value => '' } } @@ -978,4 +980,13 @@ class ProfileEditorControllerTest < ActionController::TestCase assert_equal({}, person.reload.fields_privacy) end + should 'not redirect if the profile_hostname is the same as environment hostname' do + Person.any_instance.stubs(:hostname).returns('hostname.org') + Environment.any_instance.stubs(:default_hostname).returns('hostname.org') + ActionController::TestRequest.any_instance.stubs(:host).returns('hostname.org') + get :index, :profile => profile.identifier + assert_response :success + end + + end -- libgit2 0.21.2