adjusting tests a bit

Oleg committed Jan 23, 2012
commit dff068459590d43f178dcd8d1ed0dd37f564da65
Showing 5 changed files with 28 additions and 14 deletions
.travis.yml +3 -0
@@ @@ -1,3 +1,6 @@
+ before_install:
+ - gem update --system
+ - gem --version
rvm:
- 1.8.7
- 1.9.2
app/controllers/cms_content_controller.rb +5 -2
@@ @@ -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 @@ class CmsContentController < ApplicationController
end
def render_sitemap
+ render
end
def render_css
@@ @@ -46,7 +48,8 @@ protected
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
config/routes.rb +4 -1
@@ @@ -34,7 +34,10 @@ Rails.application.routes.draw do
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
test/fixtures/cms/sites.yml +0 -7
@@ @@ -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
test/functional/cms_content_controller_test.rb +16 -4
@@ @@ -163,11 +163,23 @@ class CmsContentControllerTest < ActionController::TestCase
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