signed_form-activeadmin 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 53c6ca38e40c956ab72da4e81acf865b4fc8e836
4
+ data.tar.gz: cfdbaadf416d8fb027c88738255844e18fcacb72
5
+ SHA512:
6
+ metadata.gz: 651a4048a3a07976c35e452827437974d1b5cf2682234647e00fe4f0fae0e3c6a04d7c0a1c9a1e600a2d37cf17252e081e25b3905c6602129375dd58dd256ed7
7
+ data.tar.gz: fb0487d6090f9d4181bb3206bb6085490c7b0140b5604e4e21deb4c5b4f6796a6d51245837be9240fff5d4e69b371496f360deedb833204717d8dfefca024d38
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2014 Christopher Schramm.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to
8
+ do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
14
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
15
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
16
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ [![Gem Version](https://badge.fury.io/rb/signed_form-activeadmin.png)](http://badge.fury.io/rb/signed_form-activeadmin)
2
+ [![Dependency Status](https://gemnasium.com/cschramm/signed_form-activeadmin.png)](https://gemnasium.com/cschramm/signed_form-activeadmin)
3
+ [![Code Climate](https://codeclimate.com/github/cschramm/signed_form-activeadmin.png)](https://codeclimate.com/github/cschramm/signed_form-activeadmin)
4
+
5
+ # SignedForm / Active Admin
6
+
7
+ Integrates [SignedForm](https://github.com/erichmenge/signed_form)
8
+ with [Active Admin](http://www.activeadmin.info/).
9
+
10
+ This eliminates the need to explicitly permit all fields used in
11
+ Active Admin forms in the generated Active Admin controllers.
12
+
13
+ ## Usage
14
+
15
+ gem 'signed_form-activeadmin'
@@ -0,0 +1,13 @@
1
+ module SignedForm
2
+ module ActiveAdmin
3
+ class Version
4
+ MAJOR = 0
5
+ MINOR = 1
6
+ PATCH = 1
7
+
8
+ def self.to_s
9
+ "#{MAJOR}.#{MINOR}.#{PATCH}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module SignedForm
2
+ module ActiveAdmin
3
+ class Railtie < ::Rails::Railtie
4
+ initializer 'signed_form-activeadmin' do |_|
5
+ module ::ActiveAdmin
6
+ class BaseController
7
+ include SignedForm::ActionController::PermitSignedParams
8
+ end
9
+
10
+ module ViewHelpers
11
+ module FormHelper
12
+ alias_method :orig_active_admin_form_for, :active_admin_form_for
13
+
14
+ define_method :active_admin_form_for do |resource, options = {}, &block|
15
+ options[:signed] = true
16
+ orig_active_admin_form_for resource, options, &block
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/signed_form-activeadmin/version', __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'signed_form-activeadmin'
6
+ s.version = SignedForm::ActiveAdmin::Version.to_s
7
+ s.platform = Gem::Platform::RUBY
8
+ s.author = 'Christopher Schramm'
9
+ s.email = 'signed_form-aa@cschramm.eu'
10
+ s.homepage = 'https://github.com/cschramm/signed_form-activeadmin'
11
+ s.description = %q{
12
+ Integrates signed_form into activeadmin forms.
13
+ }
14
+ s.summary = %q{
15
+ Integrates signed_form into activeadmin forms.
16
+ }
17
+ s.licenses = %w(MIT)
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = %w(lib)
22
+ s.extra_rdoc_files = %w(README.md)
23
+
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'activemodel', '>= 3.1'
26
+ s.add_development_dependency 'actionpack', '>= 3.1'
27
+ s.add_development_dependency 'strong_parameters'
28
+ s.add_development_dependency 'minitest'
29
+
30
+ s.add_dependency 'signed_form'
31
+ s.add_dependency 'railties'
32
+
33
+ s.add_runtime_dependency 'activeadmin', '>= 0.4.0'
34
+ end
data/spec.rb ADDED
@@ -0,0 +1,70 @@
1
+ require 'active_model'
2
+ require 'action_controller'
3
+
4
+ class User
5
+ extend ActiveModel::Naming
6
+
7
+ attr_accessor :name
8
+
9
+ def to_key
10
+ [1]
11
+ end
12
+ end
13
+
14
+ require 'signed_form'
15
+
16
+ # We currently fake AA since actually using it requires a complete Rails application to be set up
17
+
18
+ module ActiveAdmin
19
+ class BaseController < ActionController::Base; end
20
+
21
+ module ViewHelpers
22
+ module FormHelper
23
+ include SignedForm::ActionView::FormHelper
24
+
25
+ alias_method :active_admin_form_for, :form_for
26
+ end
27
+ end
28
+ end
29
+
30
+ require 'signed_form-activeadmin'
31
+
32
+ require 'minitest/autorun'
33
+
34
+ describe ActiveAdmin::ViewHelpers::FormHelper do
35
+ describe 'active_admin_form_for tag' do
36
+ include ActionView::Helpers
37
+ include ActionView::Context if defined? ActionView::Context
38
+ include ActiveAdmin::ViewHelpers::FormHelper
39
+
40
+ def polymorphic_path(*)
41
+ '/users'
42
+ end
43
+
44
+ def protect_against_forgery?
45
+ false
46
+ end
47
+
48
+ it 'should build a form with signature' do
49
+ SignedForm.secret_key = 'abc123'
50
+ SignedForm.options[:digest] = false
51
+
52
+ content = active_admin_form_for(User.new) do |f|
53
+ f.text_field :name
54
+ end
55
+
56
+ regex = '<form.*>.*<input type="hidden" name="form_signature" ' \
57
+ 'value="\w+={0,2}--\w+".*/>.*' \
58
+ '<input.*name="user\[name\]".*/>.*' \
59
+ '</form>'
60
+
61
+ content.must_match Regexp.new(regex, Regexp::MULTILINE)
62
+ end
63
+ end
64
+ end
65
+
66
+ describe ActiveAdmin::BaseController do
67
+ it 'should include SignedForm::ActionController::PermitSignedParams' do
68
+ ActiveAdmin::BaseController.included_modules.must_include SignedForm::ActionController::PermitSignedParams
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: signed_form-activeadmin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Schramm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: actionpack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: strong_parameters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: signed_form
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: railties
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activeadmin
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.0
125
+ description: |2
126
+
127
+ Integrates signed_form into activeadmin forms.
128
+ email: signed_form-aa@cschramm.eu
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - README.md
133
+ files:
134
+ - ".gitignore"
135
+ - Gemfile
136
+ - LICENSE
137
+ - README.md
138
+ - lib/signed_form-activeadmin.rb
139
+ - lib/signed_form-activeadmin/version.rb
140
+ - signed_form-activeadmin.gemspec
141
+ - spec.rb
142
+ homepage: https://github.com/cschramm/signed_form-activeadmin
143
+ licenses:
144
+ - MIT
145
+ metadata: {}
146
+ post_install_message:
147
+ rdoc_options: []
148
+ require_paths:
149
+ - lib
150
+ required_ruby_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 2.2.0.rc.1
163
+ signing_key:
164
+ specification_version: 4
165
+ summary: Integrates signed_form into activeadmin forms.
166
+ test_files: []