trusty-layouts-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/MIT-LICENSE +98 -0
  2. data/README.md +115 -0
  3. data/Rakefile +144 -0
  4. data/VERSION +1 -0
  5. data/app/models/haml_filter.rb +5 -0
  6. data/app/models/rails_page.rb +39 -0
  7. data/app/views/layouts/trusty.html.haml +1 -0
  8. data/config/initializers/trusty_config.rb +1 -0
  9. data/config/routes.rb +0 -0
  10. data/layouts_extension.rb +21 -0
  11. data/lib/haml_layouts/models/layout.rb +33 -0
  12. data/lib/haml_layouts/models/page.rb +33 -0
  13. data/lib/layouts/engine.rb +5 -0
  14. data/lib/nested_layouts/tags/core.rb +150 -0
  15. data/lib/share_layouts/controllers/action_controller.rb +26 -0
  16. data/lib/share_layouts/helpers/action_view.rb +48 -0
  17. data/lib/tasks/layouts_extension_tasks.rake +55 -0
  18. data/lib/trusty-layouts-extension.rb +1 -0
  19. data/spec/controllers/share_controller_spec.rb +119 -0
  20. data/spec/datasets/layouts_layouts.rb +36 -0
  21. data/spec/datasets/layouts_pages.rb +43 -0
  22. data/spec/lib/haml_layouts/haml_layouts_extension_spec.rb +22 -0
  23. data/spec/lib/haml_layouts/models/layout_spec.rb +36 -0
  24. data/spec/lib/haml_layouts/models/page_spec.rb +40 -0
  25. data/spec/lib/nested_layouts/nested_layouts_extension_spec.rb +16 -0
  26. data/spec/lib/nested_layouts/tags/core_spec.rb +147 -0
  27. data/spec/lib/share_layouts/controllers/action_controller_spec.rb +44 -0
  28. data/spec/lib/share_layouts/helpers/action_view_spec.rb +171 -0
  29. data/spec/lib/share_layouts/share_layouts_extension_spec.rb +22 -0
  30. data/spec/models/haml_filter_spec.rb +0 -0
  31. data/spec/models/rails_page_spec.rb +63 -0
  32. data/spec/spec.opts +3 -0
  33. data/spec/spec_helper.rb +22 -0
  34. data/trusty-layouts-extension.gemspec +31 -0
  35. data/vendor/plugins/rails_upgrade/MIT-LICENSE +20 -0
  36. data/vendor/plugins/rails_upgrade/README.rdoc +26 -0
  37. data/vendor/plugins/rails_upgrade/Rakefile +22 -0
  38. data/vendor/plugins/rails_upgrade/init.rb +2 -0
  39. data/vendor/plugins/rails_upgrade/install.rb +38 -0
  40. data/vendor/plugins/rails_upgrade/lib/application_checker.rb +506 -0
  41. data/vendor/plugins/rails_upgrade/lib/gemfile_generator.rb +95 -0
  42. data/vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb +59 -0
  43. data/vendor/plugins/rails_upgrade/lib/rails_upgrade.rb +0 -0
  44. data/vendor/plugins/rails_upgrade/lib/routes_upgrader.rb +344 -0
  45. data/vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake +79 -0
  46. data/vendor/plugins/rails_upgrade/test/application_checker_test.rb +344 -0
  47. data/vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb +72 -0
  48. data/vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb +63 -0
  49. data/vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb +218 -0
  50. data/vendor/plugins/rails_upgrade/test/test_helper.rb +5 -0
  51. data/vendor/plugins/rails_upgrade/uninstall.rb +1 -0
  52. metadata +134 -0
