Commit 8c3936e60e0b168efe191b8495c4b20af80ebbc3
1 parent
09a87726
Exists in
master
and in
28 other branches
ActionItem8: unknown domains defaults to VirtualCommunity.default
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@26 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
18 additions
and
2 deletions
Show diff stats
app/controllers/application.rb
| ... | ... | @@ -8,8 +8,12 @@ class ApplicationController < ActionController::Base |
| 8 | 8 | |
| 9 | 9 | def detect_stuff_by_domain |
| 10 | 10 | @domain = Domain.find_by_name(request.host) |
| 11 | - @virtual_community = @domain.virtual_community | |
| 12 | - @profile = @domain.profile | |
| 11 | + if @domain.nil? | |
| 12 | + @virtual_community = VirtualCommunity.default | |
| 13 | + else | |
| 14 | + @virtual_community = @domain.virtual_community | |
| 15 | + @profile = @domain.profile | |
| 16 | + end | |
| 13 | 17 | end |
| 14 | 18 | |
| 15 | 19 | end | ... | ... |
test/functional/home_controller_test.rb
| ... | ... | @@ -39,4 +39,16 @@ class HomeControllerTest < Test::Unit::TestCase |
| 39 | 39 | |
| 40 | 40 | assert_kind_of Profile, assigns(:profile) |
| 41 | 41 | end |
| 42 | + | |
| 43 | + def test_unknown_domain_falls_back_to_default_virtual_community | |
| 44 | + uses_host 'veryunprobabledomain.com' | |
| 45 | + | |
| 46 | + get :index | |
| 47 | + assert_template 'index' | |
| 48 | + | |
| 49 | + assert_kind_of VirtualCommunity, assigns(:virtual_community) | |
| 50 | + assert assigns(:virtual_community).is_default? | |
| 51 | + | |
| 52 | + end | |
| 53 | + | |
| 42 | 54 | end | ... | ... |