signed_form 0.1.0 → 0.1.1
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/README.md +2 -2
- data/lib/signed_form/form_builder.rb +15 -1
- data/lib/signed_form/version.rb +1 -1
- data/spec/form_builder_spec.rb +99 -8
- data/spec/spec_helper.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2252f1f051eaa4aae342bebc6e18b690c1729e0
|
4
|
+
data.tar.gz: 14aed6537280fff1e06456e6810c3e82234482f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ba4877c2618bfca2c6906a7ecc38fd2f86c138daafd6cee98945053ed773d615954dd0478d06059dd5bbc69a9275c612dc9f0618b7f9fe37bd7bf8e32b2879
|
7
|
+
data.tar.gz: 3d9aa7420195e95e2bf864482785675ac4e9e914ed257b6e9a017c6fec011533de4e12c95bb7d4f923bfdea3e698bf0845f737eba16d8d41129b00d96d09045d
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ way you use standard forms.
|
|
49
49
|
SignedForm requires:
|
50
50
|
|
51
51
|
* Ruby 1.9 or later
|
52
|
-
*
|
52
|
+
* Rails 4 or Rails 3.1+ ([strong_parameters](https://github.com/rails/strong_parameters) gem
|
53
53
|
required for Rails 3)
|
54
54
|
|
55
55
|
## Installation
|
@@ -86,7 +86,7 @@ You'll also need to create an initializer:
|
|
86
86
|
|
87
87
|
## Support for other Builders
|
88
88
|
|
89
|
-
* [SimpleForm](https://github.com/erichmenge/signed_form-simple_form)
|
89
|
+
* [SimpleForm Adapter](https://github.com/erichmenge/signed_form-simple_form)
|
90
90
|
|
91
91
|
## Special Considerations
|
92
92
|
|
@@ -4,7 +4,21 @@ module SignedForm
|
|
4
4
|
# Base methods for form signing. Include this module in your own builders to get signatures for the base input
|
5
5
|
# helpers. Add fields to sign with #add_signed_fields
|
6
6
|
module Methods
|
7
|
-
|
7
|
+
FIELDS_TO_SIGN = [:select, :collection_select, :grouped_collection_select,
|
8
|
+
:time_zone_select, :collection_radio_buttons, :collection_check_boxes,
|
9
|
+
:date_select, :datetime_select, :time_select,
|
10
|
+
:text_field, :password_field, :hidden_field,
|
11
|
+
:file_field, :text_area, :check_box,
|
12
|
+
:radio_button, :color_field, :search_field,
|
13
|
+
:telephone_field, :phone_field, :date_field,
|
14
|
+
:time_field, :datetime_field, :datetime_local_field,
|
15
|
+
:month_field, :week_field, :url_field,
|
16
|
+
:email_field, :number_field, :range_field]
|
17
|
+
|
18
|
+
FIELDS_TO_SIGN.delete_if { |e| !::ActionView::Helpers::FormBuilder.instance_methods.include?(e) }
|
19
|
+
FIELDS_TO_SIGN.freeze
|
20
|
+
|
21
|
+
FIELDS_TO_SIGN.each do |h|
|
8
22
|
define_method(h) do |field, *args|
|
9
23
|
add_signed_fields field
|
10
24
|
super(field, *args)
|
data/lib/signed_form/version.rb
CHANGED
data/spec/form_builder_spec.rb
CHANGED
@@ -58,27 +58,118 @@ describe SignedForm::FormBuilder do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "form inputs" do
|
61
|
-
|
61
|
+
fields = ActionView::Helpers::FormBuilder.instance_methods - Object.instance_methods
|
62
|
+
fields -= [:button, :multipart=, :submit,
|
63
|
+
:field_helpers, :label, :multipart,
|
64
|
+
:emitted_hidden_id?, :to_model, :field_helpers?,
|
65
|
+
:field_helpers=, :fields_for, :object_name=,
|
66
|
+
:object=, :object_name, :model_name_from_record_or_class,
|
67
|
+
:multipart?, :options, :options=,
|
68
|
+
:convert_to_model, :to_partial_path, :index,
|
69
|
+
:object, :radio_button, :parent_builder,
|
70
|
+
:collection_check_boxes, :grouped_collection_select, :select,
|
71
|
+
:collection_select, :collection_radio_buttons, :time_select,
|
72
|
+
:datetime_select, :time_zone_select, :date_select]
|
73
|
+
|
74
|
+
after do
|
75
|
+
@data.should be
|
76
|
+
@data.size.should == 1
|
77
|
+
@data['user'].size.should == 1
|
78
|
+
@data['user'].should include(:name)
|
79
|
+
end
|
80
|
+
|
81
|
+
fields.each do |field|
|
62
82
|
it "should add to the allowed attributes when #{field} is used" do
|
63
83
|
content = signed_form_for(User.new) do |f|
|
64
84
|
f.send field, :name
|
65
85
|
end
|
66
86
|
|
67
|
-
data = get_data_from_form(content)
|
68
|
-
data.size.should == 1
|
69
|
-
data['user'].size.should == 1
|
70
|
-
data['user'].should include(:name)
|
87
|
+
@data = get_data_from_form(content)
|
71
88
|
end
|
72
89
|
end
|
73
90
|
|
91
|
+
it "should add to the allowed attributes when collection_check_boxes is used", action_pack: /4\.\d+/ do
|
92
|
+
content = signed_form_for(User.new) do |f|
|
93
|
+
f.collection_check_boxes :name, ['a', 'b'], :to_s, :to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
@data = get_data_from_form(content)
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should add to the allowed attributes when grouped_collection_select is used" do
|
100
|
+
continent = Struct.new('Continent', :continent_name, :countries)
|
101
|
+
country = Struct.new('Country', :country_id, :country_name)
|
102
|
+
|
103
|
+
content = signed_form_for(User.new) do |f|
|
104
|
+
f.grouped_collection_select(:name, [continent.new("<Africa>", [country.new("<sa>", "<South Africa>")])],
|
105
|
+
:countries, :continent_name, :country_id, :country_name)
|
106
|
+
end
|
107
|
+
|
108
|
+
@data = get_data_from_form(content)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should add to the allowed attributes when select is used" do
|
112
|
+
content = signed_form_for(User.new) do |f|
|
113
|
+
f.select :name, %w(a b)
|
114
|
+
end
|
115
|
+
|
116
|
+
@data = get_data_from_form(content)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should add to the allowed attributes when collection_select is used" do
|
120
|
+
content = signed_form_for(User.new) do |f|
|
121
|
+
f.collection_select :name, %w(a b), :to_s, :to_s
|
122
|
+
end
|
123
|
+
|
124
|
+
@data = get_data_from_form(content)
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should add to the allowed attributes when collection_radio_buttons is used", action_pack: /4\.\d+/ do
|
128
|
+
content = signed_form_for(User.new) do |f|
|
129
|
+
f.collection_radio_buttons :name, %w(a b), :to_s, :to_s
|
130
|
+
end
|
131
|
+
|
132
|
+
@data = get_data_from_form(content)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should add to the allowed attributes when date_select is used" do
|
136
|
+
content = signed_form_for(User.new) do |f|
|
137
|
+
f.date_select :name
|
138
|
+
end
|
139
|
+
|
140
|
+
@data = get_data_from_form(content)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should add to the allowed attributes when time_select is used" do
|
144
|
+
content = signed_form_for(User.new) do |f|
|
145
|
+
f.time_select :name
|
146
|
+
end
|
147
|
+
|
148
|
+
@data = get_data_from_form(content)
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should add to the allowed attributes when datetime_select is used" do
|
152
|
+
content = signed_form_for(User.new) do |f|
|
153
|
+
f.datetime_select :name
|
154
|
+
end
|
155
|
+
|
156
|
+
@data = get_data_from_form(content)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should add to the allowed attributes when time_zone_select is used" do
|
160
|
+
content = signed_form_for(User.new) do |f|
|
161
|
+
f.time_zone_select :name
|
162
|
+
end
|
163
|
+
|
164
|
+
@data = get_data_from_form(content)
|
165
|
+
end
|
166
|
+
|
74
167
|
it "should add to the allowed attributes when radio_button is used" do
|
75
168
|
content = signed_form_for(User.new) do |f|
|
76
169
|
f.radio_button :name, ['bar']
|
77
170
|
end
|
78
171
|
|
79
|
-
data = get_data_from_form(content)
|
80
|
-
data['user'].size.should == 1
|
81
|
-
data['user'].should include(:name)
|
172
|
+
@data = get_data_from_form(content)
|
82
173
|
end
|
83
174
|
end
|
84
175
|
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,7 @@ require 'signed_form'
|
|
8
8
|
require 'active_support/core_ext'
|
9
9
|
|
10
10
|
module SignedFormViewHelper
|
11
|
-
include ActionView::Helpers
|
11
|
+
include ActionView::Helpers
|
12
12
|
|
13
13
|
if defined?(ActionView::RecordIdentifier)
|
14
14
|
include ActionView::RecordIdentifier
|
@@ -58,5 +58,7 @@ RSpec.configure do |config|
|
|
58
58
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
59
59
|
config.run_all_when_everything_filtered = true
|
60
60
|
|
61
|
+
config.filter_run_excluding action_pack: ->(version) { ActionPack::VERSION::STRING.match(/\d+\.\d+/)[0] !~ version }
|
62
|
+
|
61
63
|
config.order = 'random'
|
62
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signed_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erich Menge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|