fwt_bootstrap_rails 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e61e05863493ed43c63890a02279bf76c77cde3
|
4
|
+
data.tar.gz: a1bd0777497d23a23e30ed6359018bebda00f71a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -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
|
-
|
11
|
-
|
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
|