padrino-helpers 0.12.0.rc3 → 0.12.0
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/lib/padrino-helpers/form_builder/abstract_form_builder.rb +12 -2
- data/lib/padrino-helpers/locale/lv.yml +1 -1
- data/lib/padrino-helpers/tag_helpers.rb +1 -1
- data/test/test_form_builder.rb +17 -0
- data/test/test_form_helpers.rb +3 -3
- data/test/test_tag_helpers.rb +5 -0
- metadata +6 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: abf7a7c5e2a12e941b018c62e94e24b47f1b9bf6
         | 
| 4 | 
            +
              data.tar.gz: c59d6ed08223958df60c85512571fa3b063e46af
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: b75a79d145a6a8027674b75713c11afa14fd727b02d6f60754bda869ded0c925f47c1f408158d4186f8ee70ee72826c829e92e4309708521b1fcba3f6d854e68
         | 
| 7 | 
            +
              data.tar.gz: 3be7c0827d6f9750bf536b41abb358745c474cbd5429c54e7e11619c2973a3aecb8583793f7dbbed8c96f888e28a58a30b8ac7e721c72806c59bfa7ee60eb3f3
         | 
| @@ -135,13 +135,23 @@ module Padrino | |
| 135 135 | 
             
                    # f.fields_for :addresses
         | 
| 136 136 | 
             
                    # f.fields_for :addresses, address
         | 
| 137 137 | 
             
                    # f.fields_for :addresses, @addresses
         | 
| 138 | 
            -
                     | 
| 138 | 
            +
                    # f.fields_for :addresses, address, index: i
         | 
| 139 | 
            +
                    def fields_for(child_association, instance_or_collection=nil, options={}, &block)
         | 
| 139 140 | 
             
                      default_collection = self.object.send(child_association)
         | 
| 141 | 
            +
             | 
| 140 142 | 
             
                      include_index = default_collection.respond_to?(:each)
         | 
| 143 | 
            +
                      custom_index = options.has_key?(:index)
         | 
| 144 | 
            +
             | 
| 141 145 | 
             
                      nested_options = { :parent => self, :association => child_association }
         | 
| 142 146 | 
             
                      nested_objects = instance_or_collection ? Array(instance_or_collection) : Array(default_collection)
         | 
| 143 147 | 
             
                      nested_objects.each_with_index.map do |child_instance, index|
         | 
| 144 | 
            -
                         | 
| 148 | 
            +
                        if custom_index
         | 
| 149 | 
            +
                          nested_options[:index] = options[:index]
         | 
| 150 | 
            +
                        elsif include_index
         | 
| 151 | 
            +
                          nested_options[:index] = index
         | 
| 152 | 
            +
                        else
         | 
| 153 | 
            +
                          nested_options[:index] = nil
         | 
| 154 | 
            +
                        end
         | 
| 145 155 | 
             
                        @template.fields_for(child_instance,  { :nested => nested_options }, &block)
         | 
| 146 156 | 
             
                      end.join("\n").html_safe
         | 
| 147 157 | 
             
                    end
         | 
| @@ -129,7 +129,7 @@ module Padrino | |
| 129 129 | 
             
                    if content.respond_to?(:each) && !content.is_a?(String)
         | 
| 130 130 | 
             
                      content.each { |c| output.concat c; output.safe_concat NEWLINE }
         | 
| 131 131 | 
             
                    else
         | 
| 132 | 
            -
                      output.concat content
         | 
| 132 | 
            +
                      output.concat content.to_s
         | 
| 133 133 | 
             
                    end
         | 
| 134 134 | 
             
                    output.safe_concat "</#{name}>"
         | 
| 135 135 |  | 
    
        data/test/test_form_builder.rb
    CHANGED
    
    | @@ -927,6 +927,23 @@ describe "FormBuilder" do | |
| 927 927 | 
             
                  assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_0_name', :name => 'user[addresses_attributes][1][businesses_attributes][0][name]') { actual_html }
         | 
| 928 928 | 
             
                end
         | 
| 929 929 |  | 
| 930 | 
            +
                should "display fields for nested forms with custom indices" do
         | 
| 931 | 
            +
                  actual_html = standard_builder.fields_for :addresses do |child_form|
         | 
| 932 | 
            +
                    html = ''.html_safe
         | 
| 933 | 
            +
                    child_form.object.businesses.each_with_index do |business, i|
         | 
| 934 | 
            +
                      html += child_form.fields_for(:businesses, business, :index => ('a'..'z').to_a[i]) do |second_child_form|
         | 
| 935 | 
            +
                        second_child_form.label(:name) +
         | 
| 936 | 
            +
                        second_child_form.text_field(:name) +
         | 
| 937 | 
            +
                        second_child_form.check_box('_destroy')
         | 
| 938 | 
            +
                      end
         | 
| 939 | 
            +
                    end
         | 