@@ -0,0 +1,63 @@
1
+ require 'test_helper'
2
+ require 'new_configuration_generator'
3
+
4
+ # Stub out methods on upgrader class
5
+ module Rails
6
+ module Upgrading
7
+ class NewConfigurationGenerator
8
+ attr_writer :environment_code
9
+
10
+ def has_environment?
11
+ true
12
+ end
13
+
14
+ def environment_code
15
+ @environment_code
16
+ end
17
+
18
+ def app_name
19
+ "my_application"
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ class NewConfigurationGeneratorTest < ActiveSupport::TestCase
26
+ FRAME = "# Put this in config/application.rb
27
+ require File.expand_path('../boot', __FILE__)
28
+
29
+ module MyApplication
30
+ class Application < Rails::Application
31
+ %s
32
+ end
33
+ end"
34
+
35
+ CONFIG = " config.what_have_you = 'thing'
36
+ config.action_controller = 'what'"
37
+
38
+ CODE = "require 'w/e'
39
+
40
+ this_happens_before_the(code)
41
+ more_before_the_code!
42
+
43
+ Rails::Initializer.run do |config|
44
+ %s
45
+ end
46
+
47
+ this_is_after_the_code
48
+ "
49
+
50
+ def test_raises_error_with_no_code
51
+ generator = Rails::Upgrading::NewConfigurationGenerator.new
52
+ generator.environment_code = ""
53
+
54
+ assert_raises(RuntimeError) { generator.generate_new_application_rb }
55
+ end
56
+
57
+ def test_generates_with_code
58
+ generator = Rails::Upgrading::NewConfigurationGenerator.new
59
+ generator.environment_code = CODE % [CONFIG]
60
+
61
+ assert_equal FRAME % [generator.indent(CONFIG)], generator.generate_new_application_rb
62
+ end
63
+ end
@@ -0,0 +1,218 @@
1
+ require 'test_helper'
2
+ require 'routes_upgrader'
3
+
4
+ # Stub out methods on upgrader class
5
+ module Rails
6
+ module Upgrading
7
+ class RoutesUpgrader
8
+ attr_writer :routes_code
9
+
10
+ def has_routes_file?
11
+ true
12
+ end
13
+
14
+ def routes_code
15
+ @routes_code
16
+ end
17
+ end
18
+
19
+ class RouteGenerator
20
+ def app_name
21
+ "MyApplication"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ class RoutesUpgraderTest < ActiveSupport::TestCase
28
+ def setup
29
+ Rails::Upgrading::RouteRedrawer.stack = []
30
+ end
31
+
32
+ def test_generates_routes_file
33
+ routes_code = "
34
+ ActionController::Routing::Routes.draw do |map|
35
+ map.connect '/home', :controller => 'home', :action => 'index'
36
+ map.login '/login', :controller => 'sessions', :action => 'new'
37
+
38
+ map.resources :hats
39
+ map.resource :store
40
+ end
41
+ "
42
+
43
+ new_routes_code = "MyApplication::Application.routes.draw do
44
+ match '/home' => 'home#index'
45
+ match '/login' => 'sessions#new', :as => :login
46
+ resources :hats
47
+ resource :store
48
+ end
49
+ "
50
+
51
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
52
+ upgrader.routes_code = routes_code
53
+
54
+ result = upgrader.generate_new_routes
55
+
56
+ assert_equal new_routes_code, result
57
+ end
58
+
59
+ def test_generates_code_for_regular_route
60
+ route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
61
+ assert_equal "match '/about' => 'static#about'", route.to_route_code
62
+ end
63
+
64
+ def test_generates_code_for_named_route
65
+ route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'}, "about")
66
+ assert_equal "match '/about' => 'static#about', :as => :about", route.to_route_code
67
+ end
68
+
69
+ def test_generates_code_for_namespace
70
+ ns = Rails::Upgrading::FakeNamespace.new("static")
71
+ # Add a route to the namespace
72
+ ns << Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
73
+
74
+ assert_equal "namespace :static do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
75
+ end
76
+
77
+ def test_generates_code_for_namespace_with_options
78
+ ns = Rails::Upgrading::FakeNamespace.new("static", { :path_prefix => 'prefix' })
79
+ # Add a route to the namespace
80
+ ns << Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
81
+
82
+ assert_equal "namespace :static, :path_prefix => 'prefix' do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
83
+ end
84
+
85
+ def test_generates_code_for_resources
86
+ route = Rails::Upgrading::FakeResourceRoute.new("hats")
87
+ assert_equal "resources :hats", route.to_route_code
88
+ end
89
+
90
+ def test_generates_code_for_resources
91
+ route = Rails::Upgrading::FakeSingletonResourceRoute.new("hat")
92
+ assert_equal "resource :hat", route.to_route_code
93
+ end
94
+
95
+ def test_generates_code_for_resources_with_block_and_options
96
+ routes_code = <<-ROUTES
97
+ ActionController::Routing::Routes.draw do |map|
98
+ map.resources :people, :collection => {:search => :get} do |p|
99
+ p.resource :vuvuzela
100
+ end
101
+ end
102
+ ROUTES
103
+
104
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
105
+ upgrader.routes_code = routes_code
106
+ result = upgrader.generate_new_routes
107
+
108
+ assert_equal "MyApplication::Application.routes.draw do\n resources :people do\n collection do\n get :search\n end\n \n resource :vuvuzela\n end\n\nend\n", result
109
+ end
110
+
111
+ def test_generates_code_for_resources_with_special_methods
112
+ route = Rails::Upgrading::FakeResourceRoute.new("hats", {:member => {:wear => :get}, :collection => {:toss => :post}})
113
+ assert_equal "resources :hats do\ncollection do\npost :toss\nend\nmember do\nget :wear\nend\n\nend\n", route.to_route_code
114
+ end
115
+
116
+ def test_generates_code_for_resources_with_multiple_special_methods_per_name
117
+ route = Rails::Upgrading::FakeResourceRoute.new("hats", {:member => {:wear => [:get, :put]}, :collection => {:toss => [:get, :post]}})
118
+ assert_equal "resources :hats do\ncollection do\nget :toss\npost :toss\nend\nmember do\nget :wear\nput :wear\nend\n\nend\n", route.to_route_code
119
+ end
120
+
121
+ def test_generates_code_for_route_with_extra_params
122
+ route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about', :something => 'extra'})
123
+ assert_equal "match '/about' => 'static#about', :something => 'extra'", route.to_route_code
124
+ end
125
+
126
+ def test_generates_code_for_route_with_requirements
127
+ route = Rails::Upgrading::FakeRoute.new("/foo", {:controller => 'foo', :action => 'bar', :requirements => {:digit => /%d/}})
128
+ assert_equal "match '/foo' => 'foo#bar', :constraints => { :digit => /%d/ }", route.to_route_code
129
+ end
130
+
131
+ def test_generates_code_for_root
132
+ routes_code = "
133
+ ActionController::Routing::Routes.draw do |map|
134
+ map.root :controller => 'home', :action => 'index'
135
+ end
136
+ "
137
+
138
+ new_routes_code = "MyApplication::Application.routes.draw do
139
+ match '/' => 'home#index'
140
+ end
141
+ "
142
+
143
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
144
+ upgrader.routes_code = routes_code
145
+
146
+ result = upgrader.generate_new_routes
147
+
148
+ assert_equal new_routes_code, result
149
+ end
150
+
151
+ def test_generates_code_for_default_route
152
+ routes_code = "
153
+ ActionController::Routing::Routes.draw do |map|
154
+ map.connect ':controller/:action/:id.:format'
155
+ map.connect ':controller/:action/:id'
156
+ end
157
+ "
158
+
159
+ new_routes_code = "MyApplication::Application.routes.draw do
160
+ match '/:controller(/:action(/:id))'
161
+ end
162
+ "
163
+
164
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
165
+ upgrader.routes_code = routes_code
166
+
167
+ result = upgrader.generate_new_routes
168
+
169
+ assert_equal new_routes_code, result
170
+ end
171
+
172
+
173
+ def test_preserves_resources_except_option
174
+ route = Rails::Upgrading::FakeResourceRoute.new("hats", :except => [:index])
175
+ assert_equal "resources :hats, :except => [:index]", route.to_route_code
176
+ end
177
+
178
+ def test_preserves_resources_only_option
179
+ route = Rails::Upgrading::FakeResourceRoute.new("hats", :only => :show)
180
+ assert_equal "resources :hats, :only => :show", route.to_route_code
181
+ end
182
+
183
+ def test_generates_code_for_delete_route
184
+ routes_code = %Q{
185
+ ActionController::Routing::Routes.draw do |map|
186
+ map.sign_out '/sign_out', :controller => 'sessions', :action => 'destroy', :conditions => {:method => :delete}
187
+ end
188
+ }
189
+
190
+ new_routes_code = %Q{
191
+ MyApplication::Application.routes.draw do
192
+ match '/sign_out' => 'sessions#destroy', :as => :sign_out, :via => :delete
193
+ end
194
+ }
195
+
196
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
197
+ upgrader.routes_code = routes_code
198
+ assert_equal new_routes_code.strip, upgrader.generate_new_routes.strip
199
+ end
200
+
201
+ def test_generates_code_for_delete_route
202
+ routes_code = %Q{
203
+ ActionController::Routing::Routes.draw do |map|
204
+ map.sign_out '/sign_out', :controller => 'sessions', :action => 'destroy', :conditions => {:method => [:delete, :get]}
205
+ end
206
+ }
207
+
208
+ new_routes_code = %Q{
209
+ MyApplication::Application.routes.draw do
210
+ match '/sign_out' => 'sessions#destroy', :as => :sign_out, :via => [:delete, :get]
211
+ end
212
+ }
213
+
214
+ upgrader = Rails::Upgrading::RoutesUpgrader.new
215
+ upgrader.routes_code = routes_code
216
+ assert_equal new_routes_code.strip, upgrader.generate_new_routes.strip
217
+ end
218
+ end
@@ -0,0 +1,5 @@
1
+ require 'test/unit'
2
+
3
+ require 'rubygems'
4
+ require 'active_support'
5
+ require 'active_support/test_case'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trusty-layouts-extension
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eric Sipple
9
+ - Michael Klett
10
+ - Jim Gay
11
+ - William Ross
12
+ - Tony Issakov
13
+ - Dirk Kelly
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+ date: 2014-10-06 00:00:00.000000000 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: trusty-cms
21
+ requirement: !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ type: :runtime
28
+ prerelease: false
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ description: Extends Trusty CMS Layouts to support nesting, sharing with Rails Controllers
36
+ and rendering HAML
37
+ email: sipple@trustarts.org
38
+ executables: []
39
+ extensions: []
40
+ extra_rdoc_files:
41
+ - README.md
42
+ files:
43
+ - app/models/haml_filter.rb
44
+ - app/models/rails_page.rb
45
+ - app/views/layouts/trusty.html.haml
46
+ - config/initializers/trusty_config.rb
47
+ - config/routes.rb
48
+ - layouts_extension.rb
49
+ - lib/haml_layouts/models/layout.rb
50
+ - lib/haml_layouts/models/page.rb
51
+ - lib/layouts/engine.rb
52
+ - lib/nested_layouts/tags/core.rb
53
+ - lib/share_layouts/controllers/action_controller.rb
54
+ - lib/share_layouts/helpers/action_view.rb
55
+ - lib/tasks/layouts_extension_tasks.rake
56
+ - lib/trusty-layouts-extension.rb
57
+ - MIT-LICENSE
58
+ - Rakefile
59
+ - README.md
60
+ - spec/controllers/share_controller_spec.rb
61
+ - spec/datasets/layouts_layouts.rb
62
+ - spec/datasets/layouts_pages.rb
63
+ - spec/lib/haml_layouts/haml_layouts_extension_spec.rb
64
+ - spec/lib/haml_layouts/models/layout_spec.rb
65
+ - spec/lib/haml_layouts/models/page_spec.rb
66
+ - spec/lib/nested_layouts/nested_layouts_extension_spec.rb
67
+ - spec/lib/nested_layouts/tags/core_spec.rb
68
+ - spec/lib/share_layouts/controllers/action_controller_spec.rb
69
+ - spec/lib/share_layouts/helpers/action_view_spec.rb
70
+ - spec/lib/share_layouts/share_layouts_extension_spec.rb
71
+ - spec/models/haml_filter_spec.rb
72
+ - spec/models/rails_page_spec.rb
73
+ - spec/spec.opts
74
+ - spec/spec_helper.rb
75
+ - trusty-layouts-extension.gemspec
76
+ - vendor/plugins/rails_upgrade/init.rb
77
+ - vendor/plugins/rails_upgrade/install.rb
78
+ - vendor/plugins/rails_upgrade/lib/application_checker.rb
79
+ - vendor/plugins/rails_upgrade/lib/gemfile_generator.rb
80
+ - vendor/plugins/rails_upgrade/lib/new_configuration_generator.rb
81
+ - vendor/plugins/rails_upgrade/lib/rails_upgrade.rb
82
+ - vendor/plugins/rails_upgrade/lib/routes_upgrader.rb
83
+ - vendor/plugins/rails_upgrade/lib/tasks/rails_upgrade_tasks.rake
84
+ - vendor/plugins/rails_upgrade/MIT-LICENSE
85
+ - vendor/plugins/rails_upgrade/Rakefile
86
+ - vendor/plugins/rails_upgrade/README.rdoc
87
+ - vendor/plugins/rails_upgrade/test/application_checker_test.rb
88
+ - vendor/plugins/rails_upgrade/test/gemfile_generator_test.rb
89
+ - vendor/plugins/rails_upgrade/test/new_configuration_generator_test.rb
90
+ - vendor/plugins/rails_upgrade/test/routes_upgrader_test.rb
91
+ - vendor/plugins/rails_upgrade/test/test_helper.rb
92
+ - vendor/plugins/rails_upgrade/uninstall.rb
93
+ - VERSION
94
+ homepage: https://github.com/pgharts/trusty-share-layouts-extension
95
+ licenses: []
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ! '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 1.8.29
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Extends Trusty CMS Layouts to support nesting, sharing with Rails Controllers
118
+ and rendering HAML
119
+ test_files:
120
+ - spec/controllers/share_controller_spec.rb
121
+ - spec/datasets/layouts_layouts.rb
122
+ - spec/datasets/layouts_pages.rb
123
+ - spec/lib/haml_layouts/haml_layouts_extension_spec.rb
124
+ - spec/lib/haml_layouts/models/layout_spec.rb
125
+ - spec/lib/haml_layouts/models/page_spec.rb
126
+ - spec/lib/nested_layouts/nested_layouts_extension_spec.rb
127
+ - spec/lib/nested_layouts/tags/core_spec.rb
128
+ - spec/lib/share_layouts/controllers/action_controller_spec.rb
129
+ - spec/lib/share_layouts/helpers/action_view_spec.rb
130
+ - spec/lib/share_layouts/share_layouts_extension_spec.rb
131
+ - spec/models/haml_filter_spec.rb
132
+ - spec/models/rails_page_spec.rb
133
+ - spec/spec.opts
134
+ - spec/spec_helper.rb