datagrid 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -6
  3. data/VERSION +1 -1
  4. data/app/views/datagrid/_form.html.erb +3 -1
  5. data/datagrid.gemspec +6 -6
  6. data/lib/datagrid.rb +1 -0
  7. data/lib/datagrid/columns.rb +14 -7
  8. data/lib/datagrid/columns/column.rb +7 -4
  9. data/lib/datagrid/renderer.rb +1 -1
  10. data/spec/datagrid/active_model_spec.rb +4 -4
  11. data/spec/datagrid/column_names_attribute_spec.rb +15 -11
  12. data/spec/datagrid/columns_spec.rb +80 -62
  13. data/spec/datagrid/core_spec.rb +6 -6
  14. data/spec/datagrid/drivers/active_record_spec.rb +4 -4
  15. data/spec/datagrid/drivers/array_spec.rb +41 -8
  16. data/spec/datagrid/drivers/mongo_mapper_spec.rb +42 -10
  17. data/spec/datagrid/drivers/mongoid_spec.rb +43 -11
  18. data/spec/datagrid/filters/composite_filters_spec.rb +12 -12
  19. data/spec/datagrid/filters/date_filter_spec.rb +25 -25
  20. data/spec/datagrid/filters/date_time_filter_spec.rb +20 -20
  21. data/spec/datagrid/filters/dynamic_filter_spec.rb +43 -43
  22. data/spec/datagrid/filters/enum_filter_spec.rb +6 -6
  23. data/spec/datagrid/filters/extended_boolean_filter_spec.rb +10 -10
  24. data/spec/datagrid/filters/float_filter_spec.rb +2 -2
  25. data/spec/datagrid/filters/integer_filter_spec.rb +34 -34
  26. data/spec/datagrid/filters/string_filter_spec.rb +7 -7
  27. data/spec/datagrid/filters_spec.rb +20 -20
  28. data/spec/datagrid/form_builder_spec.rb +5 -5
  29. data/spec/datagrid/helper_spec.rb +41 -40
  30. data/spec/datagrid/ordering_spec.rb +22 -22
  31. data/spec/datagrid/scaffold_spec.rb +2 -2
  32. data/spec/datagrid/utils_spec.rb +3 -3
  33. data/spec/datagrid_spec.rb +10 -7
  34. data/spec/support/matchers.rb +6 -3
  35. metadata +30 -30
@@ -9,74 +9,74 @@ describe Datagrid::Ordering do
9
9
 
10
10
 
11
11
  it "should support order" do
12
- test_report(:order => "name") do
12
+ expect(test_report(:order => "name") do
13
13
  scope do
14
14
  Entry
15
15
  end
16
16
  column :name
17
- end.assets.should == [first, second, third]
17
+ end.assets).to eq([first, second, third])
18
18
 
19
19
  end
20
20
 
21
21
  it "should support desc order" do
22
- test_report(:order => "name", :descending => true) do
22
+ expect(test_report(:order => "name", :descending => true) do
23
23
  scope do
24
24
  Entry
25
25
  end
26
26
  column :name
27
- end.assets.should == [third, second, first]
27
+ end.assets).to eq([third, second, first])
28
28
  end
29
29
 
30
30
 
31
31
  it "should raise error if ordered by not existing column" do
32
- lambda {
32
+ expect {
33
33
  test_report(:order => :hello)
34
- }.should raise_error(Datagrid::OrderUnsupported)
34
+ }.to raise_error(Datagrid::OrderUnsupported)
35
35
  end
36
36
 
37
37
  it "should raise error if ordered by column without order" do
38
- lambda do
38
+ expect do
39
39
  test_report(:order => :category) do
40
40
  filter(:category, :default, :order => false) do |value|
41
41
  self
42
42
  end
43
43
  end
44
- end.should raise_error(Datagrid::OrderUnsupported)
44
+ end.to raise_error(Datagrid::OrderUnsupported)
45
45
  end
46
46
 
47
47
  it "should override default order" do
48
- test_report(:order => :name) do
48
+ expect(test_report(:order => :name) do
49
49
  scope { Entry.order("name desc")}
50
50
  column(:name, :order => "name asc")
51
- end.assets.should == [first, second, third]
51
+ end.assets).to eq([first, second, third])
52
52
  end
53
53
 
54
54
  it "should support order given as block" do
