Skip to content

Commit 44c9051

Browse files
authored
Merge pull request #44 from workgena/compatibilty_with_activeadmin_1.3
Fix missing CSS-styling in production mode
2 parents 081593e + a7731bf commit 44c9051

File tree

11 files changed

+81
-74
lines changed

11 files changed

+81
-74
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Gemfile.lock
2+
coverage/
3+
spec/rails/rails-5.2.1/

.travis.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
sudo: required
2+
language: ruby
3+
addons:
4+
chrome: stable
5+
6+
before_install: gem install bundler -v 1.16.0.pre.3
7+
18
script: bundle exec rspec spec
2-
cache: bundler
9+
310
env:
411
matrix:
5-
- RAILS=4.2.6 AA=1.1.0
6-
- RAILS=5.0.0 AA=1.2.1
12+
- RAILS=4.2.10 AA=1.1.0
13+
- RAILS=5.1.0 AA=1.2.1
14+
- RAILS=5.2.1 AA=1.3.1
715
rvm:
8-
- 2.2.6
9-
- 2.3.3
10-
before_install:
11-
- gem update --system
12-
- rvm @global do gem install bundler -v 1.14.6
13-
- gem --version
16+
- 2.3
17+
- 2.4
18+
- 2.5

Gemfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@ source 'https://rubygems.org'
33
# Specify your gem's dependencies in active_admin_datetimepicker.gemspec
44
gemspec
55
group :test do
6-
default_rails_version = '4.2.7'
7-
default_activeadmin_version = '1.1.0'
8-
gem 'sprockets-rails', '2.3.3'
9-
gem 'rails', "#{ENV['RAILS'] || default_rails_version}"
6+
default_rails_version = '5.2.1'
7+
default_activeadmin_version = '1.3.1'
8+
9+
gem 'rails', "~> #{ENV['RAILS'] || default_rails_version}"
10+
gem 'activeadmin', "~> #{ENV['AA'] || default_activeadmin_version}"
11+
1012
gem 'rspec-rails'
11-
gem 'activeadmin', "#{ENV['AA'] || default_activeadmin_version}"
1213
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
1314
gem 'sass-rails'
1415
gem 'sqlite3'
1516
gem 'launchy'
1617
gem 'database_cleaner'
1718
gem 'capybara'
1819
gem 'selenium-webdriver'
19-
gem 'poltergeist'
20+
gem 'chromedriver-helper'
2021
end

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# ActiveAdminDatetimepicker
66

7-
Adds ability to use XDSoft's DateTime picker as the date_time_picker input for forms, and date_time_range for filters
7+
Adds ability to use XDSoft's DateTime picker as the `date_time_picker` input for forms, and `date_time_range` for filters
88

99

