Skip to content

Commit

Permalink
Merge branch 'master' into restore_1_9_3_plus_rails_4_0_and_4_1_support
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Jan 11, 2017
2 parents 81bcae3 + bf6f3e0 commit a16ad36
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ install:
- bundle exec rake setup
- ./script/travis_cache upload
script:
- bundle exec rake test_with_coveralls
- bundle exec rake test
rvm:
- 1.9.3
- 2.2.6
Expand Down
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ platform :ruby_19 do # Remove this block when we drop support for Ruby 1.9
gem 'mime-types', '< 3'
gem 'nokogiri', '< 1.7'
gem 'public_suffix', '< 1.5'
gem 'term-ansicolor', '< 1.4'
end


Expand Down Expand Up @@ -66,7 +65,7 @@ group :test do
gem 'capybara'
gem 'simplecov', require: false # Test coverage generator. Go to /coverage/ after running tests
gem 'json', '~> 1.8', require: false # Required by simplecov, > 2 removes support for Ruby 1.9
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
gem 'codecov', require: false # Test coverage website. Go to https://codecov.io
gem 'tins', '~> 1.6.0', require: false # Required by coveralls, > 1.6.0 removes support for Ruby 1.9
gem 'cucumber-rails', require: false
gem 'cucumber', '1.3.20'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Active Admin is a Ruby on Rails framework for creating elegant backends for webs
[![Version ](http://img.shields.io/gem/v/activeadmin.svg) ](https://rubygems.org/gems/activeadmin)
[![Travis CI ](http://img.shields.io/travis/activeadmin/activeadmin/master.svg) ](https://travis-ci.org/activeadmin/activeadmin)
[![Quality ](http://img.shields.io/codeclimate/github/activeadmin/activeadmin.svg) ](https://codeclimate.com/github/activeadmin/activeadmin)
[![Coverage ](http://img.shields.io/coveralls/activeadmin/activeadmin.svg) ](https://coveralls.io/r/activeadmin/activeadmin)
[![Coverage ](https://codecov.io/gh/activeadmin/activeadmin/branch/master/graph/badge.svg)](https://codecov.io/gh/activeadmin/activeadmin)
[![Inch CI ](http://inch-ci.org/github/activeadmin/activeadmin.svg?branch=master) ](http://inch-ci.org/github/activeadmin/activeadmin)

## State of the project
Expand Down
2 changes: 1 addition & 1 deletion features/development_reloading.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: Development Reloading
ActiveAdmin.register Post do
if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title,
:body, :position, :published_at, :starred
:body, :position, :published_date, :starred
end
end
"""
Expand Down
12 changes: 6 additions & 6 deletions features/edit_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Edit Page
ActiveAdmin.register Post do
if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title,
:body, :position, :published_at, :starred
:body, :position, :published_date, :starred
end
end
"""
Expand All @@ -34,15 +34,15 @@ Feature: Edit Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :category, :author, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form do |f|
f.inputs "Your Post" do
f.input :title
f.input :body
end
f.inputs "Publishing" do
f.input :published_at
f.input :published_date
end
f.actions
end
Expand All @@ -63,15 +63,15 @@ Feature: Edit Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :category, :author, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form :html => {} do |f|
f.inputs "Your Post" do
f.input :title
f.input :body
end
f.inputs "Publishing" do
f.input :published_at
f.input :published_date
end
f.actions
end
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: Edit Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :category, :author, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :category, :author, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form :partial => "form"
end
Expand Down
14 changes: 7 additions & 7 deletions features/index/filters.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Feature: Index Filtering
When I am on the index page for posts
Then I should see "Displaying all 3 Posts"
And I should see the following filters:
| Author | select |
| Category | select |
| Title | string |
| Body | string |
| Published at | date range |
| Created at | date range |
| Updated at | date range |
| Author | select |
| Category | select |
| Title | string |
| Body | string |
| Published date | date range |
| Created at | date range |
| Updated at | date range |

When I fill in "Title" with "Hello World 2"
And I press "Filter"
Expand Down
4 changes: 2 additions & 2 deletions features/index/format_as_csv.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: Format as CSV
When I am on the index page for posts
And I follow "CSV"
And I should download a CSV file for "posts" containing:
| Id | Title | Body | Published at | Position | Starred | Created at | Updated at |
| Id | Title | Body | Published date | Position | Starred | Created at | Updated at |
| \d+ | Hello World | | | | | (.*) | (.*) |

Scenario: Default with alias
Expand All @@ -24,7 +24,7 @@ Feature: Format as CSV
When I am on the index page for my_articles
And I follow "CSV"
And I should download a CSV file for "my-articles" containing:
| Id | Title | Body | Published at | Position | Starred | Created at | Updated at |
| Id | Title | Body | Published date | Position | Starred | Created at | Updated at |

Scenario: With CSV format customization
Given a configuration of:
Expand Down
12 changes: 6 additions & 6 deletions features/index/index_as_table.feature
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ Feature: Index as Table
ActiveAdmin.register Post do
index do
column :author_id do end
column 'published_at' do end
column 'published_date' do end
column :category do end
end
end
"""
Then I should see a sortable table header with "Author"
Then I should see a sortable table header with "published_at"
Then I should see a sortable table header with "published_date"
Then I should not see a sortable table header with "Category"

Scenario: Columns with block are not sortable by when sortable option equals to false
Expand All @@ -234,12 +234,12 @@ Feature: Index as Table
ActiveAdmin.register Post do
index do
column :author_id, sortable: false do end
column 'published_at', sortable: false do end
column 'published_date', sortable: false do end
end
end
"""
Then I should not see a sortable table header with "Author"
Then I should not see a sortable table header with "published_at"
Then I should not see a sortable table header with "published_date"

Scenario: Sorting
Given a post with the title "Hello World" and body "From the body" exists
Expand All @@ -250,12 +250,12 @@ Feature: Index as Table
"""
When I am on the index page for posts
Then I should see the "index_table_posts" table:
| [ ] | Id | Title | Body | Published At | Position | Starred | Created At | Updated At | |
| [ ] | Id | Title | Body | Published Date | Position | Starred | Created At | Updated At | |
| [ ] | 2 | Bye bye world | Move your... | | | No | /.*/ | /.*/ | ViewEditDelete |
| [ ] | 1 | Hello World | From the body | | | No | /.*/ | /.*/ | ViewEditDelete |
When I follow "Id"
Then I should see the "index_table_posts" table:
| [ ] | Id | Title | Body | Published At | Position | Starred | Created At | Updated At | |
| [ ] | Id | Title | Body | Published Date | Position | Starred | Created At | Updated At | |
| [ ] | 1 | Hello World | From the body | | | No | /.*/ | /.*/ | ViewEditDelete |
| [ ] | 2 | Bye bye world | Move your... | | | No | /.*/ | /.*/ | ViewEditDelete |

Expand Down
2 changes: 1 addition & 1 deletion features/index/index_scope_to.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Index Scope To
# Set up some scopes
scope :all, default: true
scope :published do |posts|
posts.where "published_at IS NOT NULL"
posts.where "published_date IS NOT NULL"
end
end
"""
Expand Down
6 changes: 3 additions & 3 deletions features/index/index_scopes.feature
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Feature: Index Scoping
ActiveAdmin.register Post do
scope :all, :default => true
scope :published do |posts|
posts.where("published_at IS NOT NULL")
posts.where("published_date IS NOT NULL")
end
end
"""
Expand All @@ -108,7 +108,7 @@ Feature: Index Scoping
ActiveAdmin.register Post do
scope :all, :default => true
scope :published do |posts|
posts.where("published_at IS NOT NULL")
posts.where("published_date IS NOT NULL")
end
end
"""
Expand Down Expand Up @@ -215,7 +215,7 @@ Feature: Index Scoping
ActiveAdmin.register Post do
scope :all, :default => true
scope :published do |posts|
posts.where("published_at IS NOT NULL")
posts.where("published_date IS NOT NULL")
end
index do
Expand Down
12 changes: 6 additions & 6 deletions features/new_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: New Page
ActiveAdmin.register Post do
if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title,
:body, :position, :published_at, :starred
:body, :position, :published_date, :starred
end
end
"""
Expand All @@ -34,15 +34,15 @@ Feature: New Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form do |f|
f.inputs "Your Post" do
f.input :title
f.input :body
end
f.inputs "Publishing" do
f.input :published_at
f.input :published_date
end
f.actions
end
Expand Down Expand Up @@ -70,7 +70,7 @@ Feature: New Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form :partial => "form"
end
Expand All @@ -87,7 +87,7 @@ Feature: New Page
Given a configuration of:
"""
ActiveAdmin.register Post do
permit_params :custom_category_id, :author_id, :title, :body, :published_at, :starred if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title, :body, :published_date, :starred if Rails::VERSION::MAJOR >= 4
form do |f|
f.inputs "Your Post" do
Expand All @@ -98,7 +98,7 @@ Feature: New Page
f.input :body
end
f.inputs "Publishing" do
f.input :published_at
f.input :published_date
end
f.actions
end
Expand Down
2 changes: 1 addition & 1 deletion features/renamed_resource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Renamed Resource
ActiveAdmin.register Blog::Post, as: 'Post' do
if Rails::VERSION::MAJOR >= 4
permit_params :custom_category_id, :author_id, :title,
:body, :position, :published_at, :starred
:body, :position, :published_date, :starred
end
end
"""
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/factory_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def create_user(name, type = 'User')
category = Category.where(name: category_name).first_or_create if category_name
title ||= "Hello World %i"
count.times do |i|
Post.create! title: title % i, body: body, author: author, published_at: published, custom_category_id: category.try(:id), starred: starred
Post.create! title: title % i, body: body, author: author, published_date: published, custom_category_id: category.try(:id), starred: starred
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/active_admin/inputs/filters/date_range_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ def to_html
end

def gt_input_name
"#{method}_gteq_date"
column && column.type == :date ? "#{method}_gteq" : "#{method}_gteq_datetime"
end
alias :input_name :gt_input_name

def lt_input_name
"#{method}_lteq_date"
column && column.type == :date ? "#{method}_lteq" : "#{method}_lteq_datetime"
end

def input_html_options(input_name = gt_input_name)
Expand Down
4 changes: 2 additions & 2 deletions lib/ransack_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
config.add_predicate old, arel_predicate: current
end

config.add_predicate 'gteq_date',
config.add_predicate 'gteq_datetime',
arel_predicate: 'gteq',
formatter: ->(v) { v.beginning_of_day }

config.add_predicate 'lteq_date',
config.add_predicate 'lteq_datetime',
arel_predicate: 'lt',
formatter: ->(v) { v + 1.day }
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
add_filter 'features/'
add_filter 'bundle/' # for Travis
end

require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
8 changes: 4 additions & 4 deletions spec/support/rails_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
copy_file File.expand_path('../templates/manifest.js', __FILE__), 'app/assets/config/manifest.js', force: true
end

generate :model, 'post title:string body:text published_at:datetime author_id:integer ' +
generate :model, 'post title:string body:text published_date:date author_id:integer ' +
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
create_file 'app/models/post.rb', <<-RUBY.strip_heredoc, force: true
class Post < ActiveRecord::Base
Expand All @@ -15,13 +15,13 @@ class Post < ActiveRecord::Base
accepts_nested_attributes_for :taggings
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
attr_accessible :id, :title, :body, :starred, :author, :position, :published_at, :author_id, :custom_category_id, :category
attr_accessible :id, :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
end
end
RUBY
copy_file File.expand_path('../templates/post_decorator.rb', __FILE__), 'app/models/post_decorator.rb'

generate :model, 'blog/post title:string body:text published_at:datetime author_id:integer ' +
generate :model, 'blog/post title:string body:text published_date:date author_id:integer ' +
'position:integer custom_category_id:integer starred:boolean foo_id:integer'
create_file 'app/models/blog/post.rb', <<-RUBY.strip_heredoc, force: true
class Blog::Post < ActiveRecord::Base
Expand All @@ -32,7 +32,7 @@ class Blog::Post < ActiveRecord::Base
accepts_nested_attributes_for :taggings
unless Rails::VERSION::MAJOR > 3 && !defined? ProtectedAttributes
attr_accessible :title, :body, :starred, :author, :position, :published_at, :author_id, :custom_category_id, :category
attr_accessible :title, :body, :starred, :author, :position, :published_date, :author_id, :custom_category_id, :category
end
end
RUBY
Expand Down
Loading

0 comments on commit a16ad36

Please sign in to comment.