datagrid 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8de0a49e930204781d435c0511d30f851660187e
4
- data.tar.gz: b078647180e79a1b9bbcb2f76af728f39c2af9ea
3
+ metadata.gz: 6ddccc0241fe7be8d5b6cce9fc48cdf20a5d9d29
4
+ data.tar.gz: d6f33446081c20970effc047a14a1b147dd17e55
5
5
  SHA512:
6
- metadata.gz: eaa488b20a9949bbb4e94876b376bdcdea83560ff1e254509e464f7087d6e3bc07e77f0b024bd758fa163f5e81fdd28732b26e68e4059dc460f2761015bd7a01
7
- data.tar.gz: ad2ea23cbf87bb2ec73fdf776904c524b8444e16db9df85a7be20aed445c4e15be624ce9d198f66f4b84168dcff5a91f9df402a4872dbef2c572f0fb1ac9477c
6
+ metadata.gz: 5120028296554128bae6a4614a1ac7a021a6c14cb4c107f55d01efb2b11493fe96db1cf9db1e589a6e9318e966ca7ba09aa628d7ba2467594d08d1a6daa333da
7
+ data.tar.gz: 4b23c861a07ded0fb42a89a6a5142e6e17372d55581e8f3b527a95060f8c397eeb5b17266c5a527341c3f070db7a4c359869fb1eb04f4202fc26969eafea5551
@@ -21,10 +21,10 @@ Ruby library that helps you to build and represent table-like data with:
21
21
 
22
22
  ### Live Demo
23
23
 