1010
![ActiveAdminDatetimepicker](https://raw.githubusercontent.com/ActiveAdminPlugins/activeadmin_datetimepicker/master/screen/screen.png "ActiveAdminDatetimepicker")
@@ -25,31 +25,37 @@ Or install it yourself as:
2525

2626
$ gem install active_admin_datetimepicker
2727

28-
## Usage
28+
Add following line into `app/assets/stylesheets/active_admin.css.scss`
2929

30-
Plugin offers the `date_time_picker` input and `date_time_range` filter , which use the [XDSoft DateTime Picker gem](https://github.com/shekibobo/xdan-datetimepicker-rails).
31-
The `date_time_picker` input accepts many of the options available to the standard jQueryUI Datepicker. For example:
30+
```css
31+
@import "active_admin_datetimepicker";
32+
```
3233

33-
JS asset
34-
```//= require active_admin_datetimepicker```
34+
Add following line into `app/assets/javascripts/active_admin.js.coffee`
3535

36-
CSS
37-
```@import "active_admin_datetimepicker";```
36+
```coffee
37+
#= require active_admin_datetimepicker
38+
```
3839

3940

40-
```ruby
41-
form do |f|
42-
f.input :starts_at, as: :date_time_picker, datepicker_options: { min_date: "2013-10-8", max_date: "+3D" }
43-
f.input :ends_at, as: :date_time_picker, datepicker_options: { min_date: 3.days.ago.to_date, max_date: "+1W +5D" }
44-
end
45-
```
41+
## Usage
42+
43+
Plugin offers the `date_time_picker` input and `date_time_range` filter, which use the [XDSoft DateTime Picker gem](https://github.com/shekibobo/xdan-datetimepicker-rails).
44+
The `date_time_picker` input accepts many of the options available to the standard jQueryUI Datepicker. For example:
4645

4746
```ruby
48-
filter :created_at, as: :date_time_range
47+
# Index page filters
48+
filter :created_at, as: :date_time_range
49+
50+
# New/Edit form
51+
form do |f|
52+
f.input :starts_at, as: :date_time_picker, datepicker_options: { min_date: "2013-10-8", max_date: "+3D" }
53+
f.input :ends_at, as: :date_time_picker, datepicker_options: { min_date: 3.days.ago.to_date, max_date: "+1W +5D" }
54+
end
4955
```
5056

51-
5257
## Override behaviour in initializer
58+
5359
```ruby
5460
# This if for front-end javascript side
5561
ActiveAdminDatetimepicker::Base.default_datetime_picker_options = {
@@ -60,9 +66,10 @@ ActiveAdminDatetimepicker::Base.format = "%Y-%m-%d %H:%M:%S"
6066
```
6167

6268
## Change datetime format
63-
If you want to change format - you need to make sure that front-end and back-end formats are identical. And remember JS and Ruby datetime format has different syntax.
69+
If you want to change format - you need to make sure that front-end and back-end formats are identical.
70+
And remember JS and Ruby datetime format has different syntax.
6471

65-
Create configuration file '/config/initializers/init_datetimpicker.rb'
72+
Create configuration file `/config/initializers/init_datetimpicker.rb`
6673

6774
```ruby
6875
# Example "11/03/2016 13:00"

active_admin_datetimepicker.gemspec

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Gem::Specification.new do |spec|
1919
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
2020
spec.require_paths = ["lib"]
2121

22-
spec.add_dependency "xdan-datetimepicker-rails", "~> 2.5.1"
2322
spec.add_dependency "activeadmin", "~> 1.1"
24-
spec.add_development_dependency "bundler", "~> 1.8"
25-
spec.add_development_dependency "rake", "~> 10.0"
26-
23+
spec.add_dependency "xdan-datetimepicker-rails", "~> 2.5.4"
2724
end

app/assets/stylesheets/active_admin_datetimepicker.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import "jquery.xdan.datetimepicker";
2-
31
form.filter_form {
42
.filter_form_field {
53
&.filter_date_time_range {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ActiveAdmin.setup do |config|
2+
config.register_stylesheet 'jquery.xdan.datetimepicker.css'
3+
end

spec/rails/.keep

Whitespace-only changes.

spec/spec_helper.rb

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
ActiveAdmin.application.current_user_method = false
3131

3232
require 'rspec/rails'
33-
require 'support/admin'
3433
require 'capybara/rails'
3534
require 'capybara/rspec'
36-
require 'capybara/poltergeist'
35+
require 'selenium-webdriver'
3736

37+
require 'support/admin'
38+
require 'support/capybara'
3839

3940
RSpec.configure do |config|
4041
config.use_transactional_fixtures = false
@@ -43,42 +44,13 @@
4344
DatabaseCleaner.strategy = :truncation
4445
DatabaseCleaner.clean_with(:truncation)
4546
end
47+
4648
config.before(:each) do
4749
DatabaseCleaner.strategy = :truncation
4850
DatabaseCleaner.start
4951
end
52+
5053
config.after(:each) do
5154
DatabaseCleaner.clean
5255
end
53-
5456
end
55-
56-
57-
Capybara.default_selector = :css
58-
59-
Capybara.configure do |config|
60-
config.match = :prefer_exact
61-
config.ignore_hidden_elements = false
62-
end
63-
64-
# Capybara.javascript_driver = :selenium
65-
#
66-
# RSpec.configure do |config|
67-
# config.before(:each, js: true) do
68-
# page.driver.browser.manage.window.maximize if page.driver.browser.respond_to?(:manage)
69-
# end
70-
# end
71-
#
72-
73-
Capybara.register_driver :poltergeist do |app|
74-
Capybara::Poltergeist::Driver.new(app, {
75-
js_errors: true,
76-
timeout: 80,
77-
debug: true,
78-
:phantomjs_options => ['--debug=no', '--load-images=no']
79-
80-
})
81-
end
82-
83-
Capybara.javascript_driver = :poltergeist
84-

spec/support/capybara.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Capybara.server = :webrick
2+
3+
Capybara.configure do |config|
4+
config.match = :prefer_exact
5+
end
6+
7+
Capybara.register_driver :selenium_chrome do |app|
8+
options = Selenium::WebDriver::Chrome::Options.new(
9+
args: %w[headless disable-gpu no-sandbox]
10+
)
11+
Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
12+
end
13+
14+
Capybara.javascript_driver = :selenium_chrome

tasks/test.rake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
desc "Creates a test rails app for the specs to run against"
22
task :setup do
33
require 'rails/version'
4-
system("mkdir spec/rails") unless File.exists?("spec/rails")
5-
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} -m spec/support/rails_template.rb --skip-spring"
4+
5+
rails_new_opts = %w(
6+
--skip-turbolinks
7+
--skip-spring
8+
--skip-bootsnap
9+
-m
10+
spec/support/rails_template.rb
11+
)
12+
system "bundle exec rails new spec/rails/rails-#{Rails::VERSION::STRING} #{rails_new_opts.join(' ')}"
613
end

0 commit comments

Comments
 (0)