fortitude 0.0.9-java → 0.0.10-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 +4 -4
 - data/CHANGES.md +69 -0
 - data/CONTRIBUTORS.md +10 -0
 - data/Gemfile +1 -0
 - data/lib/fortitude.rb +1 -0
 - data/lib/fortitude/erector.rb +45 -4
 - data/lib/fortitude/method_templates/tag_method_template.rb.smpl +4 -0
 - data/lib/fortitude/rails/rendering_methods.rb +10 -4
 - data/lib/fortitude/version.rb +1 -1
 - data/lib/fortitude/widget/integration.rb +34 -6
 - data/lib/fortitude/widget/modules_and_subclasses.rb +1 -1
 - data/lib/fortitude/widget/needs.rb +14 -3
 - data/lib/fortitude/widget/rendering.rb +19 -7
 - data/spec/helpers/system_helpers.rb +3 -0
 - data/spec/rails/complex_helpers_system_spec.rb +30 -0
 - data/spec/rails/erector_coexistence_system_spec.rb +20 -0
 - data/spec/rails/rendering_system_spec.rb +4 -0
 - data/spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb +5 -0
 - data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_tags_test.rb +23 -0
 - data/spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb +1 -2
 - data/spec/rails/templates/erector_coexistence_system_spec/app/controllers/erector_coexistence_system_spec_controller.rb +8 -0
 - data/spec/rails/templates/erector_coexistence_system_spec/app/helpers/application_helper.rb +5 -0
 - data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_from_fortitude_widget.rb +7 -0
 - data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_from_erector_widget.rb +7 -0
 - data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_erector_widget_from_fortitude_widget.rb +13 -0
 - data/spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_fortitude_widget_from_erector_widget.rb +13 -0
 - data/spec/rails/templates/rendering_system_spec/app/controllers/rendering_system_spec_controller.rb +4 -0
 - data/spec/rails/templates/rendering_system_spec/app/views/widget_to_render_with_capture.rb +19 -0
 - data/spec/system/assigns_system_spec.rb +12 -0
 - data/spec/system/helpers_system_spec.rb +6 -0
 - data/spec/system/method_precedence_system_spec.rb +22 -0
 - data/spec/system/setting_inheritance_system_spec.rb +8 -0
 - data/spec/system/yield_system_spec.rb +152 -0
 - metadata +16 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e1a542c4ed9adc0639a95c15852b627673bb55c5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 905df6f3d00b4e5740e9de43fd0486b4e4b9131e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 1245a668c62617e44b205e63f662b2a47735e97d13dd2315b26fdb832adec5a04f1eb5e464e0329f261cfcbdfe351d239306a95d97463714d4c5660c6c3cdd72
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 2f428702bbd1ed28557fe677a2f8b09c13a5864acec8669919fecd042b8a89bad35191dd706f24e3ed1bad4db7d55a47c211bd5fac05bba614eea917c57b2728
         
     | 
    
        data/CHANGES.md
    CHANGED
    
    | 
         @@ -1,5 +1,74 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Fortitude Releases
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 0.0.10, 25 November 2014
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            * Fixed an issue where `#capture` was not working properly if you rendered a widget using `render :widget =>` in a
         
     | 
| 
      
 6 
     | 
    
         
            +
              controller. The fix further simplifies Fortitude's support for that feature and integrates even more correctly with
         
     | 
