datagrid 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -6
- data/VERSION +1 -1
- data/app/views/datagrid/_form.html.erb +3 -1
- data/datagrid.gemspec +6 -6
- data/lib/datagrid.rb +1 -0
- data/lib/datagrid/columns.rb +14 -7
- data/lib/datagrid/columns/column.rb +7 -4
- data/lib/datagrid/renderer.rb +1 -1
- data/spec/datagrid/active_model_spec.rb +4 -4
- data/spec/datagrid/column_names_attribute_spec.rb +15 -11
- data/spec/datagrid/columns_spec.rb +80 -62
- data/spec/datagrid/core_spec.rb +6 -6
- data/spec/datagrid/drivers/active_record_spec.rb +4 -4
- data/spec/datagrid/drivers/array_spec.rb +41 -8
- data/spec/datagrid/drivers/mongo_mapper_spec.rb +42 -10
- data/spec/datagrid/drivers/mongoid_spec.rb +43 -11
- data/spec/datagrid/filters/composite_filters_spec.rb +12 -12
- data/spec/datagrid/filters/date_filter_spec.rb +25 -25
- data/spec/datagrid/filters/date_time_filter_spec.rb +20 -20
- data/spec/datagrid/filters/dynamic_filter_spec.rb +43 -43
- data/spec/datagrid/filters/enum_filter_spec.rb +6 -6
- data/spec/datagrid/filters/extended_boolean_filter_spec.rb +10 -10
- data/spec/datagrid/filters/float_filter_spec.rb +2 -2
- data/spec/datagrid/filters/integer_filter_spec.rb +34 -34
- data/spec/datagrid/filters/string_filter_spec.rb +7 -7
- data/spec/datagrid/filters_spec.rb +20 -20
- data/spec/datagrid/form_builder_spec.rb +5 -5
- data/spec/datagrid/helper_spec.rb +41 -40
- data/spec/datagrid/ordering_spec.rb +22 -22
- data/spec/datagrid/scaffold_spec.rb +2 -2
- data/spec/datagrid/utils_spec.rb +3 -3
- data/spec/datagrid_spec.rb +10 -7
- data/spec/support/matchers.rb +6 -3
- metadata +30 -30
@@ -8,19 +8,19 @@ describe Datagrid::Filters::StringFilter do
|
|
8
8
|
scope {Entry}
|
9
9
|
filter(:name, :string, :multiple => true)
|
10
10
|
end
|
11
|
-
report.assets.
|
12
|
-
report.assets.
|
13
|
-
report.assets.
|
11
|
+
expect(report.assets).to include(Entry.create!( :name => "one"))
|
12
|
+
expect(report.assets).to include(Entry.create!( :name => "two"))
|
13
|
+
expect(report.assets).not_to include(Entry.create!( :name => "three"))
|
14
14
|
end
|
15
15
|
it "should support custom separator multiple values" do
|
16
16
|
report = test_report(:name => "one,1|two,2") do
|
17
17
|
scope {Entry}
|
18
18
|
filter(:name, :string, :multiple => '|')
|
19
19
|
end
|
20
|
-
report.assets.
|
21
|
-
report.assets.
|
22
|
-
report.assets.
|
23
|
-
report.assets.
|
20
|
+
expect(report.assets).to include(Entry.create!( :name => "one,1"))
|
21
|
+
expect(report.assets).to include(Entry.create!( :name => "two,2"))
|
22
|
+
expect(report.assets).not_to include(Entry.create!( :name => "one"))
|
23
|
+
expect(report.assets).not_to include(Entry.create!( :name => "two"))
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
@@ -3,10 +3,10 @@ require 'spec_helper'
|
|
3
3
|
describe Datagrid::Filters do
|
4
4
|
|
5
5
|
it "should support default option as proc" do
|
6
|
-
test_report do
|
6
|
+
expect(test_report do
|
7
7
|
scope {Entry}
|
8
8
|
filter(:created_at, :date, :default => proc { Date.today } )
|
9
|
-
end.created_at.
|
9
|
+
end.created_at).to eq(Date.today)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should stack with other filters" do
|
@@ -16,7 +16,7 @@ describe Datagrid::Filters do
|
|
16
16
|
filter(:name)
|
17
17
|
filter(:category, :enum, :select => ["first", "second"])
|
18
18
|
end
|
19
|
-
report.assets.
|
19
|
+
expect(report.assets).to be_empty
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should not support array argument for not multiple filter" do
|
@@ -24,9 +24,9 @@ describe Datagrid::Filters do
|
|
24
24
|
scope {Entry}
|
25
25
|
filter(:group_id, :integer)
|
26
26
|
end
|
27
|
-
|
27
|
+
expect {
|
28
28
|
report.group_id = [1,2]
|
29
|
-
}.
|
29
|
+
}.to raise_error(Datagrid::ArgumentError)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should filter block with 2 arguments" do
|
@@ -36,15 +36,15 @@ describe Datagrid::Filters do
|
|
36
36
|
scope.where(:group_id => value)
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
expect {
|
40
40
|
report.group_id = [1,2]
|
41
|
-
}.
|
41
|
+
}.to raise_error(Datagrid::ArgumentError)
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
45
|
it "should initialize when report Scope table not exists" do
|
46
46
|
class ModelWithoutTable < ActiveRecord::Base; end
|
47
|
-
ModelWithoutTable.
|
47
|
+
expect(ModelWithoutTable).not_to be_table_exists
|
48
48
|
class TheReport
|
49
49
|
include Datagrid
|
50
50
|
|
@@ -53,7 +53,7 @@ describe Datagrid::Filters do
|
|
53
53
|
filter(:name)
|
54
54
|
filter(:limit)
|
55
55
|
end
|
56
|
-
TheReport.new(:name => 'hello').
|
56
|
+
expect(TheReport.new(:name => 'hello')).not_to be_nil
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should support inheritence" do
|
@@ -65,8 +65,8 @@ describe Datagrid::Filters do
|
|
65
65
|
child = Class.new(parent) do
|
66
66
|
filter(:group_id)
|
67
67
|
end
|
68
|
-
parent.filters.size.
|
69
|
-
child.filters.size.
|
68
|
+
expect(parent.filters.size).to eq(1)
|
69
|
+
expect(child.filters.size).to eq(2)
|
70
70
|
end
|
71
71
|
|
72
72
|
describe "allow_blank and allow_nil options" do
|
@@ -80,9 +80,9 @@ describe Datagrid::Filters do
|
|
80
80
|
self
|
81
81
|
end
|
82
82
|
end
|
83
|
-
report.name.
|
83
|
+
expect(report.name).to eq(value)
|
84
84
|
report.assets
|
85
|
-
$FILTER_PERFORMED.
|
85
|
+
expect($FILTER_PERFORMED).to eq(result)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "should support allow_blank argument" do
|
@@ -110,7 +110,7 @@ describe Datagrid::Filters do
|
|
110
110
|
scope {Entry}
|
111
111
|
filter(:limit)
|
112
112
|
end
|
113
|
-
grid.assets.to_a.size.
|
113
|
+
expect(grid.assets.to_a.size).to eq(1)
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
@@ -125,7 +125,7 @@ describe Datagrid::Filters do
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
128
|
-
grid.assets.
|
128
|
+
expect(grid.assets).not_to be_empty
|
129
129
|
end
|
130
130
|
|
131
131
|
end
|
@@ -137,7 +137,7 @@ describe Datagrid::Filters do
|
|
137
137
|
filter(:limit)
|
138
138
|
filter(:name, :before => :limit)
|
139
139
|
end
|
140
|
-
grid.filters.index {|f| f.name == :name}.
|
140
|
+
expect(grid.filters.index {|f| f.name == :name}).to eq(0)
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
@@ -149,7 +149,7 @@ describe Datagrid::Filters do
|
|
149
149
|
filter(:name)
|
150
150
|
filter(:group_id, :after => :limit)
|
151
151
|
end
|
152
|
-
grid.filters.index {|f| f.name == :group_id}.
|
152
|
+
expect(grid.filters.index {|f| f.name == :group_id}).to eq(1)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
@@ -159,7 +159,7 @@ describe Datagrid::Filters do
|
|
159
159
|
filter(:period, :date, :dummy => true, :default => proc { Date.today })
|
160
160
|
end
|
161
161
|
Entry.create!(:created_at => 3.days.ago)
|
162
|
-
grid.assets.
|
162
|
+
expect(grid.assets).not_to be_empty
|
163
163
|
end
|
164
164
|
|
165
165
|
describe "#filter_by" do
|
@@ -171,8 +171,8 @@ describe Datagrid::Filters do
|
|
171
171
|
end
|
172
172
|
e = Entry.create!(:name => 'hello')
|
173
173
|
grid.attributes = {:id => -1, :name => 'hello'}
|
174
|
-
grid.assets.
|
175
|
-
grid.filter_by(:name).
|
174
|
+
expect(grid.assets).to be_empty
|
175
|
+
expect(grid.filter_by(:name)).not_to be_empty
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -20,7 +20,7 @@ describe Datagrid::FormBuilder do
|
|
20
20
|
|
21
21
|
it "should work for every filter type" do
|
22
22
|
Datagrid::Filters::FILTER_TYPES.each do |type, klass|
|
23
|
-
Datagrid::FormBuilder.instance_methods.map(&:to_sym).
|
23
|
+
expect(Datagrid::FormBuilder.instance_methods.map(&:to_sym)).to include(klass.form_builder_helper_name)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -497,22 +497,22 @@ DOM
|
|
497
497
|
end
|
498
498
|
end
|
499
499
|
it "should generate label for filter" do
|
500
|
-
view.datagrid_label(:name).
|
500
|
+
expect(view.datagrid_label(:name)).to equal_to_dom(
|
501
501
|
'<label for="report_name">Name</label>'
|
502
502
|
)
|
503
503
|
end
|
504
504
|
it "should pass options through to the helper" do
|
505
|
-
view.datagrid_label(:name, :class => 'foo').
|
505
|
+
expect(view.datagrid_label(:name, :class => 'foo')).to equal_to_dom(
|
506
506
|
'<label class="foo" for="report_name">Name</label>'
|
507
507
|
)
|
508
508
|
end
|
509
509
|
it "should support block" do
|
510
|
-
view.datagrid_label(:name, :class => 'foo') { 'The Name' }.
|
510
|
+
expect(view.datagrid_label(:name, :class => 'foo') { 'The Name' }).to equal_to_dom(
|
511
511
|
'<label class="foo" for="report_name">The Name</label>'
|
512
512
|
)
|
513
513
|
end
|
514
514
|
it "should support explicit label" do
|
515
|
-
view.datagrid_label(:name, "The Name").
|
515
|
+
expect(view.datagrid_label(:name, "The Name")).to equal_to_dom(
|
516
516
|
'<label for="report_name">The Name</label>'
|
517
517
|
)
|
518
518
|
end
|
@@ -7,15 +7,15 @@ require 'datagrid/renderer'
|
|
7
7
|
describe Datagrid::Helper do
|
8
8
|
subject do
|
9
9
|
template = ActionView::Base.new
|
10
|
-
template.
|
10
|
+
allow(template).to receive(:protect_against_forgery?).and_return(false)
|
11
11
|
template.view_paths << File.expand_path("../../../app/views", __FILE__)
|
12
12
|
template.view_paths << File.expand_path("../../support/test_partials", __FILE__)
|
13
13
|
template
|
14
14
|
end
|
15
15
|
|
16
16
|
before(:each) do
|
17
|
-
subject.
|
18
|
-
subject.
|
17
|
+
allow(subject).to receive(:params).and_return({})
|
18
|
+
allow(subject).to receive(:url_for) do |options|
|
19
19
|
options.to_param
|
20
20
|
end
|
21
21
|
|
@@ -37,16 +37,16 @@ describe Datagrid::Helper do
|
|
37
37
|
it "should show an empty table with dashes" do
|
38
38
|
datagrid_table = subject.datagrid_table(grid)
|
39
39
|
|
40
|
-
datagrid_table.
|
40
|
+
expect(datagrid_table).to match_css_pattern(
|
41
41
|
"table.datagrid tr td.noresults" => 1
|
42
42
|
)
|
43
|
-
datagrid_table.
|
43
|
+
expect(datagrid_table).to include("——")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
describe ".datagrid_table" do
|
48
48
|
it "should have grid class as html class on table" do
|
49
|
-
subject.datagrid_table(grid).
|
49
|
+
expect(subject.datagrid_table(grid)).to match_css_pattern(
|
50
50
|
"table.datagrid.simple_report" => 1
|
51
51
|
)
|
52
52
|
end
|
@@ -57,14 +57,14 @@ describe Datagrid::Helper do
|
|
57
57
|
scope { Entry }
|
58
58
|
end
|
59
59
|
end
|
60
|
-
subject.datagrid_table(::Ns23::TestGrid.new).
|
60
|
+
expect(subject.datagrid_table(::Ns23::TestGrid.new)).to match_css_pattern(
|
61
61
|
"table.datagrid.ns23_test_grid" => 1
|
62
62
|
)
|
63
63
|
end
|
64
64
|
it "should return data table html" do
|
65
65
|
datagrid_table = subject.datagrid_table(grid)
|
66
66
|
|
67
|
-
datagrid_table.
|
67
|
+
expect(datagrid_table).to match_css_pattern({
|
68
68
|
"table.datagrid tr th.group div.order" => 1,
|
69
69
|
"table.datagrid tr th.group" => /Group.*/,
|
70
70
|
"table.datagrid tr th.name div.order" => 1,
|
@@ -78,7 +78,7 @@ describe Datagrid::Helper do
|
|
78
78
|
other_entry = Entry.create!(entry.attributes)
|
79
79
|
datagrid_table = subject.datagrid_table(grid, [entry])
|
80
80
|
|
81
|
-
datagrid_table.
|
81
|
+
expect(datagrid_table).to match_css_pattern({
|
82
82
|
"table.datagrid tr th.group div.order" => 1,
|
83
83
|
"table.datagrid tr th.group" => /Group.*/,
|
84
84
|
"table.datagrid tr th.name div.order" => 1,
|
@@ -89,7 +89,7 @@ describe Datagrid::Helper do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should support cycle option" do
|
92
|
-
subject.datagrid_rows(grid, [entry], :cycle => ["odd", "even"]).
|
92
|
+
expect(subject.datagrid_rows(grid, [entry], :cycle => ["odd", "even"])).to match_css_pattern({
|
93
93
|
"tr.odd td.group" => "Pop",
|
94
94
|
"tr.odd td.name" => "Star"
|
95
95
|
})
|
@@ -97,11 +97,11 @@ describe Datagrid::Helper do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should support no order given" do
|
100
|
-
subject.datagrid_table(grid, [entry], :order => false).
|
100
|
+
expect(subject.datagrid_table(grid, [entry], :order => false)).to match_css_pattern("table.datagrid th .order" => 0)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "should support columns option" do
|
104
|
-
subject.datagrid_table(grid, [entry], :columns => [:name]).
|
104
|
+
expect(subject.datagrid_table(grid, [entry], :columns => [:name])).to match_css_pattern(
|
105
105
|
"table.datagrid th.name" => 1,
|
106
106
|
"table.datagrid td.name" => 1,
|
107
107
|
"table.datagrid th.group" => 0,
|
@@ -119,7 +119,7 @@ describe Datagrid::Helper do
|
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should output only given column names" do
|
122
|
-
subject.datagrid_table(grid, [entry]).
|
122
|
+
expect(subject.datagrid_table(grid, [entry])).to match_css_pattern(
|
123
123
|
"table.datagrid th.name" => 1,
|
124
124
|
"table.datagrid td.name" => 1,
|
125
125
|
"table.datagrid th.category" => 0,
|
@@ -155,7 +155,7 @@ describe Datagrid::Helper do
|
|
155
155
|
scope { Entry }
|
156
156
|
column(:name, :url => lambda {|model| model.name})
|
157
157
|
end
|
158
|
-
subject.datagrid_rows(rp, [entry]).
|
158
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
159
159
|
"tr td.name a[href=Star]" => "Star"
|
160
160
|
)
|
161
161
|
end
|
@@ -165,7 +165,7 @@ describe Datagrid::Helper do
|
|
165
165
|
scope { Entry }
|
166
166
|
column(:name, :url => lambda {|model| false})
|
167
167
|
end
|
168
|
-
subject.datagrid_rows(rp, [entry]).
|
168
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
169
169
|
"tr td.name" => "Star"
|
170
170
|
)
|
171
171
|
end
|
@@ -175,7 +175,7 @@ describe Datagrid::Helper do
|
|
175
175
|
scope { Entry }
|
176
176
|
column(:name)
|
177
177
|
end
|
178
|
-
subject.datagrid_rows(rp, [entry]).
|
178
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
179
179
|
"tr td.name.ordered.asc" => "Star"
|
180
180
|
)
|
181
181
|
end
|
@@ -185,7 +185,7 @@ describe Datagrid::Helper do
|
|
185
185
|
scope { Entry }
|
186
186
|
column(:name)
|
187
187
|
end
|
188
|
-
subject.datagrid_rows(rp, [entry]).
|
188
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
189
189
|
"tr td.name.ordered.desc" => "Star"
|
190
190
|
)
|
191
191
|
end
|
@@ -197,7 +197,7 @@ describe Datagrid::Helper do
|
|
197
197
|
content_tag(:span, model.name)
|
198
198
|
end
|
199
199
|
end
|
200
|
-
subject.datagrid_rows(rp, [entry]).
|
200
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
201
201
|
"tr td.name span" => "Star"
|
202
202
|
)
|
203
203
|
end
|
@@ -207,7 +207,7 @@ describe Datagrid::Helper do
|
|
207
207
|
scope { Entry }
|
208
208
|
column(:name, :html => lambda {|data| content_tag :h1, data})
|
209
209
|
end
|
210
|
-
subject.datagrid_rows(rp, [entry]).
|
210
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
211
211
|
"tr td.name h1" => "Star"
|
212
212
|
)
|
213
213
|
end
|
@@ -219,7 +219,7 @@ describe Datagrid::Helper do
|
|
219
219
|
self.name.upcase
|
220
220
|
end
|
221
221
|
end
|
222
|
-
subject.datagrid_rows(rp, [entry]).
|
222
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
223
223
|
"tr td.name em" => "STAR"
|
224
224
|
)
|
225
225
|
end
|
@@ -231,7 +231,7 @@ describe Datagrid::Helper do
|
|
231
231
|
content_tag(:span, "#{model.name}-#{grid.assets.klass}" )
|
232
232
|
end
|
233
233
|
end
|
234
|
-
subject.datagrid_rows(rp, [entry]).
|
234
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
235
235
|
"tr td.name span" => "Star-Entry"
|
236
236
|
)
|
237
237
|
end
|
@@ -243,7 +243,7 @@ describe Datagrid::Helper do
|
|
243
243
|
content_tag :h1, "#{data}-#{model.name.downcase}"
|
244
244
|
})
|
245
245
|
end
|
246
|
-
subject.datagrid_rows(rp, [entry]).
|
246
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
247
247
|
"tr td.name h1" => "Star-star"
|
248
248
|
)
|
249
249
|
end
|
@@ -255,7 +255,7 @@ describe Datagrid::Helper do
|
|
255
255
|
content_tag :h1, "#{data}-#{model.name.downcase}-#{grid.assets.klass}"
|
256
256
|
})
|
257
257
|
end
|
258
|
-
subject.datagrid_rows(rp, [entry]).
|
258
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
259
259
|
"tr td.name h1" => "Star-star-Entry"
|
260
260
|
)
|
261
261
|
end
|
@@ -269,7 +269,7 @@ describe Datagrid::Helper do
|
|
269
269
|
self.name.upcase
|
270
270
|
end
|
271
271
|
end
|
272
|
-
subject.datagrid_rows(rp, [entry]).
|
272
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
273
273
|
"tr td.name h1" => "STAR-Star"
|
274
274
|
)
|
275
275
|
end
|
@@ -283,7 +283,7 @@ describe Datagrid::Helper do
|
|
283
283
|
self.name.upcase
|
284
284
|
end
|
285
285
|
end
|
286
|
-
subject.datagrid_rows(rp, [entry]).
|
286
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
287
287
|
"tr td.name h1" => "STAR-Star-Entry"
|
288
288
|
)
|
289
289
|
end
|
@@ -294,10 +294,10 @@ describe Datagrid::Helper do
|
|
294
294
|
column(:name)
|
295
295
|
column(:category)
|
296
296
|
end
|
297
|
-
subject.datagrid_rows(rp, [entry], :columns => [:name]).
|
297
|
+
expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
|
298
298
|
"tr td.name" => "Star"
|
299
299
|
)
|
300
|
-
subject.datagrid_rows(rp, [entry], :columns => [:name]).
|
300
|
+
expect(subject.datagrid_rows(rp, [entry], :columns => [:name])).to match_css_pattern(
|
301
301
|
"tr td.category" => 0
|
302
302
|
)
|
303
303
|
end
|
@@ -308,7 +308,7 @@ describe Datagrid::Helper do
|
|
308
308
|
column(:name, :class => 'my_class')
|
309
309
|
end
|
310
310
|
|
311
|
-
subject.datagrid_rows(rp, [entry]).
|
311
|
+
expect(subject.datagrid_rows(rp, [entry])).to match_css_pattern(
|
312
312
|
"tr td.name.my_class" => "Star"
|
313
313
|
)
|
314
314
|
end
|
@@ -324,7 +324,7 @@ describe Datagrid::Helper do
|
|
324
324
|
end
|
325
325
|
end
|
326
326
|
it "should ignore them" do
|
327
|
-
subject.datagrid_rows(grid, [entry]).
|
327
|
+
expect(subject.datagrid_rows(grid, [entry])).to match_css_pattern(
|
328
328
|
"td.name" => 1
|
329
329
|
)
|
330
330
|
end
|
@@ -339,7 +339,7 @@ describe Datagrid::Helper do
|
|
339
339
|
column(:category)
|
340
340
|
end
|
341
341
|
grid = OrderedGrid.new(:descending => true, :order => :category)
|
342
|
-
subject.datagrid_order_for(grid, grid.column_by_name(:category)).
|
342
|
+
expect(subject.datagrid_order_for(grid, grid.column_by_name(:category))).to equal_to_dom(<<-HTML)
|
343
343
|
<div class="order">
|
344
344
|
<a href="ordered_grid%5Bdescending%5D=false&ordered_grid%5Border%5D=category" class="asc">↑</a>
|
345
345
|
<a href="ordered_grid%5Bdescending%5D=true&ordered_grid%5Border%5D=category" class="desc">↓</a>
|
@@ -362,12 +362,13 @@ describe Datagrid::Helper do
|
|
362
362
|
filter(:category)
|
363
363
|
end
|
364
364
|
grid = FormForGrid.new(:category => "hello")
|
365
|
-
subject.datagrid_form_for(grid, :url => "/grid").
|
365
|
+
expect(subject.datagrid_form_for(grid, :url => "/grid")).to match_css_pattern(
|
366
366
|
"form.datagrid-form.form_for_grid[action='/grid']" => 1,
|
367
367
|
"form input[name=utf8]" => 1,
|
368
368
|
"form .filter label" => "Category",
|
369
369
|
"form .filter input.category.default_filter[name='form_for_grid[category]'][value=hello]" => 1,
|
370
|
-
"form input[name=commit][value=Search]" => 1
|
370
|
+
"form input[name=commit][value=Search]" => 1,
|
371
|
+
"form a.datagrid-reset[href='']" => 1
|
371
372
|
)
|
372
373
|
end
|
373
374
|
it "should support html classes for grid class with namespace" do
|
@@ -377,7 +378,7 @@ describe Datagrid::Helper do
|
|
377
378
|
scope { Entry }
|
378
379
|
end
|
379
380
|
end
|
380
|
-
subject.datagrid_form_for(::Ns22::TestGrid.new, :url => "grid").
|
381
|
+
expect(subject.datagrid_form_for(::Ns22::TestGrid.new, :url => "grid")).to match_css_pattern(
|
381
382
|
"form.datagrid-form.ns22_test_grid" => 1,
|
382
383
|
)
|
383
384
|
end
|
@@ -399,13 +400,13 @@ describe Datagrid::Helper do
|
|
399
400
|
|
400
401
|
it "should provide access to row data" do
|
401
402
|
r = subject.datagrid_row(grid, entry)
|
402
|
-
r.name.
|
403
|
-
r.category.
|
403
|
+
expect(r.name).to eq("Hello")
|
404
|
+
expect(r.category).to eq("greetings")
|
404
405
|
end
|
405
406
|
it "should yield block" do
|
406
407
|
subject.datagrid_row(grid, entry) do |row|
|
407
|
-
row.name.
|
408
|
-
row.category.
|
408
|
+
expect(row.name).to eq("Hello")
|
409
|
+
expect(row.category).to eq("greetings")
|
409
410
|
end
|
410
411
|
end
|
411
412
|
|
@@ -415,7 +416,7 @@ describe Datagrid::Helper do
|
|
415
416
|
subject.concat(",")
|
416
417
|
subject.concat(row.category)
|
417
418
|
end
|
418
|
-
name.
|
419
|
+
expect(name).to eq("Hello,greetings")
|
419
420
|
end
|
420
421
|
end
|
421
422
|
end
|
@@ -428,7 +429,7 @@ describe Datagrid::Helper do
|
|
428
429
|
"<b>#{e.name}</b>"
|
429
430
|
end
|
430
431
|
end
|
431
|
-
subject.datagrid_value(report, :name, entry).
|
432
|
+
expect(subject.datagrid_value(report, :name, entry)).to eq("<b>Star</b>")
|
432
433
|
end
|
433
434
|
it "should support format in column" do
|
434
435
|
report = test_report do
|
@@ -439,7 +440,7 @@ describe Datagrid::Helper do
|
|
439
440
|
end
|
440
441
|
end
|
441
442
|
end
|
442
|
-
subject.datagrid_value(report, :name, entry).
|
443
|
+
expect(subject.datagrid_value(report, :name, entry)).to eq("<a href=\"/profile\">Star</a>")
|
443
444
|
end
|
444
445
|
end
|
445
446
|
end
|