high_voltage 1.0.1 → 1.1.0
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.
- data/.gitignore +7 -0
- data/.travis.yml +3 -0
- data/Appraisals +7 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +94 -0
- data/README.md +11 -1
- data/Rakefile +14 -0
- data/app/controllers/high_voltage/pages_controller.rb +7 -2
- data/config/routes.rb +2 -1
- data/gemfiles/rails-3.0.10.gemfile +7 -0
- data/gemfiles/rails-3.0.10.gemfile.lock +124 -0
- data/gemfiles/rails-3.1.0.gemfile +7 -0
- data/gemfiles/rails-3.1.0.gemfile.lock +137 -0
- data/high_voltage.gemspec +22 -0
- data/lib/high_voltage.rb +12 -0
- data/lib/high_voltage/version.rb +3 -0
- data/spec/controllers/pages_controller_spec.rb +106 -0
- data/spec/controllers/subclassed_pages_controller_spec.rb +41 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/subclassed_pages_controller.rb +7 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/alternate.html.erb +14 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/other/wrong.html.erb +1 -0
- data/spec/dummy/app/views/other_pages/also_dir/also_nested.html.erb +1 -0
- data/spec/dummy/app/views/other_pages/also_exists.html.erb +1 -0
- data/spec/dummy/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +2 -0
- data/spec/dummy/app/views/pages/dir/nested.html.erb +1 -0
- data/spec/dummy/app/views/pages/exists.html.erb +1 -0
- data/spec/dummy/app/views/pages/exists_but_references_nonexistent_partial.html.erb +2 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +44 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +25 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/high_voltage_spec.rb +7 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/routing/routes_spec.rb +68 -0
- data/spec/spec_helper.rb +30 -0
- metadata +202 -22
@@ -0,0 +1,22 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require "high_voltage/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'high_voltage'
|
6
|
+
s.version = HighVoltage::VERSION.dup
|
7
|
+
s.authors = ['Matt Jankowski', 'Dan Croak', 'Nick Quaranto', 'Chad Pytel', 'Joe Ferris', 'J. Edward Dewyea', 'Tammer Saleh', 'Mike Burns', 'Tristan Dunn']
|
8
|
+
s.email = ['support@thoughtbot.com']
|
9
|
+
s.homepage = 'http://github.com/thoughtbot/high_voltage'
|
10
|
+
s.summary = 'Simple static page rendering controller'
|
11
|
+
s.description = 'Fire in the disco. Fire in the ... taco bell.'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.add_development_dependency("appraisal")
|
19
|
+
s.add_development_dependency("rspec-rails")
|
20
|
+
s.add_development_dependency("capybara", ">= 0.4.0")
|
21
|
+
s.add_development_dependency("sqlite3")
|
22
|
+
end
|
data/lib/high_voltage.rb
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
require 'high_voltage/version'
|
2
|
+
|
1
3
|
module HighVoltage
|
4
|
+
mattr_accessor :layout
|
5
|
+
@@layout = "application"
|
6
|
+
|
7
|
+
mattr_accessor :content_path
|
8
|
+
@@content_path = "pages/"
|
9
|
+
|
10
|
+
def self.setup
|
11
|
+
yield self
|
12
|
+
end
|
13
|
+
|
2
14
|
require 'high_voltage/engine' if defined?(Rails)
|
3
15
|
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HighVoltage::PagesController do
|
4
|
+
|
5
|
+
render_views
|
6
|
+
|
7
|
+
context "using default configuration" do
|
8
|
+
|
9
|
+
describe "on GET to /pages/exists" do
|
10
|
+
before { get :show, :id => 'exists' }
|
11
|
+
|
12
|
+
it "should respond with success and render template" do
|
13
|
+
response.should be_success
|
14
|
+
response.should render_template('exists')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should use the default layout used by ApplicationController" do
|
18
|
+
response.should render_template("layouts/application")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "on GET to /pages/dir/nested" do
|
23
|
+
before { get :show, :id => 'dir/nested' }
|
24
|
+
|
25
|
+
it "should respond with success and render template" do
|
26
|
+
response.should be_success
|
27
|
+
response.should render_template('pages/dir/nested')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should raise a routing error for an invalid page" do
|
32
|
+
lambda { get :show, :id => "invalid" }.should raise_error(ActionController::RoutingError)
|
33
|
+
end
|
34
|
+
|
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
|
+
end
|
38
|
+
|
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)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "using custom layout" do
|
45
|
+
before(:all) do
|
46
|
+
@original_layout = HighVoltage::layout
|
47
|
+
HighVoltage::layout = "alternate"
|
48
|
+
end
|
49
|
+
|
50
|
+
after(:all) do
|
51
|
+
HighVoltage::layout = @original_layout
|
52
|
+
end
|
53
|
+
|
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")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "using custom content path" do
|
65
|
+
before(:all) do
|
66
|
+
@original_content_path = HighVoltage::content_path
|
67
|
+
HighVoltage::content_path = "other_pages/"
|
68
|
+
end
|
69
|
+
|
70
|
+
after(:all) do
|
71
|
+
HighVoltage::content_path = @original_content_path
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "on GET to /other_pages/also_exists" do
|
75
|
+
before { get :show, :id => 'also_exists' }
|
76
|
+
|
77
|
+
it "should respond with success and render template" do
|
78
|
+
response.should be_success
|
79
|
+
response.should render_template('other_pages/also_exists')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "on GET to /other_pages/also_dir/nested" do
|
84
|
+
before { get :show, :id => 'also_dir/also_nested' }
|
85
|
+
|
86
|
+
it "should respond with success and render template" do
|
87
|
+
response.should be_success
|
88
|
+
response.should render_template('other_pages/also_dir/also_nested')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should raise a routing error for an invalid page" do
|
93
|
+
lambda { get :show, :id => "also_invalid" }.should raise_error(ActionController::RoutingError)
|
94
|
+
end
|
95
|
+
|
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)
|
98
|
+
end
|
99
|
+
|
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)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SubclassedPagesController do
|
4
|
+
|
5
|
+
render_views
|
6
|
+
|
7
|
+
describe "on GET to /subclassed_pages/also_exists" do
|
8
|
+
before { get :show, :id => 'also_exists' }
|
9
|
+
|
10
|
+
it "should respond with success and render template" do
|
11
|
+
response.should be_success
|
12
|
+
response.should render_template('also_exists')
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should use the custom configured layout" do
|
16
|
+
response.should_not render_template("layouts/application")
|
17
|
+
response.should render_template('layouts/alternate')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "on GET to /subclassed_pages/also_dir/nested" do
|
22
|
+
before { get :show, :id => 'also_dir/also_nested' }
|
23
|
+
|
24
|
+
it "should respond with success and render template" do
|
25
|
+
response.should be_success
|
26
|
+
response.should render_template('other_pages/also_dir/also_nested')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should raise a routing error for an invalid page" do
|
31
|
+
lambda { get :show, :id => "invalid" }.should raise_error(ActionController::RoutingError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should raise a routing error for a page in another directory" do
|
35
|
+
lambda { get :show, :id => "../other/wrong" }.should raise_error(ActionController::RoutingError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should raise missing template error for valid page with invalid partial" do
|
39
|
+
lambda { get :show, :id => "also_exists_but_references_nonexistent_partial" }.should raise_error(ActionView::MissingTemplate)
|
40
|
+
end
|
41
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1 @@
|
|
1
|
+
cant get here from pages
|
@@ -0,0 +1 @@
|
|
1
|
+
hello <%= 'world' %> from a nested dir
|
@@ -0,0 +1 @@
|
|
1
|
+
hello <%= 'world' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
hello <%= 'world' %> from a nested dir
|
@@ -0,0 +1 @@
|
|
1
|
+
hello <%= 'world' %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require "active_model/railtie"
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "action_view/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
|
8
|
+
Bundler.require
|
9
|
+
require "high_voltage"
|
10
|
+
|
11
|
+
module Dummy
|
12
|
+
class Application < Rails::Application
|
13
|
+
# Settings in config/environments/* take precedence over those specified here.
|
14
|
+
# Application configuration should go into files in config/initializers
|
15
|
+
# -- all .rb files in that directory are automatically loaded.
|
16
|
+
|
17
|
+
# Custom directories with classes and modules you want to be autoloadable.
|
18
|
+
# config.autoload_paths += %W(#{config.root}/extras)
|
19
|
+
|
20
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
21
|
+
# :all can be used as a placeholder for all plugins not explicitly named.
|
22
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
23
|
+
|
24
|
+
# Activate observers that should always be running.
|
25
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
26
|
+
|
27
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
28
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
29
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
30
|
+
|
31
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
32
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
33
|
+
# config.i18n.default_locale = :de
|
34
|
+
|
35
|
+
# JavaScript files you want as :defaults (application.js is always included).
|
36
|
+
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
|
37
|
+
|
38
|
+
# Configure the default encoding used in templates for Ruby 1.9.
|
39
|
+
config.encoding = "utf-8"
|
40
|
+
|
41
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
42
|
+
config.filter_parameters += [:password]
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the webserver when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Only use best-standards-support built into browsers
|
23
|
+
config.action_dispatch.best_standards_support = :builtin
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The production environment is meant for finished, "live" apps.
|
5
|
+
# Code is not reloaded between requests
|
6
|
+
config.cache_classes = true
|
7
|
+
|
8
|
+
# Full error reports are disabled and caching is turned on
|
9
|
+
config.consider_all_requests_local = false
|
10
|
+
config.action_controller.perform_caching = true
|
11
|
+
|
12
|
+
# Specifies the header that your server uses for sending files
|
13
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
14
|
+
|
15
|
+
# For nginx:
|
16
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
|
17
|
+
|
18
|
+
# If you have no front-end server that supports something like X-Sendfile,
|
19
|
+
# just comment this out and Rails will serve the files
|
20
|
+
|
21
|
+
# See everything in the log (default is :info)
|
22
|
+
# config.log_level = :debug
|
23
|
+
|
24
|
+
# Use a different logger for distributed setups
|
25
|
+
# config.logger = SyslogLogger.new
|
26
|
+
|
27
|
+
# Use a different cache store in production
|
28
|
+
# config.cache_store = :mem_cache_store
|
29
|
+
|
30
|
+
# Disable Rails's static asset server
|
31
|
+
# In production, Apache or nginx will already do this
|
32
|
+
config.serve_static_assets = false
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
35
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
36
|
+
|
37
|
+
# Disable delivery errors, bad email addresses will be ignored
|
38
|
+
# config.action_mailer.raise_delivery_errors = false
|
39
|
+
|
40
|
+
# Enable threaded mode
|
41
|
+
# config.threadsafe!
|
42
|
+
|
43
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
44
|
+
# the I18n.default_locale when a translation can not be found)
|
45
|
+
config.i18n.fallbacks = true
|
46
|
+
|
47
|
+
# Send deprecation notices to registered listeners
|
48
|
+
config.active_support.deprecation = :notify
|
49
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|