ajax-datatables-rails 0.4.3 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +120 -0
- data/.rubocop.yml +17 -7
- data/Appraisals +15 -20
- data/CHANGELOG.md +54 -1
- data/Gemfile +0 -5
- data/Guardfile +16 -0
- data/README.md +238 -112
- data/Rakefile +1 -0
- data/ajax-datatables-rails.gemspec +24 -20
- data/bin/_guard-core +29 -0
- data/bin/appraisal +29 -0
- data/bin/bundle +114 -0
- data/bin/guard +29 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/doc/migrate.md +97 -0
- data/doc/webpack.md +7 -2
- data/gemfiles/{rails_5.2.0.gemfile → rails_5.2.4.gemfile} +3 -5
- data/gemfiles/{rails_5.0.7.gemfile → rails_6.0.3.gemfile} +4 -6
- data/gemfiles/{rails_5.1.6.gemfile → rails_6.1.0.gemfile} +4 -6
- data/lib/ajax-datatables-rails.rb +12 -1
- data/lib/ajax-datatables-rails/active_record.rb +7 -0
- data/lib/ajax-datatables-rails/base.rb +47 -46
- data/lib/ajax-datatables-rails/datatable.rb +6 -0
- data/lib/ajax-datatables-rails/datatable/column.rb +65 -20
- data/lib/ajax-datatables-rails/datatable/column/date_filter.rb +12 -21
- data/lib/ajax-datatables-rails/datatable/column/order.rb +1 -1
- data/lib/ajax-datatables-rails/datatable/column/search.rb +37 -22
- data/lib/ajax-datatables-rails/datatable/datatable.rb +16 -7
- data/lib/ajax-datatables-rails/datatable/simple_order.rb +23 -10
- data/lib/ajax-datatables-rails/datatable/simple_search.rb +2 -0
- data/lib/ajax-datatables-rails/error.rb +9 -0
- data/lib/ajax-datatables-rails/orm.rb +6 -0
- data/lib/ajax-datatables-rails/orm/active_record.rb +11 -12
- data/lib/ajax-datatables-rails/version.rb +13 -1
- data/lib/generators/rails/templates/datatable.rb +1 -1
- data/spec/ajax-datatables-rails/base_spec.rb +129 -93
- data/spec/ajax-datatables-rails/datatable/column_spec.rb +105 -37
- data/spec/ajax-datatables-rails/datatable/datatable_spec.rb +71 -31
- data/spec/ajax-datatables-rails/datatable/simple_order_spec.rb +36 -14
- data/spec/ajax-datatables-rails/datatable/simple_search_spec.rb +4 -2
- data/spec/ajax-datatables-rails/orm/active_record_filter_records_spec.rb +315 -272
- data/spec/ajax-datatables-rails/orm/active_record_paginate_records_spec.rb +9 -8
- data/spec/ajax-datatables-rails/orm/active_record_sort_records_spec.rb +17 -14
- data/spec/factories/user.rb +3 -1
- data/spec/install_oracle.sh +9 -3
- data/spec/spec_helper.rb +33 -28
- data/spec/support/datatables/complex_datatable.rb +31 -0
- data/spec/support/datatables/complex_datatable_array.rb +16 -0
- data/spec/support/{datatable_cond_date.rb → datatables/datatable_cond_date.rb} +2 -0
- data/spec/support/{datatable_cond_numeric.rb → datatables/datatable_cond_numeric.rb} +3 -1
- data/spec/support/{datatable_cond_proc.rb → datatables/datatable_cond_proc.rb} +2 -0
- data/spec/support/{datatable_cond_string.rb → datatables/datatable_cond_string.rb} +9 -1
- data/spec/support/datatables/datatable_cond_unknown.rb +7 -0
- data/spec/support/{datatable_order_nulls_last.rb → datatables/datatable_order_nulls_last.rb} +2 -0
- data/spec/support/{test_helpers.rb → helpers/params.rb} +17 -42
- data/spec/support/{test_models.rb → models/user.rb} +2 -0
- data/spec/support/schema.rb +3 -1
- metadata +76 -75
- data/.travis.yml +0 -80
- data/gemfiles/rails_4.0.13.gemfile +0 -14
- data/gemfiles/rails_4.1.16.gemfile +0 -14
- data/gemfiles/rails_4.2.10.gemfile +0 -14
- data/lib/ajax-datatables-rails/config.rb +0 -31
- data/lib/ajax_datatables_rails.rb +0 -15
- data/lib/generators/datatable/config_generator.rb +0 -19
- data/lib/generators/datatable/templates/ajax_datatables_rails_config.rb +0 -12
- data/spec/ajax-datatables-rails/configuration_spec.rb +0 -43
- data/spec/ajax-datatables-rails/extended_spec.rb +0 -20
- data/spec/ajax-datatables-rails/orm/active_record_spec.rb +0 -25
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/configurable'
|
4
|
-
|
5
|
-
module AjaxDatatablesRails
|
6
|
-
|
7
|
-
# configure AjaxDatatablesRails global settings
|
8
|
-
# AjaxDatatablesRails.configure do |config|
|
9
|
-
# config.db_adapter = :postgresql
|
10
|
-
# end
|
11
|
-
def self.configure
|
12
|
-
yield @config ||= AjaxDatatablesRails::Configuration.new
|
13
|
-
end
|
14
|
-
|
15
|
-
# AjaxDatatablesRails global settings
|
16
|
-
def self.config
|
17
|
-
@config ||= AjaxDatatablesRails::Configuration.new
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.old_rails?
|
21
|
-
Rails::VERSION::MAJOR == 4 && (Rails::VERSION::MINOR == 1 || Rails::VERSION::MINOR == 0)
|
22
|
-
end
|
23
|
-
|
24
|
-
class Configuration
|
25
|
-
include ActiveSupport::Configurable
|
26
|
-
|
27
|
-
config_accessor(:orm) { :active_record }
|
28
|
-
config_accessor(:db_adapter) { :postgresql }
|
29
|
-
config_accessor(:nulls_last) { false }
|
30
|
-
end
|
31
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module AjaxDatatablesRails
|
4
|
-
require 'ajax-datatables-rails/version'
|
5
|
-
require 'ajax-datatables-rails/config'
|
6
|
-
require 'ajax-datatables-rails/base'
|
7
|
-
require 'ajax-datatables-rails/datatable/datatable'
|
8
|
-
require 'ajax-datatables-rails/datatable/simple_search'
|
9
|
-
require 'ajax-datatables-rails/datatable/simple_order'
|
10
|
-
require 'ajax-datatables-rails/datatable/column/search'
|
11
|
-
require 'ajax-datatables-rails/datatable/column/order'
|
12
|
-
require 'ajax-datatables-rails/datatable/column/date_filter' unless AjaxDatatablesRails.old_rails?
|
13
|
-
require 'ajax-datatables-rails/datatable/column'
|
14
|
-
require 'ajax-datatables-rails/orm/active_record'
|
15
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rails/generators'
|
4
|
-
|
5
|
-
module Datatable
|
6
|
-
module Generators
|
7
|
-
class ConfigGenerator < ::Rails::Generators::Base
|
8
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
9
|
-
desc <<DESC
|
10
|
-
Description:
|
11
|
-
Creates an initializer file for AjaxDatatablesRails configuration at config/initializers.
|
12
|
-
DESC
|
13
|
-
|
14
|
-
def copy_config_file
|
15
|
-
template 'ajax_datatables_rails_config.rb', 'config/initializers/ajax_datatables_rails.rb'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
AjaxDatatablesRails.configure do |config|
|
4
|
-
# available options for db_adapter are: :pg, :mysql, :mysql2, :sqlite, :sqlite3
|
5
|
-
# config.db_adapter = :pg
|
6
|
-
|
7
|
-
# Or you can use your rails environment adapter if you want a generic dev and production
|
8
|
-
# config.db_adapter = Rails.configuration.database_configuration[Rails.env]['adapter'].to_sym
|
9
|
-
|
10
|
-
# available options for orm are: :active_record, :mongoid
|
11
|
-
# config.orm = :active_record
|
12
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AjaxDatatablesRails do
|
4
|
-
describe 'configurations' do
|
5
|
-
context 'configurable from outside' do
|
6
|
-
before(:each) do
|
7
|
-
AjaxDatatablesRails.configure do |config|
|
8
|
-
config.db_adapter = :mysql
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should have custom value' do
|
13
|
-
expect(AjaxDatatablesRails.config.db_adapter).to eq(:mysql)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe AjaxDatatablesRails::Configuration do
|
20
|
-
let(:config) { AjaxDatatablesRails::Configuration.new }
|
21
|
-
|
22
|
-
describe 'default config' do
|
23
|
-
it 'default orm should :active_record' do
|
24
|
-
expect(config.orm).to eq(:active_record)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'default db_adapter should :postgresql' do
|
28
|
-
expect(config.db_adapter).to eq(:postgresql)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'custom config' do
|
33
|
-
it 'should accept db_adapter custom value' do
|
34
|
-
config.db_adapter = :mysql
|
35
|
-
expect(config.db_adapter).to eq(:mysql)
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'accepts a custom orm value' do
|
39
|
-
config.orm = :mongoid
|
40
|
-
expect(config.orm).to eq(:mongoid)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AjaxDatatablesRails::Base do
|
4
|
-
describe 'it can transform search value before asking the database' do
|
5
|
-
let(:view) { double('view', params: sample_params) }
|
6
|
-
let(:datatable) { DatatableWithFormater.new(view) }
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
create(:user, username: 'johndoe', email: 'johndoe@example.com', last_name: 'DOE')
|
10
|
-
create(:user, username: 'msmith', email: 'mary.smith@example.com', last_name: 'SMITH')
|
11
|
-
datatable.params[:columns]['3'][:search][:value] = 'doe'
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'should filter records' do
|
15
|
-
expect(datatable.data.size).to eq 1
|
16
|
-
item = datatable.data.first
|
17
|
-
expect(item[:last_name]).to eq 'DOE'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe AjaxDatatablesRails::ORM::ActiveRecord do
|
4
|
-
context 'Private API' do
|
5
|
-
let(:view) { double('view', params: sample_params) }
|
6
|
-
let(:datatable) { ComplexDatatable.new(view) }
|
7
|
-
|
8
|
-
before(:each) do
|
9
|
-
create(:user, username: 'johndoe', email: 'johndoe@example.com')
|
10
|
-
create(:user, username: 'msmith', email: 'mary.smith@example.com')
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#fetch_records' do
|
14
|
-
it 'calls #get_raw_records' do
|
15
|
-
expect(datatable).to receive(:get_raw_records) { User.all }
|
16
|
-
datatable.send(:fetch_records)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'returns a collection of records' do
|
20
|
-
expect(datatable).to receive(:get_raw_records) { User.all }
|
21
|
-
expect(datatable.send(:fetch_records)).to be_a(ActiveRecord::Relation)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|