10000 Merge pull request #4870 from activeadmin/drop_rails_under_4.2_support · activeadmin/activeadmin@4b49319 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b49319

Browse files
authored
Merge pull request #4870 from activeadmin/drop_rails_under_4.2_support
Drop Rails < 4.2 support
2 parents 8f44d58 + 309c279 commit 4b49319

25 files changed

+57
-176
lines changed

.travis.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ rvm:
2525
- 2.4.0
2626

2727
gemfile:
28-
- gemfiles/rails_40.gemfile
29-
- gemfiles/rails_41.gemfile
3028
- gemfiles/rails_42.gemfile
3129
- gemfiles/rails_50.gemfile
3230

@@ -41,13 +39,6 @@ matrix:
4139
- rvm: jruby-9.1.8.0
4240
gemfile: gemfiles/rails_50.gemfile
4341

44-
exclude:
45-
- rvm: 2.4.0
46-
gemfile: gemfiles/rails_40.gemfile
47-
48-
- rvm: 2.4.0
49-
gemfile: gemfiles/rails_41.gemfile
50-
5142
notifications:
5243
irc:
5344
channels:

Appraisals

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,3 @@
1-
appraise 'rails_40' do
2-
gemspec
3-
4-
gem 'rails', '4.0.13'
5-
gem 'jquery-ui-rails', '~> 5.0'
6-
gem 'devise', '~> 3.5'
7-
8-
gem 'draper', '~> 2.1'
9-
10-
gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
11-
end
12-
13-
appraise 'rails_41' do
14-
gemspec
15-
16-
gem 'rails', '4.1.16'
17-
gem 'jquery-ui-rails', '~> 5.0'
18-
gem 'devise', '~> 3.5'
19-
20-
gem 'draper', '~> 2.1'
21-
22-
gem 'activerecord-jdbcsqlite3-adapter', platforms: :jruby
23-
end
24-
251
appraise 'rails_42' do
262
gemspec
273

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* `config.show_comments_in_menu` has been removed, see `config.comments_menu` [#4187][] by [@drn][]
1111
* Rails 3.2 & Ruby 1.9.3 support has been dropped [#4848][] [@deivid-rodriguez][]
1212
* Ruby 2.0.0 support has been dropped [#4851][] [@deivid-rodriguez][]
13+
* Rails 4.0 & 4.1 support has been dropped [#4855][] [@deivid-rodriguez][]
1314

1415
### Enhancements
1516

activeadmin.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
2727
s.add_dependency 'jquery-rails'
2828
s.add_dependency 'jquery-ui-rails'
2929
s.add_dependency 'kaminari', '>= 0.15', '< 2.0'
30-
s.add_dependency 'railties', '>= 4.0', '< 5.1'
30+
s.add_dependency 'railties', '>= 4.2', '< 5.1'
3131
s.add_dependency 'ransack', '~> 1.3'
3232
s.add_dependency 'sass-rails'
3333
s.add_dependency 'sprockets', '< 4.1'

docs/9-batch-actions.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ end
147147
When you have dynamic form inputs you can pass a proc instead:
148148

149149
```ruby
150-
# NOTE: multi-pluck is new to Rails 4
151150
batch_action :doit, form: -> { {user: User.pluck(:name, :id)} } do |ids, inputs|
152151
User.find(inputs[:user])
153152
# ...

gemfiles/rails_40.gemfile

Lines changed: 0 additions & 45 deletions
This file was deleted.

gemfiles/rails_41.gemfile

Lines changed: 0 additions & 45 deletions
This file was deleted.

lib/active_admin/dependency.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module Requirements
2121
# ActiveAdmin::Dependency.draper? '~> 1.2.0'
2222
# => true
2323
#
24-
# ActiveAdmin::Dependency.rails? '>= 4.1.0', '<= 4.1.1'
24+
# ActiveAdmin::Dependency.rails? '>= 4.2.7', '<= 5.0.2'
2525
# => true
2626
#
2727
# ActiveAdmin::Dependency.rails! '5'

lib/active_admin/orm/active_record/comments.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@
4646
controller do
4747
# Prevent N+1 queries
4848
def scoped_collection
49-
super.includes *( # rails/rails#14734
50-
ActiveAdmin::Dependency.rails?('>= 4.1.0', '<= 4.1.1') ?
51-
[:author] : [:author, :resource]
52-
)
49+
super.includes(:author, :resource)
5350
end
5451

5552
# Redirect to the resource show page after comment creation

lib/active_admin/resource/routes.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def batch_action_path(params, additional_params = {})
6262
)
6363

6464
query = params.slice(:q, :scope)
65-
query = query.permit! if query.respond_to? :permit!
66-
query = query.to_h if Rails::VERSION::MAJOR >= 5
65+
query = query.permit!.to_h
6766
routes.public_send route_name, *route_collection_params(params), additional_params.merge(query)
6867
end
6968

lib/active_admin/view_helpers/fields_for.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module FormHelper
1616
def fields_for_params(params, options = {})
1717
namespace = options[:namespace]
1818
except = Array.wrap(options[:except]).map &:to_s
19-
params = params.respond_to?(:to_unsafe_h) ? params.to_unsafe_h : params
2019

2120
params.flat_map do |k, v|
2221
next if namespace.nil? && %w(controller action commit utf8).include?(k.to_s)

lib/active_admin/view_helpers/form_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def active_admin_form_for(resource, options = {}, &block)
99
end
1010

1111
def hidden_field_tags_for(params, options={})
12-
fields_for_params(params, options).map do |kv|
12+
fields_for_params(params.to_unsafe_hash, options).map do |kv|
1313
k, v = kv.first
1414
hidden_field_tag k, v, id: sanitize_to_id("hidden_active_admin_#{k}")
1515
end.join("\n").html_safe

lib/active_admin/views/components/active_admin_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def build(resource, options = {}, &block)
3434
@opening_tag, @closing_tag = split_string_on(form_string, "</form>")
3535
instance_eval(&block) if block_given?
3636

37-
# Rails 4 sets multipart automatically if a file field is present,
37+
# Rails sets multipart automatically if a file field is present,
3838
# but the form tag has already been rendered before the block eval.
3939
if multipart? && @opening_tag !~ /multipart/
4040
@opening_tag.sub!(/<form/, '<form enctype="multipart/form-data"')

spec/support/active_admin_integration_spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def render_arbre_component(assigns = {}, helpers = mock_action_view, &block)
4646
# Returns a fake action view instance to use with our renderers
4747
def mock_action_view(assigns = {})
4848
controller = ActionView::TestCase::TestController.new
49+
#this line needed because of rails bug https://github.com/rails/rails/commit/d8e98897b5703ac49bf0764da71a06d64ecda9b0
50+
controller.params = ActionController::Parameters.new
4951
MockActionView.new(ActionController::Base.view_paths, assigns, controller)
5052
end
51< 10000 /code>53
alias_method :action_view, :mock_action_view

spec/support/rails_template.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Rails template to build the sample app for specs
22

3-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
4-
copy_file File.expand_path('../templates/manifest.js', __FILE__), 'app/assets/config/manifest.js', force: true
5-
end
3+
copy_file File.expand_path('../templates/manifest.js', __FILE__), 'app/assets/config/manifest.js', force: true
64

75
generate :model, 'post title:string body:text published_date:date author_id:integer ' +
86
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
@@ -135,9 +133,7 @@ class Tagging < ActiveRecord::Base
135133
config.action_mailer.default_url_options = {host: 'example.com'}
136134
config.assets.digest = false
137135
138-
if Rails::VERSION::MAJOR >= 4 && Rails::VERSION::MINOR >= 1
139-
config.active_record.maintain_test_schema = false
140-
end
136+
config.active_record.maintain_test_schema = false
141137
142138
RUBY
143139

@@ -170,10 +166,6 @@ class Tagging < ActiveRecord::Base
170166
inject_into_file 'config/routes.rb', "\n root to: redirect('admin')", after: /.*routes.draw do/
171167
end
172168

173-
# Devise master doesn't set up its secret key on Rails 4.1
174-
# https://github.com/plataformatec/devise/issues/2554
175-
gsub_file 'config/initializers/devise.rb', /# config.secret_key =/, 'config.secret_key ='
176-
177169
rake "db:drop db:create db:migrate", env: 'development'
178170
rake "db:drop db:create db:migrate", env: 'test'
179171

spec/unit/belongs_to_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ class Blog::Author
5757

5858
describe "controller" do
5959
let(:controller) { post_config.controller.new }
60+
let(:http_params) { {user_id: user.id} }
61+
let(:user) { User.create! }
62+
6063
before do
61-
user = User.create!
6264
request = double 'Request', format: 'application/json'
63-
allow(controller).to receive(:params) { {user_id: user.id} }
65+
allow(controller).to receive(:params) { ActionController::Parameters.new(http_params) }
6466
allow(controller).to receive(:request){ request }
6567
end
68+
6669
it 'should be able to access the collection' do
6770
expect(controller.send :collection).to be_a ActiveRecord::Relation
71+
6872
end
6973
it 'should be able to build a new resource' do
7074
expect(controller.send :build_resource).to be_a Post

spec/unit/filters/active_spec.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22

33
RSpec.describe ActiveAdmin::Filters::Active do
44
subject { described_class.new(Post, params) }
5-
let(:params_klass) do
6-
if defined? ::ActionController::Parameters
7-
::ActionController::Parameters
8-
else
9-
HashWithIndifferentAccess #remove this when drop rails 3 support
10-
end
11-
end
125

136
let(:params) do
14-
params_klass.new(q: {author_id_eq: 1})
7+
::ActionController::Parameters.new(q: {author_id_eq: 1})
158
end
169

1710
it 'should have filters' do

spec/unit/resource/routes_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ::News; def self.has_many(*); end end
101101
end
102102

103103
it "should include :scope and :q params" do
104-
params = { category_id: 1, q: { name_equals: "Any" }, scope: :all }
104+
params = ActionController::Parameters.new(category_id: 1, q: { name_equals: "Any" }, scope: :all)
105105
additional_params = { locale: 'en' }
106106
batch_action_path = "/admin/categories/1/posts/batch_action?locale=en&q%5Bname_equals%5D=Any&scope=all"
107107

@@ -115,7 +115,7 @@ class ::News; def self.has_many(*); end end
115115
let(:config) { ActiveAdmin.register News }
116116

117117
it "should return the plural batch action route with _index and given params" do
118-
params = { q: { name_equals: "Any" }, scope: :all }
118+
params = ActionController::Parameters.new(q: { name_equals: "Any" }, scope: :all)
119119
additional_params = { locale: 'en' }
120120
batch_action_path = "/admin/news/batch_action?locale=en&q%5Bname_equals%5D=Any&scope=all"
121121
expect(config.route_batch_action_path(params, additional_params)).to eq batch_action_path

spec/unit/resource_controller/data_access_spec.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010
end
1111
end
1212

13-
let(:params) do
13+
let(:http_params) do
1414
{}
1515
end
1616

17+
let(:params) do
18+
ActionController::Parameters.new(http_params)
19+
end
20+
1721
let(:controller) do
1822
rc = Admin::PostsController.new
1923
allow(rc).to receive(:params) do
@@ -23,15 +27,15 @@
2327
end
2428

2529
describe "searching" do
26-
let(:params) {{ q: {} }}
30+
let(:http_params) {{ q: {} }}
2731
it "should call the search method" do
2832
chain = double "ChainObj"
2933
expect(chain).to receive(:ransack).with(params[:q]).once.and_return(Post.ransack)
3034
controller.send :apply_filtering, chain
3135
end
3236

3337
context "params includes empty values" do
34-
let(:params) do
38+
let(:http_params) do
3539
{ q: {id_eq: 1, position_eq: ""} }
3640
end
3741
it "should return relation without empty filters" do
@@ -48,7 +52,7 @@
4852
describe "sorting" do
4953

5054
context "valid clause" do
51-
let(:params) {{ order: "id_asc" }}
55+
let(:http_params) {{ order: "id_asc" }}
5256

5357
it "reorders chain" do
5458
chain = double "ChainObj"
@@ -58,7 +62,7 @@
5862
end
5963

6064
context "invalid clause" do
61-
let(:params) {{ order: "_asc" }}
65+
let(:http_params) {{ order: "_asc" }}
6266

6367
it "returns chain untouched" do
6468
chain = double "ChainObj"
@@ -79,15 +83,15 @@
7983
end
8084

8185
context "when params applicable" do
82-
let(:params) {{ order: "published_date_desc" }}
86+
let(:http_params) {{ order: "published_date_desc" }}
8387
it "reorders chain" do
8488
chain = double "ChainObj"
8589
expect(chain).to receive(:reorder).with('"posts"."published_date" desc NULLS LAST').once.and_return(Post.search)
8690
controller.send :apply_sorting, chain
8791
end
8892
end
8993
context "when params not applicable" do
90-
let(:params) {{ order: "published_date_asc" }}
94+
let(:http_params) {{ order: "published_date_asc" }}
9195
it "reorders chain" do
9296
chain = double "ChainObj"
9397
expect(chain).to receive(:reorder).with('"posts"."published_date" asc').once.and_return(Post.search)

0 commit comments

Comments
 (0)
0