24
- [Datagrid DEMO application](http://datagrid.heroku.com) is available live!
24
+ [Datagrid DEMO application](http://datagrid.herokuapp.com) is available live!
25
25
  [Demo source code](https://github.com/bogdan/datagrid-demo).
26
26
 
27
- <img src="http://datagrid.heroku.com/datagrid_demo_screenshot.png" style="margin: 7px; border: 1px solid black">
27
+ <img src="http://datagrid.herokuapp.com/datagrid_demo_screenshot.png" style="margin: 7px; border: 1px solid black">
28
28
 
29
29
  ### Example
30
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -9,10 +9,10 @@ Local variables:
9
9
  <%= datagrid_header(grid, options) %>
10
10
  </thead>
11
11
  <tbody>
12
- <% if assets.empty? %>
13
- <tr><td class="noresults" colspan="100%"><%= I18n.t('datagrid.no_results').html_safe %></td></tr>
12
+ <% if assets.any? %>
13
+ <%= datagrid_rows(grid, assets, options) %>
14
14
  <% else %>
15
- <%= datagrid_rows(grid, assets, options) %>
15
+ <tr><td class="noresults" colspan="100%"><%= I18n.t('datagrid.no_results').html_safe %></td></tr>
16
16
  <% end %>
17
17
  </tbody>
18
18
  <% end %>
@@ -2,16 +2,16 @@
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.3.0 ruby lib
5
+ # stub: datagrid 1.3.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "datagrid"
9
- s.version = "1.3.0"
9
+ s.version = "1.3.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Bogdan Gusiev"]
14
- s.date = "2014-07-23"
14
+ s.date = "2014-08-21"
15
15
  s.description = "This allows you to easily build datagrid aka data tables with sortable columns and filters"
16
16
  s.email = "agresso@gmail.com"
17
17
  s.extra_rdoc_files = [
@@ -415,8 +415,8 @@ module Datagrid
415
415
 
416
416
  def initialize(*) #:nodoc:
417
417
  self.columns_array = self.class.columns_array.clone
418
- instance_eval(&dynamic_block) if dynamic_block
419
418
  super
419
+ instance_eval(&dynamic_block) if dynamic_block
420
420
  end
421
421
 
422
422
  # Returns all columns available for current grid configuration
@@ -3,7 +3,7 @@ module Datagrid
3
3
  class Array < AbstractDriver #:nodoc:
4
4
 
5
5
  def self.match?(scope)
6
- !Datagrid::Drivers::ActiveRecord.match?(scope) && scope.is_a?(::Array)
6
+ !Datagrid::Drivers::ActiveRecord.match?(scope) && (scope.is_a?(::Array) || scope.is_a?(Enumerator))
7
7
  end
8
8
 
9
9
  def to_scope(scope)
@@ -65,13 +65,14 @@ module Datagrid
65
65
 
66
66
  def rows(grid, assets, options = {})
67
67
  result = assets.map do |asset|
68
- _render_partial('row', options[:partials],
69
- {
70
- :grid => grid,
71
- :options => options,
72
- :asset => asset
73
- })
74
- end.join
68
+ _render_partial(
69
+ 'row', options[:partials],
70
+ {
71
+ :grid => grid,
72
+ :options => options,
73
+ :asset => asset
74
+ })
75
+ end.to_a.join
75
76
 
76
77
  _safe(result)
77
78
  end
@@ -386,6 +386,19 @@ describe Datagrid::Columns do
386
386
  expect(grid.column_by_name(:id)).not_to be_nil
387
387
  expect(grid.column_by_name(:name)).not_to be_nil
388
388
  end
389
+
390
+ it "has access to attributes" do
391
+ grid = test_report(:attribute_name => 'value') do
392
+ scope {Entry}
393
+ datagrid_attribute :attribute_name
394
+ dynamic {
395
+ value = attribute_name
396
+ column(:name) { value }
397
+ }
398
+ end
399
+
400
+ expect(grid.data_value(:name, Entry.create!)).to eq('value')
401
+ end
389
402
  end
390
403
 
391
404
  describe ".data_value" do
@@ -89,5 +89,18 @@ describe Datagrid::Drivers::Array do
89
89
  it {should == [third, first, second]}
90
90
  end
91
91
  end
92
+
92
93
  end
94
+ describe "when using enumerator scope" do
95
+
96
+ it "should work fine" do
97
+ grid = test_report(to_enum: true) do
98
+ scope {[]}
99
+ filter(:to_enum, :boolean) do |_, scope|
100
+ scope.to_enum
101
+ end
102
+ end
103
+ grid.assets.should_not be_any
104
+ end
105
+ end
93
106
  end
@@ -75,7 +75,7 @@ describe Datagrid::Helper do
75
75
  end
76
76
 
77
77
  it "should support giving assets explicitly" do
78
- other_entry = Entry.create!(entry.attributes)
78
+ Entry.create!(entry.attributes)
79
79
  datagrid_table = subject.datagrid_table(grid, [entry])
80
80
 
81
81
  expect(datagrid_table).to match_css_pattern({
@@ -148,293 +148,328 @@ describe Datagrid::Helper do
148
148
  end
149
149
  end
150
150
 
151
-
152
- describe ".datagrid_rows" do
153
- it "should support urls" do
154
- rp = test_report do
155
- scope { Entry }
156
- column(:name, :url => lambda {|model| model.name})
151
+ context "when scope is enumerator" do
152
+ let(:grid) do
153
+ test_report do
154
+ scope { ['a', 'b'].to_enum }
155
+ column(:name) do |value|
156
+ value
157
+ end
157
158
  end
158
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
159
- "tr td.name a[href=Star]" => "Star"
160
- )
161
159
  end
162
-
163
- it "should support conditional urls" do
164
- rp = test_report do
165
- scope { Entry }
166
- column(:name, :url => lambda {|model| false})
167
- end
168
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
169
- "tr td.name" => "Star"
170
- )
171
- end
172
-
173
- it "should add ordering classes to column" do
174
- rp = test_report(:order => :name) do
175
- scope { Entry }
176
- column(:name)
177
- end
178
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
179
- "tr td.name.ordered.asc" => "Star"
160
+ it "should render table" do
161
+ expect(subject.datagrid_table(grid)).to match_css_pattern(
162
+ "table.datagrid th.name" => 1,
163
+ "table.datagrid td.name" => 2,
180
164
  )
181
165
  end
182
-
183
- it "should add ordering classes to column" do
184
- rp = test_report(:order => :name, :descending => true) do
185
- scope { Entry }
186
- column(:name)
187
- end
188
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
189
- "tr td.name.ordered.desc" => "Star"
190
- )
166
+ end
167
+ context "when scope is lazy enumerator" do
168
+ before(:each) do
169
+ pending("not supported by ruby < 2.0") if RUBY_VERSION < '2.0'
191
170
  end
192
-
193
- it "should render html columns" do
194
- rp = test_report do
195
- scope { Entry }
196
- column(:name, :html => true) do |model|
197
- content_tag(:span, model.name)
171
+ let(:grid) do
172
+ test_report do
173
+ scope { ['a', 'b'].lazy }
174
+ column(:name) do |value|
175
+ value
198
176
  end
199
177
  end
200
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
201
- "tr td.name span" => "Star"
178
+ end
179
+ it "should render table" do
180
+ expect(subject.datagrid_table(grid)).to match_css_pattern(
181
+ "table.datagrid th.name" => 1,
182
+ "table.datagrid td.name" => 2,
202
183
  )
203
184
  end
185
+ end
186
+ end
204
187
 
205
- it "should render argument-based html columns" do
206
- rp = test_report do
207
- scope { Entry }
208
- column(:name, :html => lambda {|data| content_tag :h1, data})
209
- end
210
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
211
- "tr td.name h1" => "Star"
212
- )
188
+ describe ".datagrid_rows" do
189
+ it "should support urls" do
190
+ rp = test_report do
191
+ scope { Entry }
192
+ column(:name, :url => lambda {|model| model.name})
213
193
  end
194
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
195
+ "tr td.name a[href=Star]" => "Star"
196
+ )
197
+ end
214
198
 
