signed_form-activeadmin 0.1.3 → 0.3.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/.travis.yml +2 -0
- data/README.md +7 -0
- data/lib/signed_form-activeadmin/version.rb +2 -2
- data/lib/signed_form-activeadmin.rb +13 -0
- data/spec/spec.rb +51 -27
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f68587a74084f6a79fa4cdcd6b49f369556f7c2
|
4
|
+
data.tar.gz: 7e0100570ee59e625a4a560622a69b8afe11bd0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09c1a2b36f7f8808659594a27f2a0becacb1df6668acb36caa115c67b93fd2b2b26bd4a81fb9cae4f98c2b0a14902f7ba3b03f33398d1709d96c96759478469c
|
7
|
+
data.tar.gz: bc5d41d583b159b6db43e9aa1daa6b471580fa7a306e7d32ca59f94dcddfe53115a1fc620f52af99186545a2587f662ec1938ccc74fa702131f10b82c5fde093
|
data/.travis.yml
CHANGED
@@ -5,6 +5,7 @@ rvm:
|
|
5
5
|
- 1.9.3
|
6
6
|
- 2.0.0
|
7
7
|
- 2.1.0
|
8
|
+
- 2.2.0
|
8
9
|
- ruby-head
|
9
10
|
|
10
11
|
env:
|
@@ -13,4 +14,5 @@ env:
|
|
13
14
|
- RAILS_VERSION=3-2-stable AA_VERSION=master
|
14
15
|
- RAILS_VERSION=4-0-stable AA_VERSION=master
|
15
16
|
- RAILS_VERSION=4-1-stable AA_VERSION=master
|
17
|
+
- RAILS_VERSION=4-2-stable AA_VERSION=master
|
16
18
|
# - RAILS_VERSION=master AA_VERSION=master
|
data/README.md
CHANGED
@@ -14,3 +14,10 @@ Active Admin forms in the generated Active Admin controllers.
|
|
14
14
|
## Usage
|
15
15
|
|
16
16
|
gem 'signed_form-activeadmin'
|
17
|
+
|
18
|
+
## Caveat
|
19
|
+
|
20
|
+
Formtastic uses the `check_box_tag` helper and not `check_box` for boolean fields, so they are not caught by SignedForm.
|
21
|
+
This gem will thus sign every formtastic boolean input if SignedForm is used in the containing form and does not limit
|
22
|
+
this to Active Admin. If you use formtastic to add boolean fields to signed forms, you probably *want* them to be signed
|
23
|
+
as other types are automatically, so this should not be an issue.
|
@@ -18,6 +18,19 @@ module SignedForm
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
module ::Formtastic
|
23
|
+
module Inputs
|
24
|
+
class BooleanInput
|
25
|
+
orig_check_box_html = instance_method :check_box_html
|
26
|
+
|
27
|
+
define_method :check_box_html do
|
28
|
+
builder.try :add_signed_fields, method
|
29
|
+
orig_check_box_html.bind(self).call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
21
34
|
end
|
22
35
|
end
|
23
36
|
end
|
data/spec/spec.rb
CHANGED
@@ -26,46 +26,70 @@ end
|
|
26
26
|
|
27
27
|
require 'minitest/autorun'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
include ActiveAdmin::ViewHelpers::FormHelper
|
36
|
-
|
37
|
-
def polymorphic_path(*)
|
38
|
-
'/users'
|
39
|
-
end
|
29
|
+
class AASFTest < Minitest::Spec
|
30
|
+
include ActionView::Helpers
|
31
|
+
include ActionView::Context if defined? ActionView::Context
|
32
|
+
include SignedForm::ActionView::FormHelper
|
33
|
+
include Formtastic::Helpers::FormHelper
|
34
|
+
include ActiveAdmin::ViewHelpers::FormHelper
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
def user_path(*)
|
37
|
+
'/user'
|
38
|
+
end
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
def polymorphic_path(*)
|
41
|
+
'/users'
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
def protect_against_forgery?
|
45
|
+
false
|
46
|
+
end
|
52
47
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
48
|
+
def assigns(*)
|
49
|
+
{}
|
50
|
+
end
|
51
|
+
|
52
|
+
SignedForm.secret_key = 'abc123'
|
53
|
+
SignedForm.options[:digest] = false
|
54
|
+
end
|
57
55
|
|
58
|
-
|
56
|
+
class FormHelperTest < AASFTest
|
57
|
+
it 'builds a form with signature' do
|
58
|
+
content = active_admin_form_for(User.new) do |f|
|
59
|
+
f.text_field :name
|
59
60
|
end
|
61
|
+
|
62
|
+
regex = '<form.*>.*<input type="hidden" name="form_signature" ' \
|
63
|
+
'value="\w+={0,2}--\w+".*/>.*' \
|
64
|
+
'<input.*name="user\[name\]".*/>.*' \
|
65
|
+
'</form>'
|
66
|
+
|
67
|
+
content.must_match Regexp.new(regex, Regexp::MULTILINE)
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
71
|
describe ActiveAdmin::BaseController do
|
64
|
-
it '
|
72
|
+
it 'includes SignedForm::ActionController::PermitSignedParams' do
|
65
73
|
ActiveAdmin::BaseController.included_modules.must_include SignedForm::ActionController::PermitSignedParams
|
66
74
|
end
|
67
75
|
|
68
|
-
it '
|
76
|
+
it 'includes app helpers' do
|
69
77
|
ActiveAdmin::BaseController._helpers.included_modules.must_include TestHelper
|
70
78
|
end
|
71
79
|
end
|
80
|
+
|
81
|
+
class BooleanInputTest < AASFTest
|
82
|
+
it 'signs boolean field automatically' do
|
83
|
+
semantic_form_for(User.new, signed: true) do |f|
|
84
|
+
f.input :name
|
85
|
+
f.instance_variable_get(:@signed_attributes_context).must_equal [:name]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'works with non signed_form builders' do
|
90
|
+
semantic_form_for(User.new) do |f|
|
91
|
+
f.input :name
|
92
|
+
f.instance_variable_get(:@signed_attributes_context).must_equal nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: signed_form-activeadmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Schramm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -135,9 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.4.5
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Integrates signed_form into activeadmin forms.
|
142
142
|
test_files: []
|
143
|
-
has_rdoc:
|