Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adjusting tests a bit

  • Loading branch information...
commit dff068459590d43f178dcd8d1ed0dd37f564da65 1 parent 72e994d
@GBH GBH authored
View
3  .travis.yml
@@ -1,3 +1,6 @@
+before_install:
+ - gem update --system
+ - gem --version
rvm:
- 1.8.7
- 1.9.2
View
7 app/controllers/cms_content_controller.rb
@@ -5,7 +5,8 @@ class CmsContentController < ApplicationController
before_filter :load_cms_site,
:load_fixtures
- before_filter :load_cms_page, :authenticate,
+ before_filter :load_cms_page,
+ :authenticate,
:only => :render_html
before_filter :load_cms_layout,
:only => [:render_css, :render_js]
@@ -20,6 +21,7 @@ def render_html(status = 200)
end
def render_sitemap
+ render
end
def render_css
@@ -46,7 +48,8 @@ def load_cms_site
if @cms_site
if params[:cms_path].present?
- params[:cms_path].gsub!(/^#{@cms_site.path}/, '').gsub!(/^\//, '')
+ params[:cms_path].gsub!(/^#{@cms_site.path}/, '')
+ params[:cms_path].to_s.gsub!(/^\//, '')
end
I18n.locale = @cms_site.locale
else
View
5 config/routes.rb
@@ -34,7 +34,10 @@
scope :controller => :cms_content do
get 'cms-css/:site_id/:identifier' => :render_css, :as => 'cms_css'
get 'cms-js/:site_id/:identifier' => :render_js, :as => 'cms_js'
- get '(:cms_path)/sitemap' => :render_sitemap, :as => 'cms_sitemap', :constraints => {:format => /xml/}, :format => :xml
+ get '(:cms_path)/sitemap' => :render_sitemap,
+ :as => 'cms_sitemap',
+ :constraints => {:format => /xml/},
+ :format => :xml
get '/' => :render_html, :as => 'cms_html', :path => "(*cms_path)"
end
View
7 test/fixtures/cms/sites.yml
@@ -4,10 +4,3 @@ default:
hostname: test.host
path:
is_mirrored: false
-
-site_with_path:
- label: Site With Path
- identifier: site-with-path
- hostname: test.path.host
- path: standard-path
- is_mirrored: false
View
20 test/functional/cms_content_controller_test.rb
@@ -163,11 +163,23 @@ def test_render_sitemap
end
def test_render_sitemap_with_path
- @request.host = 'test.path.host'
- get :render_sitemap, :cms_path => cms_sites(:site_with_path).path, :format => :xml
+ site = cms_sites(:default)
+ site.update_attribute(:path, 'en')
+
+ get :render_sitemap, :cms_path => site.path, :format => :xml
assert_response :success
- assert_equal cms_sites(:site_with_path), assigns(:cms_site)
- assert !response.body.include?("<loc>"), "No pages, no loc's in the sitemap"
+ assert_equal cms_sites(:default), assigns(:cms_site)
+ assert_match '<loc>http://test.host/en/child-page</loc>', response.body
+ end
+
+ def test_render_sitemap_with_path_invalid_with_single_site
+ site = cms_sites(:default)
+ site.update_attribute(:path, 'en')
+
+ get :render_sitemap, :cms_path => 'fr', :format => :xml
+ assert_response :success
+ assert_equal cms_sites(:default), assigns(:cms_site)
+ assert_match '<loc>http://test.host/en/child-page</loc>', response.body
end
end

0 comments on commit dff0684

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