215
- it "should render argument-based html columns with custom data" do
216
- rp = test_report do
217
- scope { Entry }
218
- column(:name, :html => lambda {|data| content_tag :em, data}) do
219
- self.name.upcase
220
- end
221
- end
222
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
223
- "tr td.name em" => "STAR"
224
- )
199
+ it "should support conditional urls" do
200
+ rp = test_report do
201
+ scope { Entry }
202
+ column(:name, :url => lambda {|model| false})
225
203
  end
204
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
205
+ "tr td.name" => "Star"
206
+ )
207
+ end
226
208
 
227
- it "should render html columns with double arguments for column" do
228
- rp = test_report do
229
- scope { Entry }
230
- column(:name, :html => true) do |model, grid|
231
- content_tag(:span, "#{model.name}-#{grid.assets.klass}" )
232
- end
233
- end
234
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
235
- "tr td.name span" => "Star-Entry"
236
- )
209
+ it "should add ordering classes to column" do
210
+ rp = test_report(:order => :name) do
211
+ scope { Entry }
212
+ column(:name)
237
213
  end
214
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
215
+ "tr td.name.ordered.asc" => "Star"
216
+ )
217
+ end
238
218
 
239
- it "should render argument-based html blocks with double arguments" do
240
- rp = test_report do
241
- scope { Entry }
242
- column(:name, :html => lambda { |data, model|
243
- content_tag :h1, "#{data}-#{model.name.downcase}"
244
- })
245
- end
246
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
247
- "tr td.name h1" => "Star-star"
248
- )
219
+ it "should add ordering classes to column" do
220
+ rp = test_report(:order => :name, :descending => true) do
221
+ scope { Entry }
222
+ column(:name)
249
223
  end
224
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
225
+ "tr td.name.ordered.desc" => "Star"
226
+ )
227
+ end
250
228
 
251
- it "should render argument-based html blocks with triple arguments" do
252
- rp = test_report do
253
- scope { Entry }
254
- column(:name, :html => lambda { |data, model, grid|
255
- content_tag :h1, "#{data}-#{model.name.downcase}-#{grid.assets.klass}"
256
- })
229
+ it "should render html columns" do
230
+ rp = test_report do
231
+ scope { Entry }
232
+ column(:name, :html => true) do |model|
233
+ content_tag(:span, model.name)
257
234
  end
258
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
259
- "tr td.name h1" => "Star-star-Entry"
260
- )
261
235
  end
236
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
237
+ "tr td.name span" => "Star"
238
+ )
239
+ end
262
240
 
263
- it "should render argument-based html blocks with double arguments and custom data" do
264
- rp = test_report do
265
- scope { Entry }
266
- column(:name, :html => lambda { |data, model|
267
- content_tag :h1, "#{data}-#{model.name}"
268
- }) do
269
- self.name.upcase
270
- end
271
- end
272
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
273
- "tr td.name h1" => "STAR-Star"
274
- )
241
+ it "should render argument-based html columns" do
242
+ rp = test_report do
243
+ scope { Entry }
244
+ column(:name, :html => lambda {|data| content_tag :h1, data})
275
245
  end
246
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
247
+ "tr td.name h1" => "Star"
248
+ )
249
+ end
276
250
 
277
- it "should render argument-based html blocks with triple arguments and custom data" do
278
- rp = test_report do
279
- scope { Entry }
280
- column(:name, :html => lambda { |data, model, grid|
281
- content_tag :h1, "#{data}-#{model.name}-#{grid.assets.klass}"
282
- }) do
283
- self.name.upcase
284
- end
251
+ it "should render argument-based html columns with custom data" do
252
+ rp = test_report do
253
+ scope { Entry }
254
+ column(:name, :html => lambda {|data| content_tag :em, data}) do
255
+ self.name.upcase
285
256
  end
