high_voltage 1.0.1 → 1.1.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 (63) hide show
  1. data/.gitignore +7 -0
  2. data/.travis.yml +3 -0
  3. data/Appraisals +7 -0
  4. data/CONTRIBUTING.md +38 -0
  5. data/Gemfile +3 -0
  6. data/Gemfile.lock +94 -0
  7. data/README.md +11 -1
  8. data/Rakefile +14 -0
  9. data/app/controllers/high_voltage/pages_controller.rb +7 -2
  10. data/config/routes.rb +2 -1
  11. data/gemfiles/rails-3.0.10.gemfile +7 -0
  12. data/gemfiles/rails-3.0.10.gemfile.lock +124 -0
  13. data/gemfiles/rails-3.1.0.gemfile +7 -0
  14. data/gemfiles/rails-3.1.0.gemfile.lock +137 -0
  15. data/high_voltage.gemspec +22 -0
  16. data/lib/high_voltage/version.rb +3 -0
  17. data/lib/high_voltage.rb +12 -0
  18. data/spec/controllers/pages_controller_spec.rb +106 -0
  19. data/spec/controllers/subclassed_pages_controller_spec.rb +41 -0
  20. data/spec/dummy/Rakefile +7 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/controllers/subclassed_pages_controller.rb +7 -0
  23. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  24. data/spec/dummy/app/views/layouts/alternate.html.erb +14 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/app/views/other/wrong.html.erb +1 -0
  27. data/spec/dummy/app/views/other_pages/also_dir/also_nested.html.erb +1 -0
  28. data/spec/dummy/app/views/other_pages/also_exists.html.erb +1 -0
  29. data/spec/dummy/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +2 -0
  30. data/spec/dummy/app/views/pages/dir/nested.html.erb +1 -0
  31. data/spec/dummy/app/views/pages/exists.html.erb +1 -0
  32. data/spec/dummy/app/views/pages/exists_but_references_nonexistent_partial.html.erb +2 -0
  33. data/spec/dummy/config/application.rb +44 -0
  34. data/spec/dummy/config/boot.rb +10 -0
  35. data/spec/dummy/config/environment.rb +5 -0
  36. data/spec/dummy/config/environments/development.rb +25 -0
  37. data/spec/dummy/config/environments/production.rb +49 -0
  38. data/spec/dummy/config/environments/test.rb +35 -0
  39. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  40. data/spec/dummy/config/initializers/inflections.rb +10 -0
  41. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  42. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  43. data/spec/dummy/config/initializers/session_store.rb +8 -0
  44. data/spec/dummy/config/locales/en.yml +5 -0
  45. data/spec/dummy/config/routes.rb +3 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/public/404.html +26 -0
  48. data/spec/dummy/public/422.html +26 -0
  49. data/spec/dummy/public/500.html +26 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/public/javascripts/application.js +2 -0
  52. data/spec/dummy/public/javascripts/controls.js +965 -0
  53. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  54. data/spec/dummy/public/javascripts/effects.js +1123 -0
  55. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  56. data/spec/dummy/public/javascripts/rails.js +191 -0
  57. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  58. data/spec/dummy/script/rails +6 -0
  59. data/spec/high_voltage_spec.rb +7 -0
  60. data/spec/integration/navigation_spec.rb +9 -0
  61. data/spec/routing/routes_spec.rb +68 -0
  62. data/spec/spec_helper.rb +30 -0
  63. metadata +202 -22
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ spec/dummy/db/*.sqlite3
5
+ spec/dummy/log/*.log
6
+ spec/dummy/tmp/
7
+ *.swp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
data/Appraisals ADDED
@@ -0,0 +1,7 @@
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"
7
+ end
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
1
+ We love pull requests. Here's a quick guide:
2
+
3
+ 1. Fork the repo.
4
+
5
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
6
+ to know that you have a clean slate: `bundle && rake`
7
+
8
+ 3. Add a test for your change. Only refactoring and documentation changes
9
+ require no new tests. If you are adding functionality or fixing a bug, we need
10
+ a test!
11
+
12
+ 4. Make the test pass.
13
+
14
+ 5. Push to your fork and submit a pull request.
15
+
16
+
17
+ At this point you're waiting on us. We like to at least comment on, if not
18
+ accept, pull requests within three business days (and, typically, one business
19
+ day). We may suggest some changes or improvements or alternatives.
20
+
21
+ Some things that will increase the chance that your pull request is accepted,
22
+ taken straight from the Ruby on Rails guide:
23
+
24
+ * Use Rails idioms and helpers
25
+ * Include tests that fail without your code, and pass with it
26
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
27
+ whatever is affected by your contribution
28
+
29
+ Syntax:
30
+
31
+ * Two spaces, no tabs.
32
+ * No trailing whitespace. Blank lines should not have any space.
33
+ * Prefer &&/|| over and/or.
34
+ * MyClass.my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
35
+ * a = b and not a=b.
36
+ * Follow the conventions you see used in the source already.
37
+
38
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ high_voltage (1.1.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ abstract (1.0.0)
10
+ actionpack (3.0.10)
11
+ activemodel (= 3.0.10)
12
+ activesupport (= 3.0.10)
13
+ builder (~> 2.1.2)
14
+ erubis (~> 2.6.6)
15
+ i18n (~> 0.5.0)
16
+ rack (~> 1.2.1)
17
+ rack-mount (~> 0.6.14)
18
+ rack-test (~> 0.5.7)
19
+ tzinfo (~> 0.3.23)
20
+ activemodel (3.0.10)
21
+ activesupport (= 3.0.10)
22
+ builder (~> 2.1.2)
23
+ i18n (~> 0.5.0)
24
+ activesupport (3.0.10)
25
+ appraisal (0.3.8)
26
+ bundler
27
+ rake
28
+ builder (2.1.2)
29
+ capybara (1.1.0)
30
+ mime-types (>= 1.16)
31
+ nokogiri (>= 1.3.3)
32
+ rack (>= 1.0.0)
33
+ rack-test (>= 0.5.4)
34
+ selenium-webdriver (~> 2.0)
35
+ xpath (~> 0.1.4)
36
+ childprocess (0.2.2)
37
+ ffi (~> 1.0.6)
38
+ diff-lcs (1.1.3)
39
+ erubis (2.6.6)
40
+ abstract (>= 1.0.0)
41
+ ffi (1.0.9)
42
+ i18n (0.5.0)
43
+ json_pure (1.5.4)
44
+ spruz (~> 0.2.8)
45
+ mime-types (1.16)
46
+ nokogiri (1.5.0)
47
+ rack (1.2.3)
48
+ rack-mount (0.6.14)
49
+ rack (>= 1.0.0)
50
+ rack-test (0.5.7)
51
+ rack (>= 1.0)
52
+ railties (3.0.10)
53
+ actionpack (= 3.0.10)
54
+ activesupport (= 3.0.10)
55
+ rake (>= 0.8.7)
56
+ rdoc (~> 3.4)
57
+ thor (~> 0.14.4)
58
+ rake (0.9.2)
59
+ rdoc (3.9.4)
60
+ rspec (2.6.0)
61
+ rspec-core (~> 2.6.0)
62
+ rspec-expectations (~> 2.6.0)
63
+ rspec-mocks (~> 2.6.0)
64
+ rspec-core (2.6.4)
65
+ rspec-expectations (2.6.0)
66
+ diff-lcs (~> 1.1.2)
67
+ rspec-mocks (2.6.0)
68
+ rspec-rails (2.6.1)
69
+ actionpack (~> 3.0)
70
+ activesupport (~> 3.0)
71
+ railties (~> 3.0)
72
+ rspec (~> 2.6.0)
73
+ rubyzip (0.9.4)
74
+ selenium-webdriver (2.5.0)
75
+ childprocess (>= 0.2.1)
76
+ ffi (>= 1.0.7)
77
+ json_pure
78
+ rubyzip
79
+ spruz (0.2.13)
80
+ sqlite3 (1.3.4)
81
+ thor (0.14.6)
82
+ tzinfo (0.3.29)
83
+ xpath (0.1.4)
84
+ nokogiri (~> 1.3)
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ appraisal
91
+ capybara (>= 0.4.0)
92
+ high_voltage!
93
+ rspec-rails
94
+ sqlite3
data/README.md CHANGED
@@ -71,6 +71,15 @@ You can route the root url to a high voltage page like this:
71
71
 
72
72
  Which will render a homepage from app/views/pages/home.html.erb
73
73
 
74
+ Customize
75
+ --------
76
+
77
+ High Voltage uses a default path and folder of 'pages', i.e. 'url.com/pages/contact' , 'app/views/pages'
78
+
79
+ You can change this in an initializer:
80
+
81
+ HighVoltage.content_path = "site/"
82
+
74
83
  Override
75
84
  --------
76
85
 
@@ -78,6 +87,7 @@ Most common reasons to override?
78
87
 
79
88
  * You need authentication around the pages to make sure a user is signed in.
80
89
  * You need to render different layouts for different pages.
90
+ * You need to render a partial from the `app/views/pages` directory.
81
91
 
82
92
  Create a PagesController of your own:
83
93
 
@@ -86,7 +96,7 @@ Create a PagesController of your own:
86
96
  Override the default route:
87
97
 
88
98
  # in config/routes.rb
89
- resources :pages
99
+ match "/pages/*id" => 'pages#show', :as => :page, :format => false
90
100
 
91
101
  Then modify it to subclass from High Voltage, adding whatever you need:
92
102
 
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'appraisal'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc "Default: run the unit tests."
9
+ task :default => [:all]
10
+
11
+ desc 'Test the plugin under all supported Rails versions.'
12
+ task :all => ["appraisal:install"] do |t|
13
+ exec('rake appraisal spec')
14
+ end
@@ -1,9 +1,10 @@
1
1
  class HighVoltage::PagesController < ApplicationController
2
2
 
3
3
  unloadable
4
+ layout Proc.new { |_| HighVoltage::layout }
4
5
 
5
6
  rescue_from ActionView::MissingTemplate do |exception|
6
- if exception.message =~ %r{Missing template pages/}
7
+ if exception.message =~ %r{Missing template #{content_path}}
7
8
  raise ActionController::RoutingError, "No such page: #{params[:id]}"
8
9
  else
9
10
  raise exception
@@ -17,7 +18,7 @@ class HighVoltage::PagesController < ApplicationController
17
18
  protected
18
19
 
19
20
  def current_page
20
- "pages/#{clean_path}"
21
+ "#{content_path}#{clean_path}"
21
22
  end
22
23
 
23
24
  def clean_path
@@ -25,4 +26,8 @@ class HighVoltage::PagesController < ApplicationController
25
26
  path.cleanpath.to_s[1..-1]
26
27
  end
27
28
 
29
+ def content_path
30
+ HighVoltage::content_path
31
+ end
32
+
28
33
  end
data/config/routes.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  Rails.application.routes.draw do
2
- match '/pages/*id' => 'high_voltage/pages#show', :as => :page, :format => false
2
+ match "/#{HighVoltage::content_path}*id" => 'high_voltage/pages#show', :as => :page, :format => false
3
+
3
4
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.0.10"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,124 @@
1
+ PATH
2
+ remote: /Users/jferris/Source/high_voltage
3
+ specs:
4
+ high_voltage (1.1.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ abstract (1.0.0)
10
+ actionmailer (3.0.10)
11
+ actionpack (= 3.0.10)
12
+ mail (~> 2.2.19)
13
+ actionpack (3.0.10)
14
+ activemodel (= 3.0.10)
15
+ activesupport (= 3.0.10)
16
+ builder (~> 2.1.2)
17
+ erubis (~> 2.6.6)
18
+ i18n (~> 0.5.0)
19
+ rack (~> 1.2.1)
20
+ rack-mount (~> 0.6.14)
21
+ rack-test (~> 0.5.7)
22
+ tzinfo (~> 0.3.23)
23
+ activemodel (3.0.10)
24
+ activesupport (= 3.0.10)
25
+ builder (~> 2.1.2)
26
+ i18n (~> 0.5.0)
27
+ activerecord (3.0.10)
28
+ activemodel (= 3.0.10)
29
+ activesupport (= 3.0.10)
30
+ arel (~> 2.0.10)
31
+ tzinfo (~> 0.3.23)
32
+ activeresource (3.0.10)
33
+ activemodel (= 3.0.10)
34
+ activesupport (= 3.0.10)
35
+ activesupport (3.0.10)
36
+ appraisal (0.3.8)
37
+ bundler
38
+ rake
39
+ arel (2.0.10)
40
+ builder (2.1.2)
41
+ capybara (1.1.0)
42
+ mime-types (>= 1.16)
43
+ nokogiri (>= 1.3.3)
44
+ rack (>= 1.0.0)
45
+ rack-test (>= 0.5.4)
46
+ selenium-webdriver (~> 2.0)
47
+ xpath (~> 0.1.4)
48
+ childprocess (0.2.2)
49
+ ffi (~> 1.0.6)
50
+ diff-lcs (1.1.3)
51
+ erubis (2.6.6)
52
+ abstract (>= 1.0.0)
53
+ ffi (1.0.9)
54
+ i18n (0.5.0)
55
+ json_pure (1.5.4)
56
+ spruz (~> 0.2.8)
57
+ mail (2.2.19)
58
+ activesupport (>= 2.3.6)
59
+ i18n (>= 0.4.0)
60
+ mime-types (~> 1.16)
61
+ treetop (~> 1.4.8)
62
+ mime-types (1.16)
63
+ nokogiri (1.5.0)
64
+ polyglot (0.3.2)
65
+ rack (1.2.3)
66
+ rack-mount (0.6.14)
67
+ rack (>= 1.0.0)
68
+ rack-test (0.5.7)
69
+ rack (>= 1.0)
70
+ rails (3.0.10)
71
+ actionmailer (= 3.0.10)
72
+ actionpack (= 3.0.10)
73
+ activerecord (= 3.0.10)
74
+ activeresource (= 3.0.10)
75
+ activesupport (= 3.0.10)
76
+ bundler (~> 1.0)
77
+ railties (= 3.0.10)
78
+ railties (3.0.10)
79
+ actionpack (= 3.0.10)
80
+ activesupport (= 3.0.10)
81
+ rake (>= 0.8.7)
82
+ rdoc (~> 3.4)
83
+ thor (~> 0.14.4)
84
+ rake (0.9.2)
85
+ rdoc (3.9.4)
86
+ rspec (2.6.0)
87
+ rspec-core (~> 2.6.0)
88
+ rspec-expectations (~> 2.6.0)
89
+ rspec-mocks (~> 2.6.0)
90
+ rspec-core (2.6.4)
91
+ rspec-expectations (2.6.0)
92
+ diff-lcs (~> 1.1.2)
93
+ rspec-mocks (2.6.0)
94
+ rspec-rails (2.6.1)
95
+ actionpack (~> 3.0)
96
+ activesupport (~> 3.0)
97
+ railties (~> 3.0)
98
+ rspec (~> 2.6.0)
99
+ rubyzip (0.9.4)
100
+ selenium-webdriver (2.5.0)
101
+ childprocess (>= 0.2.1)
102
+ ffi (>= 1.0.7)
103
+ json_pure
104
+ rubyzip
105
+ spruz (0.2.13)
106
+ sqlite3 (1.3.4)
107
+ thor (0.14.6)
108
+ treetop (1.4.10)
109
+ polyglot
110
+ polyglot (>= 0.3.1)
111
+ tzinfo (0.3.29)
112
+ xpath (0.1.4)
113
+ nokogiri (~> 1.3)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ appraisal
120
+ capybara (>= 0.4.0)
121
+ high_voltage!
122
+ rails (= 3.0.10)
123
+ rspec-rails
124
+ sqlite3
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "rails", "3.1.0"
6
+
7
+ gemspec :path=>"../"
@@ -0,0 +1,137 @@
1
+ PATH
2
+ remote: /Users/jferris/Source/high_voltage
3
+ specs:
4
+ high_voltage (1.1.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (3.1.0)
10
+ actionpack (= 3.1.0)
11
+ mail (~> 2.3.0)
12
+ actionpack (3.1.0)
13
+ activemodel (= 3.1.0)
14
+ activesupport (= 3.1.0)
15
+ builder (~> 3.0.0)
16
+ erubis (~> 2.7.0)
17
+ i18n (~> 0.6)
18
+ rack (~> 1.3.2)
19
+ rack-cache (~> 1.0.3)
20
+ rack-mount (~> 0.8.2)
21
+ rack-test (~> 0.6.1)
22
+ sprockets (~> 2.0.0)
23
+ activemodel (3.1.0)
24
+ activesupport (= 3.1.0)
25
+ bcrypt-ruby (~> 3.0.0)
26
+ builder (~> 3.0.0)
27
+ i18n (~> 0.6)
28
+ activerecord (3.1.0)
29
+ activemodel (= 3.1.0)
30
+ activesupport (= 3.1.0)
31
+ arel (~> 2.2.1)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.1.0)
34
+ activemodel (= 3.1.0)
35
+ activesupport (= 3.1.0)
36
+ activesupport (3.1.0)
37
+ multi_json (~> 1.0)
38
+ appraisal (0.3.8)
39
+ bundler
40
+ rake
41
+ arel (2.2.1)
42
+ bcrypt-ruby (3.0.0)
43
+ builder (3.0.0)
44
+ capybara (1.1.0)
45
+ mime-types (>= 1.16)
46
+ nokogiri (>= 1.3.3)
47
+ rack (>= 1.0.0)
48
+ rack-test (>= 0.5.4)
49
+ selenium-webdriver (~> 2.0)
50
+ xpath (~> 0.1.4)
51
+ childprocess (0.2.2)
52
+ ffi (~> 1.0.6)
53
+ diff-lcs (1.1.3)
54
+ erubis (2.7.0)
55
+ ffi (1.0.9)
56
+ hike (1.2.1)
57
+ i18n (0.6.0)
58
+ json_pure (1.5.4)
59
+ spruz (~> 0.2.8)
60
+ mail (2.3.0)
61
+ i18n (>= 0.4.0)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.16)
65
+ multi_json (1.0.3)
66
+ nokogiri (1.5.0)
67
+ polyglot (0.3.2)
68
+ rack (1.3.2)
69
+ rack-cache (1.0.3)
70
+ rack (>= 0.4)
71
+ rack-mount (0.8.3)
72
+ rack (>= 1.0.0)
73
+ rack-ssl (1.3.2)
74
+ rack
75
+ rack-test (0.6.1)
76
+ rack (>= 1.0)
77
+ rails (3.1.0)
78
+ actionmailer (= 3.1.0)
79
+ actionpack (= 3.1.0)
80
+ activerecord (= 3.1.0)
81
+ activeresource (= 3.1.0)
82
+ activesupport (= 3.1.0)
83
+ bundler (~> 1.0)
84
+ railties (= 3.1.0)
85
+ railties (3.1.0)
86
+ actionpack (= 3.1.0)
87
+ activesupport (= 3.1.0)
88
+ rack-ssl (~> 1.3.2)
89
+ rake (>= 0.8.7)
90
+ rdoc (~> 3.4)
91
+ thor (~> 0.14.6)
92
+ rake (0.9.2)
93
+ rdoc (3.9.4)
94
+ rspec (2.6.0)
95
+ rspec-core (~> 2.6.0)
96
+ rspec-expectations (~> 2.6.0)
97
+ rspec-mocks (~> 2.6.0)
98
+ rspec-core (2.6.4)
99
+ rspec-expectations (2.6.0)
100
+ diff-lcs (~> 1.1.2)
101
+ rspec-mocks (2.6.0)
102
+ rspec-rails (2.6.1)
103
+ actionpack (~> 3.0)
104
+ activesupport (~> 3.0)
105
+ railties (~> 3.0)
106
+ rspec (~> 2.6.0)
107
+ rubyzip (0.9.4)
108
+ selenium-webdriver (2.5.0)
109
+ childprocess (>= 0.2.1)
110
+ ffi (>= 1.0.7)
111
+ json_pure
112
+ rubyzip
113
+ sprockets (2.0.0)
114
+ hike (~> 1.2)
115
+ rack (~> 1.0)
116
+ tilt (~> 1.1, != 1.3.0)
117
+ spruz (0.2.13)
118
+ sqlite3 (1.3.4)
119
+ thor (0.14.6)
120
+ tilt (1.3.3)
121
+ treetop (1.4.10)
122
+ polyglot
123
+ polyglot (>= 0.3.1)
124
+ tzinfo (0.3.29)
125
+ xpath (0.1.4)
126
+ nokogiri (~> 1.3)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ appraisal
133
+ capybara (>= 0.4.0)
134
+ high_voltage!
135
+ rails (= 3.1.0)
136
+ rspec-rails
137
+ sqlite3
@@ -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
@@ -0,0 +1,3 @@
1
+ module HighVoltage
2
+ VERSION = '1.1.1'.freeze
3
+ 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