fortitude 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/CONTRIBUTORS.md +2 -0
- data/lib/fortitude/rails/helpers.rb +4 -1
- data/lib/fortitude/rails/yielded_object_outputter.rb +20 -5
- data/lib/fortitude/version.rb +1 -1
- data/lib/fortitude/widget/helpers.rb +4 -9
- data/spec/rails/complex_helpers_system_spec.rb +16 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb +4 -0
- data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/nesting_test.rb +21 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01ce3b6762f088fca61147da654a6f3508d1fcb5
|
4
|
+
data.tar.gz: b2cc3632e67c21dc00edcbf4f87d9b538b168b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f01af0007be5caa3b469ac3ff26952c8b365ee65f78fc402f9ea53e37ab757da20a64f271807fc1547d6c3625f755aa3f15ac918347c6c016276930e2e5a21
|
7
|
+
data.tar.gz: 89e9ca7d79dd014124cca6d12d564847206169d4f0fe9df34a71c59b1f6dfd99333ae959b22db9cf0eff8051afbc306327cf250d9210f55b96e23fc4611f8680
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Fortitude Releases
|
2
2
|
|
3
|
+
## 0.9.4, 11 February 2015
|
4
|
+
|
5
|
+
* Fixed an issue where use of Rails' `form_for` or `fields_for` from within another `form_for` or `fields_for` block
|
6
|
+
would not produce the correct output. (Thanks to [Leaf](https://github.com/leafo) for the bug report!)
|
7
|
+
|
3
8
|
## 0.9.3, 2 February 2015
|
4
9
|
|
5
10
|
* Fixed a memory leak when using `render :inline`, or certain other cases triggered by a user. (Fortitude widget
|
data/CONTRIBUTORS.md
CHANGED
@@ -35,6 +35,8 @@ Fortitude is written by [Andrew Geweke](https://github.com/ageweke), with contri
|
|
35
35
|
* Reporting, and helping verify, an issue where creating anonymous subclasses of a Fortitude widget class (like
|
36
36
|
those used by `render :inline`) would cause those anonymous subclasses to never be garbage collected, causing
|
37
37
|
a memory leak.
|
38
|
+
* Reporting an issue where use of Rails' `form_for` and/or `fields_for` from within another `form_for` or
|
39
|
+
`fields_for` block would not produce the correct output.
|
38
40
|
* [Adam Becker](https://github.com/ajb) for:
|
39
41
|
* Discussion and details around exactly what `:attribute => true`, `:attribute => false`, and so on should render
|
40
42
|
from Fortitude.
|
@@ -67,7 +67,10 @@ module Fortitude
|
|
67
67
|
# From form_options_helper
|
68
68
|
%w{select collection_select grouped_collection_select time_zone_select options_for_select} +
|
69
69
|
%w{options_from_collection_for_select option_groups_from_collection_for_select grouped_options_for_select} +
|
70
|
-
%w{time_zone_options_for_select collection_radio_buttons collection_check_boxes}
|
70
|
+
%w{time_zone_options_for_select collection_radio_buttons collection_check_boxes} +
|
71
|
+
|
72
|
+
# And these can nest inside each other
|
73
|
+
%w{form_for fields_for}
|
71
74
|
|
72
75
|
helper :form_for, :transform => :output_return_value, :output_yielded_methods => FORM_FOR_YIELDED_METHODS_TO_OUTPUT
|
73
76
|
helper :fields_for, :transform => :output_return_value, :output_yielded_methods => FORM_FOR_YIELDED_METHODS_TO_OUTPUT
|
@@ -2,9 +2,23 @@ module Fortitude
|
|
2
2
|
module Rails
|
3
3
|
YIELDED_OBJECT_OUTPUTTER_SUPERCLASS = if defined?(::BasicObject) then ::BasicObject else ::Object end
|
4
4
|
class YieldedObjectOutputter < YIELDED_OBJECT_OUTPUTTER_SUPERCLASS
|
5
|
-
|
6
|
-
|
5
|
+
class << self
|
6
|
+
def wrap_block_as_needed(output_target, for_method_name, original_block, yielded_methods_to_output)
|
7
|
+
if original_block && yielded_methods_to_output
|
8
|
+
lambda do |yielded_object, *args|
|
9
|
+
outputter = new(output_target, yielded_object, for_method_name, yielded_methods_to_output)
|
10
|
+
original_block.call(outputter, *args)
|
11
|
+
end
|
12
|
+
else
|
13
|
+
original_block
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(output_target, yielded_object, for_method_name, method_names)
|
19
|
+
@output_target = output_target
|
7
20
|
@yielded_object = yielded_object
|
21
|
+
@for_method_name = for_method_name
|
8
22
|
@method_names_hash = { }
|
9
23
|
method_names.each do |method_name|
|
10
24
|
@method_names_hash[method_name.to_sym] = true
|
@@ -14,12 +28,13 @@ module Fortitude
|
|
14
28
|
EMPTY_RETURN_VALUE = ''.freeze
|
15
29
|
|
16
30
|
def method_missing(method_name, *args, &block)
|
17
|
-
return_value = @yielded_object.send(method_name, *args, &block)
|
18
31
|
if @method_names_hash[method_name.to_sym]
|
19
|
-
@
|
32
|
+
block = ::Fortitude::Rails::YieldedObjectOutputter.wrap_block_as_needed(@output_target, method_name, block, @method_names_hash.keys)
|
33
|
+
return_value = @yielded_object.send(method_name, *args, &block)
|
34
|
+
@output_target.rawtext(return_value)
|
20
35
|
EMPTY_RETURN_VALUE
|
21
36
|
else
|
22
|
-
|
37
|
+
@yielded_object.send(method_name, *args, &block)
|
23
38
|
end
|
24
39
|
end
|
25
40
|
|
data/lib/fortitude/version.rb
CHANGED
@@ -35,15 +35,10 @@ module Fortitude
|
|
35
35
|
else raise ArgumentError, "Invalid value for :transform: #{transform.inspect}"
|
36
36
|
end
|
37
37
|
|
38
|
-
block_transform =
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
block_transform = <<-EOS
|
43
|
-
effective_block = lambda do |yielded_object|
|
44
|
-
block.call(Fortitude::Rails::YieldedObjectOutputter.new(self, yielded_object, #{yielded_methods.inspect}))
|
45
|
-
end
|
46
|
-
EOS
|
38
|
+
block_transform = if (yielded_methods_to_output = options[:output_yielded_methods])
|
39
|
+
"effective_block = ::Fortitude::Rails::YieldedObjectOutputter.wrap_block_as_needed(self, #{name.inspect}, block, #{yielded_methods_to_output.inspect})"
|
40
|
+
else
|
41
|
+
"effective_block = block"
|
47
42
|
end
|
48
43
|
|
49
44
|
text = <<-EOS
|
@@ -22,6 +22,22 @@ describe "Rails complex helper support", :type => :rails do
|
|
22
22
|
OUTSIDE_AFTER}mix)
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should render a nested fields_for inside a form_for" do
|
26
|
+
expect_match("nesting_test",
|
27
|
+
%r{OUTSIDE_BEFORE\s*<form.*action=\"/complex_helpers_system_spec/nesting_test\".*
|
28
|
+
INSIDE_FORM_BEFORE\s*
|
29
|
+
FIRST:\s*
|
30
|
+
<input.*person_first_name.*/>\s*
|
31
|
+
WHATSIT\s*BAR:\s*
|
32
|
+
<input.*person_whatsit_bar.*/>\s*
|
33
|
+
AFTER\s*WHATSIT\s*BAR\s*
|
34
|
+
LAST:\s*
|
35
|
+
<input.*person_last_name.*/>\s*
|
36
|
+
INSIDE_FORM_AFTER\s*
|
37
|
+
</form>\s*
|
38
|
+
OUTSIDE_AFTER}mix)
|
39
|
+
end
|
40
|
+
|
25
41
|
it "should cache based on a name properly" do
|
26
42
|
expect_match("cache_test?a=a1&b=b1",
|
27
43
|
/before_cache\(a1,b1\).*inside_cache\(a1,b1\).*after_cache\(a1,b1\)/mi)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Views::ComplexHelpersSystemSpec::NestingTest < Fortitude::Widgets::Html5
|
2
|
+
def content
|
3
|
+
text "OUTSIDE_BEFORE"
|
4
|
+
form_for :person do |f|
|
5
|
+
text "INSIDE_FORM_BEFORE"
|
6
|
+
text "FIRST: "
|
7
|
+
f.text_field :first_name
|
8
|
+
|
9
|
+
f.fields_for :whatsit do |w|
|
10
|
+
text "WHATSIT BAR: "
|
11
|
+
w.text_field :bar
|
12
|
+
text "AFTER WHATSIT BAR"
|
13
|
+
end
|
14
|
+
|
15
|
+
text "LAST: "
|
16
|
+
f.text_field :last_name
|
17
|
+
text "INSIDE_FORM_AFTER"
|
18
|
+
end
|
19
|
+
text "OUTSIDE_AFTER"
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Geweke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -393,6 +393,7 @@ files:
|
|
393
393
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
|
394
394
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
|
395
395
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
|
396
|
+
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/nesting_test.rb
|
396
397
|
- spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb
|
397
398
|
- spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb
|
398
399
|
- spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb
|
@@ -676,7 +677,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
676
677
|
version: '0'
|
677
678
|
requirements: []
|
678
679
|
rubyforge_project:
|
679
|
-
rubygems_version: 2.
|
680
|
+
rubygems_version: 2.4.5
|
680
681
|
signing_key:
|
681
682
|
specification_version: 4
|
682
683
|
summary: 'Views Are Code: use all the power of Ruby to build views in your own language.'
|
@@ -751,6 +752,7 @@ test_files:
|
|
751
752
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
|
752
753
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
|
753
754
|
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
|
755
|
+
- spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/nesting_test.rb
|
754
756
|
- spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb
|
755
757
|
- spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb
|
756
758
|
- spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb
|
@@ -1014,4 +1016,3 @@ test_files:
|
|
1014
1016
|
- spec/system/widget_method_system_spec.rb
|
1015
1017
|
- spec/system/widget_return_values_system_spec.rb
|
1016
1018
|
- spec/system/yield_system_spec.rb
|
1017
|
-
has_rdoc:
|