radiant-templates-extension 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/HELP_designer.textile +3 -3
  2. data/README.textile +3 -3
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/app/views/admin/pages/_edit_template.html.haml +1 -2
  6. data/app/views/admin/pages/_switch_templates.html.haml +4 -4
  7. data/app/views/admin/pages/_template_chooser.html.haml +43 -0
  8. data/app/views/admin/templates/index.html.haml +0 -1
  9. data/pkg/radiant-templates-extension-1.0.0.gem +0 -0
  10. data/radiant-templates-extension.gemspec +176 -0
  11. data/templates_extension.rb +1 -1
  12. data/vendor/plugins/make_resourceful/.gitignore +1 -0
  13. data/vendor/plugins/make_resourceful/DEFAULTS +1 -1
  14. data/vendor/plugins/make_resourceful/README +7 -6
  15. data/vendor/plugins/make_resourceful/Rakefile +2 -13
  16. data/vendor/plugins/make_resourceful/VERSION +1 -1
  17. data/vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb +1 -8
  18. data/vendor/plugins/make_resourceful/lib/resourceful/base.rb +11 -0
  19. data/vendor/plugins/make_resourceful/lib/resourceful/builder.rb +33 -2
  20. data/vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb +63 -7
  21. data/vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb +15 -6
  22. data/vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb +7 -7
  23. data/vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb +6 -6
  24. data/vendor/plugins/make_resourceful/lib/resourceful/maker.rb +1 -0
  25. data/vendor/plugins/make_resourceful/spec/accessors_spec.rb +3 -2
  26. data/vendor/plugins/make_resourceful/spec/actions_spec.rb +33 -6
  27. data/vendor/plugins/make_resourceful/spec/integration_spec.rb +22 -22
  28. data/vendor/plugins/make_resourceful/spec/{rspec_on_rails → rspec-rails}/LICENSE +8 -6
  29. data/vendor/plugins/make_resourceful/spec/rspec-rails/redirect_to.rb +113 -0
  30. data/vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb +90 -0
  31. data/vendor/plugins/make_resourceful/spec/spec_helper.rb +62 -22
  32. data/vendor/plugins/make_resourceful/spec/urls_spec.rb +2 -0
  33. metadata +15 -11
  34. data/vendor/plugins/make_resourceful/spec/rspec_on_rails/redirect_to.rb +0 -81
  35. data/vendor/plugins/make_resourceful/spec/rspec_on_rails/render_template.rb +0 -28
@@ -1,18 +1,20 @@
1
- All the code in this directory comes from the rspec_on_rails plugin.
1
+ All the code in this directory comes from the rspec-rails plugin.
2
2
  We've pilfered it as needed to make the make_resourceful specs easier to write.
3
3
  It was made available by its authors under the following license terms:
4
4
 
5
+ (The MIT License)
6
+
5
7
  ====================================================================
6
- == RSpec
7
- Copyright (c) 2005-2007 The RSpec Development Team
8
+ ==== RSpec, RSpec-Rails
9
+ Copyright (c) 2005-2008 The RSpec Development Team
8
10
  ====================================================================
9
- == ARTS
11
+ ==== ARTS
10
12
  Copyright (c) 2006 Kevin Clark, Jake Howerton
11
13
  ====================================================================
12
- == ZenTest
14
+ ==== ZenTest
13
15
  Copyright (c) 2001-2006 Ryan Davis, Eric Hodel, Zen Spider Software
14
16
  ====================================================================
15
- == AssertSelect
17
+ ==== AssertSelect
16
18
  Copyright (c) 2006 Assaf Arkin
17
19
  ====================================================================
18
20
 
