Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

adjusting tests a bit

  • Loading branch information...
commit dff068459590d43f178dcd8d1ed0dd37f564da65 1 parent 72e994d
Oleg authored
3  .travis.yml
... ...
@@ -1,3 +1,6 @@
  1
+before_install:
  2
+  - gem update --system
  3
+  - gem --version
1 4
 rvm:
2 5
   - 1.8.7
3 6
   - 1.9.2
7  app/controllers/cms_content_controller.rb
@@ -5,7 +5,8 @@ class CmsContentController < ApplicationController
5 5
   
6 6
   before_filter :load_cms_site,
7 7
                 :load_fixtures
8  
-  before_filter :load_cms_page, :authenticate,
  8
+  before_filter :load_cms_page,
  9
+                :authenticate,
9 10
     :only => :render_html
10 11
   before_filter :load_cms_layout,
11 12
     :only => [:render_css, :render_js]
@@ -20,6 +21,7 @@ def render_html(status = 200)
20 21
   end
21 22
 
22 23
   def render_sitemap
  24
+    render
23 25
   end
24 26
 
25 27
   def render_css
@@ -46,7 +48,8 @@ def load_cms_site
46 48
     
47 49
     if @cms_site
48 50
       if params[:cms_path].present?
49  
-        params[:cms_path].gsub!(/^#{@cms_site.path}/, '').gsub!(/^\//, '')
  51
+        params[:cms_path].gsub!(/^#{@cms_site.path}/, '')
  52
+        params[:cms_path].to_s.gsub!(/^\//, '')
50 53
       end
51 54
       I18n.locale = @cms_site.locale
52 55
     else
5  config/routes.rb
@@ -34,7 +34,10 @@
34 34
   scope :controller => :cms_content do
35 35
     get 'cms-css/:site_id/:identifier' => :render_css,  :as => 'cms_css'
36 36
     get 'cms-js/:site_id/:identifier'  => :render_js,   :as => 'cms_js'
37  
-    get '(:cms_path)/sitemap'  => :render_sitemap,   :as => 'cms_sitemap', :constraints => {:format => /xml/}, :format => :xml
  37
+    get '(:cms_path)/sitemap' => :render_sitemap,
  38
+      :as           => 'cms_sitemap',
  39
+      :constraints  => {:format => /xml/},
  40
+      :format       => :xml
38 41
     get '/' => :render_html,  :as => 'cms_html',  :path => "(*cms_path)"
39 42
   end
40 43
   
7  test/fixtures/cms/sites.yml
@@ -4,10 +4,3 @@ default:
4 4
   hostname: test.host
5 5
   path:
6 6
   is_mirrored: false
7  
-
8  
-site_with_path:
9  
-  label: Site With Path
10  
-  identifier: site-with-path
11  
-  hostname: test.path.host
12  
-  path: standard-path
13  
-  is_mirrored: false
20  test/functional/cms_content_controller_test.rb
@@ -163,11 +163,23 @@ def test_render_sitemap
163 163
   end
164 164
 
165 165
   def test_render_sitemap_with_path
166  
-    @request.host = 'test.path.host'
167  
-    get :render_sitemap, :cms_path => cms_sites(:site_with_path).path, :format => :xml
  166
+    site = cms_sites(:default)
  167
+    site.update_attribute(:path, 'en')
  168
+    
  169
+    get :render_sitemap, :cms_path => site.path, :format => :xml
168 170
     assert_response :success
169  
-    assert_equal cms_sites(:site_with_path), assigns(:cms_site)
170  
-    assert !response.body.include?("<loc>"), "No pages, no loc's in the sitemap"
  171
+    assert_equal cms_sites(:default), assigns(:cms_site)
  172
+    assert_match '<loc>http://test.host/en/child-page</loc>', response.body
  173
+  end
  174
+  
  175
+  def test_render_sitemap_with_path_invalid_with_single_site
  176
+    site = cms_sites(:default)
  177
+    site.update_attribute(:path, 'en')
  178
+    
  179
+    get :render_sitemap, :cms_path => 'fr', :format => :xml
  180
+    assert_response :success
  181
+    assert_equal cms_sites(:default), assigns(:cms_site)
  182
+    assert_match '<loc>http://test.host/en/child-page</loc>', response.body
171 183
   end
172 184
 
173 185
 end

0 notes on commit dff0684

Please sign in to comment.
Something went wrong with that request. Please try again.