fwt_bootstrap_rails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03faadd618e1cf964ef4ea154066a97f8331fa03
4
- data.tar.gz: 3b1728a1efc224f0386fe0e73af2d008dbca0a71
3
+ metadata.gz: 5e61e05863493ed43c63890a02279bf76c77cde3
4
+ data.tar.gz: a1bd0777497d23a23e30ed6359018bebda00f71a
5
5
  SHA512:
6
- metadata.gz: 6d2f529117619117359ce6a484ff473b4b2cbb76776a473ce645d864d3e5f45cc51d0e3d375e347cd751c825d55c95f8132fb069444b2b3a21e3c29996c524b2
7
- data.tar.gz: dec4b83eda7e8b7386ebe5674b03ecdddf4d244eeb327dbbc2a51bd8353b7f3688958470e6a550d5a7fd5f492499a6cf140736ed6ec547d956f6d7ce553e4cd0
6
+ metadata.gz: 39f8d1a07c61bb340601abfdfd8643fe655662a355b3764b0da2d52ba07e27a1fe78afa12445715e2d2d2c9948e30789cc67f4dc3bd2ad83becd3669afa7d8f7
7
+ data.tar.gz: fddfbcc0a28fc55b07dce05a6976d910c948d766985d5d8218bb1d6e5c05a377f137fdc4df34fa34d2510d4ad9945524641550658eb4b7eb73dd6ef541eb049d
@@ -78,6 +78,10 @@ class BootstrapFormBuilder < ActionView::Helpers::FormBuilder
78
78
  hidden_field(fields_for_name, :id, {:value => fields_for_object.id}) if fields_for_object && !fields_for_object.kind_of?(Hash)
79
79
  end
80
80
 
81
+ def hidden_field(name, *args, &block)
82
+ super(@object_name, name, *(args << options.merge(:value => @object.send(name))))
83
+ end
84
+
81
85
  def self.create_tagged_field(method_name)
82
86
  define_method(method_name) do |name, *args|
83
87
  if [:file_field, :select].include? method_name
@@ -1,3 +1,3 @@
1
1
  module FwtBootstrapRails
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -5,25 +5,37 @@ class TestHelper < ActionView::Base; end
5
5
 
6
6
  describe BootstrapFormBuilder do
7
7
 
8
+ let(:helper) { TestHelper.new }
9
+ let(:resource) { User.new }
10
+ let(:builder) { BootstrapFormBuilder.new :user, resource, helper, {} }
11
+
8
12
  describe '#checkbox' do
13
+ let(:output) { builder.check_box :administrator }
9
14
 
10
- let(:helper) { TestHelper.new }
11
- let(:resource) { User.new }
12
- let(:builder) { BootstrapFormBuilder.new :user, resource, helper, {} }
13
- let(:output) {
14
- builder.check_box(:administrator)
15
- }
16
-
17
- it 'wraps input and label' do
18
- expect(output).to have_tag('input', :with => { :id => :user_administrator })
15
+ it 'creates a checkbox input' do
16
+ expect(output).to have_tag('input', :with => { :id => :user_administrator, :type => :checkbox })
19
17
  end
20
18
 
21
19
  it 'creates a label' do
22
20
  expect(output).to include '<label'
23
21
  end
24
22
  end
23
+
24
+ describe '#hidden' do
25
+
26
+ let(:output) { builder.hidden_field :administrator }
27
+
28
+ it 'creates a hidden input' do
29
+ expect(output).to have_tag('input', :with => {:type => :hidden, :id => :user_administrator, :value => true})
30
+ end
31
+ end
32
+
25
33
  end
26
34
 
27
35
  class User
28
36
  attr_accessor :administrator
37
+
38
+ def administrator
39
+ true
40
+ end
29
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fwt_bootstrap_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brooke-Smith