Skip to content

Commit e900b93

Browse files
authored
Merge pull request #67 from workgena/aa_2.6
Fix compatibility with ActiveAdmin 2.6
2 parents fa1d2ad + 6561d7c commit e900b93

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
bin/
12
Gemfile.lock
23
coverage/
34
spec/rails/rails-*

.travis.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ script: bundle exec rspec spec
1111

1212
env:
1313
matrix:
14-
- RAILS=4.2.0 AA=1.1.0
15-
- RAILS=5.1.0 AA=1.2.0
16-
- RAILS=5.2.0 AA=1.3.0
1714
- RAILS=5.2.0 AA=1.4.0
1815
- RAILS=5.2.0 AA=2.0.0
16+
- RAILS=6.0.0 AA=2.6.0
1917

2018
rvm:
21-
- 2.4
19+
- 2.5
2220
- 2.6

Gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ source 'https://rubygems.org'
44
gemspec
55

66
group :test do
7-
default_rails_version = '5.2.1'
8-
default_activeadmin_version = '2.0.0'
7+
default_rails_version = '6.0.0'
8+
default_activeadmin_version = '2.6.0'
99

1010
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
1111
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
@@ -14,7 +14,7 @@ group :test do
1414
gem 'rspec-rails'
1515
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
1616
gem 'sass-rails'
17-
gem 'sqlite3', '~> 1.3.6'
17+
gem 'sqlite3', '~> 1.4.0'
1818
gem 'launchy'
1919
gem 'database_cleaner'
2020
gem 'capybara'

lib/active_admin_datetimepicker/inputs/filters/date_time_range_input.rb

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ def input_html_options(input_name = gt_input_name, placeholder = gt_input_placeh
1111
end
1212
end
1313

14+
# This method is for compatibility for ActiveAdmin 2.6
15+
def input_html_options_for(input_name, placeholder)
16+
super.merge placeholder: placeholder,
17+
value: input_value(input_name)
18+
end
19+
1420
def gt_input_name
1521
column && column.type == :date ? super : "#{method}_gteq_datetime_picker"
1622
end

spec/filter_form_spec.rb

+9-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
page.find('.xdsoft_datetimepicker', visible: true)
7272
.find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click
7373

74+
@value_from = page.find('#q_created_at_gteq_datetime_picker').value
75+
@value_to = page.find('#q_created_at_lteq_datetime_picker').value
76+
7477
page.find('#sidebar input[type=submit]').click
7578
page.has_css?('h4', text: 'Current filters:')
7679
end
@@ -80,9 +83,13 @@
8083
expect(page).not_to have_text('from-the-future')
8184
end
8285

83-
it 'submit filter form' do
86+
it 'input#value and placeholder is the same as before form submit' do
8487
# created_at(Timestamp type) should contain Hours:Minutes, as selected before submit
85-
expect(page.find('#q_created_at_gteq_datetime_picker').value).to match(/\A\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\z/)
88+
expect(page.find('#q_created_at_gteq_datetime_picker').value).to match(@value_from)
89+
expect(page.find('#q_created_at_lteq_datetime_picker').value).to match(@value_to)
90+
91+
expect(page).to have_css('#q_created_at_gteq_datetime_picker[placeholder=From]')
92+
expect(page).to have_css('#q_created_at_lteq_datetime_picker[placeholder=To]')
8693
end
8794
end
8895
end

spec/spec_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
require 'active_model'
2222
# require ActiveRecord to ensure that Ransack loads correctly
2323
require 'active_record'
24+
require 'action_view'
2425
require 'active_admin'
2526
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
2627
require ENV['RAILS_ROOT'] + '/config/environment.rb'

0 commit comments

Comments
 (0)