286
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
287
- "tr td.name h1" => "STAR-Star-Entry"
288
- )
289
257
  end
258
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
259
+ "tr td.name em" => "STAR"
260
+ )
261
+ end
290
262
 
291
- it "should support columns option" do
292
- rp = test_report do
293
- scope { Entry }
294
- column(:name)
295
- column(:category)
263
+ it "should render html columns with double arguments for column" do
264
+ rp = test_report do
265
+ scope { Entry }
266
+ column(:name, :html => true) do |model, grid|
267
+ content_tag(:span, "#{model.name}-#{grid.assets.klass}" )
296
268
  end
297
- expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
298
- "tr td.name" => "Star"
299
- )
300
- expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
301
- "tr td.category" => 0
302
- )
303
269
  end
270
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
271
+ "tr td.name span" => "Star-Entry"
272
+ )
273
+ end
304
274
 
305
- it "should allow CSS classes to be specified for a column" do
306
- rp = test_report do
307
- scope { Entry }
308
- column(:name, :class => 'my_class')
309
- end
275
+ it "should render argument-based html blocks with double arguments" do
276
+ rp = test_report do
277
+ scope { Entry }
278
+ column(:name, :html => lambda { |data, model|
279
+ content_tag :h1, "#{data}-#{model.name.downcase}"
280
+ })
281
+ end
282
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
283
+ "tr td.name h1" => "Star-star"
284
+ )
285
+ end
310
286
 
311
- expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
312
- "tr td.name.my_class" => "Star"
313
- )
287
+ it "should render argument-based html blocks with triple arguments" do
288
+ rp = test_report do
289
+ scope { Entry }
290
+ column(:name, :html => lambda { |data, model, grid|
291
+ content_tag :h1, "#{data}-#{model.name.downcase}-#{grid.assets.klass}"
292
+ })
314
293
  end
294
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
295
+ "tr td.name h1" => "Star-star-Entry"
296
+ )
297
+ end
315
298
 
316
- context "when grid has complicated columns" do
317
- let(:grid) do
318
- test_report(:name => 'Hello') do
319
- scope {Entry}
320
- filter(:name)
321
- column(:name) do |model, grid|
322
- "'#{model.name}' filtered by '#{grid.name}'"
323
- end
324
- end
325
- end
326
- it "should ignore them" do
327
- expect(subject.datagrid_rows(grid, [entry])).to match_css_pattern(
328
- "td.name" => 1
329
- )
299
+ it "should render argument-based html blocks with double arguments and custom data" do
300
+ rp = test_report do
301
+ scope { Entry }
302
+ column(:name, :html => lambda { |data, model|
303
+ content_tag :h1, "#{data}-#{model.name}"
304
+ }) do
305
+ self.name.upcase
330
306
  end
331
307
  end
308
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
309
+ "tr td.name h1" => "STAR-Star"
310
+ )
332
311
  end
333
312
 
334
- describe ".datagrid_order_for" do
335
- it "should render ordering layout" do
336
- class OrderedGrid
337
- include Datagrid
338
- scope { Entry }
339
- column(:category)
313
+ it "should render argument-based html blocks with triple arguments and custom data" do
314
+ rp = test_report do
315
+ scope { Entry }
316
+ column(:name, :html => lambda { |data, model, grid|
317
+ content_tag :h1, "#{data}-#{model.name}-#{grid.assets.klass}"
318
+ }) do
319
+ self.name.upcase
340
320
  end
341
- grid = OrderedGrid.new(:descending => true, :order => :category)
342
- expect(subject.datagrid_order_for(grid, grid.column_by_name(:category))).to equal_to_dom(<<-HTML)
343
- <div class="order">
344
- <a href="/location?ordered_grid%5Bdescending%5D=false&amp;ordered_grid%5Border%5D=category" class="asc">&uarr;</a>
345
- <a href="/location?ordered_grid%5Bdescending%5D=true&amp;ordered_grid%5Border%5D=category" class="desc">&darr;</a>
346
- </div>
347
- HTML
348
321
  end
322
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
323
+ "tr td.name h1" => "STAR-Star-Entry"
324
+ )
349
325
  end