| 940 | 
            +
                    html
         | 
| 941 | 
            +
                  end
         | 
| 942 | 
            +
             | 
| 943 | 
            +
                  assert_has_tag('label', :for => 'user_addresses_attributes_1_businesses_attributes_a_name', :content => 'Name') { actual_html }
         | 
| 944 | 
            +
                  assert_has_tag('input', :type => 'text', :id => 'user_addresses_attributes_1_businesses_attributes_a_name', :name => 'user[addresses_attributes][1][businesses_attributes][a][name]') { actual_html }
         | 
| 945 | 
            +
                end
         | 
| 946 | 
            +
             | 
| 930 947 | 
             
                should "display nested children fields in erb" do
         | 
| 931 948 | 
             
                  visit '/erb/fields_for'
         | 
| 932 949 | 
             
                  # Telephone
         | 
    
        data/test/test_form_helpers.rb
    CHANGED
    
    | @@ -646,9 +646,9 @@ describe "FormHelpers" do | |
| 646 646 | 
             
                should "take a range as a collection for options" do
         | 
| 647 647 | 
             
                  actual_html = select_tag(:favorite_color, :options => (1..3))
         | 
| 648 648 | 
             
                  assert_has_tag(:select) { actual_html }
         | 
| 649 | 
            -
                  assert_has_tag('select option', :value => '1') { actual_html }
         | 
| 650 | 
            -
                  assert_has_tag('select option', :value => '2') { actual_html }
         | 
| 651 | 
            -
                  assert_has_tag('select option', :value => '3') { actual_html }
         | 
| 649 | 
            +
                  assert_has_tag('select option', :content => '1', :value => '1') { actual_html }
         | 
| 650 | 
            +
                  assert_has_tag('select option', :content => '2', :value => '2') { actual_html }
         | 
| 651 | 
            +
                  assert_has_tag('select option', :content => '3', :value => '3') { actual_html }
         | 
| 652 652 | 
             
                end
         | 
| 653 653 |  | 
| 654 654 | 
             
                should "include blank for grouped options" do
         | 
    
        data/test/test_tag_helpers.rb
    CHANGED
    
    | @@ -64,6 +64,11 @@ describe "TagHelpers" do | |
| 64 64 | 
             
                  assert_has_tag('p.large#star', :content => "<>") { actual_html }
         | 
| 65 65 | 
             
                end
         | 
| 66 66 |  | 
| 67 | 
            +
                should "convert to a string if the content is not a string" do
         | 
| 68 | 
            +
                  actual_html = content_tag(:p, 97)
         | 
| 69 | 
            +
                  assert_has_tag('p', :content => "97") { actual_html }
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 67 72 | 
             
                should "support tags with erb" do
         | 
| 68 73 | 
             
                  visit '/erb/content_tag'
         | 
| 69 74 | 
             
                  assert_have_selector :p, :content => "Test 1", :class => 'test', :id => 'test1'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: padrino-helpers
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.12.0 | 
| 4 | 
            +
              version: 0.12.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Padrino Team
         | 
| @@ -11,7 +11,7 @@ authors: | |
| 11 11 | 
             
            autorequire: 
         | 
| 12 12 | 
             
            bindir: bin
         | 
| 13 13 | 
             
            cert_chain: []
         | 
| 14 | 
            -
            date: 2014- | 
| 14 | 
            +
            date: 2014-02-09 00:00:00.000000000 Z
         | 
| 15 15 | 
             
            dependencies:
         | 
| 16 16 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 17 17 | 
             
              name: padrino-core
         | 
| @@ -19,14 +19,14 @@ dependencies: | |
| 19 19 | 
             
                requirements:
         | 
| 20 20 | 
             
                - - '='
         | 
| 21 21 | 
             
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            -
                    version: 0.12.0 | 
| 22 | 
            +
                    version: 0.12.0
         | 
| 23 23 | 
             
              type: :runtime
         | 
| 24 24 | 
             
              prerelease: false
         | 
| 25 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 26 26 | 
             
                requirements:
         | 
| 27 27 | 
             
                - - '='
         | 
| 28 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: 0.12.0 | 
| 29 | 
            +
                    version: 0.12.0
         | 
| 30 30 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 31 | 
             
              name: i18n
         | 
| 32 32 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -192,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 192 192 | 
             
                  version: '0'
         | 
| 193 193 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 194 194 | 
             
              requirements:
         | 
| 195 | 
            -
              - - ' | 
| 195 | 
            +
              - - '>='
         | 
| 196 196 | 
             
                - !ruby/object:Gem::Version
         | 
| 197 | 
            -
                  version: 1.3. | 
| 197 | 
            +
                  version: 1.3.6
         | 
| 198 198 | 
             
            requirements: []
         | 
| 199 199 | 
             
            rubyforge_project: padrino-helpers
         | 
| 200 200 | 
             
            rubygems_version: 2.0.6
         |