tabulatr2 0.9.20 → 0.9.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/app/assets/javascripts/tabulatr/_events.js +252 -0
- data/app/assets/javascripts/tabulatr/_pagination.js +85 -0
- data/app/assets/javascripts/tabulatr/_tabulatr.js +70 -372
- data/app/assets/javascripts/tabulatr/application.js +2 -0
- data/app/views/tabulatr/_tabulatr_actual_table.html.slim +7 -7
- data/app/views/tabulatr/_tabulatr_filter_dialog.html.slim +1 -1
- data/app/views/tabulatr/_tabulatr_static_table.html.slim +5 -3
- data/lib/tabulatr/data/data.rb +1 -1
- data/lib/tabulatr/data/dsl.rb +62 -86
- data/lib/tabulatr/data/filtering.rb +32 -52
- data/lib/tabulatr/data/sorting.rb +1 -1
- data/lib/tabulatr/params_builder.rb +50 -0
- data/lib/tabulatr/rails/action_view.rb +2 -2
- data/lib/tabulatr/rails/active_record.rb +3 -8
- data/lib/tabulatr/renderer/action.rb +1 -1
- data/lib/tabulatr/renderer/association.rb +3 -3
- data/lib/tabulatr/renderer/buttons.rb +1 -1
- data/lib/tabulatr/renderer/column.rb +40 -125
- data/lib/tabulatr/renderer/columns_from_block.rb +10 -7
- data/lib/tabulatr/renderer/renderer.rb +26 -15
- data/lib/tabulatr/version.rb +1 -1
- data/lib/tabulatr.rb +1 -0
- data/spec/dummy/app/controllers/products_controller.rb +5 -6
- data/spec/dummy/app/tabulatr_data/product_tabulatr_data.rb +6 -6
- data/spec/dummy/app/views/products/stupid_array.html.erb +20 -6
- data/spec/dummy/app/views/products/with_styling.html.erb +1 -1
- data/spec/dummy/app/views/products/without_filters.html.erb +1 -0
- data/spec/dummy/config/routes.rb +1 -0
- data/spec/features/tabulatrs_spec.rb +7 -2
- data/spec/lib/tabulatr/data/data_spec.rb +2 -2
- data/spec/lib/tabulatr/data/dsl_spec.rb +54 -4
- data/spec/lib/tabulatr/data/filtering_spec.rb +164 -7
- data/spec/lib/tabulatr/data/formatting_spec.rb +2 -2
- data/spec/lib/tabulatr/data/sorting_spec.rb +6 -6
- data/spec/lib/tabulatr/params_builder_spec.rb +19 -0
- data/spec/lib/tabulatr/renderer/association_spec.rb +29 -0
- data/spec/lib/tabulatr/renderer/renderer_spec.rb +8 -0
- data/spec/rails_helper.rb +4 -0
- metadata +13 -3
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Tabulatr::ParamsBuilder do
|
4
|
+
it 'accepts an argument which is in the ALLOWED_PARAMS array' do
|
5
|
+
pb = nil
|
6
|
+
expect{pb = Tabulatr::ParamsBuilder.new(filter: false)}.to_not raise_error
|
7
|
+
expect(pb.filter).to be_falsey
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'does not accept a param which is not in the ALLOWED_PARAMS array' do
|
11
|
+
stub_const('Tabulatr::ParamsBuilder::ALLOWED_PARAMS', [:allowed_params])
|
12
|
+
expect{Tabulatr::ParamsBuilder.new(non_allowed_param: 'test')}.to raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does not accept a param which is in the DEPRECATED_PARAMS array' do
|
16
|
+
stub_const('Tabulatr::ParamsBuilder::DEPRECATED_PARAMS', [:deprecated_param])
|
17
|
+
expect{Tabulatr::ParamsBuilder.new(deprecated_param: 'test')}.to raise_error
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe Tabulatr::Renderer::Association do
|
4
|
+
|
5
|
+
describe '#principal_value' do
|
6
|
+
|
7
|
+
before {
|
8
|
+
@p = Product.create(title: 'product')
|
9
|
+
@p.tags.create(title: 'foo')
|
10
|
+
@p.tags.create(title: 'bar')
|
11
|
+
}
|
12
|
+
|
13
|
+
context 'name == "count"' do
|
14
|
+
it 'returns the associations\'s count' do
|
15
|
+
assoc = Tabulatr::Renderer::Association.from(table_name: 'tags', name: :count)
|
16
|
+
expect(assoc.principal_value(@p, nil)).to eq 2
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'name != "count"' do
|
22
|
+
it 'maps the association' do
|
23
|
+
assoc = Tabulatr::Renderer::Association.from(table_name: 'tags', name: :title)
|
24
|
+
expect(assoc.principal_value(@p, nil)).to match_array(['foo', 'bar'])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -45,5 +45,13 @@ describe Tabulatr::Renderer do
|
|
45
45
|
filters = renderer.instance_variable_get('@filters')
|
46
46
|
expect(filters.map(&:name)).to match_array([:simple_filter])
|
47
47
|
end
|
48
|
+
|
49
|
+
it 'renders no custom filters if `filters` option is false' do
|
50
|
+
allow_any_instance_of(Tabulatr::Data).to receive(:table_columns).and_return([])
|
51
|
+
renderer = Tabulatr::Renderer.new(Product, double_view)
|
52
|
+
renderer.build_table([], false, 'FakeRendererSpecTabulatrData')
|
53
|
+
filters = renderer.instance_variable_get('@filters')
|
54
|
+
expect(filters).to be_nil
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
data/spec/rails_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabulatr2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Horn
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -110,6 +110,7 @@ executables: []
|
|
110
110
|
extensions: []
|
111
111
|
extra_rdoc_files: []
|
112
112
|
files:
|
113
|
+
- ".codeclimate.yml"
|
113
114
|
- ".gitignore"
|
114
115
|
- ".rspec"
|
115
116
|
- ".travis.yml"
|
@@ -121,6 +122,8 @@ files:
|
|
121
122
|
- app/assets/images/pacman-loader.gif
|
122
123
|
- app/assets/images/standard-loader.gif
|
123
124
|
- app/assets/javascripts/tabulatr.js
|
125
|
+
- app/assets/javascripts/tabulatr/_events.js
|
126
|
+
- app/assets/javascripts/tabulatr/_pagination.js
|
124
127
|
- app/assets/javascripts/tabulatr/_storage.js
|
125
128
|
- app/assets/javascripts/tabulatr/_tabulatr.js
|
126
129
|
- app/assets/javascripts/tabulatr/application.js
|
@@ -156,6 +159,7 @@ files:
|
|
156
159
|
- lib/tabulatr/generators/tabulatr/templates/tabulatr.yml
|
157
160
|
- lib/tabulatr/generators/tabulatr/templates/tabulatr_data.rb
|
158
161
|
- lib/tabulatr/json_builder.rb
|
162
|
+
- lib/tabulatr/params_builder.rb
|
159
163
|
- lib/tabulatr/rails/action_controller.rb
|
160
164
|
- lib/tabulatr/rails/action_view.rb
|
161
165
|
- lib/tabulatr/rails/active_record.rb
|
@@ -202,6 +206,7 @@ files:
|
|
202
206
|
- spec/dummy/app/views/products/stupid_array.html.erb
|
203
207
|
- spec/dummy/app/views/products/with_batch_actions.html.erb
|
204
208
|
- spec/dummy/app/views/products/with_styling.html.erb
|
209
|
+
- spec/dummy/app/views/products/without_filters.html.erb
|
205
210
|
- spec/dummy/app/views/tabulatr/filter/_product_price_range.html.slim
|
206
211
|
- spec/dummy/app/views/vendors/index.html.slim
|
207
212
|
- spec/dummy/bin/bundle
|
@@ -245,6 +250,8 @@ files:
|
|
245
250
|
- spec/lib/tabulatr/data/pagination_spec.rb
|
246
251
|
- spec/lib/tabulatr/data/sorting_spec.rb
|
247
252
|
- spec/lib/tabulatr/json_builder_spec.rb
|
253
|
+
- spec/lib/tabulatr/params_builder_spec.rb
|
254
|
+
- spec/lib/tabulatr/renderer/association_spec.rb
|
248
255
|
- spec/lib/tabulatr/renderer/checkbox_spec.rb
|
249
256
|
- spec/lib/tabulatr/renderer/columns_from_block_spec.rb
|
250
257
|
- spec/lib/tabulatr/renderer/filter_spec.rb
|
@@ -274,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
281
|
version: '0'
|
275
282
|
requirements: []
|
276
283
|
rubyforge_project:
|
277
|
-
rubygems_version: 2.4.
|
284
|
+
rubygems_version: 2.4.7
|
278
285
|
signing_key:
|
279
286
|
specification_version: 4
|
280
287
|
summary: A tight DSL to build tables of ActiveRecord models with sorting, pagination,
|
@@ -310,6 +317,7 @@ test_files:
|
|
310
317
|
- spec/dummy/app/views/products/stupid_array.html.erb
|
311
318
|
- spec/dummy/app/views/products/with_batch_actions.html.erb
|
312
319
|
- spec/dummy/app/views/products/with_styling.html.erb
|
320
|
+
- spec/dummy/app/views/products/without_filters.html.erb
|
313
321
|
- spec/dummy/app/views/tabulatr/filter/_product_price_range.html.slim
|
314
322
|
- spec/dummy/app/views/vendors/index.html.slim
|
315
323
|
- spec/dummy/bin/bundle
|
@@ -353,6 +361,8 @@ test_files:
|
|
353
361
|
- spec/lib/tabulatr/data/pagination_spec.rb
|
354
362
|
- spec/lib/tabulatr/data/sorting_spec.rb
|
355
363
|
- spec/lib/tabulatr/json_builder_spec.rb
|
364
|
+
- spec/lib/tabulatr/params_builder_spec.rb
|
365
|
+
- spec/lib/tabulatr/renderer/association_spec.rb
|
356
366
|
- spec/lib/tabulatr/renderer/checkbox_spec.rb
|
357
367
|
- spec/lib/tabulatr/renderer/columns_from_block_spec.rb
|
358
368
|
- spec/lib/tabulatr/renderer/filter_spec.rb
|