350
- describe ".datagrid_form_for" do
351
- it 'returns namespaced partial if partials options is passed' do
352
- rendered_form = subject.datagrid_form_for(grid, {
353
- :url => '',
354
- :partials => 'client/datagrid'
355
- })
356
- expect(rendered_form).to include 'Namespaced form partial.'
326
+
327
+ it "should support columns option" do
328
+ rp = test_report do
329
+ scope { Entry }
330
+ column(:name)
331
+ column(:category)
357
332
  end
358
- it "should render form and filter inputs" do
359
- class FormForGrid
360
- include Datagrid
361
- scope { Entry }
362
- filter(:category)
363
- end
364
- grid = FormForGrid.new(:category => "hello")
365
- expect(subject.datagrid_form_for(grid, :url => "/grid")).to match_css_pattern(
366
- "form.datagrid-form.form_for_grid[action='/grid']" => 1,
367
- "form input[name=utf8]" => 1,
368
- "form .filter label" => "Category",
369
- "form .filter input.category.default_filter[name='form_for_grid[category]'][value=hello]" => 1,
370
- "form input[name=commit][value=Search]" => 1,
371
- "form a.datagrid-reset[href='/location']" => 1
372
- )
333
+ expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
334
+ "tr td.name" => "Star"
335
+ )
336
+ expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
337
+ "tr td.category" => 0
338
+ )
339
+ end
340
+
341
+ it "should allow CSS classes to be specified for a column" do
342
+ rp = test_report do
343
+ scope { Entry }
344
+ column(:name, :class => 'my_class')
373
345
  end
374
- it "should support html classes for grid class with namespace" do
375
- module ::Ns22
376
- class TestGrid
377
- include Datagrid
378
- scope { Entry }
379
- filter(:id)
346
+
347
+ expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
348
+ "tr td.name.my_class" => "Star"
349
+ )
350
+ end
351
+
352
+ context "when grid has complicated columns" do
353
+ let(:grid) do
354
+ test_report(:name => 'Hello') do
355
+ scope {Entry}
356
+ filter(:name)
357
+ column(:name) do |model, grid|
358
+ "'#{model.name}' filtered by '#{grid.name}'"
380
359
  end
381
360
  end
