Skip to content

Fix compatibility with ActiveAdmin 2.6 #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin/
Gemfile.lock
coverage/
spec/rails/rails-*
Expand Down
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ script: bundle exec rspec spec

env:
matrix:
- RAILS=4.2.0 AA=1.1.0
- RAILS=5.1.0 AA=1.2.0
- RAILS=5.2.0 AA=1.3.0
- RAILS=5.2.0 AA=1.4.0
- RAILS=5.2.0 AA=2.0.0
- RAILS=6.0.0 AA=2.6.0

rvm:
- 2.4
- 2.5
- 2.6
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ source 'https://rubygems.org'
gemspec

group :test do
default_rails_version = '5.2.1'
default_activeadmin_version = '2.0.0'
default_rails_version = '6.0.0'
default_activeadmin_version = '2.6.0'

gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
Expand All @@ -14,7 +14,7 @@ group :test do
gem 'rspec-rails'
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
gem 'sass-rails'
gem 'sqlite3', '~> 1.3.6'
gem 'sqlite3', '~> 1.4.0'
gem 'launchy'
gem 'database_cleaner'
gem 'capybara'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def input_html_options(input_name = gt_input_name, placeholder = gt_input_placeh
end
end

# This method is for compatibility for ActiveAdmin 2.6
def input_html_options_for(input_name, placeholder)
super.merge placeholder: placeholder,
value: input_value(input_name)
end

def gt_input_name
column && column.type == :date ? super : "#{method}_gteq_datetime_picker"
end
Expand Down
11 changes: 9 additions & 2 deletions spec/filter_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
page.find('.xdsoft_datetimepicker', visible: true)
.find('.xdsoft_timepicker.active .xdsoft_time.xdsoft_current').click

@value_from = page.find('#q_created_at_gteq_datetime_picker').value
@value_to = page.find('#q_created_at_lteq_datetime_picker').value

page.find('#sidebar input[type=submit]').click
page.has_css?('h4', text: 'Current filters:')
end
Expand All @@ -80,9 +83,13 @@
expect(page).not_to have_text('from-the-future')
end

it 'submit filter form' do
it 'input#value and placeholder is the same as before form submit' do
# created_at(Timestamp type) should contain Hours:Minutes, as selected before submit
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/)
expect(page.find('#q_created_at_gteq_datetime_picker').value).to match(@value_from)
expect(page.find('#q_created_at_lteq_datetime_picker').value).to match(@value_to)

expect(page).to have_css('#q_created_at_gteq_datetime_picker[placeholder=From]')
expect(page).to have_css('#q_created_at_lteq_datetime_picker[placeholder=To]')
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require 'active_model'
# require ActiveRecord to ensure that Ransack loads correctly
require 'active_record'
require 'action_view'
require 'active_admin'
ActiveAdmin.application.load_paths = [ENV['RAILS_ROOT'] + "/app/admin"]
require ENV['RAILS_ROOT'] + '/config/environment.rb'
Expand Down