| 
      
 7 
     | 
    
         
            +
              Rails in that way. (Thanks to [Leaf](https://github.com/leafo) for the bug report!)
         
     | 
| 
      
 8 
     | 
    
         
            +
            * Fixed an issue where, if you overrode a "needs" method in a class, subclasses of that class would not use the
         
     | 
| 
      
 9 
     | 
    
         
            +
              overridden method, but instead access the "needs" method directly. (Thanks to [Leaf](https://github.com/leafo)
         
     | 
| 
      
 10 
     | 
    
         
            +
              for the bug report!)
         
     | 
| 
      
 11 
     | 
    
         
            +
            * Fixed a simple mistake that meant the module Fortitude uses to declare `needs` methods was not given a name at all,
         
     | 
| 
      
 12 
     | 
    
         
            +
              and instead the module it uses to declare helpers was given two names, one of them incorrect. (Thanks to
         
     | 
| 
      
 13 
     | 
    
         
            +
              [Leaf](https://github.com/leafo) for catching this.)
         
     | 
| 
      
 14 
     | 
    
         
            +
            * When you're invoking a widget from another widget using the `#widget` method, and you pass a block, that block is
         
     | 
| 
      
 15 
     | 
    
         
            +
              evaluated in the context of the parent widget. (This has always been true.) However, this meant that something like
         
     | 
| 
      
 16 
     | 
    
         
            +
              the following was impossible, where you're effectively defining new DSL on a widget-by-widget basis:
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 19 
     | 
    
         
            +
            class Views::ModalDialog < Views::Base
         
     | 
| 
      
 20 
     | 
    
         
            +
              needs :title
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              def content
         
     | 
| 
      
 23 
     | 
    
         
            +
                h3 "Modal: #{title}"
         
     | 
| 
      
 24 
     | 
    
         
            +
                yield
         
     | 
| 
      
 25 
     | 
    
         
            +
                button "Submit"
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              def modal_header(name)
         
     | 
| 
      
 29 
     | 
    
         
            +
                h5 "Modal header: #{name}"
         
     | 
| 
      
 30 
     | 
    
         
            +
                hr
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            class Views::MyView < Views::Base
         
     | 
| 
      
 35 
     | 
    
         
            +
              needs :username
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              def content
         
     | 
| 
      
 38 
     | 
    
         
            +
                h1 "User #{username}"
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                widget Views::ModalDialog, :title => "User Settings" do
         
     | 
| 
      
 41 
     | 
    
         
            +
                  modal_header "Settings for #{username}"
         
     | 
| 
      
 42 
     | 
    
         
            +
                  input :type => :text, :name => :email
         
     | 
| 
      
 43 
     | 
    
         
            +
                  ...
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
| 
      
 47 
     | 
    
         
            +
            ```
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              The problem arises because, within the block in `Views::MyView#content`, you want to be able to access methods from
         
     | 
| 
      
 50 
     | 
    
         
            +
              two contexts: the parent widget (for `#username`), and the child widget (for `#modal_header`). Ruby provides no
         
     | 
| 
      
 51 
     | 
    
         
            +
              single, simple way to do this, but, without it, it's very difficult to come up with a truly elegant DSL for cases
         
     | 
| 
      
 52 
     | 
    
         
            +
              like this.
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              Fortitude now supports this via a small bit of `method_missing` magic: the block passed to a widget is still
         
     | 
| 
      
 55 
     | 
    
         
            +
              evaluated in the context of the parent, but, if a method is called that is not present, Fortitude looks for that
         
     | 
| 
      
 56 
     | 
    
         
            +
              method in the child widget and invokes it there, if present. This allows the above situation, which is important
         
     | 
| 
      
 57 
     | 
    
         
            +
              for writing libraries that "feel right" to a Ruby programmer. (The fact that the block is evaluated primarily in the
         
     | 
| 
      
 58 
     | 
    
         
            +
              context of the parent widget, like all other Ruby blocks, preserves important standard Ruby semantics, and also
         
     | 
| 
      
 59 
     | 
    
         
            +
              means that the onus is on the author of a feature like `Views::ModalDialog` to present method names that are
         
     | 
| 
      
 60 
     | 
    
         
            +
              unlikely to conflict with those in use in parent widgets — which seems correct.)
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            * You can now render Erector widgets from Fortitude widgets using just `widget MyErectorWidget`, and vice-versa, using
         
     | 
| 
      
 63 
     | 
    
         
            +
              either the class-and-assigns or instantiated-widget calling conventions. Note that this integration is not 100%
         
     | 
| 
      
 64 
     | 
    
         
            +
              perfect; in particular, passing a block from a Fortitude widget to an Erector widget, or vice-versa, is likely to
         
     | 
| 
      
 65 
     | 
    
         
            +
              fail or produce incorrect output due to the way Erector manipulates output buffers. However, the simple case of
         
     | 
| 
      
 66 
     | 
    
         
            +
              invoking a widget from another works fine, and can be very useful to those migrating to Fortitude. (Thanks to
         
     | 
| 
      
 67 
     | 
    
         
            +
              [Adam Becker](https://github.com/ajb) for the bug report!)
         
     | 
| 
      
 68 
     | 
    
         
            +
            * Fixed an issue where Fortitude could write the close tag of an element to the wrong output buffer if the output
         
     | 
| 
      
 69 
     | 
    
         
            +
              buffer was changed inside the element (as can happen with, among other things, Rails' `cache` method). This could
         
     | 
| 
      
 70 
     | 
    
         
            +
              cause the output HTML to be structured improperly. (Thanks to [Leaf](https://github.com/leafo) for the bug report,tracking down the exact cause, and providing the fix!)
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       3 
72 
     | 
    
         
             
            ## 0.0.9, 20 November 2014
         
     | 
| 
       4 
73 
     | 
    
         | 
| 
       5 
74 
     | 
    
         
             
            * Fortitude now supports passing blocks to widgets (above and beyond support for Rails' standard layouts and their
         
     | 
    
        data/CONTRIBUTORS.md
    CHANGED
    
    | 
         @@ -20,6 +20,16 @@ Fortitude is written by [Andrew Geweke](https://github.com/ageweke), with contri 
     | 
|
| 
       20 
20 
     | 
    
         
             
                from Fortitude.
         
     | 
| 
       21 
21 
     | 
    
         
             
              * Reporting multiple bugs in support for `render :widget => ...`, and many useful pointers to possible fixes and
         
     | 
| 
       22 
22 
     | 
    
         
             
                additional methods to make the implementation a lot more robust.
         
     | 
| 
      
 23 
     | 
    
         
            +
              * Reporting a bug, tracking down the exact cause, and providing a fix for a case where the closing tag of an element
         
     | 
| 
      
 24 
     | 
    
         
            +
                would get written to the wrong output buffer if the output buffer was changed inside the element (as could happen
         
     | 
| 
      
 25 
     | 
    
         
            +
                with, among other things, Rails' `cache` method).
         
     | 
| 
      
 26 
     | 
    
         
            +
              * Reporting a bug where overriding a "needs" method would work only for the class it was defined on, and not any
         
     | 
| 
      
 27 
     | 
    
         
            +
                subclasses.
         
     | 
| 
      
 28 
     | 
    
         
            +
              * Reporting an issue where the module Fortitude uses to mix in its "needs" methods was not given a name, and instead
         
     | 
| 
      
 29 
     | 
    
         
            +
                the module it used to mix in helper methods was given two names, one of them incorrect.
         
     | 
| 
      
 30 
     | 
    
         
            +
              * Reporting a bug where using `#capture` inside a widget being rendered via `render :widget => ...` would not work
         
     | 
| 
      
 31 
     | 
    
         
            +
                properly.
         
     | 
| 
       23 
32 
     | 
    
         
             
            * [Adam Becker](https://github.com/ajb) for:
         
     | 
| 
       24 
33 
     | 
    
         
             
              * Discussion and details around exactly what `:attribute => true`, `:attribute => false`, and so on should render
         
     | 
| 
       25 
34 
     | 
    
         
             
                from Fortitude.
         
     | 
| 
      
 35 
     | 
    
         
            +
              * Reporting an issue where you could not easily render a Fortitude widget from Erector, nor vice-versa.
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/lib/fortitude.rb
    CHANGED
    
    
    
        data/lib/fortitude/erector.rb
    CHANGED
    
    | 
         @@ -3,10 +3,12 @@ module Fortitude 
     | 
|
| 
       3 
3 
     | 
    
         
             
                class << self
         
     | 
| 
       4 
4 
     | 
    
         
             
                  def is_erector_available?
         
     | 
| 
       5 
5 
     | 
    
         
             
                    @is_erector_available ||= begin
         
     | 
| 
       6 
     | 
    
         
            -
                       
     | 
| 
       7 
     | 
    
         
            -
                         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                         
     | 
| 
      
 6 
     | 
    
         
            +
                      %w{erector-rails4 erector}.each do |gem_name|
         
     | 
| 
      
 7 
     | 
    
         
            +
                        begin
         
     | 
| 
      
 8 
     | 
    
         
            +
                          gem gem_name
         
     | 
| 
      
 9 
     | 
    
         
            +
                        rescue Gem::LoadError => le
         
     | 
| 
      
 10 
     | 
    
         
            +
                          # ok
         
     | 
| 
      
 11 
     | 
    
         
            +
                        end
         
     | 
| 
       10 
12 
     | 
    
         
             
                      end
         
     | 
| 
       11 
13 
     | 
    
         | 
| 
       12 
14 
     | 
    
         
             
                      begin
         
     | 
| 
         @@ -28,6 +30,45 @@ module Fortitude 
     | 
|
| 
       28 
30 
     | 
    
         
             
                    return false if widget_class == ::Object
         
     | 
| 
       29 
31 
     | 
    
         
             
                    return is_erector_widget_class?(widget_class.superclass)
         
     | 
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def is_erector_widget?(widget)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    is_erector_widget_class?(widget.class)
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                class ErectorOutputBufferHolder
         
     | 
| 
      
 40 
     | 
    
         
            +
                  def initialize(erector_output)
         
     | 
| 
      
 41 
     | 
    
         
            +
                    @erector_output = erector_output
         
     | 
| 
      
 42 
     | 
    
         
            +
                  end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                  def output_buffer
         
     | 
| 
      
 45 
     | 
    
         
            +
                    erector_output.buffer
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  private
         
     | 
| 
      
 49 
     | 
    
         
            +
                  attr_reader :erector_output
         
     | 
| 
       31 
50 
     | 
    
         
             
                end
         
     | 
| 
       32 
51 
     | 
    
         
             
              end
         
     | 
| 
       33 
52 
     | 
    
         
             
            end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            if ::Fortitude::Erector.is_erector_available?
         
     | 
| 
      
 55 
     | 
    
         
            +
              ::Erector::AbstractWidget.class_eval do
         
     | 
| 
      
 56 
     | 
    
         
            +
                def widget_with_fortitude(target, assigns = {}, options = {}, &block)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  if (target.kind_of?(::Class) && target < ::Fortitude::Widget)
         
     | 
| 
      
 58 
     | 
    
         
            +
                    target = target.new(assigns)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  if target.kind_of?(::Fortitude::Widget)
         
     | 
| 
      
 62 
     | 
    
         
            +
                    rendering_context = ::Fortitude::RenderingContext.new(
         
     | 
| 
      
 63 
     | 
    
         
            +
                      :delegate_object => parent,
         
     | 
| 
      
 64 
     | 
    
         
            +
                      :output_buffer_holder => ::Fortitude::Erector::ErectorOutputBufferHolder.new(output),
         
     | 
| 
      
 65 
     | 
    
         
            +
                      :helpers_object => helpers)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    return target.render_to(rendering_context, &block)
         
     | 
| 
      
 67 
     | 
    
         
            +
                  else
         
     | 
| 
      
 68 
     | 
    
         
            +
                    return widget_without_fortitude(target, assigns, options, &block)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  end
         
     | 
| 
      
 70 
     | 
    
         
            +
                end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                alias_method_chain :widget, :fortitude
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -15,6 +15,7 @@ def #{method_name}(content_or_attributes = nil, attributes = nil) 
     | 
|
| 
       15 
15 
     | 
    
         
             
                    _fortitude_raise_no_content_allowed_error(#{tag_object_const})     # :if ! content_allowed
         
     | 
| 
       16 
16 
     | 
    
         
             
                    o.#{concat_method}(#{open_const})
         
     | 
| 
       17 
17 
     | 
    
         
             
                    #{yield_call}
         
     | 
| 
      
 18 
     | 
    
         
            +
                    o = @_fortitude_output_buffer_holder.output_buffer
         
     | 
| 
       18 
19 
     | 
    
         
             
                    o.#{concat_method}(#{close_const})
         
     | 
| 
       19 
20 
     | 
    
         
             
                  else
         
     | 
| 
       20 
21 
     | 
    
         
             
                    o.#{concat_method}(#{alone_const})
         
     | 
| 
         @@ -29,6 +30,7 @@ def #{method_name}(content_or_attributes = nil, attributes = nil) 
     | 
|
| 
       29 
30 
     | 
    
         
             
                    _fortitude_raise_no_content_allowed_error(#{tag_object_const})     # :if ! content_allowed
         
     | 
| 
       30 
31 
     | 
    
         
             
                    o.#{concat_method}(#{partial_open_end_const})
         
     | 
| 
       31 
32 
     | 
    
         
             
                    #{yield_call}
         
     | 
| 
      
 33 
     | 
    
         
            +
                    o = @_fortitude_output_buffer_holder.output_buffer
         
     | 
| 
       32 
34 
     | 
    
         
             
                    o.#{concat_method}(#{close_const})
         
     | 
| 
       33 
35 
     | 
    
         
             
                  else
         
     | 
| 
       34 
36 
     | 
    
         
             
                    o.#{concat_method}(#{partial_open_alone_end_const})
         
     | 
| 
         @@ -42,6 +44,7 @@ def #{method_name}(content_or_attributes = nil, attributes = nil) 
     | 
|
| 
       42 
44 
     | 
    
         
             
                  if block_given?
         
     | 
| 
       43 
45 
     | 
    
         
             
                    _fortitude_raise_no_content_allowed_error(#{tag_object_const})     # :if ! content_allowed
         
     | 
| 
       44 
46 
     | 
    
         
             
                    #{yield_call}
         
     | 
| 
      
 47 
     | 
    
         
            +
                    o = @_fortitude_output_buffer_holder.output_buffer
         
     | 
| 
       45 
48 
     | 
    
         
             
                  end
         
     | 
| 
       46 
49 
     | 
    
         
             
                  o.#{concat_method}(#{close_const})
         
     | 
| 
       47 
50 
     | 
    
         
             
                else
         
     | 
| 
         @@ -58,6 +61,7 @@ def #{method_name}(content_or_attributes = nil, attributes = nil) 
     | 
|
| 
       58 
61 
     | 
    
         
             
                  if block_given?
         
     | 
| 
       59 
62 
     | 
    
         
             
                    _fortitude_raise_no_content_allowed_error(#{tag_object_const})     # :if ! content_allowed
         
     | 
| 
       60 
63 
     | 
    
         
             
                    #{yield_call}
         
     | 
| 
      
 64 
     | 
    
         
            +
                    o = @_fortitude_output_buffer_holder.output_buffer
         
     | 
| 
       61 
65 
     | 
    
         
             
                  end
         
     | 
| 
       62 
66 
     | 
    
         
             
                  o.#{concat_method}(#{close_const})
         
     | 
| 
       63 
67 
     | 
    
         
             
                end
         
     | 
| 
         @@ -25,9 +25,11 @@ module Fortitude 
     | 
|
| 
       25 
25 
     | 
    
         
             
                      return ::Erector::Rails.render(widget, controller.view_context, { }, false, options)
         
     | 
| 
       26 
26 
     | 
    
         
             
                    end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
      
 28 
     | 
    
         
            +
                    view_context = controller.view_context
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       28 
30 
     | 
    
         
             
                    if widget.kind_of?(Class)
         
     | 
| 
       29 
31 
     | 
    
         
             
                      if widget < ::Fortitude::Widget
         
     | 
| 
       30 
     | 
    
         
            -
                        widget = widget.new(widget.extract_needed_assigns_from( 
     | 
| 
      
 32 
     | 
    
         
            +
                        widget = widget.new(widget.extract_needed_assigns_from(view_context.assigns))
         
     | 
| 
       31 
33 
     | 
    
         
             
                      else
         
     | 
| 
       32 
34 
     | 
    
         
             
                        raise "You tried to render something using 'render :widget' that is a class, but not a subclass of Fortitude::Widget: #{widget.inspect}"
         
     | 
| 
       33 
35 
     | 
    
         
             
                      end
         
     | 
| 
         @@ -37,12 +39,16 @@ module Fortitude 
     | 
|
| 
       37 
39 
     | 
    
         
             
                      raise "You tried to render something using 'render :widget' that is neither an instance of a subclass of Fortitude::Widget, nor a class that inherits from Fortitude::Widget: #{widget.inspect}"
         
     | 
| 
       38 
40 
     | 
    
         
             
                    end
         
     | 
| 
       39 
41 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
                    rendering_context = controller.create_fortitude_rendering_context( 
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
                    rendering_context = controller.create_fortitude_rendering_context(
         
     | 
| 
      
 43 
     | 
    
         
            +
                      :helpers_object => view_context, :output_buffer_holder => view_context)
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
                    output_buffer = view_context.with_output_buffer do
         
     | 
| 
      
 46 
     | 
    
         
            +
                      widget.render_to(rendering_context)
         
     | 
| 
      
 47 
     | 
    
         
            +
                    end
         
     | 
| 
       42 
48 
     | 
    
         | 
| 
       43 
49 
     | 
    
         
             
                    passed_options = options.dup
         
     | 
| 
       44 
50 
     | 
    
         
             
                    passed_options.delete(:widget)
         
     | 
| 
       45 
     | 
    
         
            -
                    passed_options[:text] =  
     | 
| 
      
 51 
     | 
    
         
            +
                    passed_options[:text] = output_buffer.to_s
         
     | 
| 
       46 
52 
     | 
    
         
             
                    passed_options[:layout] = true unless passed_options.has_key?(:layout)
         
     | 
| 
       47 
53 
     | 
    
         | 
| 
       48 
54 
     | 
    
         
             
                    return controller.render_to_string(passed_options)
         
     | 
    
        data/lib/fortitude/version.rb
    CHANGED
    
    
| 
         @@ -33,18 +33,46 @@ module Fortitude 
     | 
|
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                  # RUBY CALLBACK
         
     | 
| 
       35 
35 
     | 
    
         
             
                  def method_missing(name, *args, &block)
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                       
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
                    target_method_and_args = _fortitude_target_method_and_args_for_method_missing(name, *args, &block)
         
     | 
| 
      
 37 
     | 
    
         
            +
                    if target_method_and_args
         
     | 
| 
      
 38 
     | 
    
         
            +
                      target = target_method_and_args[0]
         
     | 
| 
      
 39 
     | 
    
         
            +
                      method = target_method_and_args[1]
         
     | 
| 
      
 40 
     | 
    
         
            +
                      args = target_method_and_args[2..-1]
         
     | 
| 
       40 
41 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                      @_fortitude_rendering_context.helpers_object.send(name, *args, &block)
         
     | 
| 
      
 42 
     | 
    
         
            +
                      target.send(method, *args, &block)
         
     | 
| 
       43 
43 
     | 
    
         
             
                    else
         
     | 
| 
       44 
44 
     | 
    
         
             
                      super(name, *args, &block)
         
     | 
| 
       45 
45 
     | 
    
         
             
                    end
         
     | 
| 
       46 
46 
     | 
    
         
             
                  end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
                  def respond_to?(name, include_all = false)
         
     | 
| 
      
 49 
     | 
    
         
            +
                    out = super(name, include_all)
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                    if (! out)
         
     | 
| 
      
 52 
     | 
    
         
            +
                      target_method_and_args = _fortitude_target_method_and_args_for_method_missing(name)
         
     | 
| 
      
 53 
     | 
    
         
            +
                      out = true if target_method_and_args
         
     | 
| 
      
 54 
     | 
    
         
            +
                    end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                    out
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                  def _fortitude_target_method_and_args_for_method_missing(missing_method_name, *missing_method_args, &missing_method_block)
         
     | 
| 
      
 60 
     | 
    
         
            +
                    if self.class.extra_assigns == :use && missing_method_args.length == 0 && (! missing_method_block)
         
     | 
| 
      
 61 
     | 
    
         
            +
                      ivar_name = self.class.instance_variable_name_for_need(missing_method_name)
         
     | 
| 
      
 62 
     | 
    
         
            +
                      return [ self, :instance_variable_get, ivar_name ] if instance_variable_defined?(ivar_name)
         
     | 
| 
      
 63 
     | 
    
         
            +
                    end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                    if self.class.automatic_helper_access && @_fortitude_rendering_context && @_fortitude_rendering_context.helpers_object && @_fortitude_rendering_context.helpers_object.respond_to?(missing_method_name, true)
         
     | 
| 
      
 66 
     | 
    
         
            +
                      return [ @_fortitude_rendering_context.helpers_object, missing_method_name, *missing_method_args ]
         
     | 
| 
      
 67 
     | 
    
         
            +
                    end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                    if @_fortitude_in_block_for_sub_widget
         
     | 
| 
      
 70 
     | 
    
         
            +
                      return [ @_fortitude_in_block_for_sub_widget, missing_method_name, *missing_method_args ]
         
     | 
| 
      
 71 
     | 
    
         
            +
                    end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    nil
         
     | 
| 
      
 74 
     | 
    
         
            +
                  end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
       48 
76 
     | 
    
         
             
                  included do
         
     | 
| 
       49 
77 
     | 
    
         
             
                    _fortitude_on_class_inheritable_attribute_change(
         
     | 
| 
       50 
78 
     | 
    
         
             
                      :format_output, :enforce_element_nesting_rules, :record_tag_emission) do |attribute_name, old_value, new_value|
         
     | 
| 
         @@ -47,7 +47,7 @@ module Fortitude 
     | 
|
| 
       47 
47 
     | 
    
         
             
                      const_set(:DefinedFortitudeHelpers, @helpers_module)
         
     | 
| 
       48 
48 
     | 
    
         
             
                      @needs_module = Module.new
         
     | 
| 
       49 
49 
     | 
    
         
             
                      include @needs_module
         
     | 
| 
       50 
     | 
    
         
            -
                      const_set(:FortitudeNeedsMethods, @ 
     | 
| 
      
 50 
     | 
    
         
            +
                      const_set(:FortitudeNeedsMethods, @needs_module)
         
     | 
| 
       51 
51 
     | 
    
         
             
                    end
         
     | 
| 
       52 
52 
     | 
    
         
             
                    private :create_modules!
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
         @@ -64,6 +64,11 @@ module Fortitude 
     | 
|
| 
       64 
64 
     | 
    
         
             
                      end
         
     | 
| 
       65 
65 
     | 
    
         
             
                    end
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
      
 67 
     | 
    
         
            +
                    # INTERNAL USE ONLY
         
     | 
| 
      
 68 
     | 
    
         
            +
                    def my_needs_as_hash
         
     | 
| 
      
 69 
     | 
    
         
            +
                      @this_class_needs ||= { }
         
     | 
| 
      
 70 
     | 
    
         
            +
                    end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
       67 
72 
     | 
    
         
             
                    # INTERNAL USE ONLY
         
     | 
| 
       68 
73 
     | 
    
         
             
                    def invalidate_needs!(why, klass = self)
         
     | 
| 
       69 
74 
     | 
    
         
             
                      invalidating(:needs, why, klass) do
         
     | 
| 
         @@ -117,10 +122,11 @@ module Fortitude 
     | 
|
| 
       117 
122 
     | 
    
         
             
                    end
         
     | 
| 
       118 
123 
     | 
    
         | 
| 
       119 
124 
     | 
    
         
             
                    def rebuild_my_needs_methods!
         
     | 
| 
       120 
     | 
    
         
            -
                       
     | 
| 
      
 125 
     | 
    
         
            +
                      all_needs_as_hash = needs_as_hash
         
     | 
| 
      
 126 
     | 
    
         
            +
                      mnah = my_needs_as_hash
         
     | 
| 
       121 
127 
     | 
    
         | 
| 
       122 
128 
     | 
    
         
             
                      start_time = Time.now
         
     | 
| 
       123 
     | 
    
         
            -
                      needs_text =  
     | 
| 
      
 129 
     | 
    
         
            +
                      needs_text = all_needs_as_hash.map do |need, default_value|
         
     | 
| 
       124 
130 
     | 
    
         
             
                        Fortitude::MethodTemplates::SimpleCompiledTemplate.template('need_assignment_template').result(:extra_assigns => extra_assigns,
         
     | 
| 
       125 
131 
     | 
    
         
             
                          :need => need, :has_default => (default_value != REQUIRED_NEED),
         
     | 
| 
       126 
132 
     | 
    
         
             
                          :ivar_name => instance_variable_name_for_need(need)
         
     | 
| 
         @@ -131,7 +137,7 @@ module Fortitude 
     | 
|
| 
       131 
137 
     | 
    
         
             
                        :extra_assigns => extra_assigns, :needs_text => needs_text)
         
     | 
| 
       132 
138 
     | 
    
         | 
| 
       133 
139 
     | 
    
         
             
                      needs_methods_text = ""
         
     | 
| 
       134 
     | 
    
         
            -
                       
     | 
| 
      
 140 
     | 
    
         
            +
                      mnah.each do |need, default_value|
         
     | 
| 
       135 
141 
     | 
    
         
             
                        needs_methods_text << (Fortitude::MethodTemplates::SimpleCompiledTemplate.template('need_method_template').result(
         
     | 
| 
       136 
142 
     | 
    
         
             
                          :need => need, :ivar_name => instance_variable_name_for_need(need),
         
     | 
| 
       137 
143 
     | 
    
         
             
                          :debug => self.debug))
         
     | 
| 
         @@ -164,6 +170,11 @@ module Fortitude 
     | 
|
| 
       164 
170 
     | 
    
         
             
                    @_fortitude_needs_as_hash ||= self.class.needs_as_hash
         
     | 
| 
       165 
171 
     | 
    
         
             
                  end
         
     | 
| 
       166 
172 
     | 
    
         | 
| 
      
 173 
     | 
    
         
            +
                  # INTERNAL USE ONLY
         
     | 
| 
      
 174 
     | 
    
         
            +
                  def my_needs_as_hash
         
     | 
| 
      
 175 
     | 
    
         
            +
                    @_fortitude_my_needs_as_hash ||= self.class.my_needs_as_hash
         
     | 
| 
      
 176 
     | 
    
         
            +
                  end
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
       167 
178 
     | 
    
         
             
                  # PUBLIC API
         
     | 
| 
       168 
179 
     | 
    
         
             
                  def assigns
         
     | 
| 
       169 
180 
     | 
    
         
             
                    @_fortitude_assigns_proxy ||= begin
         
     | 
| 
         @@ -53,11 +53,23 @@ module Fortitude 
     | 
|
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                  # PUBLIC API
         
     | 
| 
       55 
55 
     | 
    
         
             
                  def widget(w, hash = nil, &block)
         
     | 
| 
       56 
     | 
    
         
            -
                    if w. 
     | 
| 
       57 
     | 
    
         
            -
                      w.render_to(@_fortitude_rendering_context, &block)
         
     | 
| 
       58 
     | 
    
         
            -
                    elsif w.kind_of?(Class)
         
     | 
| 
      
 56 
     | 
    
         
            +
                    if w.kind_of?(Class) && ((w < ::Fortitude::Widget) || ::Fortitude::Erector.is_erector_widget_class?(w))
         
     | 
| 
       59 
57 
     | 
    
         
             
                      hash ||= { }
         
     | 
| 
       60 
     | 
    
         
            -
                      w.new(hash 
     | 
| 
      
 58 
     | 
    
         
            +
                      w = w.new(hash)
         
     | 
| 
      
 59 
     | 
    
         
            +
                    end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                    if w.kind_of?(::Fortitude::Widget)
         
     | 
| 
      
 62 
     | 
    
         
            +
                      begin
         
     | 
| 
      
 63 
     | 
    
         
            +
                        @_fortitude_in_block_for_sub_widget = w if block
         
     | 
| 
      
 64 
     | 
    
         
            +
                        w.render_to(@_fortitude_rendering_context, &block)
         
     | 
| 
      
 65 
     | 
    
         
            +
                      ensure
         
     | 
| 
      
 66 
     | 
    
         
            +
                        @_fortitude_in_block_for_sub_widget = nil
         
     | 
| 
      
 67 
     | 
    
         
            +
                      end
         
     | 
| 
      
 68 
     | 
    
         
            +
                    elsif ::Fortitude::Erector.is_erector_widget?(w)
         
     | 
| 
      
 69 
     | 
    
         
            +
                      w.send(:_emit,
         
     | 
| 
      
 70 
     | 
    
         
            +
                        :parent => rendering_context.helpers_object,
         
     | 
| 
      
 71 
     | 
    
         
            +
                        :helpers => rendering_context.helpers_object,
         
     | 
| 
      
 72 
     | 
    
         
            +
                        :output => rendering_context.output_buffer_holder.output_buffer)
         
     | 
| 
       61 
73 
     | 
    
         
             
                    else
         
     | 
| 
       62 
74 
     | 
    
         
             
                      raise "You tried to render a widget, but this is not valid: #{w.inspect}(#{hash.inspect})"
         
     | 
| 
       63 
75 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -103,15 +115,15 @@ module Fortitude 
     | 
|
| 
       103 
115 
     | 
    
         
             
                    if @_fortitude_block_for_content_method
         
     | 
| 
       104 
116 
     | 
    
         
             
                      @_fortitude_block_for_content_method.call(*args)
         
     | 
| 
       105 
117 
     | 
    
         
             
                    elsif @_fortitude_constructor_block
         
     | 
| 
       106 
     | 
    
         
            -
                      @_fortitude_constructor_block.call(*args)
         
     | 
| 
      
 118 
     | 
    
         
            +
                      @_fortitude_constructor_block.call(self, *args)
         
     | 
| 
       107 
119 
     | 
    
         
             
                    else
         
     | 
| 
       108 
     | 
    
         
            -
                      @_fortitude_rendering_context.yield_from_widget(*args)
         
     | 
| 
      
 120 
     | 
    
         
            +
                      @_fortitude_rendering_context.yield_from_widget(self, *args)
         
     | 
| 
       109 
121 
     | 
    
         
             
                    end
         
     | 
| 
       110 
122 
     | 
    
         
             
                  end
         
     | 
| 
       111 
123 
     | 
    
         | 
| 
       112 
124 
     | 
    
         
             
                  # PUBLIC API
         
     | 
| 
       113 
125 
     | 
    
         
             
                  def yield_from_widget(*args)
         
     | 
| 
       114 
     | 
    
         
            -
                    _fortitude_yield_from_widget( 
     | 
| 
      
 126 
     | 
    
         
            +
                    _fortitude_yield_from_widget(*args)
         
     | 
| 
       115 
127 
     | 
    
         
             
                  end
         
     | 
| 
       116 
128 
     | 
    
         | 
| 
       117 
129 
     | 
    
         
             
                  # PUBLIC API (Erector compatibility)
         
     | 
| 
         @@ -59,6 +59,9 @@ module SystemHelpers 
     | 
|
| 
       59 
59 
     | 
    
         
             
                tag :b
         
     | 
| 
       60 
60 
     | 
    
         
             
                tag :nav, :newline_before => true
         
     | 
| 
       61 
61 
     | 
    
         
             
                tag :h1, :newline_before => true
         
     | 
| 
      
 62 
     | 
    
         
            +
                tag :h3, :newline_before => true
         
     | 
| 
      
 63 
     | 
    
         
            +
                tag :h5, :newline_before => true
         
     | 
| 
      
 64 
     | 
    
         
            +
                tag :button, :newline_before => true
         
     | 
| 
       62 
65 
     | 
    
         
             
                tag :img, :content_allowed => false
         
     | 
| 
       63 
66 
     | 
    
         
             
                tag :script, :newline_before => true, :escape_direct_content => false
         
     | 
| 
       64 
67 
     | 
    
         
             
                tag :head, :newline_before => true
         
     | 
| 
         @@ -30,4 +30,34 @@ describe "Rails complex helper support", :type => :rails do 
     | 
|
| 
       30 
30 
     | 
    
         
             
                expect_match("cache_test?a=a2&b=b2",
         
     | 
| 
       31 
31 
     | 
    
         
             
                  /before_cache\(a2,b2\).*inside_cache\(a2,b2\).*after_cache\(a2,b2\)/mi)
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              it "should cache with nesting in tags properly" do
         
     | 
| 
      
 35 
     | 
    
         
            +
                expect_match("cache_tags_test?a=a1&b=b1",
         
     | 
| 
      
 36 
     | 
    
         
            +
                  %r{<p\s+class="before_cache">\s*
         
     | 
| 
      
 37 
     | 
    
         
            +
                      <span>before_cache:\s*a=a1,b=b1</span>\s*
         
     | 
| 
      
 38 
     | 
    
         
            +
                      <p\s+class="in_cache">\s*
         
     | 
| 
      
 39 
     | 
    
         
            +
                        <span>in_cache:\s*a=a1,b=b1</span>\s*
         
     | 
| 
      
 40 
     | 
    
         
            +
                      </p>\s*
         
     | 
| 
      
 41 
     | 
    
         
            +
                      <span>after_cache:\s*a=a1,b=b1</span>\s*
         
     | 
| 
      
 42 
     | 
    
         
            +
                     </p>\s*
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                     <p\s+class="after_cache_2">\s*
         
     | 
| 
      
 45 
     | 
    
         
            +
                       <span>after_cache_2:\s*a=a1,b=b1</span>\s*
         
     | 
| 
      
 46 
     | 
    
         
            +
                     </p>}mix
         
     | 
| 
      
 47 
     | 
    
         
            +
                  )
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                expect_match("cache_tags_test?a=a1&b=b2",
         
     | 
| 
      
 50 
     | 
    
         
            +
                  %r{<p\s+class="before_cache">\s*
         
     | 
| 
      
 51 
     | 
    
         
            +
                      <span>before_cache:\s*a=a1,b=b2</span>\s*
         
     | 
| 
      
 52 
     | 
    
         
            +
                      <p\s+class="in_cache">\s*
         
     | 
| 
      
 53 
     | 
    
         
            +
                        <span>in_cache:\s*a=a1,b=b1</span>\s*
         
     | 
| 
      
 54 
     | 
    
         
            +
                      </p>\s*
         
     | 
| 
      
 55 
     | 
    
         
            +
                      <span>after_cache:\s*a=a1,b=b2</span>\s*
         
     | 
| 
      
 56 
     | 
    
         
            +
                     </p>\s*
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                     <p\s+class="after_cache_2">\s*
         
     | 
| 
      
 59 
     | 
    
         
            +
                       <span>after_cache_2:\s*a=a1,b=b2</span>\s*
         
     | 
| 
      
 60 
     | 
    
         
            +
                     </p>}mix
         
     | 
| 
      
 61 
     | 
    
         
            +
                  )
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
       33 
63 
     | 
    
         
             
            end
         
     | 
| 
         @@ -45,5 +45,25 @@ describe "Erector coexistence support", :type => :rails do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                it "should be able to render an Erector widget with just a class using render :widget" do
         
     | 
| 
       46 
46 
     | 
    
         
             
                  expect_match("render_widget_erector_class", /this is an Erector widget/, :no_layout => true)
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                it "should be able to render an Erector widget from a Fortitude widget using just 'widget'" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  expect_match("render_erector_widget_from_fortitude_widget",
         
     | 
| 
      
 51 
     | 
    
         
            +
                    %r{before erector widget: this is my_helper\!\s*inside erector widget: this is my_helper\!, passed_foo\s*after erector widget: this is my_helper\!}mi)
         
     | 
| 
      
 52 
     | 
    
         
            +
                end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                it "should be able to render an Erector widget from a Fortitude widget using just 'widget' with an instantiated widget" do
         
     | 
| 
      
 55 
     | 
    
         
            +
                  expect_match("render_erector_widget_from_fortitude_widget?instantiate_widget=true",
         
     | 
| 
      
 56 
     | 
    
         
            +
                    %r{before erector widget: this is my_helper\!\s*inside erector widget: this is my_helper\!, passed_foo\s*after erector widget: this is my_helper\!}mi)
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                it "should be able to render a Fortitude widget from an Erector widget using just 'widget'" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                  expect_match("render_fortitude_widget_from_erector_widget",
         
     | 
| 
      
 61 
     | 
    
         
            +
                    %r{before fortitude widget: this is my_helper\!\s*inside fortitude widget: this is my_helper\!, passed_foo\s*after fortitude widget: this is my_helper\!}mi)
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                it "should be able to render a Fortitude widget from an Erector widget using just 'widget' with an instantiated widget" do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  expect_match("render_fortitude_widget_from_erector_widget?instantiate_widget=true",
         
     | 
| 
      
 66 
     | 
    
         
            +
                    %r{before fortitude widget: this is my_helper\!\s*inside fortitude widget: this is my_helper\!, passed_foo\s*after fortitude widget: this is my_helper\!}mi)
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
       48 
68 
     | 
    
         
             
              end
         
     | 
| 
       49 
69 
     | 
    
         
             
            end
         
     | 
| 
         @@ -24,6 +24,10 @@ describe "Rails rendering support", :type => :rails do 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  expect_match("render_widget_with_helper", /hello from a widget named Judy/)
         
     | 
| 
       25 
25 
     | 
    
         
             
                end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
      
 27 
     | 
    
         
            +
                it "should let you use #capture from within a widget passed to 'render :widget =>'" do
         
     | 
| 
      
 28 
     | 
    
         
            +
                  expect_match("render_widget_with_capture", %r{<p class="one">before_captureafter_capture</p><p class="two">before_splat<p>inside_capture</p>after_splat</p>})
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       27 
31 
     | 
    
         
             
                it "should let you specify just a widget class with 'render :widget =>'" do
         
     | 
| 
       28 
32 
     | 
    
         
             
                  expect_match("render_widget_class_only", /hello from a simple widget/)
         
     | 
| 
       29 
33 
     | 
    
         
             
                end
         
     | 
| 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Views::ComplexHelpersSystemSpec::CacheTagsTest < Fortitude::Widgets::Html5
         
     | 
| 
      
 2 
     | 
    
         
            +
              needs :a, :b
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              format_output true
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def content
         
     | 
| 
      
 7 
     | 
    
         
            +
                p(:class => 'before_cache') do
         
     | 
| 
      
 8 
     | 
    
         
            +
                  span "before_cache: a=#{a},b=#{b}"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                  cache("cache_tags_test-#{a}") do
         
     | 
| 
      
 11 
     | 
    
         
            +
                    p(:class => "in_cache") do
         
     | 
| 
      
 12 
     | 
    
         
            +
                      span "in_cache: a=#{a},b=#{b}"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    end
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  span("after_cache: a=#{a},b=#{b}")
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                p(:class => "after_cache_2") do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  span "after_cache_2: a=#{a},b=#{b}"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -3,8 +3,7 @@ class Views::ComplexHelpersSystemSpec::CacheTest < Fortitude::Widgets::Html5 
     | 
|
| 
       3 
3 
     | 
    
         | 
| 
       4 
4 
     | 
    
         
             
              def content
         
     | 
| 
       5 
5 
     | 
    
         
             
                text "before_cache(#{a},#{b})"
         
     | 
| 
       6 
     | 
    
         
            -
                 
     | 
| 
       7 
     | 
    
         
            -
                cache(a) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                cache("cache_test-#{a}") do
         
     | 
| 
       8 
7 
     | 
    
         
             
                  text "inside_cache(#{a},#{b})"
         
     | 
| 
       9 
8 
     | 
    
         
             
                end
         
     | 
| 
       10 
9 
     | 
    
         
             
                text "after_cache(#{a},#{b})"
         
     | 
| 
         @@ -32,4 +32,12 @@ class ErectorCoexistenceSystemSpecController < ApplicationController 
     | 
|
| 
       32 
32 
     | 
    
         
             
              def render_widget_erector_class
         
     | 
| 
       33 
33 
     | 
    
         
             
                render :widget => ::Views::ErectorWidget
         
     | 
| 
       34 
34 
     | 
    
         
             
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              def render_erector_widget_from_fortitude_widget
         
     | 
| 
      
 37 
     | 
    
         
            +
                @instantiate_widget = !! (params[:instantiate_widget] == "true")
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              def render_fortitude_widget_from_erector_widget
         
     | 
| 
      
 41 
     | 
    
         
            +
                @instantiate_widget = !! (params[:instantiate_widget] == "true")
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
       35 
43 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Views::ErectorCoexistenceSystemSpec::RenderErectorWidgetFromFortitudeWidget < Fortitude::Widgets::Html5
         
     | 
| 
      
 2 
     | 
    
         
            +
              needs :instantiate_widget
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              def content
         
     | 
| 
      
 5 
     | 
    
         
            +
                text "before erector widget: #{my_helper}"
         
     | 
| 
      
 6 
     | 
    
         
            +
                if instantiate_widget
         
     | 
| 
      
 7 
     | 
    
         
            +
                  widget Views::ErectorCoexistenceSystemSpec::ErectorWidgetFromFortitudeWidget.new(:foo => 'passed_foo')
         
     | 
| 
      
 8 
     | 
    
         
            +
                else
         
     | 
| 
      
 9 
     | 
    
         
            +
                  widget Views::ErectorCoexistenceSystemSpec::ErectorWidgetFromFortitudeWidget, :foo => 'passed_foo'
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
                text "after erector widget: #{my_helper}"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Views::ErectorCoexistenceSystemSpec::RenderFortitudeWidgetFromErectorWidget < ::Erector::Widget
         
     | 
| 
      
 2 
     | 
    
         
            +
              needs :instantiate_widget
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              def content
         
     | 
| 
      
 5 
     | 
    
         
            +
                text "before fortitude widget: #{my_helper}"
         
     | 
| 
      
 6 
     | 
    
         
            +
                if @instantiate_widget
         
     | 
| 
      
 7 
     | 
    
         
            +
                  widget Views::ErectorCoexistenceSystemSpec::FortitudeWidgetFromErectorWidget.new(:foo => 'passed_foo')
         
     | 
| 
      
 8 
     | 
    
         
            +
                else
         
     | 
| 
      
 9 
     | 
    
         
            +
                  widget Views::ErectorCoexistenceSystemSpec::FortitudeWidgetFromErectorWidget, :foo => 'passed_foo'
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
                text "after fortitude widget: #{my_helper}"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/rails/templates/rendering_system_spec/app/controllers/rendering_system_spec_controller.rb
    CHANGED
    
    | 
         @@ -15,6 +15,10 @@ class RenderingSystemSpecController < ApplicationController 
     | 
|
| 
       15 
15 
     | 
    
         
             
                render :widget => Views::WidgetToRenderWithHelper.new
         
     | 
| 
       16 
16 
     | 
    
         
             
              end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
      
 18 
     | 
    
         
            +
              def render_widget_with_capture
         
     | 
| 
      
 19 
     | 
    
         
            +
                render :widget => Views::WidgetToRenderWithCapture.new
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
       18 
22 
     | 
    
         
             
              def render_widget_class_only
         
     | 
| 
       19 
23 
     | 
    
         
             
                render :widget => Views::WidgetToRenderClassOnly
         
     | 
| 
       20 
24 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Views::WidgetToRenderWithCapture < ::Fortitude::Widgets::Html5
         
     | 
| 
      
 2 
     | 
    
         
            +
              def content
         
     | 
| 
      
 3 
     | 
    
         
            +
                x = nil
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
                p(:class => 'one') {
         
     | 
| 
      
 6 
     | 
    
         
            +
                  text "before_capture"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  x = capture {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    p "inside_capture"
         
     | 
| 
      
 9 
     | 
    
         
            +
                  }
         
     | 
| 
      
 10 
     | 
    
         
            +
                  text "after_capture"
         
     | 
| 
      
 11 
     | 
    
         
            +
                }
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                p(:class => 'two') {
         
     | 
| 
      
 14 
     | 
    
         
            +
                  text "before_splat"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  rawtext(x)
         
     | 
| 
      
 16 
     | 
    
         
            +
                  text "after_splat"
         
     | 
| 
      
 17 
     | 
    
         
            +
                }
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -44,6 +44,18 @@ describe "Fortitude assigns access", :type => :system do 
     | 
|
| 
       44 
44 
     | 
    
         
             
                expect(render(wc.new(:foo => 'the_foo', :bar => 'the_bar'))).to eq("assigns[:foo] = the_foo, assigns[:bar] = the_bar")
         
     | 
| 
       45 
45 
     | 
    
         
             
              end
         
     | 
| 
       46 
46 
     | 
    
         | 
| 
      
 47 
     | 
    
         
            +
              it "should allow accessing extra assigns via method, and also indicate respond_to?" do
         
     | 
| 
      
 48 
     | 
    
         
            +
                wc = widget_class do
         
     | 
| 
      
 49 
     | 
    
         
            +
                  extra_assigns :use
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 52 
     | 
    
         
            +
                    text "foo = #{foo}, respond_to? #{respond_to?(:foo).inspect}"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                expect(render(wc.new(:foo => 'the_foo'))).to eq("foo = the_foo, respond_to? true")
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
       47 
59 
     | 
    
         
             
              it "should allow changing assigns, and always return the current value of the assign" do
         
     | 
| 
       48 
60 
     | 
    
         
             
                wc = widget_class do
         
     | 
| 
       49 
61 
     | 
    
         
             
                  needs :foo
         
     | 
| 
         @@ -93,6 +93,12 @@ describe "Fortitude helper support", :type => :system do 
     | 
|
| 
       93 
93 
     | 
    
         
             
                expect(render(widget_class_with_content { helper3("ho") })).to eq("this is ho helper3")
         
     | 
| 
       94 
94 
     | 
    
         
             
              end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
      
 96 
     | 
    
         
            +
              it "should indicate that it responds to helpers using respond_to? for automatic helper methods" do
         
     | 
| 
      
 97 
     | 
    
         
            +
                expect(render(widget_class_with_content { text "respond_to helper1: #{respond_to?(:helper1)}" } )).to eq("respond_to helper1: true")
         
     | 
| 
      
 98 
     | 
    
         
            +
                expect(render(widget_class_with_content { text "respond_to helper2: #{respond_to?(:helper2)}" } )).to eq("respond_to helper2: true")
         
     | 
| 
      
 99 
     | 
    
         
            +
                expect(render(widget_class_with_content { text "respond_to helper3: #{respond_to?(:helper3)}" } )).to eq("respond_to helper3: true")
         
     | 
| 
      
 100 
     | 
    
         
            +
              end
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
       96 
102 
     | 
    
         
             
              it "should not allow automatic access to helpers if we say not to" do
         
     | 
| 
       97 
103 
     | 
    
         
             
                wc = widget_class do
         
     | 
| 
       98 
104 
     | 
    
         
             
                  automatic_helper_access false
         
     | 
| 
         @@ -45,4 +45,26 @@ describe "Fortitude method precedence", :type => :system do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                expect(render(wc, :rendering_context => rc(
         
     | 
| 
       46 
46 
     | 
    
         
             
                  :helpers_object => helpers_object))).to eq("foo: method foo, bar: need_bar, baz: helper_baz, <quux></quux>")
         
     | 
| 
       47 
47 
     | 
    
         
             
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              it "should let you override 'needs' methods in superclasses, and have them still apply in subclasses" do
         
     | 
| 
      
 50 
     | 
    
         
            +
                wc_parent = widget_class do
         
     | 
| 
      
 51 
     | 
    
         
            +
                  needs :foo, :bar => 'default_bar'
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  def foo
         
     | 
| 
      
 54 
     | 
    
         
            +
                    "pre#{super}post"
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 58 
     | 
    
         
            +
                    text "parent: foo: #{foo}, bar: #{bar}"
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                wc_child = widget_class(:superclass => wc_parent) do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 64 
     | 
    
         
            +
                    text "child: foo: #{foo}, bar: #{bar}"
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                expect(render(wc_child.new(:foo => 'supplied_foo'))).to eq("child: foo: presupplied_foopost, bar: default_bar")
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
       48 
70 
     | 
    
         
             
            end
         
     | 
| 
         @@ -577,6 +577,14 @@ describe "Fortitude setting inheritance", :type => :system do 
     | 
|
| 
       577 
577 
     | 
    
         
             
                  end
         
     | 
| 
       578 
578 
     | 
    
         
             
                end
         
     | 
| 
       579 
579 
     | 
    
         | 
| 
      
 580 
     | 
    
         
            +
                # We need to redefine this method on all child classes, because we let 'needs' methods inherit -- and only
         
     | 
| 
      
 581 
     | 
    
         
            +
                # build such methods if the need is defined on the class in question. Without this, the only class that will
         
     | 
| 
      
 582 
     | 
    
         
            +
                # actually define the method is @grandparent, and so none of the children will actually be affected when we set
         
     | 
| 
      
 583 
     | 
    
         
            +
                # .debug on them.
         
     | 
| 
      
 584 
     | 
    
         
            +
                [ @parent1, @child11, @child12, @parent2, @child21, @child22 ].each do |klass|
         
     | 
| 
      
 585 
     | 
    
         
            +
                  klass.send(:needs, :p => 'abc')
         
     | 
| 
      
 586 
     | 
    
         
            +
                end
         
     | 
| 
      
 587 
     | 
    
         
            +
             
     | 
| 
       580 
588 
     | 
    
         
             
                debug_should_be(false, @grandparent, @parent1, @child11, @child12, @parent2, @child21, @child22)
         
     | 
| 
       581 
589 
     | 
    
         | 
| 
       582 
590 
     | 
    
         
             
                @parent1.debug true
         
     | 
| 
         @@ -185,4 +185,156 @@ describe "Fortitude widgets and 'yield'", :type => :system do 
     | 
|
| 
       185 
185 
     | 
    
         | 
| 
       186 
186 
     | 
    
         
             
                expect(render(wc.new { |widget| widget.text "constructor" }, :rendering_context => the_rc)).to eq("beforeinner_beforemiddleinner_afterafter")
         
     | 
| 
       187 
187 
     | 
    
         
             
              end
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
              it "should evaluate blocks passed to #widget in their defining context, but allow falling back to child-widget methods (but only as a recourse)" do
         
     | 
| 
      
 190 
     | 
    
         
            +
                wc_sub = widget_class do
         
     | 
| 
      
 191 
     | 
    
         
            +
                  def baz
         
     | 
| 
      
 192 
     | 
    
         
            +
                    "sub_baz"
         
     | 
| 
      
 193 
     | 
    
         
            +
                  end
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
                  def quux
         
     | 
| 
      
 196 
     | 
    
         
            +
                    "sub_quux"
         
     | 
| 
      
 197 
     | 
    
         
            +
                  end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 200 
     | 
    
         
            +
                    text "sub_before"
         
     | 
| 
      
 201 
     | 
    
         
            +
                    yield
         
     | 
| 
      
 202 
     | 
    
         
            +
                    text "sub_after"
         
     | 
| 
      
 203 
     | 
    
         
            +
                  end
         
     | 
| 
      
 204 
     | 
    
         
            +
                end
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
                wc_parent = widget_class do
         
     | 
| 
      
 207 
     | 
    
         
            +
                  cattr_accessor :wc_sub
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
                  needs :foo
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                  def bar
         
     | 
| 
      
 212 
     | 
    
         
            +
                    "wc_bar"
         
     | 
| 
      
 213 
     | 
    
         
            +
                  end
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                  def baz
         
     | 
| 
      
 216 
     | 
    
         
            +
                    "wc_baz"
         
     | 
| 
      
 217 
     | 
    
         
            +
                  end
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 220 
     | 
    
         
            +
                    text "before"
         
     | 
| 
      
 221 
     | 
    
         
            +
                    widget wc_sub.new do
         
     | 
| 
      
 222 
     | 
    
         
            +
                      text "in block: #{foo}, #{bar}, #{baz}, #{quux}"
         
     | 
| 
      
 223 
     | 
    
         
            +
                      text "respond: #{respond_to?(:foo).inspect}, #{respond_to?(:bar).inspect}, #{respond_to?(:baz).inspect}, #{respond_to?(:quux).inspect}"
         
     | 
| 
      
 224 
     | 
    
         
            +
                    end
         
     | 
| 
      
 225 
     | 
    
         
            +
                    text "after"
         
     | 
| 
      
 226 
     | 
    
         
            +
                  end
         
     | 
| 
      
 227 
     | 
    
         
            +
                end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                wc_parent.wc_sub = wc_sub
         
     | 
| 
      
 230 
     | 
    
         
            +
             
     | 
| 
      
 231 
     | 
    
         
            +
                expect(render(wc_parent.new(:foo => 'passed_foo'))).to eq("beforesub_beforein block: passed_foo, wc_bar, wc_baz, sub_quuxrespond: true, true, true, truesub_afterafter")
         
     | 
| 
      
 232 
     | 
    
         
            +
              end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
              it "should allow creating an elegant modal-dialog widget" do
         
     | 
| 
      
 235 
     | 
    
         
            +
                parent_class = widget_class do
         
     | 
| 
      
 236 
     | 
    
         
            +
                  format_output true
         
     | 
| 
      
 237 
     | 
    
         
            +
                end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                modal_dialog_module = Module.new do
         
     | 
| 
      
 240 
     | 
    
         
            +
                  mattr_accessor :modal_dialog_class
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                  def modal_dialog(title, options = { }, &block)
         
     | 
| 
      
 243 
     | 
    
         
            +
                    widget(modal_dialog_class.new(options.merge(:title => title)), &block)
         
     | 
| 
      
 244 
     | 
    
         
            +
                  end
         
     | 
| 
      
 245 
     | 
    
         
            +
                end
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
                modal_section_class = widget_class(:superclass => parent_class) do
         
     | 
| 
      
 248 
     | 
    
         
            +
                  needs :section_title
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 251 
     | 
    
         
            +
                    div(:class => 'modal_section') do
         
     | 
| 
      
 252 
     | 
    
         
            +
                      h5 "Modal section: #{section_title}"
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
                      yield("#{section_title}345", "456#{section_title}")
         
     | 
| 
      
 255 
     | 
    
         
            +
                    end
         
     | 
| 
      
 256 
     | 
    
         
            +
                  end
         
     | 
| 
      
 257 
     | 
    
         
            +
                end
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                modal_dialog_class = widget_class(:superclass => parent_class) do
         
     | 
| 
      
 260 
     | 
    
         
            +
                  cattr_accessor :modal_section_class
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                  needs :title, :button_text => 'Go!'
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 265 
     | 
    
         
            +
                    div(:class => 'modal_dialog') do
         
     | 
| 
      
 266 
     | 
    
         
            +
                      h3 "Modal title: #{title}"
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
                      yield("#{title}123", "234#{title}")
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                      button button_text, :class => 'modal_button'
         
     | 
| 
      
 271 
     | 
    
         
            +
                    end
         
     | 
| 
      
 272 
     | 
    
         
            +
                  end
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
                  def modal_section(title, &block)
         
     | 
| 
      
 275 
     | 
    
         
            +
                    widget(modal_section_class.new(:section_title => title), &block)
         
     | 
| 
      
 276 
     | 
    
         
            +
                  end
         
     | 
| 
      
 277 
     | 
    
         
            +
                end
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
      
 279 
     | 
    
         
            +
                modal_dialog_class.modal_section_class = modal_section_class
         
     | 
| 
      
 280 
     | 
    
         
            +
                modal_dialog_module.modal_dialog_class = modal_dialog_class
         
     | 
| 
      
 281 
     | 
    
         
            +
             
     | 
| 
      
 282 
     | 
    
         
            +
                wc = widget_class(:superclass => parent_class) do
         
     | 
| 
      
 283 
     | 
    
         
            +
                  needs :name
         
     | 
| 
      
 284 
     | 
    
         
            +
             
     | 
| 
      
 285 
     | 
    
         
            +
                  def banner(text)
         
     | 
| 
      
 286 
     | 
    
         
            +
                    p(text, :class => 'banner')
         
     | 
| 
      
 287 
     | 
    
         
            +
                  end
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                  def content
         
     | 
| 
      
 290 
     | 
    
         
            +
                    h1 "Name: #{name}"
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
                    modal_dialog('Details', :button_text => 'Submit Details') { |modal_arg1, modal_arg2|
         
     | 
| 
      
 293 
     | 
    
         
            +
                      banner "Before details modal_section for #{name}: #{modal_arg1}, #{modal_arg2}"
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
                      modal_section("Details for #{name}") { |section_arg1, section_arg2|
         
     | 
| 
      
 296 
     | 
    
         
            +
                        p "These are the details for #{name}: #{section_arg1}, #{section_arg2}"
         
     | 
| 
      
 297 
     | 
    
         
            +
                      }
         
     | 
| 
      
 298 
     | 
    
         
            +
             
     | 
| 
      
 299 
     | 
    
         
            +
                      p "After details modal_section for #{name}"
         
     | 
| 
      
 300 
     | 
    
         
            +
                    }
         
     | 
| 
      
 301 
     | 
    
         
            +
             
     | 
| 
      
 302 
     | 
    
         
            +
                    modal_dialog('Security', :button_text => 'Submit Security') { |modal_arg1, modal_arg2|
         
     | 
| 
      
 303 
     | 
    
         
            +
                      banner "Before security modal_section for #{name}: #{modal_arg1}, #{modal_arg2}"
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
                      modal_section("Security for #{name}") { |section_arg1, section_arg2|
         
     | 
| 
      
 306 
     | 
    
         
            +
                        text "These are the security settings for #{name}: #{section_arg1}, #{section_arg2}"
         
     | 
| 
      
 307 
     | 
    
         
            +
                      }
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
                      text "After security modal_section for #{name}"
         
     | 
| 
      
 310 
     | 
    
         
            +
                    }
         
     | 
| 
      
 311 
     | 
    
         
            +
                  end
         
     | 
| 
      
 312 
     | 
    
         
            +
                end
         
     | 
| 
      
 313 
     | 
    
         
            +
             
     | 
| 
      
 314 
     | 
    
         
            +
                wc.send(:include, modal_dialog_module)
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
                expect(render(wc.new(:name => 'Jones'))).to match(%r{
         
     | 
| 
      
 317 
     | 
    
         
            +
                  <h1>Name:\ Jones</h1>\s+
         
     | 
| 
      
 318 
     | 
    
         
            +
                  <div\ class="modal_dialog">\s+
         
     | 
| 
      
 319 
     | 
    
         
            +
                    <h3>Modal\ title:\ Details</h3>\s+
         
     | 
| 
      
 320 
     | 
    
         
            +
                    <p\ class="banner">Before\ details\ modal_section\ for\ Jones:\ Details123,\ 234Details</p>\s+
         
     | 
| 
      
 321 
     | 
    
         
            +
                    <div\ class="modal_section">\s+
         
     | 
| 
      
 322 
     | 
    
         
            +
                      <h5>Modal\ section:\ Details\ for\ Jones</h5>\s+
         
     | 
| 
      
 323 
     | 
    
         
            +
                      <p>These\ are\ the\ details\ for\ Jones:\ Details\ for\ Jones345,\ 456Details\ for\ Jones</p>\s+
         
     | 
| 
      
 324 
     | 
    
         
            +
                    </div>\s+
         
     | 
| 
      
 325 
     | 
    
         
            +
                    <p>After\ details\ modal_section\ for\ Jones</p>\s+
         
     | 
| 
      
 326 
     | 
    
         
            +
                    <button\ class="modal_button">Submit\ Details</button>\s+
         
     | 
| 
      
 327 
     | 
    
         
            +
                  </div>\s+
         
     | 
| 
      
 328 
     | 
    
         
            +
                  <div\ class="modal_dialog">\s+
         
     | 
| 
      
 329 
     | 
    
         
            +
                    <h3>Modal\ title:\ Security</h3>\s+
         
     | 
| 
      
 330 
     | 
    
         
            +
                    <p\ class="banner">Before\ security\ modal_section\ for\ Jones:\ Security123,\ 234Security</p>\s+
         
     | 
| 
      
 331 
     | 
    
         
            +
                    <div\ class="modal_section">\s+
         
     | 
| 
      
 332 
     | 
    
         
            +
                      <h5>Modal\ section:\ Security\ for\ Jones</h5>\s+
         
     | 
| 
      
 333 
     | 
    
         
            +
                      These\ are\ the\ security\ settings\ for\ Jones:\ Security\ for\ Jones345,\ 456Security\ for\ Jones\s+
         
     | 
| 
      
 334 
     | 
    
         
            +
                    </div>\s+
         
     | 
| 
      
 335 
     | 
    
         
            +
                    After\ security\ modal_section\ for\ Jones\s+
         
     | 
| 
      
 336 
     | 
    
         
            +
                    <button\ class="modal_button">Submit\ Security</button>\s+
         
     | 
| 
      
 337 
     | 
    
         
            +
                  </div>
         
     | 
| 
      
 338 
     | 
    
         
            +
                  }mix)
         
     | 
| 
      
 339 
     | 
    
         
            +
              end
         
     | 
| 
       188 
340 
     | 
    
         
             
            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.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: java
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Geweke
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2014-11- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2014-11-25 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: activesupport
         
     | 
| 
         @@ -288,6 +288,7 @@ files: 
     | 
|
| 
       288 
288 
     | 
    
         
             
            - spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/widget_defined_outside_app_views.rb
         
     | 
| 
       289 
289 
     | 
    
         
             
            - spec/rails/templates/class_loading_system_spec/lib/views/lib_widget.rb
         
     | 
| 
       290 
290 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb
         
     | 
| 
      
 291 
     | 
    
         
            +
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_tags_test.rb
         
     | 
| 
       291 
292 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
         
     | 
| 
       292 
293 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
         
     | 
| 
       293 
294 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
         
     | 
| 
         @@ -362,10 +363,15 @@ files: 
     | 
|
| 
       362 
363 
     | 
    
         
             
            - spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial.html.erb
         
     | 
| 
       363 
364 
     | 
    
         
             
            - spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial_partial.rb
         
     | 
| 
       364 
365 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/controllers/erector_coexistence_system_spec_controller.rb
         
     | 
| 
      
 366 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/helpers/application_helper.rb
         
     | 
| 
       365 
367 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/erector_widget_in_app_v_views.rb
         
     | 
| 
       366 
368 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/fortitude_widget_in_app_v_views.rb
         
     | 
| 
      
 369 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_from_fortitude_widget.rb
         
     | 
| 
       367 
370 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_in_app_views.rb
         
     | 
| 
      
 371 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_from_erector_widget.rb
         
     | 
| 
       368 
372 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_in_app_views.rb
         
     | 
| 
      
 373 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_erector_widget_from_fortitude_widget.rb
         
     | 
| 
      
 374 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_fortitude_widget_from_erector_widget.rb
         
     | 
| 
       369 
375 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_widget.rb
         
     | 
| 
       370 
376 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/fortitude_widget.rb
         
     | 
| 
       371 
377 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/config/application.rb
         
     | 
| 
         @@ -483,6 +489,7 @@ files: 
     | 
|
| 
       483 
489 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/word.rb
         
     | 
| 
       484 
490 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render.rb
         
     | 
| 
       485 
491 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_class_only.rb
         
     | 
| 
      
 492 
     | 
    
         
            +
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_with_capture.rb
         
     | 
| 
       486 
493 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_with_helper.rb
         
     | 
| 
       487 
494 
     | 
    
         
             
            - spec/rails/templates/rules_system_spec/app/controllers/rules_system_spec_controller.rb
         
     | 
| 
       488 
495 
     | 
    
         
             
            - spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb
         
     | 
| 
         @@ -626,6 +633,7 @@ test_files: 
     | 
|
| 
       626 
633 
     | 
    
         
             
            - spec/rails/templates/class_loading_system_spec/lib/views/class_loading_system_spec/widget_defined_outside_app_views.rb
         
     | 
| 
       627 
634 
     | 
    
         
             
            - spec/rails/templates/class_loading_system_spec/lib/views/lib_widget.rb
         
     | 
| 
       628 
635 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/controllers/complex_helpers_system_spec_controller.rb
         
     | 
| 
      
 636 
     | 
    
         
            +
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_tags_test.rb
         
     | 
| 
       629 
637 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/cache_test.rb
         
     | 
| 
       630 
638 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/fields_for_test.rb
         
     | 
| 
       631 
639 
     | 
    
         
             
            - spec/rails/templates/complex_helpers_system_spec/app/views/complex_helpers_system_spec/form_for_test.rb
         
     | 
| 
         @@ -700,10 +708,15 @@ test_files: 
     | 
|
| 
       700 
708 
     | 
    
         
             
            - spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial.html.erb
         
     | 
| 
       701 
709 
     | 
    
         
             
            - spec/rails/templates/erb_integration_system_spec/app/views/erb_integration_system_spec/prefers_erb_partial_partial.rb
         
     | 
| 
       702 
710 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/controllers/erector_coexistence_system_spec_controller.rb
         
     | 
| 
      
 711 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/helpers/application_helper.rb
         
     | 
| 
       703 
712 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/erector_widget_in_app_v_views.rb
         
     | 
| 
       704 
713 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/v/views/erector_coexistence_system_spec/fortitude_widget_in_app_v_views.rb
         
     | 
| 
      
 714 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_from_fortitude_widget.rb
         
     | 
| 
       705 
715 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/erector_widget_in_app_views.rb
         
     | 
| 
      
 716 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_from_erector_widget.rb
         
     | 
| 
       706 
717 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/fortitude_widget_in_app_views.rb
         
     | 
| 
      
 718 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_erector_widget_from_fortitude_widget.rb
         
     | 
| 
      
 719 
     | 
    
         
            +
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_coexistence_system_spec/render_fortitude_widget_from_erector_widget.rb
         
     | 
| 
       707 
720 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/erector_widget.rb
         
     | 
| 
       708 
721 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/app/views/fortitude_widget.rb
         
     | 
| 
       709 
722 
     | 
    
         
             
            - spec/rails/templates/erector_coexistence_system_spec/config/application.rb
         
     | 
| 
         @@ -821,6 +834,7 @@ test_files: 
     | 
|
| 
       821 
834 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/rendering_system_spec/word.rb
         
     | 
| 
       822 
835 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render.rb
         
     | 
| 
       823 
836 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_class_only.rb
         
     | 
| 
      
 837 
     | 
    
         
            +
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_with_capture.rb
         
     | 
| 
       824 
838 
     | 
    
         
             
            - spec/rails/templates/rendering_system_spec/app/views/widget_to_render_with_helper.rb
         
     | 
| 
       825 
839 
     | 
    
         
             
            - spec/rails/templates/rules_system_spec/app/controllers/rules_system_spec_controller.rb
         
     | 
| 
       826 
840 
     | 
    
         
             
            - spec/rails/templates/rules_system_spec/app/views/layouts/fortitude_layout_with_p.rb
         
     |