55
- test_report(:order => :name) do
55
+ expect(test_report(:order => :name) do
56
56
  scope { Entry }
57
57
  column(:name, :order => proc { order("name desc") })
58
- end.assets.should == [third, second, first]
58
+ end.assets).to eq([third, second, first])
59
59
  end
60
60
 
61
61
  it "should support reversing order given as block" do
62
- test_report(:order => :name, :descending => true) do
62
+ expect(test_report(:order => :name, :descending => true) do
63
63
  scope { Entry }
64
64
  column(:name, :order => proc { order("name desc") })
65
- end.assets.should == [first, second, third]
65
+ end.assets).to eq([first, second, third])
66
66
  end
67
67
 
68
68
  it "should support order desc given as block" do
69
- test_report(:order => :name, :descending => true) do
69
+ expect(test_report(:order => :name, :descending => true) do
70
70
  scope { Entry }
71
71
  column(:name, :order_desc => proc { order("name desc")})
72
- end.assets.should == [third, second, first]
72
+ end.assets).to eq([third, second, first])
73
73
  end
74
74
 
75
75
  it "should treat true order as default" do
76
- test_report(:order => :name) do
76
+ expect(test_report(:order => :name) do
77
77
  scope { Entry }
78
78
  column(:name, :order => true)
79
- end.assets.should == [first, second, third]
79
+ end.assets).to eq([first, second, third])
80
80
  end
81
81
 
82
82
  it "should support order_by_value" do
@@ -86,9 +86,9 @@ describe Datagrid::Ordering do
86
86
  name
87
87
  end
88
88
  end
89
- report.assets.should == [first, second, third]
89
+ expect(report.assets).to eq([first, second, third])
90
90
  report.descending = true
91
- report.assets.should == [third, second, first]
91
+ expect(report.assets).to eq([third, second, first])
92
92
  end
93
93
 
94
94
  it "should support order_by_value as block" do
@@ -101,9 +101,9 @@ describe Datagrid::Ordering do
101
101
  name
102
102
  end
103
103
  end
104
- report.assets.should == [third, first, second]
104
+ expect(report.assets).to eq([third, first, second])
105
105
  report.descending = true
106
- report.assets.should == [second, first, third]
106
+ expect(report.assets).to eq([second, first, third])
107
107
  end
108
108
 
109
109
  end
@@ -5,13 +5,13 @@ describe Datagrid::Scaffold do
5
5
 
6
6
  describe '.paginate_code' do
7
7
  it 'should fall through options successfully' do
8
- subject.paginate_code.should eql('paginate_somehow')
8
+ expect(subject.paginate_code).to eql('paginate_somehow')
9
9
  end
10
10
  end
11
11
 
12
12
  describe '.pagination_helper_code' do
13
13
  it 'should fall through options successfully' do
14
- subject.pagination_helper_code.should eql('some_pagination_helper(@assets)')
14
+ expect(subject.pagination_helper_code).to eql('some_pagination_helper(@assets)')
15
15
  end
16
16
  end
17
17
  end
@@ -6,13 +6,13 @@ describe Datagrid::Utils do
6
6
  describe ".warn_once" do
7
7
  it "should work" do
8
8
  silence_warnings do
9
- Datagrid::Utils.warn_once("hello", 0.2).should be_true
9
+ expect(Datagrid::Utils.warn_once("hello", 0.2)).to be_true
10
10
  end
11
11
  sleep(0.1)
12
- Datagrid::Utils.warn_once("hello", 0.2).should be_false
12
+ expect(Datagrid::Utils.warn_once("hello", 0.2)).to be_false
13
13
  sleep(0.2)
14
14
  silence_warnings do
15
- Datagrid::Utils.warn_once("hello", 0.2).should be_true
15
+ expect(Datagrid::Utils.warn_once("hello", 0.2)).to be_true
16
16
  end
17
17
  end
18
18
  end
@@ -22,12 +22,15 @@ describe SimpleReport do
22
22
  :group => group, :name => "Star", :disabled => false, :confirmed => false, :category => "first"
23
23
  ) }
24
24
 
25
- its(:assets) { should include(entry) }
25
+ describe '#assets' do
26
+ subject { super().assets }
27
+ it { should include(entry) }
28
+ end
26
29
 
27
30
  describe ".attributes" do