@@ -0,0 +1,113 @@
1
+ module Spec
2
+ module Rails
3
+ module Matchers
4
+
5
+ class RedirectTo #:nodoc:
6
+
7
+ def initialize(request, expected)
8
+ @expected = expected
9
+ @request = request
10
+ end
11
+
12
+ def matches?(response)
13
+ @redirected = response.redirect?
14
+ @actual = response.redirect_url
15
+ return false unless @redirected
16
+ if @expected.instance_of? Hash
17
+ return false unless @actual =~ %r{^\w+://#{@request.host}}
18
+ return false unless actual_redirect_to_valid_route
19
+ return actual_hash == expected_hash
20
+ else
21
+ return @actual == expected_url
22
+ end
23
+ end
24
+
25
+ def actual_hash
26
+ hash_from_url @actual
27
+ end
28
+
29
+ def expected_hash
30
+ hash_from_url expected_url
31
+ end
32
+
33
+ def actual_redirect_to_valid_route
34
+ actual_hash
35
+ end
36
+
37
+ def hash_from_url(url)
38
+ query_hash(url).merge(path_hash(url)).with_indifferent_access
39
+ end
40
+
41
+ def path_hash(url)
42
+ path = url.sub(%r{^\w+://#{@request.host}(?::\d+)?}, "").split("?", 2)[0]
43
+ ActionController::Routing::Routes.recognize_path path
44
+ end
45
+
46
+ def query_hash(url)
47
+ query = url.split("?", 2)[1] || ""
48
+ QueryParameterParser.parse_query_parameters(query, @request)
49
+ end
50
+
51
+ def expected_url
52
+ case @expected
53
+ when Hash
54
+ return ActionController::UrlRewriter.new(@request, {}).rewrite(@expected)
55
+ when :back
56
+ return @request.env['HTTP_REFERER']
57
+ when %r{^\w+://.*}
58
+ return @expected
59
+ else
60
+ return "http://#{@request.host}" + (@expected.split('')[0] == '/' ? '' : '/') + @expected
61
+ end
62
+ end
63
+
64
+ def failure_message
65
+ if @redirected
66
+ return %Q{expected redirect to #{@expected.inspect}, got redirect to #{@actual.inspect}}
67
+ else
68
+ return %Q{expected redirect to #{@expected.inspect}, got no redirect}
69
+ end
70
+ end
71
+
72
+ def negative_failure_message
73
+ return %Q{expected not to be redirected to #{@expected.inspect}, but was} if @redirected
74
+ end
75
+
76
+ def description
77
+ "redirect to #{@actual.inspect}"
78
+ end
79
+
80
+ class QueryParameterParser
81
+ def self.parse_query_parameters(query, request)
82
+ if defined?(CGIMethods)
83
+ CGIMethods.parse_query_parameters(query)
84
+ else
85
+ request.class.parse_query_parameters(query)
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ # :call-seq:
92
+ # response.should redirect_to(url)
93
+ # response.should redirect_to(:action => action_name)
94
+ # response.should redirect_to(:controller => controller_name, :action => action_name)
95
+ # response.should_not redirect_to(url)
96
+ # response.should_not redirect_to(:action => action_name)
97
+ # response.should_not redirect_to(:controller => controller_name, :action => action_name)
98
+ #
99
+ # Passes if the response is a redirect to the url, action or controller/action.
100
+ # Useful in controller specs (integration or isolation mode).
101
+ #
102
+ # == Examples
103
+ #
104
+ # response.should redirect_to("path/to/action")
105
+ # response.should redirect_to("http://test.host/path/to/action")
106
+ # response.should redirect_to(:action => 'list')
107
+ def redirect_to(opts)
108
+ RedirectTo.new(request, opts)
109
+ end
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,90 @@
1
+ module Spec
2
+ module Rails
3
+ module Matchers
4
+
5
+ class RenderTemplate #:nodoc:
6
+
7
+ def initialize(expected, controller)
8
+ @controller = controller
9
+ @expected = expected
10
+ end
11
+
12
+ def matches?(response)
13
+
14
+ if response.respond_to?(:rendered_file)
15
+ @actual = response.rendered_file
16
+ else
17
+ @actual = response.rendered_template.to_s
18
+ end
19
+ return false if @actual.blank?
20
+ given_controller_path, given_file = path_and_file(@actual)
21
+ expected_controller_path, expected_file = path_and_file(@expected)
22
+ given_controller_path == expected_controller_path && given_file.match(expected_file)
23
+ end
24
+
25
+ def failure_message
26
+ "expected #{@expected.inspect}, got #{@actual.inspect}"
27
+ end
28
+
29
+ def negative_failure_message
30
+ "expected not to render #{@expected.inspect}, but did"
31
+ end
32
+
33
+ def description
34
+ "render template #{@expected.inspect}"
35
+ end
36
+
37
+ private
38
+ def path_and_file(path)
39
+ parts = path.split('/')
40
+ file = parts.pop
41
+ controller = parts.empty? ? current_controller_path : parts.join('/')
42
+ return controller, file
43
+ end
44
+
45
+ def controller_path_from(path)
46
+ parts = path.split('/')
47
+ parts.pop
48
+ parts.join('/')
49
+ end
50
+
51
+ def current_controller_path
52
+ @controller.class.to_s.underscore.gsub(/_controller$/,'')
53
+ end
54
+
55
+ end
56
+
57
+ # :call-seq:
58
+ # response.should render_template(path)
59
+ # response.should_not render_template(path)
60
+ #
61
+ # Passes if the specified template is rendered by the response.
62
+ # Useful in controller specs (integration or isolation mode).
63
+ #
64
+ # <code>path</code> can include the controller path or not. It
65
+ # can also include an optional extension (no extension assumes .rhtml).
66
+ #
67
+ # Note that partials must be spelled with the preceding underscore.
68
+ #
69
+ # == Examples
70
+ #
71
+ # response.should render_template('list')
72
+ # response.should render_template('same_controller/list')
73
+ # response.should render_template('other_controller/list')
74
+ #
75
+ # #rjs
76
+ # response.should render_template('list.rjs')
77
+ # response.should render_template('same_controller/list.rjs')
78
+ # response.should render_template('other_controller/list.rjs')
79
+ #
80
+ # #partials
81
+ # response.should render_template('_a_partial')
82
+ # response.should render_template('same_controller/_a_partial')
83
+ # response.should render_template('other_controller/_a_partial')
84
+ def render_template(path)
85
+ RenderTemplate.new(path.to_s, @controller)
86
+ end
87
+
88
+ end
89
+ end
90
+ end
@@ -1,13 +1,20 @@
1
1
  $: << File.dirname(__FILE__) + '/../lib'
2
+
2
3
  require 'rubygems'
3
- %w[spec action_pack active_record resourceful/maker
4
+ %w[spec rails/version action_pack active_record resourceful/maker
4
5
  action_controller action_controller/test_process action_controller/integration
5
- spec/rspec_on_rails/redirect_to spec/rspec_on_rails/render_template].each &method(:require)
6
+ spec/rspec-rails/redirect_to spec/rspec-rails/render_template].each &method(:require)
6
7
 
7
8
  Spec::Runner.configure do |config|
8
9
  config.mock_with :mocha
9
10
  end
10
11
 
12
+ module MetaClass
13
+ def metaclass
14
+ class << self; self; end
15
+ end
16
+ end
17
+
11
18
  def should_be_called(&block)
12
19
  pstub = stub
13
20
  pstub.expects(:call).instance_eval(&(block || proc {}))
@@ -39,6 +46,7 @@ end
39
46
  def stub_const(name)
40
47
  unless Object.const_defined?(name)
41
48
  obj = Object.new
49
+ obj.extend MetaClass
42
50
  obj.metaclass.send(:define_method, :to_s) { name.to_s }
43
51
  obj.metaclass.send(:alias_method, :inspect, :to_s)
44
52
  Object.const_set(name, obj)
@@ -93,7 +101,7 @@ module ControllerMocks
93
101
  @builder = Resourceful::Builder.new(@kontroller)
94
102
  class << @builder
95
103
  alias_method :made_resourceful, :instance_eval
96
- end
104
+ end
97
105
  end
98
106
 
99
107
  def responses
@@ -143,11 +151,11 @@ module RailsMocks
143
151
  end
144
152
 
145
153
  def redirect_to(opts)
146
- RedirectTo.new(request, opts)
154
+ Spec::Rails::Matchers::RedirectTo.new(request, opts)
147
155
  end
148
156
 
149
157
  def render_template(path)
150
- RenderTemplate.new(path.to_s, @controller)
158
+ Spec::Rails::Matchers::RenderTemplate.new(path.to_s, @controller)
151
159
  end
152
160
 
153
161
  private
@@ -155,6 +163,7 @@ module RailsMocks
155
163
  def init_kontroller(options)
156
164
  @kontroller = Class.new ActionController::Base
157
165
  @kontroller.extend Resourceful::Maker
166
+ @kontroller.extend MetaClass
158
167
 
159
168
  @kontroller.metaclass.send(:define_method, :controller_name) { options[:name] }
160
169
  @kontroller.metaclass.send(:define_method, :controller_path) { options[:name] }
@@ -175,7 +184,7 @@ module RailsMocks
175
184
  route_block = options[:routes] || proc { |map| map.resources options[:name] }
176
185
  ActionController::Routing::Routes.draw(&route_block)
177
186
  end
178
-
187
+
179
188
  def init_controller(options)
180
189
  @controller = kontroller.new
181
190
  @request = ActionController::TestRequest.new
@@ -208,26 +217,53 @@ module RailsMocks
208
217
  end
209
218
 
210
219
  module ControllerMethods
211
- def render(options=nil, deprecated_status=nil, &block)
220
+ # From rspec-rails ControllerExampleGroup
221
+
222
+ def render(options=nil, deprecated_status_or_extra_options=nil, &block)
223
+ if ::Rails::VERSION::STRING >= '2.0.0' && deprecated_status_or_extra_options.nil?
224
+ deprecated_status_or_extra_options = {}
225
+ end
226
+
212
227
  unless block_given?
213
- @template.metaclass.class_eval do
214
- define_method :file_exists? do true end
228
+ if @template.respond_to?(:finder)
229
+ (class << @template.finder; self; end).class_eval do
230
+ define_method :file_exists? do; true; end
231
+ end
232
+ else
233
+ (class << @template; self; end).class_eval do
234
+ define_method :file_exists? do; true; end
235
+ end
236
+ end
237
+ (class << @template; self; end).class_eval do
215
238
  define_method :render_file do |*args|
216
- @first_render ||= args[0]
239
+ @first_render ||= args[0] unless args[0] =~ /^layouts/
240
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
241
+ end
242
+
243
+ define_method :_pick_template do |*args|
244
+ @_first_render ||= args[0] unless args[0] =~ /^layouts/
245
+ PickedTemplate.new
217
246
  end
218
247
  end
219
248
  end
220
249
 
221
- super(options, deprecated_status, &block)
250
+ super(options, deprecated_status_or_extra_options, &block)
251
+ end
252
+
253
+ class PickedTemplate
254
+ def render_template(*ignore_args); end
255
+ def render_partial(*ignore_args); end
222
256
  end
223
257
  end
258
+
224
259
  end
225
260
 
226
261
  module Spec::Example::ExampleGroupMethods
227
262
  def should_render_html(action)
228
263
  it "should render HTML by default for #{action_string(action)}" do
229
264
  action_method(action)[action, action_params(action)]
230
- response.should be_success
265
+ response.should_have "Missing template things"
266
+ #response.should be_success
231
267
  response.content_type.should == 'text/html'
232
268
  end
233
269
  end
@@ -235,7 +271,8 @@ module Spec::Example::ExampleGroupMethods
235
271
  def should_render_js(action)
236
272
  it "should render JS for #{action_string(action)}" do
237
273
  action_method(action)[action, action_params(action, :format => 'js')]
238
- response.should be_success
274
+ #response.contents.should.include? "Missing template things"
275
+ #response.should be_success
239
276
  response.content_type.should == 'text/javascript'
240
277
  end
241
278
  end
@@ -262,18 +299,21 @@ module Spec::Example::ExampleGroupMethods
262
299
  end
263
300
 
264
301
  module Spec::Example
265
- class IntegrationExampleGroup < Test::Unit::TestCase
266
- include ExampleMethods
267
- class << self
268
- include ExampleGroupMethods
302
+ class IntegrationExampleGroup < Spec::Example::ExampleGroup
303
+ include ActionController::TestProcess
304
+ include ActionController::Assertions
305
+ include RailsMocks
306
+
307
+ # Need this helper, because we made current_objects private
308
+ def current_objects
309
+ controller.instance_eval("current_objects")
269
310
  end
270
311
 
271
- def initialize(defined_description, &implementation)
272
- super()
273
- @_defined_description = defined_description
274
- @_implementation = implementation
312
+ # Need this helper, because we made current_object private
313
+ def current_object
314
+ controller.instance_eval("current_object")
275
315
  end
276
-
316
+
277
317
  ExampleGroupFactory.register(:integration, self)
278
318
  end
279
319
  end
@@ -120,6 +120,7 @@ describe Resourceful::Default::URLs, " for a controller with a parent object" do
120
120
  @controller.stubs(:parent_object).returns(@person)
121
121
  @controller.stubs(:parent_name).returns('person')
122
122
  @controller.stubs(:parent?).returns(true)
123
+ @controller.stubs(:parent_class_name).returns('Person')
123
124
  @controller.stubs(:namespaces).returns([])
124
125
  end
125
126
 
@@ -247,6 +248,7 @@ describe Resourceful::Default::URLs, " for a controller with a parent object and
247
248
  @controller.stubs(:parent_object).returns(@person)
248
249
  @controller.stubs(:parent_name).returns('person')
249
250
  @controller.stubs(:parent?).returns(true)
251
+ @controller.stubs(:parent_class_name).returns('Person')
250
252
  @controller.stubs(:namespaces).returns([:admin, :main])
251
253
  end
252
254
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-templates-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew vonderLuft
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-28 00:00:00 -07:00
19
+ date: 2011-04-06 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- hash: 57
30
+ hash: 23
31
31
  segments:
32
- - 0
33
- - 9
34
32
  - 1
35
- version: 0.9.1
33
+ - 0
34
+ - 0
35
+ version: 1.0.0
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  description: Imposes structure on pages via content templates.
@@ -58,6 +58,7 @@ files:
58
58
  - app/views/admin/pages/_edit_template.html.haml
59
59
  - app/views/admin/pages/_edit_template_part.html.haml
60
60
  - app/views/admin/pages/_switch_templates.html.haml
61
+ - app/views/admin/pages/_template_chooser.html.haml
61
62
  - app/views/admin/pages/_template_column.html.haml
62
63
  - app/views/admin/pages/_template_column_header.html.haml
63
64
  - app/views/admin/part_types/_form.html.haml
@@ -95,6 +96,7 @@ files:
95
96
  - lib/templates/helper.rb
96
97
  - lib/templates/page_extensions.rb
97
98
  - lib/templates/tags.rb
99
+ - pkg/radiant-templates-extension-1.0.0.gem
98
100
  - public/images/admin/menu_arrow.png
99
101
  - public/images/admin/move_higher.png
100
102
  - public/images/admin/move_lower.png
@@ -102,6 +104,7 @@ files:
102
104
  - public/images/admin/move_to_top.png
103
105
  - public/images/admin/part_type.png
104
106
  - public/images/admin/template.png
107
+ - radiant-templates-extension.gemspec
105
108
  - spec/controllers/admin_page_controller_extensions_spec.rb
106
109
  - spec/controllers/part_types_controller_spec.rb
107
110
  - spec/controllers/templates_controller_spec.rb
@@ -120,6 +123,7 @@ files:
120
123
  - vendor/plugins/acts_as_list/init.rb
121
124
  - vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
122
125
  - vendor/plugins/acts_as_list/test/list_test.rb
126
+ - vendor/plugins/make_resourceful/.gitignore
123
127
  - vendor/plugins/make_resourceful/DEFAULTS
124
128
  - vendor/plugins/make_resourceful/LICENSE
125
129
  - vendor/plugins/make_resourceful/README
@@ -159,9 +163,9 @@ files:
159
163
  - vendor/plugins/make_resourceful/spec/maker_spec.rb
160
164
  - vendor/plugins/make_resourceful/spec/response_spec.rb
161
165
  - vendor/plugins/make_resourceful/spec/responses_spec.rb
162
- - vendor/plugins/make_resourceful/spec/rspec_on_rails/LICENSE
163
- - vendor/plugins/make_resourceful/spec/rspec_on_rails/redirect_to.rb
164
- - vendor/plugins/make_resourceful/spec/rspec_on_rails/render_template.rb
166
+ - vendor/plugins/make_resourceful/spec/rspec-rails/LICENSE
167
+ - vendor/plugins/make_resourceful/spec/rspec-rails/redirect_to.rb
168
+ - vendor/plugins/make_resourceful/spec/rspec-rails/render_template.rb
165
169
  - vendor/plugins/make_resourceful/spec/serialize_spec.rb
166
170
  - vendor/plugins/make_resourceful/spec/spec_helper.rb
167
171
  - vendor/plugins/make_resourceful/spec/urls_spec.rb