datagrid 1.5.9 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -4
- data/Gemfile +7 -3
- data/Readme.markdown +2 -1
- data/VERSION +1 -1
- data/app/views/datagrid/_table.html.erb +1 -1
- data/datagrid.gemspec +9 -8
- data/lib/datagrid/columns.rb +7 -5
- data/lib/datagrid/core.rb +13 -1
- data/lib/datagrid/drivers/active_record.rb +2 -1
- data/lib/datagrid/drivers/mongoid.rb +5 -1
- data/lib/datagrid/helper.rb +1 -1
- data/lib/datagrid/renderer.rb +1 -2
- data/lib/datagrid/utils.rb +2 -6
- data/spec/datagrid/core_spec.rb +14 -0
- data/spec/datagrid/filters/date_filter_spec.rb +6 -3
- data/spec/datagrid/form_builder_spec.rb +3 -6
- data/spec/datagrid/helper_spec.rb +50 -7
- data/spec/datagrid_spec.rb +13 -2
- data/spec/spec_helper.rb +16 -7
- data/spec/support/simple_report.rb +1 -1
- data/spec/support/test_partials/client/datagrid/_order_for.html.erb +2 -2
- data/spec/support/test_partials/client/datagrid/_table.html.erb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76bece54343c202c79e7ca4d5e90ae1cc91d2c5a77b965a175b36df801e10bd1
|
4
|
+
data.tar.gz: 68e58ec9dec5f010b43a7e078fdbf2c3c1b0923c9f2ab38c327d3665570d08fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aeb7a29ea7df278090a6417e1f940dfe9f8b1aa57dd907f9f739c4d2bc3e613be66be28635c5cf51a70b9067a7f7da4a00e7adaf09ae8ddea0247c7f34a56b1
|
7
|
+
data.tar.gz: 8660381aa1d508c624b0bc6d1c6e71ca3e6c1e89cad518733aeaee31d1968dc6382c45d1d06cbb60cd33ea1407d3e79e92e5920d93483bdfd47a31ffa1e23cef
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -6,17 +6,21 @@ group :development do
|
|
6
6
|
|
7
7
|
gem "bundler"
|
8
8
|
if RUBY_VERSION >= "2.3"
|
9
|
-
gem "jeweler", ">= 2.1.2", platform:
|
9
|
+
gem "jeweler", ">= 2.1.2", platform: :mri, github: 'technicalpickles/jeweler'
|
10
10
|
end
|
11
11
|
|
12
12
|
|
13
13
|
#gem "json", ">= 1.9"
|
14
|
-
gem "pry-byebug"
|
14
|
+
gem "pry-byebug"
|
15
15
|
|
16
16
|
gem "rspec", ">= 3"
|
17
17
|
gem "nokogiri" # used to test html output
|
18
18
|
|
19
|
-
|
19
|
+
if RUBY_VERSION >= "2.5"
|
20
|
+
gem "sqlite3", "~> 1.4", platform: :mri
|
21
|
+
else
|
22
|
+
gem "sqlite3", "~> 1.3.6"
|
23
|
+
end
|
20
24
|
gem "sequel"
|
21
25
|
|
22
26
|
group :mongo do
|
data/Readme.markdown
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Datagrid
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/bogdan/datagrid.svg?branch=master)](https://travis-ci.org/bogdan/datagrid)
|
4
|
+
|
4
5
|
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid?ref=badge_shield)
|
5
6
|
|
6
7
|
Ruby library that helps you to build and represent table-like data with:
|
@@ -201,4 +202,4 @@ Read [author blog](http://gusiev.com).
|
|
201
202
|
|
202
203
|
|
203
204
|
## License
|
204
|
-
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid?ref=badge_large)
|
205
|
+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Fdatagrid?ref=badge_large)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.6.1
|
@@ -11,7 +11,7 @@ Local variables:
|
|
11
11
|
</thead>
|
12
12
|
<tbody>
|
13
13
|
<% if assets.any? %>
|
14
|
-
<%= datagrid_rows(grid, assets, options) %>
|
14
|
+
<%= datagrid_rows(grid, assets, **options) %>
|
15
15
|
<% else %>
|
16
16
|
<tr><td class="noresults" colspan="100%"><%= I18n.t('datagrid.no_results').html_safe %></td></tr>
|
17
17
|
<% end %>
|
data/datagrid.gemspec
CHANGED
@@ -2,20 +2,21 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: datagrid 1.
|
5
|
+
# stub: datagrid 1.6.1 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "datagrid".freeze
|
9
|
-
s.version = "1.
|
9
|
+
s.version = "1.6.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Bogdan Gusiev".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2020-09-07"
|
15
15
|
s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters".freeze
|
16
16
|
s.email = "agresso@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt"
|
18
|
+
"LICENSE.txt",
|
19
|
+
"Readme.markdown"
|
19
20
|
]
|
20
21
|
s.files = [
|
21
22
|
".document",
|
@@ -130,7 +131,7 @@ Gem::Specification.new do |s|
|
|
130
131
|
s.homepage = "http://github.com/bogdan/datagrid".freeze
|
131
132
|
s.licenses = ["MIT".freeze]
|
132
133
|
s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
|
133
|
-
s.rubygems_version = "
|
134
|
+
s.rubygems_version = "3.0.8".freeze
|
134
135
|
s.summary = "Ruby gem to create datagrids".freeze
|
135
136
|
|
136
137
|
if s.respond_to? :specification_version then
|
@@ -143,7 +144,7 @@ Gem::Specification.new do |s|
|
|
143
144
|
s.add_development_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
144
145
|
s.add_development_dependency(%q<rspec>.freeze, [">= 3"])
|
145
146
|
s.add_development_dependency(%q<nokogiri>.freeze, [">= 0"])
|
146
|
-
s.add_development_dependency(%q<sqlite3>.freeze, ["~> 1.
|
147
|
+
s.add_development_dependency(%q<sqlite3>.freeze, ["~> 1.4"])
|
147
148
|
s.add_development_dependency(%q<sequel>.freeze, [">= 0"])
|
148
149
|
s.add_development_dependency(%q<mongoid>.freeze, [">= 0"])
|
149
150
|
s.add_development_dependency(%q<bson>.freeze, [">= 0"])
|
@@ -155,7 +156,7 @@ Gem::Specification.new do |s|
|
|
155
156
|
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
156
157
|
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
157
158
|
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
158
|
-
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.
|
159
|
+
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.4"])
|
159
160
|
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
160
161
|
s.add_dependency(%q<mongoid>.freeze, [">= 0"])
|
161
162
|
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
@@ -168,7 +169,7 @@ Gem::Specification.new do |s|
|
|
168
169
|
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
169
170
|
s.add_dependency(%q<rspec>.freeze, [">= 3"])
|
170
171
|
s.add_dependency(%q<nokogiri>.freeze, [">= 0"])
|
171
|
-
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.
|
172
|
+
s.add_dependency(%q<sqlite3>.freeze, ["~> 1.4"])
|
172
173
|
s.add_dependency(%q<sequel>.freeze, [">= 0"])
|
173
174
|
s.add_dependency(%q<mongoid>.freeze, [">= 0"])
|
174
175
|
s.add_dependency(%q<bson>.freeze, [">= 0"])
|
data/lib/datagrid/columns.rb
CHANGED
@@ -16,6 +16,7 @@ module Datagrid
|
|
16
16
|
self.default_column_options = {}
|
17
17
|
|
18
18
|
class_attribute :batch_size
|
19
|
+
self.batch_size = 1000
|
19
20
|
|
20
21
|
class_attribute :columns_array
|
21
22
|
self.columns_array = []
|
@@ -315,9 +316,8 @@ module Datagrid
|
|
315
316
|
def to_csv(*column_names)
|
316
317
|
require "csv"
|
317
318
|
options = column_names.extract_options!
|
318
|
-
|
319
|
-
|
320
|
-
) do |csv|
|
319
|
+
options = {:headers => self.header(*column_names), :write_headers => true}.merge!(options)
|
320
|
+
CSV.generate(**options) do |csv|
|
321
321
|
each_with_batches do |asset|
|
322
322
|
csv << row_for(asset, *column_names)
|
323
323
|
end
|
@@ -406,7 +406,7 @@ module Datagrid
|
|
406
406
|
# Defines a column at instance level
|
407
407
|
#
|
408
408
|
# See Datagrid::Columns::ClassMethods#column for more info
|
409
|
-
def column(name, options_or_query = {}, options = {}, &block)
|
409
|
+
def column(name, options_or_query = {}, options = {}, &block)
|
410
410
|
self.class.define_column(columns_array, name, options_or_query, options, &block)
|
411
411
|
end
|
412
412
|
|
@@ -415,7 +415,7 @@ module Datagrid
|
|
415
415
|
super
|
416
416
|
end
|
417
417
|
|
418
|
-
# Returns all columns
|
418
|
+
# Returns all columns that are possible to be displayed for the current grid object
|
419
419
|
#
|
420
420
|
# class MyGrid
|
421
421
|
# filter(:search) {|scope, value| scope.full_text_search(value)}
|
@@ -535,6 +535,8 @@ module Datagrid
|
|
535
535
|
def value_from_html_block(context, asset, column)
|
536
536
|
args = []
|
537
537
|
remaining_arity = column.html_block.arity
|
538
|
+
remaining_arity = 1 if remaining_arity < 0
|
539
|
+
|
538
540
|
asset = decorate(asset)
|
539
541
|
|
540
542
|
if column.data?
|
data/lib/datagrid/core.rb
CHANGED
@@ -9,7 +9,7 @@ module Datagrid
|
|
9
9
|
base.class_eval do
|
10
10
|
class_attribute :scope_value
|
11
11
|
|
12
|
-
class_attribute :datagrid_attributes
|
12
|
+
class_attribute :datagrid_attributes, instance_writer: false
|
13
13
|
self.datagrid_attributes = []
|
14
14
|
|
15
15
|
class_attribute :dynamic_block, :instance_writer => false
|
@@ -163,6 +163,9 @@ module Datagrid
|
|
163
163
|
end
|
164
164
|
|
165
165
|
# Returns serializable query arguments skipping all nil values
|
166
|
+
#
|
167
|
+
# grid = ProductsGrid.new(category: 'dresses', available: true)
|
168
|
+
# grid.as_query # => {category: 'dresses', available: true}
|
166
169
|
def as_query
|
167
170
|
attributes = self.attributes.clone
|
168
171
|
attributes.each do |key, value|
|
@@ -171,6 +174,15 @@ module Datagrid
|
|
171
174
|
attributes
|
172
175
|
end
|
173
176
|
|
177
|
+
# Returns query parameters to link this grid from a page
|
178
|
+
#
|
179
|
+
# grid = ProductsGrid.new(category: 'dresses', available: true)
|
180
|
+
# Rails.application.routes.url_helpers.products_path(grid.query_params)
|
181
|
+
# # => "/products?products_grid[category]=dresses&products_grid[available]=true"
|
182
|
+
def query_params(attributes = {})
|
183
|
+
{ param_name.to_sym => as_query.merge(attributes) }
|
184
|
+
end
|
185
|
+
|
174
186
|
# Redefines scope at instance level
|
175
187
|
#
|
176
188
|
# class MyGrid
|
@@ -105,7 +105,8 @@ module Datagrid
|
|
105
105
|
if scope.limit_value
|
106
106
|
raise Datagrid::ConfigurationError, "ActiveRecord can not use batches in combination with SQL limit"
|
107
107
|
end
|
108
|
-
|
108
|
+
options = batch_size ? { batch_size: batch_size } : {}
|
109
|
+
scope.find_each(**options, &block)
|
109
110
|
end
|
110
111
|
|
111
112
|
def default_cache_key(asset)
|
data/lib/datagrid/helper.rb
CHANGED
@@ -73,7 +73,7 @@ module Datagrid
|
|
73
73
|
# %td= row.project_name
|
74
74
|
# %td.project-status{class: row.status}= row.status
|
75
75
|
def datagrid_rows(grid, assets = grid.assets, **options, &block)
|
76
|
-
datagrid_renderer.rows(grid, assets, options, &block)
|
76
|
+
datagrid_renderer.rows(grid, assets, **options, &block)
|
77
77
|
end
|
78
78
|
|
79
79
|
# Renders ordering controls for the given column name
|
data/lib/datagrid/renderer.rb
CHANGED
@@ -81,10 +81,9 @@ module Datagrid
|
|
81
81
|
def order_path(grid, column, descending, request)
|
82
82
|
column = grid.column_by_name(column)
|
83
83
|
query = request ? request.query_parameters : {}
|
84
|
-
order_parameter = {grid.param_name => grid.as_query.merge(:order => column.name, :descending => descending)}
|
85
84
|
ActionDispatch::Http::URL.path_for(
|
86
85
|
path: request ? request.path : '/',
|
87
|
-
params: query.merge(
|
86
|
+
params: query.merge(grid.query_params(order: column.name, descending: descending))
|
88
87
|
)
|
89
88
|
end
|
90
89
|
|
data/lib/datagrid/utils.rb
CHANGED
@@ -72,12 +72,8 @@ module Datagrid
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def apply_args(*args, &block)
|
75
|
-
|
76
|
-
args
|
77
|
-
(args.size - block.arity).times do
|
78
|
-
args.pop
|
79
|
-
end
|
80
|
-
block.call(*args)
|
75
|
+
size = block.arity < 0 ? args.size : block.arity
|
76
|
+
block.call(*args.slice(0, size))
|
81
77
|
end
|
82
78
|
|
83
79
|
def parse_date(value)
|
data/spec/datagrid/core_spec.rb
CHANGED
@@ -193,4 +193,18 @@ describe Datagrid::Core do
|
|
193
193
|
}.to_not raise_error
|
194
194
|
end
|
195
195
|
end
|
196
|
+
|
197
|
+
|
198
|
+
describe ".query_param" do
|
199
|
+
it "works" do
|
200
|
+
grid = test_report(name: 'value') do
|
201
|
+
scope {Entry}
|
202
|
+
filter(:name)
|
203
|
+
def param_name
|
204
|
+
'grid'
|
205
|
+
end
|
206
|
+
end
|
207
|
+
expect(grid.query_params).to eq({grid: {name: 'value'}})
|
208
|
+
end
|
209
|
+
end
|
196
210
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require "active_support/testing/time_helpers"
|
2
3
|
|
3
4
|
describe Datagrid::Filters::DateFilter do
|
4
5
|
|
@@ -122,14 +123,16 @@ describe Datagrid::Filters::DateFilter do
|
|
122
123
|
|
123
124
|
|
124
125
|
it "should support block" do
|
125
|
-
|
126
|
+
date = Date.new(2018, 01, 07)
|
127
|
+
time = Time.utc(2018, 01, 07, 2, 2)
|
128
|
+
report = test_report(:created_at => date) do
|
126
129
|
scope { Entry }
|
127
130
|
filter(:created_at, :date, :range => true) do |value|
|
128
131
|
where("created_at >= ?", value)
|
129
132
|
end
|
130
133
|
end
|
131
|
-
expect(report.assets).not_to include(Entry.create!(:created_at => 1.day
|
132
|
-
expect(report.assets).to include(Entry.create!(:created_at =>
|
134
|
+
expect(report.assets).not_to include(Entry.create!(:created_at => time - 1.day))
|
135
|
+
expect(report.assets).to include(Entry.create!(:created_at => time))
|
133
136
|
end
|
134
137
|
|
135
138
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
require 'spec_helper'
|
3
|
+
require "action_controller"
|
3
4
|
|
4
5
|
class MyFormBuilder
|
5
6
|
include Datagrid::FormBuilder
|
@@ -11,19 +12,15 @@ end
|
|
11
12
|
|
12
13
|
|
13
14
|
describe Datagrid::FormBuilder do
|
14
|
-
|
15
15
|
let(:template) do
|
16
|
-
|
17
|
-
v.view_paths << File.expand_path("../../../app/views", __FILE__)
|
18
|
-
v.view_paths << File.expand_path("../../support/test_partials", __FILE__)
|
19
|
-
end
|
16
|
+
action_view_template
|
20
17
|
end
|
18
|
+
|
21
19
|
let(:view) { ActionView::Helpers::FormBuilder.new(:report, _grid, template, view_options)}
|
22
20
|
let(:view_options) { {} }
|
23
21
|
|
24
22
|
|
25
23
|
describe ".datagrid_filter" do
|
26
|
-
|
27
24
|
it "should work for every filter type" do
|
28
25
|
Datagrid::Filters::FILTER_TYPES.each do |type, klass|
|
29
26
|
expect(Datagrid::FormBuilder.instance_methods.map(&:to_sym)).to include(klass.form_builder_helper_name)
|
@@ -1,16 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require "active_support/core_ext/hash"
|
3
3
|
require "active_support/core_ext/object"
|
4
|
+
require "action_controller"
|
4
5
|
|
5
6
|
require 'datagrid/renderer'
|
6
7
|
|
7
8
|
describe Datagrid::Helper do
|
8
9
|
subject do
|
9
|
-
|
10
|
-
allow(template).to receive(:protect_against_forgery?).and_return(false)
|
11
|
-
template.view_paths << File.expand_path("../../../app/views", __FILE__)
|
12
|
-
template.view_paths << File.expand_path("../../support/test_partials", __FILE__)
|
13
|
-
template
|
10
|
+
action_view_template
|
14
11
|
end
|
15
12
|
|
16
13
|
before(:each) do
|
@@ -248,6 +245,17 @@ describe Datagrid::Helper do
|
|
248
245
|
)
|
249
246
|
end
|
250
247
|
|
248
|
+
it "should render columns with &:symbol block" do
|
249
|
+
rp = test_report do
|
250
|
+
scope { Entry }
|
251
|
+
column(:name, &:name)
|
252
|
+
end
|
253
|
+
|
254
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
255
|
+
"tr td.name" => "Star"
|
256
|
+
)
|
257
|
+
end
|
258
|
+
|
251
259
|
it "should render html columns" do
|
252
260
|
rp = test_report do
|
253
261
|
scope { Entry }
|
@@ -260,6 +268,41 @@ describe Datagrid::Helper do
|
|
260
268
|
)
|
261
269
|
end
|
262
270
|
|
271
|
+
it "should render :html columns with &:symbol block" do
|
272
|
+
rp = test_report do
|
273
|
+
scope { Entry }
|
274
|
+
column(:name, :html => true, &:name)
|
275
|
+
end
|
276
|
+
|
277
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
278
|
+
"tr td.name" => "Star"
|
279
|
+
)
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should render format columns with &:symbol block" do
|
283
|
+
rp = test_report do
|
284
|
+
scope { Entry }
|
285
|
+
column(:name) do |record|
|
286
|
+
format(record, &:name)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
291
|
+
"tr td.name" => "Star"
|
292
|
+
)
|
293
|
+
end
|
294
|
+
|
295
|
+
it "should render :html columns with &:symbol block with a data attribute" do
|
296
|
+
rp = test_report do
|
297
|
+
scope { Entry }
|
298
|
+
column(:name, :html => true, data: 'DATA', &:name)
|
299
|
+
end
|
300
|
+
|
301
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
302
|
+
"tr td.name" => "Star"
|
303
|
+
)
|
304
|
+
end
|
305
|
+
|
263
306
|
it "should render argument-based html columns" do
|
264
307
|
rp = test_report do
|
265
308
|
scope { Entry }
|
@@ -389,14 +432,14 @@ describe Datagrid::Helper do
|
|
389
432
|
end
|
390
433
|
|
391
434
|
it "should escape html" do
|
392
|
-
entry.
|
435
|
+
entry.update!(:name => "<div>hello</div>")
|
393
436
|
expect(subject.datagrid_rows(grid, [entry], :columns => [:name])).to equal_to_dom(<<-HTML)
|
394
437
|
<tr><td class="name"><div>hello</div></td></tr>
|
395
438
|
HTML
|
396
439
|
end
|
397
440
|
|
398
441
|
it "should not escape safe html" do
|
399
|
-
entry.
|
442
|
+
entry.update!(:name => "<div>hello</div>")
|
400
443
|
grid.column(:safe_name) do |model|
|
401
444
|
model.name.html_safe
|
402
445
|
end
|
data/spec/datagrid_spec.rb
CHANGED
@@ -60,8 +60,8 @@ describe Datagrid do
|
|
60
60
|
|
61
61
|
describe ".batch_size" do
|
62
62
|
context "when not defined on class level" do
|
63
|
-
it "returns
|
64
|
-
expect(subject.batch_size).to eq(
|
63
|
+
it "returns 1000" do
|
64
|
+
expect(subject.batch_size).to eq(1000)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -77,6 +77,17 @@ describe Datagrid do
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
context "when set to nil in the grid class" do
|
81
|
+
subject do
|
82
|
+
test_report do
|
83
|
+
self.batch_size = nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
it "returns nil" do
|
88
|
+
expect(subject.batch_size).to eq(nil)
|
89
|
+
end
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
93
|
|
data/spec/spec_helper.rb
CHANGED
@@ -17,7 +17,7 @@ require 'action_view'
|
|
17
17
|
require "rails"
|
18
18
|
require "mongoid"
|
19
19
|
begin
|
20
|
-
require 'mongo_mapper'
|
20
|
+
require 'mongo_mapper'
|
21
21
|
rescue LoadError
|
22
22
|
end
|
23
23
|
|
@@ -55,9 +55,11 @@ begin
|
|
55
55
|
"database" =>"datagrid_mongoid",
|
56
56
|
"autocreate_indexes" => true,
|
57
57
|
"logger" => nil,
|
58
|
-
|
59
|
-
|
60
|
-
wait_queue_timeout: 2
|
58
|
+
options: {
|
59
|
+
connect_timeout: 2,
|
60
|
+
wait_queue_timeout: 2,
|
61
|
+
server_selection_timeout: 2,
|
62
|
+
socket_timeout: 1
|
61
63
|
}
|
62
64
|
}
|
63
65
|
}
|
@@ -80,8 +82,6 @@ rescue Mongo::Error::NoServerAvailable
|
|
80
82
|
end
|
81
83
|
|
82
84
|
RSpec.configure do |config|
|
83
|
-
|
84
|
-
|
85
85
|
config.after(:each) do
|
86
86
|
#TODO better database truncation
|
87
87
|
Group.delete_all
|
@@ -103,12 +103,21 @@ RSpec.configure do |config|
|
|
103
103
|
#c.syntax = :expect
|
104
104
|
c.syntax = [:should, :expect]
|
105
105
|
end
|
106
|
+
end
|
106
107
|
|
108
|
+
def action_view_template
|
109
|
+
context = ActionView::LookupContext.new([
|
110
|
+
File.expand_path("../../app/views", __FILE__),
|
111
|
+
File.expand_path("../support/test_partials", __FILE__),
|
112
|
+
], {})
|
113
|
+
klass = ActionView::Base.respond_to?(:with_empty_template_cache) ? ActionView::Base.with_empty_template_cache : ActionView::Base
|
114
|
+
template = klass.new(context, {}, ::ActionController::Base.new)
|
115
|
+
allow(template).to receive(:protect_against_forgery?).and_return(false)
|
116
|
+
template
|
107
117
|
end
|
108
118
|
|
109
119
|
|
110
120
|
|
111
121
|
# Requires supporting files with custom matchers and macros, etc,
|
112
122
|
# in ./support/ and its subdirectories.
|
113
|
-
Dir["#{File.dirname(__FILE__)}/support/schema.rb"].each {|f| require f}
|
114
123
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
@@ -45,7 +45,7 @@ class SimpleReport
|
|
45
45
|
end
|
46
46
|
|
47
47
|
column(:actions, :html => true) do |model|
|
48
|
-
render :partial => "actions", :locals => {:model => model}
|
48
|
+
render :partial => "/actions", :locals => {:model => model}
|
49
49
|
end
|
50
50
|
|
51
51
|
column(:pet, :html => lambda {|data| content_tag :em, data}) do
|
@@ -2,10 +2,10 @@
|
|
2
2
|
<p>Namespaced order_for partial.</p>
|
3
3
|
<%= link_to(
|
4
4
|
I18n.t("datagrid.table.order.asc").html_safe,
|
5
|
-
url_for(grid.
|
5
|
+
url_for(grid.query_params(order: column.name, descending: false)),
|
6
6
|
:class => "asc") %>
|
7
7
|
<%= link_to(
|
8
8
|
I18n.t("datagrid.table.order.desc").html_safe,
|
9
|
-
url_for(grid.
|
9
|
+
url_for(grid.query_params(order: column.name, descending: true)),
|
10
10
|
:class => "desc") %>
|
11
11
|
</div>
|
@@ -13,7 +13,7 @@ Local variables:
|
|
13
13
|
<% if assets.empty? %>
|
14
14
|
<tr><td class="noresults" colspan="100%"><%= I18n.t('datagrid.no_results').html_safe %></td></tr>
|
15
15
|
<% else %>
|
16
|
-
<%= datagrid_rows(grid, assets, options) %>
|
16
|
+
<%= datagrid_rows(grid, assets, **options) %>
|
17
17
|
<% end %>
|
18
18
|
</tbody>
|
19
19
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagrid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.
|
103
|
+
version: '1.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.
|
110
|
+
version: '1.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sequel
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,6 +171,7 @@ executables: []
|
|
171
171
|
extensions: []
|
172
172
|
extra_rdoc_files:
|
173
173
|
- LICENSE.txt
|
174
|
+
- Readme.markdown
|
174
175
|
files:
|
175
176
|
- ".document"
|
176
177
|
- ".rspec"
|
@@ -284,7 +285,7 @@ homepage: http://github.com/bogdan/datagrid
|
|
284
285
|
licenses:
|
285
286
|
- MIT
|
286
287
|
metadata: {}
|
287
|
-
post_install_message:
|
288
|
+
post_install_message:
|
288
289
|
rdoc_options: []
|
289
290
|
require_paths:
|
290
291
|
- lib
|
@@ -299,9 +300,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
300
|
- !ruby/object:Gem::Version
|
300
301
|
version: '0'
|
301
302
|
requirements: []
|
302
|
-
|
303
|
-
|
304
|
-
signing_key:
|
303
|
+
rubygems_version: 3.0.8
|
304
|
+
signing_key:
|
305
305
|
specification_version: 4
|
306
306
|
summary: Ruby gem to create datagrids
|
307
307
|
test_files: []
|