fortitude 0.0.5-java → 0.0.6-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +20 -20
- data/CHANGES.md +19 -0
- data/CONTRIBUTORS.md +2 -0
- data/fortitude.gemspec +1 -0
- data/lib/fortitude/rails/railtie.rb +27 -75
- data/lib/fortitude/rails/rendering_methods.rb +77 -0
- data/lib/fortitude/tags/tags_module.rb +1 -0
- data/lib/fortitude/tilt/fortitude_template.rb +3 -1
- data/lib/fortitude/version.rb +1 -1
- data/lib/fortitude/widget/modules_and_subclasses.rb +2 -0
- data/spec/helpers/fortitude_rails_helpers.rb +19 -0
- data/spec/helpers/global_helper.rb +4 -2
- data/spec/rails/capture_system_spec.rb +1 -1
- data/spec/rails/development_mode_system_spec.rb +100 -6
- data/spec/rails/mailer_system_spec.rb +31 -0
- data/spec/rails/rendering_system_spec.rb +3 -3
- data/spec/rails/templates/development_mode_system_spec/app/controllers/development_mode_system_spec_controller.rb +16 -0
- data/spec/rails/templates/development_mode_system_spec/app/controllers/replaced_controller.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/mailers/development_mode_mailer.rb +17 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_formatting_test.rb +7 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_layout_test.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_mailer/mailer_view_test.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_formatting_test.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_layout_test.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/mailer_view_test.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/development_mode_system_spec/reload_widget_with_html_extension.html.rb +8 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/layouts/mail_layout.rb +7 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/replaced/reload_widget.rb +7 -0
- data/spec/rails/templates/development_mode_system_spec/app/views/shared/some_module.rb +5 -0
- data/spec/rails/templates/development_mode_system_spec/config/environments/development.rb +39 -0
- data/spec/rails/templates/mailer_system_spec/app/controllers/mailer_system_spec_controller.rb +17 -0
- data/spec/rails/templates/mailer_system_spec/app/mailers/basic_mailer.rb +25 -0
- data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/basic_mail.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_erb_layout_and_fortitude_view.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_fortitude_layout.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/basic_mailer/mail_with_fortitude_layout_and_erb_view.html.erb +1 -0
- data/spec/rails/templates/mailer_system_spec/app/views/layouts/erb_layout.html.erb +1 -0
- data/spec/rails/templates/mailer_system_spec/app/views/layouts/fortitude_layout.rb +8 -0
- data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_erb_layout_and_fortitude_view.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_fortitude_layout.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/app/views/mailer_system_spec/send_mail_with_fortitude_layout_and_erb_view.rb +5 -0
- data/spec/rails/templates/mailer_system_spec/config/environments/production.rb +84 -0
- data/spec/rails/templates/rendering_system_spec/app/views/layouts/application.html.erb +1 -1
- data/spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb +1 -1
- data/spec/system/tilt_system_spec.rb +15 -0
- metadata +73 -16
- data/spec/helpers/rails_helpers.rb +0 -85
- data/spec/helpers/rails_server.rb +0 -390
- data/spec/rails/templates/base/app/controllers/application_controller.rb +0 -15
- data/spec/rails/templates/base/app/controllers/working_controller.rb +0 -5
- data/spec/rails/templates/base/app/views/layouts/application.html.erb +0 -11
- data/spec/rails/templates/base/config/routes.rb +0 -4
- data/spec/rails/templates/base/config/secrets.yml +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6873a97f02e1143925c964b189cfd9179d8a991
|
4
|
+
data.tar.gz: aef2a4ba446bcf7ef5801d3e5fd45f8ad5ba30d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d282d9c7a2a9d081155daf048ba4fb55db3fcc7fd264b80e4347228a4f41f9bcc0fb6e1434128b13dadd3339a7db130f6e56a6e0bd7c8c372534c4eb940bb46e
|
7
|
+
data.tar.gz: ab5e0c410bb9d1ebbb5716f07728ead4da423f2ad96d6fb270fe84a83d17081a2f79437623fa762fd22cf4c43a3c10677c0f327b820737426af973be8d6b95c4
|
data/.travis.yml
CHANGED
@@ -2,15 +2,15 @@ rvm:
|
|
2
2
|
- "1.8.7"
|
3
3
|
- "1.9.3"
|
4
4
|
- "2.0.0"
|
5
|
-
- "2.1.
|
6
|
-
- "jruby-1.7.
|
5
|
+
- "2.1.4"
|
6
|
+
- "jruby-1.7.16.1"
|
7
7
|
env:
|
8
|
-
- FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
9
|
-
- FORTITUDE_SPECS_RAILS_VERSION=4.0.
|
10
|
-
- FORTITUDE_SPECS_RAILS_VERSION=3.2.
|
8
|
+
- FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
9
|
+
- FORTITUDE_SPECS_RAILS_VERSION=4.0.11
|
10
|
+
- FORTITUDE_SPECS_RAILS_VERSION=3.2.20
|
11
11
|
- FORTITUDE_SPECS_RAILS_VERSION=3.1.12
|
12
12
|
- FORTITUDE_SPECS_RAILS_VERSION=3.0.20
|
13
|
-
- FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
13
|
+
- FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
14
14
|
- FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=3.0.20
|
15
15
|
before_script:
|
16
16
|
- export JRUBY_OPTS="$JRUBY_OPTS -J-Xmx128m -J-Xms128m -J-Xss2048k"
|
@@ -18,11 +18,11 @@ matrix:
|
|
18
18
|
exclude:
|
19
19
|
# Rails 4.x doesn't support Ruby 1.8.7
|
20
20
|
- rvm: 1.8.7
|
21
|
-
env: FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
21
|
+
env: FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
22
22
|
- rvm: 1.8.7
|
23
|
-
env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
23
|
+
env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
24
24
|
- rvm: 1.8.7
|
25
|
-
env: FORTITUDE_SPECS_RAILS_VERSION=4.0.
|
25
|
+
env: FORTITUDE_SPECS_RAILS_VERSION=4.0.11
|
26
26
|
# 2014-06-19 ageweke -- ARGH. After trying about seventeen different things, no matter what I do,
|
27
27
|
# Travis fails JRuby builds about 20% of the time with "Killed". Their documentation indicates that this
|
28
28
|
# is likely an out-of-memory issue (i.e., entire VM's memory is consumed). However, I'm running JRuby with
|
@@ -34,17 +34,17 @@ matrix:
|
|
34
34
|
# one manually to make sure there aren't other failures, too. This is very frustrating, but I can't seem to
|
35
35
|
# find a way around it. If there's a fix out there somewhere, I'm all ears!
|
36
36
|
allow_failures:
|
37
|
-
- rvm: jruby-1.7.
|
38
|
-
env: FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
39
|
-
- rvm: jruby-1.7.
|
40
|
-
env: FORTITUDE_SPECS_RAILS_VERSION=4.0.
|
41
|
-
- rvm: jruby-1.7.
|
42
|
-
env: FORTITUDE_SPECS_RAILS_VERSION=3.2.
|
43
|
-
- rvm: jruby-1.7.
|
37
|
+
- rvm: jruby-1.7.16.1
|
38
|
+
env: FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
39
|
+
- rvm: jruby-1.7.16.1
|
40
|
+
env: FORTITUDE_SPECS_RAILS_VERSION=4.0.11
|
41
|
+
- rvm: jruby-1.7.16.1
|
42
|
+
env: FORTITUDE_SPECS_RAILS_VERSION=3.2.20
|
43
|
+
- rvm: jruby-1.7.16.1
|
44
44
|
env: FORTITUDE_SPECS_RAILS_VERSION=3.1.12
|
45
|
-
- rvm: jruby-1.7.
|
45
|
+
- rvm: jruby-1.7.16.1
|
46
46
|
env: FORTITUDE_SPECS_RAILS_VERSION=3.0.20
|
47
|
-
- rvm: jruby-1.7.
|
48
|
-
env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.
|
49
|
-
- rvm: jruby-1.7.
|
47
|
+
- rvm: jruby-1.7.16.1
|
48
|
+
env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=4.1.7
|
49
|
+
- rvm: jruby-1.7.16.1
|
50
50
|
env: FORTITUDE_NATIVE_EXTENSIONS=false FORTITUDE_SPECS_RAILS_VERSION=3.0.20
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# Fortitude Releases
|
2
2
|
|
3
|
+
## 0.0.6, 11 November 2014
|
4
|
+
|
5
|
+
* Fixed an issue where naming a widget with an `.html.rb` extension (for example) at the end would work at first,
|
6
|
+
but cause really irritating errors (like `uninitialized constant Views::Foo::Bar` apparently _in_ the very file
|
7
|
+
that defines `Views::Foo::Bar` correctly in `app/views/foo/bar.html.rb`) when editing code in development mode.
|
8
|
+
(Thanks to [Jacob Maine](https://github.com/mainej) for the very detailed bug report!)
|
9
|
+
* Fixed an issue where trying to use Fortitude as a Tilt engine, but passing `nil` for the `locals`, would cause an
|
10
|
+
exception. (Thanks to [Roman Heinrich](https://github.com/mindreframer) for reporting the bug!)
|
11
|
+
* Using Fortitude as a template engine for mailers (`ActionMailer::Base` subclasses) now works. (Believe it or not,
|
12
|
+
this was almost completely an issue of forgetting to support this, rather than it being undone — the code
|
13
|
+
was complete, and it was just a matter of applying it to `ActionMailer::Base` as well as `ActionController::Base`.)
|
14
|
+
(Thanks to [Jacob Maine](https://github.com/mainej) for the bug report and pull request!)
|
15
|
+
* The various on-the-fly modules that Fortitude creates and mixes in to widgets (and define helpers, tag methods,
|
16
|
+
and `needs` methods) now all have actual names, which makes them much easier to identify in debugging printouts.
|
17
|
+
* The code in `spec/` that knew how to reliably create, maintain, shut down, and otherwise manipulate an external
|
18
|
+
`rails server` process has now been pulled out into its own gem, `oop_rails_server`; this is so I can also use it
|
19
|
+
with a new, closely-related upcoming project, and because reuse is good. ;)
|
20
|
+
* Updated the Travis configuration to the very latest Ruby and Rails versions.
|
21
|
+
|
3
22
|
## 0.0.5, 22 September 2014
|
4
23
|
|
5
24
|
* You can now load both Fortitude and Erector at the same time into a project, and it will "just work": Erector
|
data/CONTRIBUTORS.md
CHANGED
@@ -4,3 +4,5 @@ Fortitude is written by [Andrew Geweke](https://github.com/ageweke), with contri
|
|
4
4
|
|
5
5
|
* [Ahto Jussila](https://github.com/ahto): a patch to provide separate MRI and JRuby gems, so that
|
6
6
|
`gem install fortitude` works properly no matter which platform you're on.
|
7
|
+
* [Roman Heinrich](https://github.com/mindreframer): reporting a bug where trying to use Fortitude as a Tilt
|
8
|
+
engine to render would fail if the locals passed in were `nil`.
|
data/fortitude.gemspec
CHANGED
@@ -130,18 +130,34 @@ module Fortitude
|
|
130
130
|
# "Search for a file in autoload_paths matching the provided suffix."
|
131
131
|
#
|
132
132
|
# So, we just look to see if the given +path_suffix+ is specifying something like
|
133
|
-
# <tt>views/foo/bar</tt
|
134
|
-
# <tt>views/</tt> first. (Otherwise, the mechanism would expect
|
133
|
+
# <tt>views/foo/bar</tt> or the fully-qualified version thereof; if so, we glue it together properly,
|
134
|
+
# removing the initial <tt>views/</tt> first. (Otherwise, the mechanism would expect
|
135
135
|
# <tt>Views::Foo::Bar</tt> to show up in <tt>app/views/views/foo/bar</tt> (yes, a double
|
136
136
|
# +views+), since <tt>app/views</tt> is on the autoload path.)
|
137
137
|
def search_for_file_with_fortitude(path_suffix)
|
138
|
-
#
|
139
|
-
|
140
|
-
new_path_suffix = path_suffix.sub(/(\.rb)?$/, ".rb")
|
138
|
+
# Remove any ".rb" extension, if present...
|
139
|
+
new_path_suffix = path_suffix.sub(/(\.rb)?$/, "")
|
141
140
|
|
142
|
-
if new_path_suffix =~ %r{^views(/.*)$}i
|
143
|
-
|
144
|
-
|
141
|
+
found_subpath = if new_path_suffix =~ %r{^views(/.*)$}i
|
142
|
+
$1
|
143
|
+
elsif new_path_suffix =~ %r{^#{Regexp.escape(@@_fortitude_views_root)}(/.*)$}i
|
144
|
+
$1
|
145
|
+
end
|
146
|
+
|
147
|
+
if found_subpath
|
148
|
+
full_path = File.join(@@_fortitude_views_root, "#{found_subpath}")
|
149
|
+
directory = File.dirname(full_path)
|
150
|
+
filename = File.basename(full_path)
|
151
|
+
|
152
|
+
regexp1 = /^#{Regexp.escape(filename)}\./
|
153
|
+
regexp2 = /\.rb$/i
|
154
|
+
applicable_entries = Dir.entries(directory).select do |entry|
|
155
|
+
((entry == filename) || (entry =~ regexp1 && entry =~ regexp2)) && File.file?(File.join(directory, entry))
|
156
|
+
end
|
157
|
+
return nil if applicable_entries.length == 0
|
158
|
+
|
159
|
+
entry_to_use = applicable_entries.sort_by { |e| e.length }.reverse.first
|
160
|
+
return File.join(directory, entry_to_use)
|
145
161
|
end
|
146
162
|
|
147
163
|
# Make sure that we remove the views autoload path before letting the rest of
|
@@ -184,74 +200,10 @@ module Fortitude
|
|
184
200
|
end
|
185
201
|
|
186
202
|
require "fortitude/rails/template_handler"
|
203
|
+
require "fortitude/rails/rendering_methods"
|
187
204
|
|
188
|
-
|
189
|
-
|
190
|
-
# template system is predicated around the idea that you have a template, which is compiled to output
|
191
|
-
# Ruby source code, and then that gets evaluated to actually generate output.
|
192
|
-
#
|
193
|
-
# Because <tt>render :widget => ...</tt> takes an already-instantiated widget as input, this simply isn't
|
194
|
-
# possible: you can't reverse-engineer an arbitrary Ruby object into source code, and, without source code,
|
195
|
-
# the whole templating paradigm doesn't make sense.
|
196
|
-
#
|
197
|
-
# So, instead, we simply transform <tt>render :widget => ...</tt> into a <tt>render :text => ...</tt> of the
|
198
|
-
# widget's output, and let Rails take it away from there.
|
199
|
-
::ActionController::Base.class_eval do
|
200
|
-
def fortitude_rendering_context_for(delegate_object, yield_block)
|
201
|
-
@_fortitude_rendering_contexts ||= { }
|
202
|
-
@_fortitude_rendering_contexts[delegate_object.object_id] ||= create_fortitude_rendering_context(
|
203
|
-
:delegate_object => delegate_object, :yield_block => yield_block)
|
204
|
-
end
|
205
|
-
|
206
|
-
def create_fortitude_rendering_context(options)
|
207
|
-
::Fortitude::RenderingContext.new(options)
|
208
|
-
end
|
209
|
-
|
210
|
-
def render_with_fortitude(*args, &block)
|
211
|
-
if (options = args[0]).kind_of?(Hash)
|
212
|
-
if (widget = options[:widget])
|
213
|
-
rendering_context = fortitude_rendering_context_for(self, nil)
|
214
|
-
widget.render_to(rendering_context)
|
215
|
-
|
216
|
-
options = options.dup
|
217
|
-
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
218
|
-
options[:layout] = true unless options.has_key?(:layout)
|
219
|
-
|
220
|
-
new_args = [ options ] + args[1..-1]
|
221
|
-
return render_without_fortitude(*new_args, &block)
|
222
|
-
elsif (widget_block = options[:inline]) && (options[:type] == :fortitude)
|
223
|
-
options.delete(:inline)
|
224
|
-
|
225
|
-
rendering_context = fortitude_rendering_context_for(self, nil)
|
226
|
-
widget_class = Class.new(Fortitude::Widgets::Html5)
|
227
|
-
widget_class.use_instance_variables_for_assigns(true)
|
228
|
-
widget_class.extra_assigns(:use)
|
229
|
-
widget_class.send(:define_method, :content, &widget_block)
|
230
|
-
|
231
|
-
assigns = { }
|
232
|
-
instance_variables.each do |ivar_name|
|
233
|
-
value = instance_variable_get(ivar_name)
|
234
|
-
assigns[$1.to_sym] = value if ivar_name =~ /^@(.*)$/
|
235
|
-
end
|
236
|
-
assigns = assigns.merge(options[:locals] || { })
|
237
|
-
|
238
|
-
widget = widget_class.new(assigns)
|
239
|
-
widget.render_to(rendering_context)
|
240
|
-
|
241
|
-
options = options.dup
|
242
|
-
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
243
|
-
options[:layout] = true unless options.has_key?(:layout)
|
244
|
-
|
245
|
-
new_args = [ options ] + args[1..-1]
|
246
|
-
return render_without_fortitude(*new_args, &block)
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
return render_without_fortitude(*args, &block)
|
251
|
-
end
|
252
|
-
|
253
|
-
alias_method_chain :render, :fortitude
|
254
|
-
end
|
205
|
+
::ActionController::Base.send(:include, ::Fortitude::Rails::RenderingMethods)
|
206
|
+
::ActionMailer::Base.send(:include, ::Fortitude::Rails::RenderingMethods)
|
255
207
|
end
|
256
208
|
end
|
257
209
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Fortitude
|
4
|
+
module Rails
|
5
|
+
module RenderingMethods
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
alias_method_chain :render, :fortitude
|
10
|
+
end
|
11
|
+
|
12
|
+
def fortitude_rendering_context_for(delegate_object, yield_block)
|
13
|
+
@_fortitude_rendering_contexts ||= { }
|
14
|
+
@_fortitude_rendering_contexts[delegate_object.object_id] ||= create_fortitude_rendering_context(
|
15
|
+
:delegate_object => delegate_object, :yield_block => yield_block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_fortitude_rendering_context(options)
|
19
|
+
::Fortitude::RenderingContext.new(options)
|
20
|
+
end
|
21
|
+
|
22
|
+
# This is our support for render :widget. Although, originally, it looked like creating a new subclass
|
23
|
+
# of ActionView::Template was going to be the correct thing to do here, it turns out it isn't: the entire
|
24
|
+
# template system is predicated around the idea that you have a template, which is compiled to output
|
25
|
+
# Ruby source code, and then that gets evaluated to actually generate output.
|
26
|
+
#
|
27
|
+
# Because <tt>render :widget => ...</tt> takes an already-instantiated widget as input, this simply isn't
|
28
|
+
# possible: you can't reverse-engineer an arbitrary Ruby object into source code, and, without source code,
|
29
|
+
# the whole templating paradigm doesn't make sense.
|
30
|
+
#
|
31
|
+
# So, instead, we simply transform <tt>render :widget => ...</tt> into a <tt>render :text => ...</tt> of the
|
32
|
+
# widget's output, and let Rails take it away from there.
|
33
|
+
def render_with_fortitude(*args, &block)
|
34
|
+
if (options = args[0]).kind_of?(Hash)
|
35
|
+
if (widget = options[:widget])
|
36
|
+
rendering_context = fortitude_rendering_context_for(self, nil)
|
37
|
+
widget.render_to(rendering_context)
|
38
|
+
|
39
|
+
options = options.dup
|
40
|
+
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
41
|
+
options[:layout] = true unless options.has_key?(:layout)
|
42
|
+
|
43
|
+
new_args = [ options ] + args[1..-1]
|
44
|
+
return render_without_fortitude(*new_args, &block)
|
45
|
+
elsif (widget_block = options[:inline]) && (options[:type] == :fortitude)
|
46
|
+
options.delete(:inline)
|
47
|
+
|
48
|
+
rendering_context = fortitude_rendering_context_for(self, nil)
|
49
|
+
widget_class = Class.new(Fortitude::Widgets::Html5)
|
50
|
+
widget_class.use_instance_variables_for_assigns(true)
|
51
|
+
widget_class.extra_assigns(:use)
|
52
|
+
widget_class.send(:define_method, :content, &widget_block)
|
53
|
+
|
54
|
+
assigns = { }
|
55
|
+
instance_variables.each do |ivar_name|
|
56
|
+
value = instance_variable_get(ivar_name)
|
57
|
+
assigns[$1.to_sym] = value if ivar_name =~ /^@(.*)$/
|
58
|
+
end
|
59
|
+
assigns = assigns.merge(options[:locals] || { })
|
60
|
+
|
61
|
+
widget = widget_class.new(assigns)
|
62
|
+
widget.render_to(rendering_context)
|
63
|
+
|
64
|
+
options = options.dup
|
65
|
+
options[:text] = rendering_context.output_buffer_holder.output_buffer.html_safe
|
66
|
+
options[:layout] = true unless options.has_key?(:layout)
|
67
|
+
|
68
|
+
new_args = [ options ] + args[1..-1]
|
69
|
+
return render_without_fortitude(*new_args, &block)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
return render_without_fortitude(*args, &block)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -19,7 +19,9 @@ module Fortitude
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def render(scope=Object.new, locals=
|
22
|
+
def render(scope=Object.new, locals = nil, &block)
|
23
|
+
locals ||= { }
|
24
|
+
|
23
25
|
rendering_context = Fortitude::RenderingContext.new({
|
24
26
|
:yield_block => block, :render_yield_result => false,
|
25
27
|
:helpers_object => scope, :instance_variables_object => scope })
|
data/lib/fortitude/version.rb
CHANGED
@@ -44,8 +44,10 @@ module Fortitude
|
|
44
44
|
@tags_module = Fortitude::Tags::TagsModule.new(self)
|
45
45
|
@helpers_module = Module.new
|
46
46
|
include @helpers_module
|
47
|
+
const_set(:DefinedFortitudeHelpers, @helpers_module)
|
47
48
|
@needs_module = Module.new
|
48
49
|
include @needs_module
|
50
|
+
const_set(:FortitudeNeedsMethods, @helpers_module)
|
49
51
|
end
|
50
52
|
private :create_modules!
|
51
53
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spec
|
2
|
+
module Helpers
|
3
|
+
module FortitudeRailsHelpers
|
4
|
+
def rails_server_project_root
|
5
|
+
@rails_server_project_root ||= File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def rails_server_additional_gemfile_lines
|
9
|
+
[
|
10
|
+
"gem 'fortitude', :path => '#{rails_server_project_root}'"
|
11
|
+
]
|
12
|
+
end
|
13
|
+
|
14
|
+
def rails_server_default_version
|
15
|
+
ENV['FORTITUDE_SPECS_RAILS_VERSION']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'fortitude'
|
2
|
-
require '
|
2
|
+
require 'oop_rails_server'
|
3
3
|
require 'helpers/system_helpers'
|
4
|
+
require 'helpers/fortitude_rails_helpers'
|
4
5
|
|
5
6
|
RSpec.configure do |c|
|
6
|
-
c.include
|
7
|
+
c.include ::OopRailsServer::Helpers, :type => :rails
|
8
|
+
c.include ::Spec::Helpers::FortitudeRailsHelpers, :type => :rails
|
7
9
|
c.include SystemHelpers, :type => :system
|
8
10
|
end
|
@@ -23,7 +23,7 @@ describe "Rails capture support", :type => :rails do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be able to provide content in a widget with provide" do
|
26
|
-
skip "Rails 3.0.x doesn't support :provide" if
|
26
|
+
skip "Rails 3.0.x doesn't support :provide" if rails_server.rails_version =~ /^3\.0\./
|
27
27
|
|
28
28
|
expect_match('widget_provide',
|
29
29
|
%r{erb_layout_needing_content}i,
|
@@ -13,11 +13,21 @@ describe "Rails development-mode support", :type => :rails do
|
|
13
13
|
expect_match("reload_widget", /after_reload/)
|
14
14
|
end
|
15
15
|
|
16
|
+
it "should automatically reload widgets if related files change on disk, even if they're named '.html.rb' at the end" do
|
17
|
+
expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
|
18
|
+
sleep 1
|
19
|
+
splat_new_module_for_reload_widget_failing!
|
20
|
+
expect_exception("reload_widget_with_html_extension", NameError, "some_helper")
|
21
|
+
sleep 1
|
22
|
+
splat_new_module_for_reload_widget!
|
23
|
+
expect_match("reload_widget_with_html_extension", /with_html_extension.*helper: yo/)
|
24
|
+
end
|
25
|
+
|
16
26
|
it "should let you change the controller, and that should work fine, too" do
|
17
|
-
|
27
|
+
expect(rails_server.get("replaced/reload_widget")).to match(/datum\s+one\s+datum/)
|
18
28
|
sleep 1
|
19
29
|
splat_new_controller!
|
20
|
-
|
30
|
+
expect(rails_server.get("replaced/reload_widget")).to match(/datum\s+two\s+datum/)
|
21
31
|
end
|
22
32
|
|
23
33
|
it "should, by default, format output" do
|
@@ -32,6 +42,42 @@ describe "Rails development-mode support", :type => :rails do
|
|
32
42
|
<!-- END Views::DevelopmentModeSystemSpec::SampleOutput depth 0 -->}mi)
|
33
43
|
end
|
34
44
|
|
45
|
+
it "should pick up changes to mailer views" do
|
46
|
+
expect_match("mailer_view_test", /mail sent/i)
|
47
|
+
mail = mail_sent_to('mailer_view_test@example.com')
|
48
|
+
expect(mail[:body].strip).to match(%r{<p>this is the basic mail!</p>}mi)
|
49
|
+
clear_mails!
|
50
|
+
|
51
|
+
sleep 1
|
52
|
+
splat_new_mailer_view!
|
53
|
+
expect_match("mailer_view_test", /mail sent/i)
|
54
|
+
mail = mail_sent_to('mailer_view_test@example.com')
|
55
|
+
expect(mail[:body].strip).to match(%r{<p>this is the NEW basic mail!</p>}mi)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should pick up changes to mailer layouts" do
|
59
|
+
expect_match("mailer_layout_test", /mail sent/i)
|
60
|
+
mail = mail_sent_to('mailer_layout_test@example.com')
|
61
|
+
expect(mail[:body].strip).to match(%r{this is the layout, before.*this is the basic mail!.*this is the layout, after}mi)
|
62
|
+
clear_mails!
|
63
|
+
|
64
|
+
sleep 1
|
65
|
+
splat_new_mailer_layout!
|
66
|
+
expect_match("mailer_layout_test", /mail sent/i)
|
67
|
+
mail = mail_sent_to('mailer_layout_test@example.com')
|
68
|
+
expect(mail[:body].strip).to match(%r{this is the NEW layout, before.*this is the basic mail!.*this is the NEW layout, after}mi)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should format output and output BEGIN/END debugging tags in mailers" do
|
72
|
+
expect_match("mailer_formatting_test", /mail sent/i)
|
73
|
+
mail = mail_sent_to('mailer_formatting_test@example.com')
|
74
|
+
expect(mail[:body].strip).to eq(%{<!-- BEGIN Views::DevelopmentModeMailer::MailerFormattingTest depth 0 -->
|
75
|
+
<div>
|
76
|
+
<p>this is the text!</p>
|
77
|
+
</div>
|
78
|
+
<!-- END Views::DevelopmentModeMailer::MailerFormattingTest depth 0 -->})
|
79
|
+
end
|
80
|
+
|
35
81
|
private
|
36
82
|
def splat_new_widget!
|
37
83
|
reload_file = File.join(rails_server.rails_root, 'app/views/development_mode_system_spec/reload_widget.rb')
|
@@ -48,17 +94,65 @@ EOS
|
|
48
94
|
end
|
49
95
|
end
|
50
96
|
|
97
|
+
def splat_new_module_for_reload_widget_failing!
|
98
|
+
module_file = File.join(rails_server.rails_root, 'app/views/shared/some_module.rb')
|
99
|
+
File.open(module_file, 'w') do |f|
|
100
|
+
f.puts <<-EOS
|
101
|
+
module Views::Shared::SomeModule
|
102
|
+
end
|
103
|
+
EOS
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def splat_new_module_for_reload_widget!
|
108
|
+
module_file = File.join(rails_server.rails_root, 'app/views/shared/some_module.rb')
|
109
|
+
File.open(module_file, 'w') do |f|
|
110
|
+
f.puts <<-EOS
|
111
|
+
module Views::Shared::SomeModule
|
112
|
+
def some_helper
|
113
|
+
"yo"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
EOS
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
51
120
|
def splat_new_controller!
|
52
|
-
controller_file = File.join(rails_server.rails_root, 'app/controllers/
|
121
|
+
controller_file = File.join(rails_server.rails_root, 'app/controllers/replaced_controller.rb')
|
53
122
|
File.open(controller_file, 'w') do |f|
|
54
123
|
f.puts <<-EOS
|
55
|
-
class
|
124
|
+
class ReplacedController < ApplicationController
|
56
125
|
def reload_widget
|
57
126
|
@datum = "two"
|
58
127
|
end
|
128
|
+
end
|
129
|
+
EOS
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def splat_new_mailer_view!
|
134
|
+
reload_file = File.join(rails_server.rails_root, 'app/views/development_mode_mailer/mailer_view_test.rb')
|
135
|
+
File.open(reload_file, 'w') do |f|
|
136
|
+
f.puts <<-EOS
|
137
|
+
class Views::DevelopmentModeMailer::MailerViewTest < Fortitude::Widgets::Html5
|
138
|
+
def content
|
139
|
+
p "this is the NEW basic mail!"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
EOS
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
59
146
|
|
60
|
-
def
|
61
|
-
|
147
|
+
def splat_new_mailer_layout!
|
148
|
+
reload_file = File.join(rails_server.rails_root, 'app/views/layouts/mail_layout.rb')
|
149
|
+
File.open(reload_file, 'w') do |f|
|
150
|
+
f.puts <<-EOS
|
151
|
+
class Views::Layouts::MailLayout < Fortitude::Widgets::Html5
|
152
|
+
def content
|
153
|
+
p "this is the NEW layout, before"
|
154
|
+
yield
|
155
|
+
p "this is the NEW layout, after"
|
62
156
|
end
|
63
157
|
end
|
64
158
|
EOS
|