signed_form-activeadmin 0.1.3 → 0.3.0

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: b6affe6000a6841d3a2714fa0cb042f33d48f5e7
4
- data.tar.gz: 66bf4fcc7eed2e518579886e09c70a966c604cf7
3
+ metadata.gz: 5f68587a74084f6a79fa4cdcd6b49f369556f7c2
4
+ data.tar.gz: 7e0100570ee59e625a4a560622a69b8afe11bd0a
5
5
  SHA512:
6
- metadata.gz: 0a59063cf1908248e33d680c02c1db880be7cc4922c7ed4548e3af25e657a060d69fcb48435955e441d24534f76cdcb40017c5f329252c2b7cd0bd4504cc5425
7
- data.tar.gz: a11742def7ba3df63a70a20ee7e6897fc554f61a01df81d44d606330196878a3a353c0edf0c4b6fb790f22d0fd40006fb296240a0f3b443377fad098db2b52ab
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.
@@ -2,8 +2,8 @@ module SignedForm
2
2
  module ActiveAdmin
3
3
  class Version
4
4
  MAJOR = 0
5
- MINOR = 1
6
- PATCH = 3
5
+ MINOR = 3
6
+ PATCH = 0
7
7
 
8
8
  def self.to_s
9
9
  "#{MAJOR}.#{MINOR}.#{PATCH}"
@@ -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
- describe ActiveAdmin::ViewHelpers::FormHelper do
30
- describe 'active_admin_form_for tag' do
31
- include ActionView::Helpers
32
- include ActionView::Context if defined? ActionView::Context
33
- include SignedForm::ActionView::FormHelper
34
- include Formtastic::Helpers::FormHelper
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
- def protect_against_forgery?
42
- false
43
- end
36
+ def user_path(*)
37
+ '/user'
38
+ end
44
39
 
45
- it 'should build a form with signature' do
46
- SignedForm.secret_key = 'abc123'
47
- SignedForm.options[:digest] = false
40
+ def polymorphic_path(*)
41
+ '/users'
42
+ end
48
43
 
49
- content = active_admin_form_for(User.new) do |f|
50
- f.text_field :name
51
- end
44
+ def protect_against_forgery?
45
+ false
46
+ end
52
47
 
53
- regex = '<form.*>.*<input type="hidden" name="form_signature" ' \
54
- 'value="\w+={0,2}--\w+".*/>.*' \
55
- '<input.*name="user\[name\]".*/>.*' \
56
- '</form>'
48
+ def assigns(*)
49
+ {}
50
+ end
51
+
52
+ SignedForm.secret_key = 'abc123'
53
+ SignedForm.options[:digest] = false
54
+ end
57
55
 
58
- content.must_match Regexp.new(regex, Regexp::MULTILINE)
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 'should include SignedForm::ActionController::PermitSignedParams' do
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 'must include app helpers' do
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.1.3
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: 2014-09-17 00:00:00.000000000 Z
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.2.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: