Commit 97f389ba1297ef930f59f97b7ab16980e7eaeb82
1 parent
acd66894
Exists in
master
and in
22 other branches
needs_profile: not redirect if request.host is equal to profile hostname
(ActionItem2887)
Showing
2 changed files
with
12 additions
and
1 deletions
Show diff stats
lib/needs_profile.rb
@@ -24,7 +24,7 @@ module NeedsProfile | @@ -24,7 +24,7 @@ module NeedsProfile | ||
24 | @profile ||= environment.profiles.find_by_identifier(params[:profile]) | 24 | @profile ||= environment.profiles.find_by_identifier(params[:profile]) |
25 | if @profile | 25 | if @profile |
26 | profile_hostname = @profile.hostname | 26 | profile_hostname = @profile.hostname |
27 | - if profile_hostname && request.host == @environment.default_hostname | 27 | + if profile_hostname && profile_hostname != request.host |
28 | params.delete(:profile) | 28 | params.delete(:profile) |
29 | redirect_to(Noosfero.url_options.merge(params).merge(:host => profile_hostname)) | 29 | redirect_to(Noosfero.url_options.merge(params).merge(:host => profile_hostname)) |
30 | end | 30 | end |
test/functional/profile_editor_controller_test.rb
@@ -624,6 +624,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -624,6 +624,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
624 | 624 | ||
625 | profile.domains << Domain.new(:name => 'myowndomain.net') | 625 | profile.domains << Domain.new(:name => 'myowndomain.net') |
626 | profile.environment.domains << Domain.new(:name => 'myenv.net') | 626 | profile.environment.domains << Domain.new(:name => 'myenv.net') |
627 | + ActionController::TestRequest.any_instance.stubs(:host).returns(profile.hostname) | ||
627 | 628 | ||
628 | get :edit, :profile => profile.identifier | 629 | get :edit, :profile => profile.identifier |
629 | assert_tag :tag => 'select', :attributes => { :name => 'profile_data[preferred_domain_id]' }, :descendant => { :tag => "option", :content => 'myowndomain.net' } | 630 | 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 | @@ -639,6 +640,7 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
639 | 640 | ||
640 | profile.domains << Domain.new(:name => 'myowndomain.net') | 641 | profile.domains << Domain.new(:name => 'myowndomain.net') |
641 | profile.environment.domains << Domain.new(:name => 'myenv.net') | 642 | profile.environment.domains << Domain.new(:name => 'myenv.net') |
643 | + ActionController::TestRequest.any_instance.stubs(:host).returns(profile.hostname) | ||
642 | 644 | ||
643 | get :edit, :profile => profile.identifier | 645 | get :edit, :profile => profile.identifier |
644 | assert_tag :tag => "select", :attributes => { :name => 'profile_data[preferred_domain_id]'}, :descendant => { :tag => 'option', :content => '<Select domain>', :attributes => { :value => '' } } | 646 | 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 | @@ -978,4 +980,13 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
978 | assert_equal({}, person.reload.fields_privacy) | 980 | assert_equal({}, person.reload.fields_privacy) |
979 | end | 981 | end |
980 | 982 | ||
983 | + should 'not redirect if the profile_hostname is the same as environment hostname' do | ||
984 | + Person.any_instance.stubs(:hostname).returns('hostname.org') | ||
985 | + Environment.any_instance.stubs(:default_hostname).returns('hostname.org') | ||
986 | + ActionController::TestRequest.any_instance.stubs(:host).returns('hostname.org') | ||
987 | + get :index, :profile => profile.identifier | ||
988 | + assert_response :success | ||
989 | + end | ||
990 | + | ||
991 | + | ||
981 | end | 992 | end |