382
- expect(subject.datagrid_form_for(::Ns22::TestGrid.new, :url => "grid")).to match_css_pattern(
383
- "form.datagrid-form.ns22_test_grid" => 1,
384
- "form.datagrid-form label[for=ns22_test_grid_id]" => 1,
385
- "form.datagrid-form input#ns22_test_grid_id[name='ns22_test_grid[id]']" => 1,
361
+ end
362
+ it "should ignore them" do
363
+ expect(subject.datagrid_rows(grid, [entry])).to match_css_pattern(
364
+ "td.name" => 1
386
365
  )
387
366
  end
367
+ end
368
+ end
388
369
 
389
- it "should have overridable param_name method" do
390
- class ParamNameGrid81
370
+ describe ".datagrid_order_for" do
371
+ it "should render ordering layout" do
372
+ class OrderedGrid
373
+ include Datagrid
374
+ scope { Entry }
375
+ column(:category)
376
+ end
377
+ grid = OrderedGrid.new(:descending => true, :order => :category)
378
+ expect(subject.datagrid_order_for(grid, grid.column_by_name(:category))).to equal_to_dom(<<-HTML)
379
+ <div class="order">
380
+ <a href="/location?ordered_grid%5Bdescending%5D=false&amp;ordered_grid%5Border%5D=category" class="asc">&uarr;</a>
381
+ <a href="/location?ordered_grid%5Bdescending%5D=true&amp;ordered_grid%5Border%5D=category" class="desc">&darr;</a>
382
+ </div>
383
+ HTML
384
+ end
385
+ end
386
+ describe ".datagrid_form_for" do
387
+ it 'returns namespaced partial if partials options is passed' do
388
+ rendered_form = subject.datagrid_form_for(grid, {
389
+ :url => '',
390
+ :partials => 'client/datagrid'
391
+ })
392
+ expect(rendered_form).to include 'Namespaced form partial.'
393
+ end
394
+ it "should render form and filter inputs" do
395
+ class FormForGrid
396
+ include Datagrid
397
+ scope { Entry }
398
+ filter(:category)
399
+ end
400
+ grid = FormForGrid.new(:category => "hello")
401
+ expect(subject.datagrid_form_for(grid, :url => "/grid")).to match_css_pattern(
402
+ "form.datagrid-form.form_for_grid[action='/grid']" => 1,
403
+ "form input[name=utf8]" => 1,
404
+ "form .filter label" => "Category",
405
+ "form .filter input.category.default_filter[name='form_for_grid[category]'][value=hello]" => 1,
406
+ "form input[name=commit][value=Search]" => 1,
407
+ "form a.datagrid-reset[href='/location']" => 1
408
+ )
409
+ end
410
+ it "should support html classes for grid class with namespace" do
411
+ module ::Ns22
412
+ class TestGrid
391
413
  include Datagrid
392
414
  scope { Entry }
393
415
  filter(:id)
394
- def param_name
395
- 'g'
396
- end
397
416
  end
398
- expect(subject.datagrid_form_for(::ParamNameGrid81.new, :url => "/grid")).to match_css_pattern(
399
- "form.datagrid-form input[name='g[id]']" => 1,
400
- )
401
417
  end
418
+ expect(subject.datagrid_form_for(::Ns22::TestGrid.new, :url => "grid")).to match_css_pattern(
419
+ "form.datagrid-form.ns22_test_grid" => 1,
420
+ "form.datagrid-form label[for=ns22_test_grid_id]" => 1,
421
+ "form.datagrid-form input#ns22_test_grid_id[name='ns22_test_grid[id]']" => 1,
422
+ )
402
423
  end
403
424
 
404
-
405
- describe ".datagrid_row" do
406
- let(:grid) do
407
- test_report do
408
- scope { Entry }
409
- column(:name)
410
- column(:category)
425
+ it "should have overridable param_name method" do
426
+ class ParamNameGrid81
427
+ include Datagrid
428
+ scope { Entry }
429
+ filter(:id)
430
+ def param_name
431
+ 'g'
411
432
  end
412
433
  end
434
+ expect(subject.datagrid_form_for(::ParamNameGrid81.new, :url => "/grid")).to match_css_pattern(
435
+ "form.datagrid-form input[name='g[id]']" => 1,
436
+ )
437
+ end
438
+ end
413
439
 
414
- let(:entry) do
415
- Entry.create!(:name => "Hello", :category => "greetings")
416
- end
417
440
 
418
- it "should provide access to row data" do
419
- r = subject.datagrid_row(grid, entry)
420
- expect(r.name).to eq("Hello")
421
- expect(r.category).to eq("greetings")
441
+ describe ".datagrid_row" do
442
+ let(:grid) do
443
+ test_report do
444
+ scope { Entry }
445
+ column(:name)
446
+ column(:category)
422
447
  end
423
- it "should yield block" do
424
- subject.datagrid_row(grid, entry) do |row|
425
- expect(row.name).to eq("Hello")
426
- expect(row.category).to eq("greetings")
427
- end
448
+ end
449
+
450
+ let(:entry) do
451
+ Entry.create!(:name => "Hello", :category => "greetings")
452
+ end
453
+
454
+ it "should provide access to row data" do
455
+ r = subject.datagrid_row(grid, entry)
456
+ expect(r.name).to eq("Hello")
457
+ expect(r.category).to eq("greetings")
458
+ end
459
+ it "should yield block" do
460
+ subject.datagrid_row(grid, entry) do |row|
461
+ expect(row.name).to eq("Hello")
462
+ expect(row.category).to eq("greetings")
428
463
  end
464
+ end
429
465
 
430
- it "should output data from block" do
431
- name = subject.datagrid_row(grid, entry) do |row|
432
- subject.concat(row.name)
433
- subject.concat(",")
434
- subject.concat(row.category)
435
- end
436
- expect(name).to eq("Hello,greetings")
466
+ it "should output data from block" do
467
+ name = subject.datagrid_row(grid, entry) do |row|
468
+ subject.concat(row.name)
469
+ subject.concat(",")
470
+ subject.concat(row.category)
437
471
  end
472
+ expect(name).to eq("Hello,greetings")
438
473
  end
439
474
  end
440
475
 
@@ -83,7 +83,11 @@ class CssPattern
83
83
  end
84
84
 
85
85
  def failure_message
86
- "Expected do not match dom pattern. But it was"
86
+ "Expected to match dom pattern. But it wasn't."
87
+ end
88
+
89
+ def failure_message_when_negated
90
+ "Expected to not match dom pattern. But it was."
87
91
  end
88
92
 
89
93
  def description
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.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-23 00:00:00.000000000 Z
11
+ date: 2014-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails