fortitude 0.9.3-java → 0.9.4-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 467436a25faae7e85366ea30823ff7347b3db824
4
- data.tar.gz: ab92630c1074a321afd13e52d525b065cf964df2
3
+ metadata.gz: 2884a8e72cb352ce8949fb50d90e09a3c088cd4d
4
+ data.tar.gz: 2570a3cc59ba2567fb99c125826cc7c8c7aca494
5
5
  SHA512:
6
- metadata.gz: b36a5556e62012835d1b0c283cdb6457eb2d292137ae153e3c0da268df71334a64082fa29698742f2973e702ea9c305ef70ed888a8ca777865dc1929deb25e6f
7
- data.tar.gz: e7eb439ae801b5defebc88d85fa5c2a02fe67f5c7f2e06098e6819f524abd462629a30a878a246c40bd59862de14b7f6d9cc62a56c8a26d7677c9cffbd488686
6
+ metadata.gz: 694c82aea14f52773ead6cfb78761571f5e2f8c0bf0f16a536f58ebcfaac9fdab583d717930f0180886d6d57564c6ab89cd8b06106b1320aeb27c95aa9a0f3a6
7
+ data.tar.gz: f898850d1ae571dd410b0919e557c1190700a0512c51a7a6ab4274a771ec5c4587e6dc58ef892e111a13df30dec62e13db9002544a2733e0b6df59d7d9312178
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
@@ -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
- def initialize(widget, yielded_object, method_names)
6
- @widget = widget
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
- @widget.rawtext(return_value)
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
- return_value
37
+ @yielded_object.send(method_name, *args, &block)
23
38
  end
24
39
  end
25
40
 
@@ -1,3 +1,3 @@
1
1
  module Fortitude
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.4"
3
3
  end
@@ -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 = "effective_block = block"
39
-
40
- yielded_methods = options[:output_yielded_methods]
41
- if yielded_methods
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)
@@ -7,6 +7,10 @@ class ComplexHelpersSystemSpecController < ApplicationController
7
7
  # nothing here
8
8
  end
9
9
 
10
+ def nesting_test
11
+ # nothing here
12
+ end
13
+
10
14
  def cache_test
11
15
  @a = params[:a]
12
16
  @b = params[:b]
@@ -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.3
4
+ version: 0.9.4
5
5
  platform: java
6
6
  authors:
7
7
  - Andrew Geweke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -392,6 +392,7 @@ files:
392
392
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
393
393
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
394
394
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
395
+ - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/nesting_test.rb
395
396
  - spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb
396
397
  - spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb
397
398
  - spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb
@@ -675,7 +676,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
675
676
  version: '0'
676
677
  requirements: []
677
678
  rubyforge_project:
678
- rubygems_version: 2.1.9
679
+ rubygems_version: 2.4.5
679
680
  signing_key:
680
681
  specification_version: 4
681
682
  summary: 'Views Are Code: use all the power of Ruby to build views in your own language.'
@@ -750,6 +751,7 @@ test_files:
750
751
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
751
752
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
752
753
  - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
754
+ - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/nesting_test.rb
753
755
  - spec/rails/templates/complex_helpers_system_spec/config/environments/development.rb
754
756
  - spec/rails/templates/data_passing_system_spec/app/controllers/data_passing_system_spec_controller.rb
755
757
  - spec/rails/templates/data_passing_system_spec/app/views/data_passing_system_spec/_erb_to_parallel_widget_handoff_erb.html.erb