activeadmin-rb 1.5.0 → 1.5.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/.travis.yml +1 -2
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -2
- data/activeadmin-rb.gemspec +4 -4
- data/gemfiles/rails_50.gemfile +2 -0
- data/gemfiles/rails_51.gemfile +2 -0
- data/gemfiles/rails_52.gemfile +2 -0
- data/gemfiles/rails_60.gemfile +4 -1
- data/lib/active_admin.rb +1 -0
- data/lib/active_admin/application.rb +3 -4
- data/lib/active_admin/base_controller/authorization.rb +2 -4
- data/lib/active_admin/dependency.rb +0 -76
- data/lib/active_admin/orm/active_record/comments.rb +4 -4
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +1 -1
- data/lib/active_admin/scope.rb +2 -2
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/views/components/attributes_table.rb +1 -1
- data/lib/active_admin/views/components/sidebar_section.rb +0 -3
- data/lib/active_admin/views/components/table_for.rb +1 -1
- data/lib/bug_report_templates/active_admin_master.rb +0 -1
- data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb +1 -15
- data/spec/support/rails_template.rb +13 -11
- data/spec/unit/action_builder_spec.rb +1 -3
- data/spec/unit/authorization/index_overriding_spec.rb +1 -1
- data/tasks/local.rake +1 -1
- metadata +17 -20
- data/lib/active_admin/helpers/output_safety_helper.rb +0 -35
- data/lib/active_admin/reloader.rb +0 -25
- data/spec/unit/helpers/output_safety_helper_spec.rb +0 -79
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ced5dec79ddb057e1fc140d5eba3046d2b16462252732ae69fbbd1df9b13fda
|
|
4
|
+
data.tar.gz: 8a4c7165581418d169b8b621e2441bfe459650918d19a625b40834fbe8c2e126
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6ad1faa5eb2118b68378c42b4e6c32a2d56f3ad6e2491212ced8ef74bbb0a13da3ea8aebe9556358761f343bd80f9b2a5ca1ae1d16efbad42a6ac848f11ed08f
|
|
7
|
+
data.tar.gz: f8214d1c7f9eb277cd14f5c719feb9d3b163d52c621ebb809e42bec70565633bbc35431d730f376f50d052d6ce80cd6b1a433497781b34d85894a679d7e1b031
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.5.1 [☰](https://github.com/varyonic/activeadmin-rb/compare/v1.5.0...v1.5.1)
|
|
4
|
+
|
|
5
|
+
* More fixes to support final release of Rails 6.0.
|
|
6
|
+
|
|
3
7
|
## 1.5.0 [☰](https://github.com/varyonic/activeadmin-rb/compare/v1.4.0...v1.5.0)
|
|
4
8
|
|
|
5
9
|
### Enhancements
|
|
@@ -47,6 +51,10 @@
|
|
|
47
51
|
|
|
48
52
|
* gemspec should have more permissive ransack dependency. [#5448] by [@varyonic]
|
|
49
53
|
|
|
54
|
+
### Removals
|
|
55
|
+
|
|
56
|
+
* Rails 4.2 support has been dropped. [#5104][] by [@javierjulio][] and [@deivid-rodriguez][]
|
|
57
|
+
|
|
50
58
|
## 1.3.0 [☰](https://github.com/activeadmin/activeadmin/compare/v1.2.1...v1.3.0)
|
|
51
59
|
|
|
52
60
|
### Enhancements
|
|
@@ -292,6 +300,7 @@ Please check [0-6-stable] for previous changes.
|
|
|
292
300
|
[#5069]: https://github.com/activeadmin/activeadmin/pull/5069
|
|
293
301
|
[#5088]: https://github.com/activeadmin/activeadmin/pull/5088
|
|
294
302
|
[#5093]: https://github.com/activeadmin/activeadmin/pull/5093
|
|
303
|
+
[#5104]: https://github.com/activeadmin/activeadmin/pull/5104
|
|
295
304
|
[#5119]: https://github.com/activeadmin/activeadmin/pull/5119
|
|
296
305
|
[#5120]: https://github.com/activeadmin/activeadmin/pull/5120
|
|
297
306
|
[#5125]: https://github.com/activeadmin/activeadmin/pull/5125
|
data/Gemfile
CHANGED
|
@@ -24,7 +24,7 @@ gem 'yard' # Documentation generator
|
|
|
24
24
|
gem 'redcarpet', platforms: :mri # Markdown implementation (for yard)
|
|
25
25
|
gem 'kramdown', platforms: :jruby # Markdown implementation (for yard)
|
|
26
26
|
|
|
27
|
-
group :development do
|
|
27
|
+
group :development, :test do
|
|
28
28
|
# Debugging
|
|
29
29
|
gem 'better_errors' # Web UI to debug exceptions. Go to /__better_errors to access the latest one
|
|
30
30
|
|
|
@@ -45,6 +45,5 @@ group :test do
|
|
|
45
45
|
gem 'launchy'
|
|
46
46
|
gem 'rspec-rails'
|
|
47
47
|
gem 'i18n-spec'
|
|
48
|
-
gem 'sqlite3', '< 1.4', platforms: :mri
|
|
49
48
|
gem 'poltergeist'
|
|
50
49
|
end
|
data/activeadmin-rb.gemspec
CHANGED
|
@@ -25,9 +25,9 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.add_dependency 'inherited_resources', '>= 1.9.0'
|
|
26
26
|
s.add_dependency 'jquery-rails', '>= 4.2.0'
|
|
27
27
|
s.add_dependency 'jquery-ui-rails', '~> 6.0'
|
|
28
|
-
s.add_dependency 'kaminari', '>= 0.
|
|
29
|
-
s.add_dependency 'railties', '>=
|
|
28
|
+
s.add_dependency 'kaminari', '>= 1.0.1'
|
|
29
|
+
s.add_dependency 'railties', '>= 5.0'
|
|
30
30
|
s.add_dependency 'ransack', '>= 1.8.7'
|
|
31
|
-
s.add_dependency 'sass'
|
|
32
|
-
s.add_dependency 'sprockets'
|
|
31
|
+
s.add_dependency 'sass-rails'
|
|
32
|
+
s.add_dependency 'sprockets'
|
|
33
33
|
end
|
data/gemfiles/rails_50.gemfile
CHANGED
|
@@ -3,10 +3,12 @@ source "https://rubygems.org"
|
|
|
3
3
|
eval_gemfile(File.expand_path(File.join("..", "Gemfile"), __dir__))
|
|
4
4
|
|
|
5
5
|
gem "rails", "5.0.7"
|
|
6
|
+
gem "sprockets", "< 4"
|
|
6
7
|
gem "devise", "~> 4.0"
|
|
7
8
|
gem "draper", "~> 3.0"
|
|
8
9
|
gem "ransack", "~> 1.8.7" # 2.x for Rails 5.2+ only.
|
|
9
10
|
gem "rails-i18n"
|
|
11
|
+
gem 'sqlite3', '< 1.4', platforms: :mri
|
|
10
12
|
gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platforms: :jruby
|
|
11
13
|
|
|
12
14
|
gemspec path: "../"
|
data/gemfiles/rails_51.gemfile
CHANGED
|
@@ -3,10 +3,12 @@ source "https://rubygems.org"
|
|
|
3
3
|
eval_gemfile(File.expand_path(File.join("..", "Gemfile"), __dir__))
|
|
4
4
|
|
|
5
5
|
gem "rails", "5.1.6"
|
|
6
|
+
gem "sprockets", "< 4"
|
|
6
7
|
gem "devise", "~> 4.3"
|
|
7
8
|
gem "draper", "~> 3.0"
|
|
8
9
|
gem "ransack", "~> 1.8.7" # 2.x for Rails 5.2+ only.
|
|
9
10
|
gem "rails-i18n"
|
|
11
|
+
gem 'sqlite3', '< 1.4', platforms: :mri
|
|
10
12
|
gem "activerecord-jdbcsqlite3-adapter", "~> 51.0", platforms: :jruby
|
|
11
13
|
|
|
12
14
|
gemspec path: "../"
|
data/gemfiles/rails_52.gemfile
CHANGED
|
@@ -3,11 +3,13 @@ source "https://rubygems.org"
|
|
|
3
3
|
eval_gemfile(File.expand_path(File.join("..", "Gemfile"), __dir__))
|
|
4
4
|
|
|
5
5
|
gem "rails", "5.2.1"
|
|
6
|
+
gem "sprockets", "< 4"
|
|
6
7
|
gem "bootsnap"
|
|
7
8
|
gem "devise", "~> 4.4"
|
|
8
9
|
gem "draper", "~> 3.0"
|
|
9
10
|
gem "ransack", "2.0" # 2.x for Rails 5.2+ only.
|
|
10
11
|
gem "rails-i18n"
|
|
12
|
+
gem 'sqlite3', '< 1.4', platforms: :mri
|
|
11
13
|
gem "activerecord-jdbcsqlite3-adapter", ">= 52.0", platforms: :jruby
|
|
12
14
|
|
|
13
15
|
gemspec path: "../"
|
data/gemfiles/rails_60.gemfile
CHANGED
|
@@ -4,10 +4,13 @@ eval_gemfile(File.expand_path(File.join("..", "Gemfile"), __dir__))
|
|
|
4
4
|
|
|
5
5
|
gem "rails", ">= 6.0.x"
|
|
6
6
|
gem "rails-i18n", ">= 6.0.x"
|
|
7
|
+
gem "sass-rails", ">= 6.0.x"
|
|
8
|
+
gem "sprockets", ">= 4.0.x"
|
|
7
9
|
gem "bootsnap"
|
|
8
10
|
gem "devise", "~> 4.4"
|
|
9
11
|
gem "draper", "~> 3.0"
|
|
10
12
|
gem "ransack", ">= 2.0" # 2.x for Rails 5.2+ only.
|
|
11
|
-
gem
|
|
13
|
+
gem 'sqlite3', platforms: :mri
|
|
14
|
+
gem "activerecord-jdbcsqlite3-adapter", ">= 60.0.x", platform: :jruby
|
|
12
15
|
|
|
13
16
|
gemspec path: "../"
|
data/lib/active_admin.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'active_admin/router'
|
|
2
|
-
require 'active_admin/reloader'
|
|
3
2
|
require 'active_admin/application_settings'
|
|
4
3
|
require 'active_admin/namespace_settings'
|
|
5
4
|
|
|
@@ -201,11 +200,11 @@ module ActiveAdmin
|
|
|
201
200
|
# Rails is about to unload all the app files (e.g. models), so we
|
|
202
201
|
# should first unload the classes generated by Active Admin, otherwise
|
|
203
202
|
# they will contain references to the stale (unloaded) classes.
|
|
204
|
-
Reloader.to_prepare(prepend: true, &unload_active_admin)
|
|
203
|
+
ActiveSupport::Reloader.to_prepare(prepend: true, &unload_active_admin)
|
|
205
204
|
else
|
|
206
205
|
# If the user has configured the app to always reload app files after
|
|
207
206
|
# each request, so we should unload the generated classes too.
|
|
208
|
-
Reloader.to_complete(&unload_active_admin)
|
|
207
|
+
ActiveSupport::Reloader.to_complete(&unload_active_admin)
|
|
209
208
|
end
|
|
210
209
|
|
|
211
210
|
admin_dirs = {}
|
|
@@ -220,7 +219,7 @@ module ActiveAdmin
|
|
|
220
219
|
|
|
221
220
|
app.reloaders << routes_reloader
|
|
222
221
|
|
|
223
|
-
Reloader.to_prepare do
|
|
222
|
+
ActiveSupport::Reloader.to_prepare do
|
|
224
223
|
# Rails might have reloaded the routes for other reasons (e.g.
|
|
225
224
|
# routes.rb has changed), in which case Active Admin would have been
|
|
226
225
|
# loaded via the `ActiveAdmin.routes` call in `routes.rb`.
|
|
@@ -111,16 +111,14 @@ module ActiveAdmin
|
|
|
111
111
|
redirect_backwards_or_to_root
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
-
body
|
|
115
|
-
|
|
116
|
-
format.csv { render body => error, status: :unauthorized }
|
|
114
|
+
format.csv { render body: error, status: :unauthorized }
|
|
117
115
|
format.json { render json: { error: error }, status: :unauthorized }
|
|
118
116
|
format.xml { render xml: "<error>#{error}</error>", status: :unauthorized }
|
|
119
117
|
end
|
|
120
118
|
end
|
|
121
119
|
|
|
122
120
|
def redirect_backwards_or_to_root
|
|
123
|
-
|
|
121
|
+
redirect_back fallback_location: active_admin_root
|
|
124
122
|
end
|
|
125
123
|
|
|
126
124
|
end
|
|
@@ -55,10 +55,6 @@ module ActiveAdmin
|
|
|
55
55
|
Matcher.new name.to_s
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def self.rails5?
|
|
59
|
-
rails >= '5.x'
|
|
60
|
-
end
|
|
61
|
-
|
|
62
58
|
class Matcher
|
|
63
59
|
attr_reader :name
|
|
64
60
|
|
|
@@ -94,78 +90,6 @@ module ActiveAdmin
|
|
|
94
90
|
info = spec ? "#{spec.name} #{spec.version}" : '(missing)'
|
|
95
91
|
"<ActiveAdmin::Dependency::Matcher for #{info}>"
|
|
96
92
|
end
|
|
97
|
-
|
|
98
|
-
def adapter
|
|
99
|
-
@adapter ||= Adapter.const_get(@name.camelize).new self
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def method_missing(method, *args, &block)
|
|
103
|
-
if respond_to_missing?(method)
|
|
104
|
-
adapter.send method, *args, &block
|
|
105
|
-
else
|
|
106
|
-
super
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
def respond_to_missing?(method, include_private = false)
|
|
111
|
-
adapter.respond_to?(method) || super
|
|
112
|
-
rescue NameError
|
|
113
|
-
# 🐾
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
# Dependency adapters provide an easy way to wrap the conditional logic
|
|
118
|
-
# necessary to support multiple versions of a gem.
|
|
119
|
-
#
|
|
120
|
-
# ActiveAdmin::Dependency.rails.adapter.parameterize 'a b'
|
|
121
|
-
# => 'a_b'
|
|
122
|
-
#
|
|
123
|
-
# ActiveAdmin::Dependency.rails.parameterize 'a b'
|
|
124
|
-
# => 'a_b'
|
|
125
|
-
#
|
|
126
|
-
# ActiveAdmin::Dependency.devise.adapter
|
|
127
|
-
# -> NameError: uninitialized constant ActiveAdmin::Dependency::Adapter::Devise
|
|
128
|
-
#
|
|
129
|
-
module Adapter
|
|
130
|
-
class Base
|
|
131
|
-
def initialize(version)
|
|
132
|
-
@version = version
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
class Rails < Base
|
|
137
|
-
def optional_belongs_to_flag
|
|
138
|
-
if Dependency.rails5?
|
|
139
|
-
{ optional: true }
|
|
140
|
-
else
|
|
141
|
-
{ required: false }
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def parameterize(string)
|
|
146
|
-
if Dependency.rails5?
|
|
147
|
-
string.parameterize separator: '_'
|
|
148
|
-
else
|
|
149
|
-
string.parameterize '_'
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def redirect_back(controller, fallback_location)
|
|
154
|
-
controller.instance_exec do
|
|
155
|
-
if Dependency.rails5?
|
|
156
|
-
redirect_back fallback_location: fallback_location
|
|
157
|
-
elsif controller.request.headers.key? 'HTTP_REFERER'
|
|
158
|
-
redirect_to :back
|
|
159
|
-
else
|
|
160
|
-
redirect_to fallback_location
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def render_key
|
|
166
|
-
Dependency.rails5? ? :body : :text
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
93
|
end
|
|
170
94
|
|
|
171
95
|
end
|
|
@@ -64,21 +64,21 @@ ActiveAdmin.after_load do |app|
|
|
|
64
64
|
def create
|
|
65
65
|
create! do |success, failure|
|
|
66
66
|
success.html do
|
|
67
|
-
|
|
67
|
+
redirect_back fallback_location: active_admin_root
|
|
68
68
|
end
|
|
69
69
|
failure.html do
|
|
70
70
|
flash[:error] = I18n.t 'active_admin.comments.errors.empty_text'
|
|
71
|
-
|
|
71
|
+
redirect_back fallback_location: active_admin_root
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def destroy
|
|
76
76
|
destroy! do |success, failure|
|
|
77
77
|
success.html do
|
|
78
|
-
|
|
78
|
+
redirect_back fallback_location: active_admin_root
|
|
79
79
|
end
|
|
80
80
|
failure.html do
|
|
81
|
-
|
|
81
|
+
redirect_back fallback_location: active_admin_root
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -3,7 +3,7 @@ module ActiveAdmin
|
|
|
3
3
|
|
|
4
4
|
self.table_name = "#{table_name_prefix}active_admin_comments#{table_name_suffix}"
|
|
5
5
|
|
|
6
|
-
belongs_to :resource,
|
|
6
|
+
belongs_to :resource, polymorphic: true, optional: true
|
|
7
7
|
belongs_to :author, polymorphic: true
|
|
8
8
|
|
|
9
9
|
validates_presence_of :body, :namespace, :resource
|
|
@@ -187,7 +187,7 @@ module ActiveAdmin
|
|
|
187
187
|
delegate :before_save, :after_save, to: :controller
|
|
188
188
|
delegate :before_destroy, :after_destroy, to: :controller
|
|
189
189
|
|
|
190
|
-
# This code defines both *_filter and *_action for Rails
|
|
190
|
+
# This code defines both *_filter and *_action for Rails 5.0 and *_action for Rails >= 5.1
|
|
191
191
|
phases = [
|
|
192
192
|
:before, :skip_before,
|
|
193
193
|
:after, :skip_after,
|
data/lib/active_admin/scope.rb
CHANGED
|
@@ -32,10 +32,10 @@ module ActiveAdmin
|
|
|
32
32
|
|
|
33
33
|
if name.is_a? Proc
|
|
34
34
|
raise "A string/symbol is required as the second argument if your label is a proc." unless method
|
|
35
|
-
@id =
|
|
35
|
+
@id = method.to_s.parameterize(separator: "_")
|
|
36
36
|
else
|
|
37
37
|
@scope_method ||= name.to_sym
|
|
38
|
-
@id =
|
|
38
|
+
@id = name.to_s.parameterize(separator: "_")
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
@scope_method = nil if @scope_method == :all
|
data/lib/active_admin/version.rb
CHANGED
|
@@ -26,7 +26,7 @@ module ActiveAdmin
|
|
|
26
26
|
if options[:class]
|
|
27
27
|
classes << options[:class]
|
|
28
28
|
elsif title.present?
|
|
29
|
-
classes << "row-#{
|
|
29
|
+
classes << "row-#{title.to_s.parameterize(separator: "_")}"
|
|
30
30
|
end
|
|
31
31
|
options[:class] = classes.join(' ')
|
|
32
32
|
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
require 'active_admin/helpers/output_safety_helper'
|
|
2
|
-
|
|
3
1
|
module ActiveAdmin
|
|
4
2
|
module Views
|
|
5
3
|
|
|
6
4
|
class SidebarSection < Panel
|
|
7
5
|
builder_method :sidebar_section
|
|
8
|
-
include OutputSafetyHelper
|
|
9
6
|
|
|
10
7
|
# Takes a ActiveAdmin::SidebarSection instance
|
|
11
8
|
def build(section)
|
|
@@ -147,7 +147,7 @@ module ActiveAdmin
|
|
|
147
147
|
if @options.has_key?(:class)
|
|
148
148
|
html_classes << @options.delete(:class)
|
|
149
149
|
elsif @title.present?
|
|
150
|
-
html_classes << "col-#{
|
|
150
|
+
html_classes << "col-#{@title.to_s.parameterize(separator: "_")}"
|
|
151
151
|
end
|
|
152
152
|
@html_class = html_classes.join(' ')
|
|
153
153
|
@data = args[1] || args[0]
|
|
@@ -18,7 +18,6 @@ gemfile(true) do
|
|
|
18
18
|
# Change Rails version if necessary.
|
|
19
19
|
gem 'rails', '~> 5.1.0'
|
|
20
20
|
|
|
21
|
-
gem 'sass-rails'
|
|
22
21
|
gem 'sqlite3', '< 1.4', platform: :mri
|
|
23
22
|
gem 'activerecord-jdbcsqlite3-adapter', "~> 51.0", platform: :jruby
|
|
24
23
|
gem 'jruby-openssl', '~> 0.10.1', platforms: :jruby
|
data/lib/generators/active_admin/install/templates/migrations/create_active_admin_comments.rb.erb
CHANGED
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
parent_class = ActiveRecord::Migration
|
|
3
|
-
parent_class = parent_class[parent_class.current_version] if Rails::VERSION::MAJOR >= 5
|
|
4
|
-
-%>
|
|
5
|
-
class CreateActiveAdminComments < <%= parent_class.to_s %>
|
|
1
|
+
class CreateActiveAdminComments < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version.to_s %>]
|
|
6
2
|
def self.up
|
|
7
3
|
create_table :active_admin_comments do |t|
|
|
8
4
|
t.string :namespace
|
|
9
5
|
t.text :body
|
|
10
6
|
t.references :resource, polymorphic: true
|
|
11
7
|
t.references :author, polymorphic: true
|
|
12
|
-
<%- if Rails::VERSION::MAJOR >= 5 -%>
|
|
13
8
|
t.timestamps
|
|
14
|
-
<%- else -%>
|
|
15
|
-
t.timestamps null: false
|
|
16
|
-
<%- end -%>
|
|
17
9
|
end
|
|
18
10
|
add_index :active_admin_comments, [:namespace]
|
|
19
|
-
<%- unless Rails::VERSION::MAJOR >= 5 -%>
|
|
20
|
-
|
|
21
|
-
add_index :active_admin_comments, [:author_type, :author_id]
|
|
22
|
-
add_index :active_admin_comments, [:resource_type, :resource_id]
|
|
23
|
-
<%- end -%>
|
|
24
|
-
|
|
25
11
|
end
|
|
26
12
|
|
|
27
13
|
def self.down
|
|
@@ -6,19 +6,13 @@ create_file 'app/assets/stylesheets/some-random-css.css'
|
|
|
6
6
|
create_file 'app/assets/javascripts/some-random-js.js'
|
|
7
7
|
create_file 'app/assets/images/a/favicon.ico'
|
|
8
8
|
|
|
9
|
-
belongs_to_optional_flag = if Rails::VERSION::MAJOR < 5
|
|
10
|
-
"required: false"
|
|
11
|
-
else
|
|
12
|
-
"optional: true"
|
|
13
|
-
end
|
|
14
|
-
|
|
15
9
|
generate :model, 'post title:string body:text published_date:date author_id:integer ' +
|
|
16
10
|
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
|
|
17
11
|
|
|
18
12
|
create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
|
|
19
13
|
class Post < ActiveRecord::Base
|
|
20
|
-
belongs_to :category, foreign_key: :custom_category_id,
|
|
21
|
-
belongs_to :author, class_name: 'User',
|
|
14
|
+
belongs_to :category, foreign_key: :custom_category_id, optional: true
|
|
15
|
+
belongs_to :author, class_name: 'User', optional: true
|
|
22
16
|
has_many :taggings
|
|
23
17
|
accepts_nested_attributes_for :author
|
|
24
18
|
accepts_nested_attributes_for :taggings, allow_destroy: true
|
|
@@ -102,14 +96,14 @@ RUBY
|
|
|
102
96
|
generate :model, 'tagging post_id:integer tag_id:integer position:integer'
|
|
103
97
|
create_file 'app/models/tagging.rb', <<-RUBY.strip_heredoc, force: true
|
|
104
98
|
class Tagging < ActiveRecord::Base
|
|
105
|
-
belongs_to :post,
|
|
106
|
-
belongs_to :tag,
|
|
99
|
+
belongs_to :post, optional: true
|
|
100
|
+
belongs_to :tag, optional: true
|
|
107
101
|
|
|
108
102
|
delegate :name, to: :tag, prefix: true
|
|
109
103
|
end
|
|
110
104
|
RUBY
|
|
111
105
|
|
|
112
|
-
gsub_file 'config/environments/test.rb', / config.cache_classes =
|
|
106
|
+
gsub_file 'config/environments/test.rb', / config.cache_classes = .*$/, <<-RUBY
|
|
113
107
|
|
|
114
108
|
config.cache_classes = !ENV['CLASS_RELOADING']
|
|
115
109
|
config.action_mailer.default_url_options = {host: 'example.com'}
|
|
@@ -117,6 +111,14 @@ gsub_file 'config/environments/test.rb', / config.cache_classes = true/, <<-RUB
|
|
|
117
111
|
|
|
118
112
|
config.active_record.maintain_test_schema = false
|
|
119
113
|
|
|
114
|
+
if Rails::VERSION::MAJOR >= 6
|
|
115
|
+
config.hosts = [
|
|
116
|
+
IPAddr.new("0.0.0.0/0"), # All IPv4 addresses.
|
|
117
|
+
IPAddr.new("::/0"), # All IPv6 addresses.
|
|
118
|
+
"www.example.com",
|
|
119
|
+
"localhost" # The localhost reserved domain.
|
|
120
|
+
]
|
|
121
|
+
end
|
|
120
122
|
RUBY
|
|
121
123
|
|
|
122
124
|
# TODO: remove this line after the STI pre-loading is fixed
|
|
@@ -58,9 +58,7 @@ RSpec.describe 'defining actions from registration blocks', type: :controller do
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it 'sets the page title' do
|
|
61
|
-
params
|
|
62
|
-
params = {params: params} if ActiveAdmin::Dependency.rails5?
|
|
63
|
-
get :comment, params
|
|
61
|
+
get :comment, params: { id: 1 }
|
|
64
62
|
|
|
65
63
|
expect(controller.instance_variable_get(:@page_title)).to eq 'My Awesome Comment'
|
|
66
64
|
end
|
data/tasks/local.rake
CHANGED
|
@@ -12,7 +12,7 @@ task :local do
|
|
|
12
12
|
# If it's a rails command, or we're using Rails 5, auto add the rails script
|
|
13
13
|
rails_commands = %w(generate console server db dbconsole g c s runner)
|
|
14
14
|
|
|
15
|
-
if
|
|
15
|
+
if rails_commands.include?(argv[0])
|
|
16
16
|
argv.unshift('rails')
|
|
17
17
|
end
|
|
18
18
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeadmin-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Greg Bell
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: arbre
|
|
@@ -114,28 +114,28 @@ dependencies:
|
|
|
114
114
|
requirements:
|
|
115
115
|
- - ">="
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
117
|
+
version: 1.0.1
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - ">="
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
124
|
+
version: 1.0.1
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
126
|
name: railties
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '
|
|
131
|
+
version: '5.0'
|
|
132
132
|
type: :runtime
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - ">="
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '
|
|
138
|
+
version: '5.0'
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: ransack
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,33 +151,33 @@ dependencies:
|
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
152
|
version: 1.8.7
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
|
-
name: sass
|
|
154
|
+
name: sass-rails
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
|
156
156
|
requirements:
|
|
157
|
-
- - "
|
|
157
|
+
- - ">="
|
|
158
158
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: '
|
|
159
|
+
version: '0'
|
|
160
160
|
type: :runtime
|
|
161
161
|
prerelease: false
|
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
163
|
requirements:
|
|
164
|
-
- - "
|
|
164
|
+
- - ">="
|
|
165
165
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: '
|
|
166
|
+
version: '0'
|
|
167
167
|
- !ruby/object:Gem::Dependency
|
|
168
168
|
name: sprockets
|
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
|
170
170
|
requirements:
|
|
171
|
-
- - "
|
|
171
|
+
- - ">="
|
|
172
172
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: '
|
|
173
|
+
version: '0'
|
|
174
174
|
type: :runtime
|
|
175
175
|
prerelease: false
|
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements:
|
|
178
|
-
- - "
|
|
178
|
+
- - ">="
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
|
-
version: '
|
|
180
|
+
version: '0'
|
|
181
181
|
description: The administration framework for Ruby on Rails.
|
|
182
182
|
email:
|
|
183
183
|
- gregdbell@gmail.com
|
|
@@ -504,7 +504,6 @@ files:
|
|
|
504
504
|
- lib/active_admin/helpers/collection.rb
|
|
505
505
|
- lib/active_admin/helpers/i18n.rb
|
|
506
506
|
- lib/active_admin/helpers/optional_display.rb
|
|
507
|
-
- lib/active_admin/helpers/output_safety_helper.rb
|
|
508
507
|
- lib/active_admin/helpers/routes/url_helpers.rb
|
|
509
508
|
- lib/active_admin/helpers/scope_chain.rb
|
|
510
509
|
- lib/active_admin/inputs.rb
|
|
@@ -542,7 +541,6 @@ files:
|
|
|
542
541
|
- lib/active_admin/page_dsl.rb
|
|
543
542
|
- lib/active_admin/page_presenter.rb
|
|
544
543
|
- lib/active_admin/pundit_adapter.rb
|
|
545
|
-
- lib/active_admin/reloader.rb
|
|
546
544
|
- lib/active_admin/resource.rb
|
|
547
545
|
- lib/active_admin/resource/action_items.rb
|
|
548
546
|
- lib/active_admin/resource/attributes.rb
|
|
@@ -700,7 +698,6 @@ files:
|
|
|
700
698
|
- spec/unit/form_builder_spec.rb
|
|
701
699
|
- spec/unit/generators/install_spec.rb
|
|
702
700
|
- spec/unit/helpers/collection_spec.rb
|
|
703
|
-
- spec/unit/helpers/output_safety_helper_spec.rb
|
|
704
701
|
- spec/unit/helpers/scope_chain_spec.rb
|
|
705
702
|
- spec/unit/i18n_spec.rb
|
|
706
703
|
- spec/unit/localizers/resource_localizer_spec.rb
|
|
@@ -793,7 +790,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
793
790
|
- !ruby/object:Gem::Version
|
|
794
791
|
version: '0'
|
|
795
792
|
requirements: []
|
|
796
|
-
|
|
793
|
+
rubyforge_project:
|
|
794
|
+
rubygems_version: 2.7.10
|
|
797
795
|
signing_key:
|
|
798
796
|
specification_version: 4
|
|
799
797
|
summary: The administration framework for Ruby on Rails.
|
|
@@ -951,7 +949,6 @@ test_files:
|
|
|
951
949
|
- spec/unit/form_builder_spec.rb
|
|
952
950
|
- spec/unit/generators/install_spec.rb
|
|
953
951
|
- spec/unit/helpers/collection_spec.rb
|
|
954
|
-
- spec/unit/helpers/output_safety_helper_spec.rb
|
|
955
952
|
- spec/unit/helpers/scope_chain_spec.rb
|
|
956
953
|
- spec/unit/i18n_spec.rb
|
|
957
954
|
- spec/unit/localizers/resource_localizer_spec.rb
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module ActiveAdmin
|
|
2
|
-
module OutputSafetyHelper
|
|
3
|
-
# Converts the array to a comma-separated sentence where the last element is
|
|
4
|
-
# joined by the connector word. This is the html_safe-aware version of
|
|
5
|
-
# ActiveSupport's {Array#to_sentence}[http://api.rubyonrails.org/classes/Array.html#method-i-to_sentence].
|
|
6
|
-
#
|
|
7
|
-
# Copied from Rails 5 to support Rails 4.
|
|
8
|
-
# https://github.com/rails/rails/blob/9c35bf2a6a27431c6aa283db781c19f61c5155be/actionview/lib/action_view/helpers/output_safety_helper.rb#L43
|
|
9
|
-
def to_sentence(array, options = {})
|
|
10
|
-
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
|
|
11
|
-
|
|
12
|
-
default_connectors = {
|
|
13
|
-
words_connector: ", ",
|
|
14
|
-
two_words_connector: " and ",
|
|
15
|
-
last_word_connector: ", and "
|
|
16
|
-
}
|
|
17
|
-
if defined?(::I18n)
|
|
18
|
-
i18n_connectors = ::I18n.translate(:'support.array', locale: options[:locale], default: {})
|
|
19
|
-
default_connectors.merge!(i18n_connectors)
|
|
20
|
-
end
|
|
21
|
-
options = default_connectors.merge!(options)
|
|
22
|
-
|
|
23
|
-
case array.length
|
|
24
|
-
when 0
|
|
25
|
-
"".html_safe
|
|
26
|
-
when 1
|
|
27
|
-
ERB::Util.html_escape(array[0])
|
|
28
|
-
when 2
|
|
29
|
-
safe_join([array[0], array[1]], options[:two_words_connector])
|
|
30
|
-
else
|
|
31
|
-
safe_join([safe_join(array[0...-1], options[:words_connector]), options[:last_word_connector], array[-1]], nil)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module ActiveAdmin
|
|
2
|
-
module Reloader
|
|
3
|
-
# ActionDispatch::Reloader.to_prepare is deprecated in Rails 5.0 and will be removed from Rails 5.1
|
|
4
|
-
#
|
|
5
|
-
# Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
|
|
6
|
-
def self.to_prepare(*args, &block)
|
|
7
|
-
if defined? ActiveSupport::Reloader
|
|
8
|
-
ActiveSupport::Reloader.to_prepare(*args, &block)
|
|
9
|
-
else
|
|
10
|
-
ActionDispatch::Reloader.to_prepare(*args, &block)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# ActionDispatch::Reloader.to_cleanup is deprecated in Rails 5.0 and will be removed from Rails 5.1
|
|
15
|
-
#
|
|
16
|
-
# Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
|
|
17
|
-
def self.to_complete(*args, &block)
|
|
18
|
-
if defined? ActiveSupport::Reloader
|
|
19
|
-
ActiveSupport::Reloader.to_complete(*args, &block)
|
|
20
|
-
else
|
|
21
|
-
ActionDispatch::Reloader.to_cleanup(*args, &block)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
require 'rails_helper'
|
|
2
|
-
|
|
3
|
-
# Adapted from Rails 5 to support Rails 4.
|
|
4
|
-
# https://github.com/rails/rails/blob/9c35bf2a6a27431c6aa283db781c19f61c5155be/actionview/test/template/output_safety_helper_test.rb
|
|
5
|
-
RSpec.describe ActiveAdmin::OutputSafetyHelper, type: :view do
|
|
6
|
-
include described_class
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
@string = "hello"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "to_sentence" do
|
|
13
|
-
it "escapes non-html_safe values" do
|
|
14
|
-
actual = to_sentence(%w(< > & ' "))
|
|
15
|
-
assert actual.html_safe?
|
|
16
|
-
assert_equal("<, >, &, ', and "", actual)
|
|
17
|
-
|
|
18
|
-
actual = to_sentence(%w(<script>))
|
|
19
|
-
assert actual.html_safe?
|
|
20
|
-
assert_equal("<script>", actual)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "does not double escape if single value is html_safe" do
|
|
24
|
-
assert_equal("<script>", to_sentence([ERB::Util.html_escape("<script>")]))
|
|
25
|
-
assert_equal("<script>", to_sentence(["<script>".html_safe]))
|
|
26
|
-
assert_equal("&lt;script&gt;", to_sentence(["<script>"]))
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "checks connector words for html safety" do
|
|
30
|
-
assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe)
|
|
31
|
-
assert_equal "one & two", to_sentence(["one", "two"], two_words_connector: " & ".html_safe)
|
|
32
|
-
assert_equal "one, two <script>alert(1)</script> three", to_sentence(["one", "two", "three"], last_word_connector: " <script>alert(1)</script> ")
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "does not escape html_safe values" do
|
|
36
|
-
ptag = content_tag("p") do
|
|
37
|
-
safe_join(["<marquee>shady stuff</marquee>", tag("br")])
|
|
38
|
-
end
|
|
39
|
-
url = "https://example.com"
|
|
40
|
-
expected = %(<a href="#{url}">#{url}</a> and <p><marquee>shady stuff</marquee><br /></p>)
|
|
41
|
-
actual = to_sentence([link_to(url, url), ptag])
|
|
42
|
-
assert actual.html_safe?
|
|
43
|
-
assert_equal(expected, actual)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "handles blank strings" do
|
|
47
|
-
actual = to_sentence(["", "two", "three"])
|
|
48
|
-
assert actual.html_safe?
|
|
49
|
-
assert_equal ", two, and three", actual
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
it "handles nil values" do
|
|
53
|
-
actual = to_sentence([nil, "two", "three"])
|
|
54
|
-
assert actual.html_safe?
|
|
55
|
-
assert_equal ", two, and three", actual
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "still supports ActiveSupports Array#to_sentence arguments" do
|
|
59
|
-
assert_equal "one two, and three", to_sentence(["one", "two", "three"], words_connector: " ")
|
|
60
|
-
assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe)
|
|
61
|
-
assert_equal "onetwo, and three", to_sentence(["one", "two", "three"], words_connector: nil)
|
|
62
|
-
assert_equal "one, two, and also three", to_sentence(["one", "two", "three"], last_word_connector: ", and also ")
|
|
63
|
-
assert_equal "one, twothree", to_sentence(["one", "two", "three"], last_word_connector: nil)
|
|
64
|
-
assert_equal "one, two three", to_sentence(["one", "two", "three"], last_word_connector: " ")
|
|
65
|
-
assert_equal "one, two and three", to_sentence(["one", "two", "three"], last_word_connector: " and ")
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it "is not affected by $," do
|
|
69
|
-
separator_was = $,
|
|
70
|
-
$, = "|"
|
|
71
|
-
begin
|
|
72
|
-
assert_equal "one and two", to_sentence(["one", "two"])
|
|
73
|
-
assert_equal "one, two, and three", to_sentence(["one", "two", "three"])
|
|
74
|
-
ensure
|
|
75
|
-
$, = separator_was
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|