28
31
  it "should return report attributes" do
29
32
  (subject.filters.map(&:name) + [:order, :descending]).each do |attribute|
30
- subject.attributes.should have_key(attribute)
33
+ expect(subject.attributes).to have_key(attribute)
31
34
  end
32
35
  end
33
36
 
@@ -35,7 +38,7 @@ describe SimpleReport do
35
38
 
36
39
  describe ".scope" do
37
40
  it "should return defined scope of objects" do
38
- subject.scope.should respond_to(:each)
41
+ expect(subject.scope).to respond_to(:each)
39
42
  end
40
43
 
41
44
 
@@ -45,9 +48,9 @@ describe SimpleReport do
45
48
  end
46
49
 
47
50
  it "should raise ConfigurationError" do
48
- lambda {
51
+ expect {
49
52
  subject.scope
50
- }.should raise_error(Datagrid::ConfigurationError)
53
+ }.to raise_error(Datagrid::ConfigurationError)
51
54
 
52
55
  end
53
56
  end
@@ -56,7 +59,7 @@ describe SimpleReport do
56
59
  describe ".batch_size" do
57
60
  context "when not defined on class level" do
58
61
  it "returns nil" do
59
- subject.batch_size.should == nil
62
+ expect(subject.batch_size).to eq(nil)
60
63
  end
61
64
  end
62
65
 
@@ -68,7 +71,7 @@ describe SimpleReport do
68
71
  end
69
72
 
70
73
  it "returns the configured batch size" do
71
- subject.batch_size.should == 25
74
+ expect(subject.batch_size).to eq(25)
72
75
  end
73
76
  end
74
77
 
@@ -11,15 +11,18 @@ end
11
11
  class EqualToDom
12
12
 
13
13
  def initialize(expectation)
14
- @expectation = Nokogiri::HTML::DocumentFragment.parse(force_encoding(expectation).strip).to_s
14
+ @expectation = normalize(expectation)
15
15
  end
16
16
 
17
17
  def matches?(text)
18
-
19
- @matcher = Nokogiri::HTML::DocumentFragment.parse(force_encoding(text).strip).to_s
18
+ @matcher = normalize(text)
20
19
  @matcher == @expectation
21
20
  end
22
21
 
22
+ def normalize(text)
23
+ Nokogiri::HTML::DocumentFragment.parse(force_encoding(text.split("\n").map(&:strip).join(""))).to_s
24
+ end
25
+
23
26
  def failure_message
24
27
  "Expected dom \n#{@matcher}\n to match \n#{@expectation}\n, but it wasn't"
25
28
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datagrid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.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-05-10 00:00:00.000000000 Z
11
+ date: 2014-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jeweler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: debugger
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: ruby-debug
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
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
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: nokogiri
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - '>='
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: sqlite3-ruby
126
+ name: sqlite3
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - '>='
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
@@ -154,14 +154,14 @@ dependencies:
154
154
  name: mongo_mapper
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ">="
157
+ - - '>='
158
158
  - !ruby/object:Gem::Version
159
159
  version: 0.11.0
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ">="
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.11.0
167
167
  - !ruby/object:Gem::Dependency
@@ -196,14 +196,14 @@ dependencies:
196
196
  name: fastercsv
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ">="
199
+ - - '>='
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - '>='
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  description: This allows you to easily build datagrid aka data tables with sortable
@@ -214,9 +214,9 @@ extensions: []
214
214
  extra_rdoc_files:
215
215
  - LICENSE.txt
216
216
  files:
217
- - ".document"
218
- - ".rspec"
219
- - ".travis.yml"
217
+ - .document
218
+ - .rspec
219
+ - .travis.yml
220
220
  - Gemfile
221
221
  - LICENSE.txt
222
222
  - Rakefile
@@ -320,12 +320,12 @@ require_paths:
320
320
  - lib
321
321
  required_ruby_version: !ruby/object:Gem::Requirement
322
322
  requirements:
323
- - - ">="
323
+ - - '>='
324
324
  - !ruby/object:Gem::Version
325
325
  version: '0'
326
326
  required_rubygems_version: !ruby/object:Gem::Requirement
327
327
  requirements:
328
- - - ">="
328
+ - - '>='
329
329
  - !ruby/object:Gem::Version
330
330
  version: '0'
331
331
  requirements: []