Commit b1393db34f54670208108fcf8fda656eb6d29440
1 parent
bd63f775
Exists in
staging
and in
42 other branches
Fix content viewer routes and associated tests
Showing
2 changed files
with
11 additions
and
12 deletions
Show diff stats
config/routes.rb
| ... | ... | @@ -125,11 +125,10 @@ Noosfero::Application.routes.draw do |
| 125 | 125 | match ':profile/edit_comment/:id/*page', :controller => 'content_viewer', :action => 'edit_comment', :profile => /#{Noosfero.identifier_format}/ |
| 126 | 126 | |
| 127 | 127 | # match requests for profiles that don't have a custom domain |
| 128 | - #FIXME probably this route is wrong | |
| 129 | - match ':profile/*page', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/, :conditions => { :if => lambda { |env| !Domain.hosting_profile_at(env[:host]) } } | |
| 128 | + match ':profile(/*page)', :controller => 'content_viewer', :action => 'view_page', :profile => /#{Noosfero.identifier_format}/, :constraints => EnvironmentDomainConstraint.new | |
| 130 | 129 | |
| 131 | 130 | |
| 132 | 131 | # match requests for content in domains hosted for profiles |
| 133 | 132 | match '*page', :controller => 'content_viewer', :action => 'view_page' |
| 134 | 133 | |
| 135 | -end | |
| 136 | 134 | \ No newline at end of file |
| 135 | +end | ... | ... |
test/integration/routing_test.rb
| ... | ... | @@ -160,35 +160,35 @@ class RoutingTest < ActionController::IntegrationTest |
| 160 | 160 | |
| 161 | 161 | def test_hosted_domain_routing |
| 162 | 162 | user = create_user('testuser').person |
| 163 | - domain = Domain.create!(:name => 'example.com', :owner => user) | |
| 163 | + domain = Domain.new(:name => 'example.com').tap { |d| d.owner = user; d.save! } | |
| 164 | 164 | |
| 165 | - ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') | |
| 165 | + ActionDispatch::Request.any_instance.stubs(:host).returns('www.example.com') | |
| 166 | 166 | |
| 167 | - assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => [ 'work', 'free-software'] ) | |
| 167 | + assert_routing('/work/free-software', :controller => 'content_viewer', :action => 'view_page', :page => 'work/free-software' ) | |
| 168 | 168 | end |
| 169 | 169 | |
| 170 | 170 | def test_root_of_hosted_domain |
| 171 | 171 | user = create_user('testuser').person |
| 172 | - domain = Domain.create!(:name => 'example.com', :owner => user) | |
| 172 | + domain = Domain.new(:name => 'example.com').tap { |d| d.owner = user; d.save! } | |
| 173 | 173 | |
| 174 | - ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') | |
| 174 | + ActionDispatch::Request.any_instance.stubs(:host).returns('www.example.com') | |
| 175 | 175 | |
| 176 | 176 | assert_routing('', :controller => 'content_viewer', :action => 'view_page', :page => []) |
| 177 | 177 | end |
| 178 | 178 | |
| 179 | 179 | def test_profile_under_hosted_domain |
| 180 | 180 | community = Community.create!(:identifier => 'testcomm', :name => "test community") |
| 181 | - domain = Domain.create!(:name => 'example.com', :owner => community) | |
| 181 | + domain = Domain.new(:name => 'example.com').tap { |d| d.owner = community; d.save! } | |
| 182 | 182 | |
| 183 | - ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') | |
| 183 | + ActionDispatch::Request.any_instance.stubs(:host).returns('www.example.com') | |
| 184 | 184 | |
| 185 | 185 | assert_routing('/profile/testcomm/refuse_for_now', :controller => 'profile', :action => 'refuse_for_now', :profile => 'testcomm') |
| 186 | 186 | end |
| 187 | 187 | |
| 188 | 188 | def test_must_not_route_as_profile_hosted_domain_for_domains_registered_for_environments |
| 189 | 189 | environment = Environment.default |
| 190 | - domain = Domain.create!(:name => 'example.com', :owner => environment) | |
| 191 | - ActionController::TestRequest.any_instance.expects(:host).returns('www.example.com') | |
| 190 | + domain = Domain.new(:name => 'example.com').tap { |d| d.owner = environment; d.save! } | |
| 191 | + ActionDispatch::Request.any_instance.stubs(:host).returns('www.example.com') | |
| 192 | 192 | |
| 193 | 193 | assert_routing('/', :controller => 'home', :action => 'index') |
| 194 | 194 | end | ... | ... |