high_voltage 1.1.1 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/.gitignore +2 -0
  2. data/.travis.yml +6 -0
  3. data/Appraisals +4 -6
  4. data/Gemfile.lock +3 -3
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +83 -16
  7. data/Rakefile +10 -6
  8. data/app/controllers/high_voltage/pages_controller.rb +12 -15
  9. data/config/routes.rb +3 -2
  10. data/gemfiles/{rails-3.0.10.gemfile → rails-3.0.15.gemfile} +1 -1
  11. data/gemfiles/{rails-3.1.0.gemfile → rails-3.1.6.gemfile} +1 -1
  12. data/gemfiles/rails-3.2.6.gemfile +7 -0
  13. data/lib/high_voltage/constraints/root_route.rb +24 -0
  14. data/lib/high_voltage/engine.rb +0 -2
  15. data/lib/high_voltage/page_finder.rb +37 -0
  16. data/lib/high_voltage/route_drawers/default.rb +15 -0
  17. data/lib/high_voltage/route_drawers/root.rb +16 -0
  18. data/lib/high_voltage/version.rb +1 -1
  19. data/lib/high_voltage.rb +12 -2
  20. data/spec/constraints/root_route_spec.rb +21 -0
  21. data/spec/controllers/alternative_finder_controller_spec.rb +12 -0
  22. data/spec/controllers/pages_controller_spec.rb +63 -41
  23. data/spec/controllers/subclassed_pages_controller_spec.rb +19 -20
  24. data/spec/dummy/app/controllers/alternative_finder_controller.rb +14 -0
  25. data/spec/dummy/app/controllers/subclassed_pages_controller.rb +0 -4
  26. data/spec/dummy/app/views/pages/also_dir/also_nested.html.erb +1 -0
  27. data/spec/dummy/app/views/pages/also_exists.html.erb +1 -0
  28. data/spec/dummy/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +2 -0
  29. data/spec/dummy/app/views/pages/rot13.html.erb +1 -0
  30. data/spec/dummy/config/application.rb +0 -1
  31. data/spec/dummy/config/environments/test.rb +0 -5
  32. data/spec/dummy/config/routes.rb +1 -0
  33. data/spec/high_voltage/page_finder_spec.rb +52 -0
  34. data/spec/high_voltage_spec.rb +2 -2
  35. data/spec/integration/navigation_spec.rb +3 -3
  36. data/spec/routing/routes_spec.rb +114 -32
  37. data/spec/spec_helper.rb +4 -16
  38. metadata +99 -86
  39. data/gemfiles/rails-3.0.10.gemfile.lock +0 -124
  40. data/gemfiles/rails-3.1.0.gemfile.lock +0 -137
data/.gitignore CHANGED
@@ -5,3 +5,5 @@ spec/dummy/db/*.sqlite3
5
5
  spec/dummy/log/*.log
6
6
  spec/dummy/tmp/
7
7
  *.swp
8
+ gemfiles/*.lock
9
+ *.gem
data/.travis.yml CHANGED
@@ -1,3 +1,9 @@
1
+ language: ruby
1
2
  rvm:
2
3
  - 1.8.7
3
4
  - 1.9.2
5
+ - 1.9.3
6
+ gemfile:
7
+ - gemfiles/rails-3.0.15.gemfile
8
+ - gemfiles/rails-3.1.6.gemfile
9
+ - gemfiles/rails-3.2.6.gemfile
data/Appraisals CHANGED
@@ -1,7 +1,5 @@
1
- appraise "rails-3.1.0" do
2
- gem "rails", "3.1.0"
3
- end
4
-
5
- appraise "rails-3.0.10" do
6
- gem "rails", "3.0.10"
1
+ ['3.2.6', '3.1.6', '3.0.15'].each do |rails_version|
2
+ appraise "rails-#{rails_version}" do
3
+ gem "rails", rails_version
4
+ end
7
5
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (1.1.1)
4
+ high_voltage (1.2.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -22,7 +22,7 @@ GEM
22
22
  builder (~> 2.1.2)
23
23
  i18n (~> 0.5.0)
24
24
  activesupport (3.0.10)
25
- appraisal (0.3.8)
25
+ appraisal (0.4.1)
26
26
  bundler
27
27
  rake
28
28
  builder (2.1.2)
@@ -55,7 +55,7 @@ GEM
55
55
  rake (>= 0.8.7)
56
56
  rdoc (~> 3.4)
57
57
  thor (~> 0.14.4)
58
- rake (0.9.2)
58
+ rake (0.9.2.2)
59
59
  rdoc (3.9.4)
60
60
  rspec (2.6.0)
61
61
  rspec-core (~> 2.6.0)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010 thoughtbot, inc.
1
+ Copyright 2010-2012 thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # High Voltage [![Build Status](http://travis-ci.org/thoughtbot/high_voltage.png)](http://travis-ci.org/thoughtbot/high_voltage)
1
+ # High Voltage [![Build Status](https://travis-ci.org/thoughtbot/high_voltage.png)](http://travis-ci.org/thoughtbot/high_voltage)
2
2
 
3
3
  Rails engine for static pages.
4
4
 
@@ -57,26 +57,59 @@ In that case, you'd need an app/views/pages/home.html.erb file.
57
57
 
58
58
  Generally speaking, you need to route to the 'show' action with an :id param of the view filename.
59
59
 
60
- High Voltage will generate a named route method of `page_path` which you can use, as well. If you
61
- want to generate a named route (with the :as routing option) for some route which will be handled
62
- by High Voltage, make sure not to use :page as the name, because that will conflict with the named
63
- route generated by High Voltage itself. For example, this will work for top-level routes (we will
60
+ High Voltage will generate a named route method of `page_path` which you can use, as well. If you
61
+ want to generate a named route (with the :as routing option) for some route which will be handled
62
+ by High Voltage, make sure not to use :page as the name, because that will conflict with the named
63
+ route generated by High Voltage itself.
64
+
65
+ For example, this will work for top-level routes (we will
64
66
  get a named route called `static_path` which does not conflict with the generated `page_path` method):
65
67
 
66
68
  match '/:id' => 'high_voltage/pages#show', :as => :static, :via => :get
67
69
 
70
+ #### Specifying a root path
71
+
68
72
  You can route the root url to a high voltage page like this:
69
73
 
70
74
  root :to => 'high_voltage/pages#show', :id => 'home'
71
75
 
72
76
  Which will render a homepage from app/views/pages/home.html.erb
73
77
 
78
+ #### Enabling root domain routes
79
+
80
+ You can remove the directory `pages` from the URL path and serve up routes from
81
+ the root of the domain path:
82
+
83
+ http://www.example.com/about
84
+ http://www.example.com/company
85
+
86
+ Would look for corresponding files:
87
+
88
+ app/views/pages/about.html.erb
89
+ app/views/pages/company.html.erb
90
+
91
+ This is accomplished by changing the `HighVoltage.route_drawer` to `HighVoltage::RouteDrawers::Root`
92
+
93
+ # config/initializers/high_voltage.rb
94
+ HighVoltage.route_drawer = HighVoltage::RouteDrawers::Root
95
+
96
+ Note: This is not a catchall route. It will check the `HighVoltage.content_path`
97
+ (by default this is `app/views/pages`) and validate the view exists.
98
+
99
+ #### Disabling routes
100
+
101
+ The default routes can be completely removed by changing the
102
+ `HighVoltage.routes` to `false`
103
+
104
+ # config/initializers/high_voltage.rb
105
+ HighVoltage.routes = false
106
+
74
107
  Customize
75
108
  --------
76
109
 
77
110
  High Voltage uses a default path and folder of 'pages', i.e. 'url.com/pages/contact' , 'app/views/pages'
78
111
 
79
- You can change this in an initializer:
112
+ You can change this in an initializer:
80
113
 
81
114
  HighVoltage.content_path = "site/"
82
115
 
@@ -115,25 +148,58 @@ Then modify it to subclass from High Voltage, adding whatever you need:
115
148
  end
116
149
  end
117
150
 
151
+ Custom finding
152
+ --------------
153
+
154
+ You can further control the algorithm used to find pages by overriding
155
+ the `page_finder_factory` method:
156
+
157
+ class PagesController < HighVoltage::PagesController
158
+ private
159
+
160
+ def page_finder_factory
161
+ Rot13PageFinder
162
+ end
163
+ end
164
+
165
+ The easiest thing is to subclass `HighVoltage::PageFinder`, which
166
+ provides you with `page_id`:
167
+
168
+ class Rot13PageFinder < HighVoltage::PageFinder
169
+ def find
170
+ paths = super.split('/')
171
+ directory = paths[0..-2]
172
+ filename = paths[-1].tr('a-z','n-za-m')
173
+
174
+ File.join(*directory, filename)
175
+ end
176
+ end
177
+
178
+ Use this to create a custom file mapping, clean filenames for your file
179
+ system, A/B test, and so on.
180
+
118
181
  Testing
119
182
  -------
120
183
 
121
- Just a suggestion, but you can test your pages using Shoulda pretty easily:
122
-
123
- class PagesControllerTest < ActionController::TestCase
124
- tests PagesController
184
+ You can test your static pages using [RSpec](https://github.com/rspec/rspec-rails)
185
+ and [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers):
125
186
 
187
+ # spec/controllers/pages_controller_spec.rb
188
+ describe PagesController, '#show' do
126
189
  %w(earn_money screencast about contact).each do |page|
127
- context "on GET to /pages/#{page}" do
128
- setup { get :show, :id => page }
190
+ context 'on GET to /pages/#{page}' do
191
+ before do
192
+ get :show, :id => page
193
+ end
129
194
 
130
- should_respond_with :success
131
- should_render_template page
195
+ it { should respond_with(:success) }
196
+ it { should render_template(page) }
132
197
  end
133
198
  end
134
199
  end
135
200
 
136
- If you're not using a custom PagesController be sure to test <code>HighVoltage::PagesController</code> instead.
201
+ If you're not using a custom PagesController be sure to test
202
+ `HighVoltage::PagesController` instead.
137
203
 
138
204
  Enjoy!
139
205
 
@@ -156,4 +222,5 @@ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
156
222
  License
157
223
  -------
158
224
 
159
- High Voltage is Copyright © 2009-2011 thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
225
+ High Voltage is Copyright © 2009-2012 thoughtbot. It is free software, and may
226
+ be redistributed under the terms specified in the MIT-LICENSE file.
data/Rakefile CHANGED
@@ -1,14 +1,18 @@
1
1
  require 'bundler/setup'
2
2
  require 'bundler/gem_tasks'
3
3
  require 'appraisal'
4
- require 'rspec/core/rake_task'
5
4
 
5
+ require 'rspec/core/rake_task'
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- desc "Default: run the unit tests."
9
- task :default => [:all]
8
+ task :default do |t|
9
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
10
+ exec 'rake spec'
11
+ else
12
+ Rake::Task['appraise'].execute
13
+ end
14
+ end
10
15
 
11
- desc 'Test the plugin under all supported Rails versions.'
12
- task :all => ["appraisal:install"] do |t|
13
- exec('rake appraisal spec')
16
+ task :appraise => ['appraisal:install'] do |t|
17
+ exec 'rake appraisal'
14
18
  end
@@ -1,10 +1,9 @@
1
1
  class HighVoltage::PagesController < ApplicationController
2
-
3
2
  unloadable
4
- layout Proc.new { |_| HighVoltage::layout }
3
+ layout Proc.new { |_| HighVoltage.layout }
5
4
 
6
5
  rescue_from ActionView::MissingTemplate do |exception|
7
- if exception.message =~ %r{Missing template #{content_path}}
6
+ if exception.message =~ %r{Missing template #{page_finder.content_path}}
8
7
  raise ActionController::RoutingError, "No such page: #{params[:id]}"
9
8
  else
10
9
  raise exception
@@ -15,19 +14,17 @@ class HighVoltage::PagesController < ApplicationController
15
14
  render :template => current_page
16
15
  end
17
16
 
18
- protected
19
-
20
- def current_page
21
- "#{content_path}#{clean_path}"
22
- end
17
+ private
23
18
 
24
- def clean_path
25
- path = Pathname.new "/#{params[:id]}"
26
- path.cleanpath.to_s[1..-1]
27
- end
19
+ def current_page
20
+ page_finder.find
21
+ end
28
22
 
29
- def content_path
30
- HighVoltage::content_path
31
- end
23
+ def page_finder
24
+ page_finder_factory.new(params[:id])
25
+ end
32
26
 
27
+ def page_finder_factory
28
+ HighVoltage::PageFinder
29
+ end
33
30
  end
data/config/routes.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  Rails.application.routes.draw do
2
- match "/#{HighVoltage::content_path}*id" => 'high_voltage/pages#show', :as => :page, :format => false
3
-
2
+ if HighVoltage.routes
3
+ get HighVoltage.route_drawer.match_attributes
4
+ end
4
5
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "3.0.10"
5
+ gem "rails", "3.0.15"
6
6
 
7
7
  gemspec :path=>"../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "rails", "3.1.0"
5
+ gem "rails", "3.1.6"
6
6
 
7
7
  gemspec :path=>"../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.2.6"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,24 @@
1
+ module HighVoltage
2
+ module Constraints
3
+ # Routing constraint to validate request.path has a corresponding view
4
+ class RootRoute
5
+ VIEW_EXTENSIONS = 'html.erb,html.haml,html'
6
+
7
+ def self.matches?(request)
8
+ pattern = file_pattern(request.path)
9
+
10
+ Dir.glob(pattern).any?
11
+ end
12
+
13
+ private
14
+
15
+ def self.file_pattern(page_id)
16
+ "#{content_path}#{page_id}.{#{VIEW_EXTENSIONS}}"
17
+ end
18
+
19
+ def self.content_path
20
+ Rails.root.join('app', 'views', HighVoltage.content_path).to_s
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,6 +1,4 @@
1
1
  module HighVoltage
2
-
3
2
  class Engine < Rails::Engine
4
3
  end
5
-
6
4
  end
@@ -0,0 +1,37 @@
1
+ module HighVoltage
2
+ # A command for finding pages by id. This encapsulates the concepts of
3
+ # mapping page names to file names.
4
+ class PageFinder
5
+ VALID_CHARACTERS = "a-zA-Z0-9~!@$%^&*()#`_+-=<>\"{}|[];',?".freeze
6
+
7
+ def initialize(page_id)
8
+ @page_id = page_id
9
+ end
10
+
11
+ # Produce a template path to the page, in a format understood by
12
+ # `render :template => find`
13
+ def find
14
+ "#{content_path}#{clean_path}"
15
+ end
16
+
17
+ def content_path
18
+ HighVoltage.content_path
19
+ end
20
+
21
+ protected
22
+
23
+ # The raw page id passed in by the user
24
+ attr_reader :page_id
25
+
26
+ private
27
+
28
+ def clean_path
29
+ path = Pathname.new("/#{clean_id}")
30
+ path.cleanpath.to_s[1..-1]
31
+ end
32
+
33
+ def clean_id
34
+ @page_id.tr("^#{VALID_CHARACTERS}", '')
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,15 @@
1
+ module HighVoltage
2
+ module RouteDrawers
3
+ # Matches routes in the HighVoltage.content_path directory. By default this looks
4
+ # for /pages/id. e.g. http://www.example.com/pages/about_us
5
+ class Default
6
+ def self.match_attributes
7
+ {
8
+ "/#{HighVoltage.content_path}*id" => 'high_voltage/pages#show',
9
+ :as => :page,
10
+ :format => false
11
+ }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module HighVoltage
2
+ module RouteDrawers
3
+ # Matches routes from root of the domain e.g. http://www.example.com/about_us
4
+ # Uses HighVoltage::Constraints::RootRoute to validate view exists.
5
+ class Root
6
+ def self.match_attributes
7
+ {
8
+ "/*id" => 'high_voltage/pages#show',
9
+ :as => :page,
10
+ :format => false,
11
+ :constraints => HighVoltage::Constraints::RootRoute
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module HighVoltage
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
data/lib/high_voltage.rb CHANGED
@@ -1,11 +1,21 @@
1
1
  require 'high_voltage/version'
2
+ require 'high_voltage/constraints/root_route'
3
+ require 'high_voltage/page_finder'
4
+ require 'high_voltage/route_drawers/default'
5
+ require 'high_voltage/route_drawers/root'
2
6
 
3
7
  module HighVoltage
4
8
  mattr_accessor :layout
5
- @@layout = "application"
9
+ @@layout = 'application'
6
10
 
7
11
  mattr_accessor :content_path
8
- @@content_path = "pages/"
12
+ @@content_path = 'pages/'
13
+
14
+ mattr_accessor :route_drawer
15
+ @@route_drawer = HighVoltage::RouteDrawers::Default
16
+
17
+ mattr_accessor :routes
18
+ @@routes = true
9
19
 
10
20
  def self.setup
11
21
  yield self
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe HighVoltage::Constraints::RootRoute, '.matches?' do
4
+ context 'view file exists' do
5
+ it 'should return true' do
6
+ request = stub(:path => 'index')
7
+ Dir.stub!(:glob).and_return(['about.html.erb'])
8
+
9
+ HighVoltage::Constraints::RootRoute.matches?(request).should be_true
10
+ end
11
+ end
12
+
13
+ context 'view file does not exist' do
14
+ it 'should return false' do
15
+ request = stub(:path => 'index')
16
+ File.stub!(:glob).and_return([])
17
+
18
+ HighVoltage::Constraints::RootRoute.matches?(request).should be_false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ describe AlternativeFinderController do
4
+ render_views
5
+
6
+ it 'renders the file from the alternative directory' do
7
+ get :show, :id => 'ebg13'
8
+
9
+ response.should be_success
10
+ response.should render_template('rot13')
11
+ end
12
+ end
@@ -1,106 +1,128 @@
1
+ # encoding: UTF-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe HighVoltage::PagesController do
4
-
5
5
  render_views
6
6
 
7
- context "using default configuration" do
8
-
9
- describe "on GET to /pages/exists" do
7
+ context 'using default configuration' do
8
+ describe 'on GET to /pages/exists' do
10
9
  before { get :show, :id => 'exists' }
11
10
 
12
- it "should respond with success and render template" do
11
+ it 'should respond with success and render template' do
13
12
  response.should be_success
14
13
  response.should render_template('exists')
15
14
  end
16
15
 
17
- it "should use the default layout used by ApplicationController" do
18
- response.should render_template("layouts/application")
16
+ it 'should use the default layout used by ApplicationController' do
17
+ response.should render_template('layouts/application')
19
18
  end
20
19
  end
21
20
 
22
- describe "on GET to /pages/dir/nested" do
21
+ describe 'on GET to /pages/dir/nested' do
23
22
  before { get :show, :id => 'dir/nested' }
24
23
 
25
- it "should respond with success and render template" do
24
+ it 'should respond with success and render template' do
26
25
  response.should be_success
27
26
  response.should render_template('pages/dir/nested')
28
27
  end
29
28
  end
30
29
 
31
- it "should raise a routing error for an invalid page" do
32
- lambda { get :show, :id => "invalid" }.should raise_error(ActionController::RoutingError)
30
+ it 'should raise a routing error for an invalid page' do
31
+ lambda {
32
+ get :show,
33
+ :id => 'invalid'
34
+ }.should raise_error(ActionController::RoutingError)
33
35
  end
34
36
 
35
- it "should raise a routing error for a page in another directory" do
36
- lambda { get :show, :id => "../other/wrong" }.should raise_error(ActionController::RoutingError)
37
+ it 'should raise a routing error for a page in another directory' do
38
+ lambda {
39
+ get :show,
40
+ :id => '../other/wrong'
41
+ }.should raise_error(ActionController::RoutingError)
37
42
  end
38
43
 
39
- it "should raise missing template error for valid page with invalid partial" do
40
- lambda { get :show, :id => "exists_but_references_nonexistent_partial" }.should raise_error(ActionView::MissingTemplate)
44
+ it 'should raise missing template error for valid page with invalid partial' do
45
+ lambda {
46
+ get :show,
47
+ :id => 'exists_but_references_nonexistent_partial'
48
+ }.should raise_error(ActionView::MissingTemplate)
41
49
  end
42
50
  end
43
51
 
44
- context "using custom layout" do
52
+ context 'using custom layout' do
45
53
  before(:all) do
46
- @original_layout = HighVoltage::layout
47
- HighVoltage::layout = "alternate"
54
+ @original_layout = HighVoltage.layout
55
+ HighVoltage.layout = 'alternate'
48
56
  end
49
57
 
50
58
  after(:all) do
51
- HighVoltage::layout = @original_layout
59
+ HighVoltage.layout = @original_layout
52
60
  end
53
61
 
54
- describe "on GET to /pages/exists" do
55
- before { get :show, :id => "exists" }
56
-
57
- it "should use the custom configured layout" do
58
- response.should_not render_template("layouts/application")
59
- response.should render_template("layouts/alternate")
62
+ describe 'on GET to /pages/exists' do
63
+ before { get :show, :id => 'exists' }
64
+
65
+ it 'should use the custom configured layout' do
66
+ response.should_not render_template('layouts/application')
67
+ response.should render_template('layouts/alternate')
60
68
  end
61
69
  end
62
70
  end
63
71
 
64
- context "using custom content path" do
72
+ context 'using custom content path' do
65
73
  before(:all) do
66
- @original_content_path = HighVoltage::content_path
67
- HighVoltage::content_path = "other_pages/"
74
+ @original_content_path = HighVoltage.content_path
75
+ HighVoltage.content_path = 'other_pages/'
68
76
  end
69
77
 
70
78
  after(:all) do
71
- HighVoltage::content_path = @original_content_path
79
+ HighVoltage.content_path = @original_content_path
72
80
  end
73
81
 
74
- describe "on GET to /other_pages/also_exists" do
82
+ describe 'on GET to /other_pages/also_exists' do
75
83
  before { get :show, :id => 'also_exists' }
76
84
 
77
- it "should respond with success and render template" do
85
+ it 'should respond with success and render template' do
78
86
  response.should be_success
79
87
  response.should render_template('other_pages/also_exists')
80
88
  end
81
89
  end
82
90
 
83
- describe "on GET to /other_pages/also_dir/nested" do
91
+ describe 'on GET to /other_pages/also_dir/nested' do
84
92
  before { get :show, :id => 'also_dir/also_nested' }
85
93
 
86
- it "should respond with success and render template" do
94
+ it 'should respond with success and render template' do
87
95
  response.should be_success
88
96
  response.should render_template('other_pages/also_dir/also_nested')
89
97
  end
90
98
  end
91
99
 
92
- it "should raise a routing error for an invalid page" do
93
- lambda { get :show, :id => "also_invalid" }.should raise_error(ActionController::RoutingError)
100
+ it 'should raise a routing error for an invalid page' do
101
+ lambda {
102
+ get :show,
103
+ :id => 'also_invalid'
104
+ }.should raise_error(ActionController::RoutingError)
94
105
  end
95
106
 
96
- it "should raise a routing error for a page in another directory" do
97
- lambda { get :show, :id => "../other/wrong" }.should raise_error(ActionController::RoutingError)
107
+ it 'should raise a routing error for a page in another directory' do
108
+ lambda {
109
+ get :show,
110
+ :id => '../other/wrong'
111
+ }.should raise_error(ActionController::RoutingError)
98
112
  end
99
113
 
100
- it "should raise missing template error for valid page with invalid partial" do
101
- lambda { get :show, :id => "also_exists_but_references_nonexistent_partial" }.should raise_error(ActionView::MissingTemplate)
114
+ it 'should raise a routing error for a page in another directory when using a Unicode exploit' do
115
+ lambda {
116
+ get :show,
117
+ :id => '/\\../other/wrong'
118
+ }.should raise_error(ActionController::RoutingError)
102
119
  end
103
- end
104
-
105
120
 
121
+ it 'should raise missing template error for valid page with invalid partial' do
122
+ lambda {
123
+ get :show,
124
+ :id => 'also_exists_but_references_nonexistent_partial'
125
+ }.should raise_error(ActionView::MissingTemplate)
126
+ end
127
+ end
106
128
  end