ransack 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +16 -16
- data/CHANGELOG.md +21 -1
- data/CONTRIBUTING.md +4 -4
- data/README.md +4 -4
- data/docs/docs/getting-started/simple-mode.md +24 -24
- data/docs/docs/getting-started/sorting.md +1 -1
- data/docs/docs/going-further/acts-as-taggable-on.md +6 -6
- data/docs/docs/going-further/exporting-to-csv.md +2 -2
- data/docs/docs/intro.md +2 -2
- data/docs/docusaurus.config.js +14 -1
- data/docs/package.json +3 -2
- data/docs/yarn.lock +1311 -546
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/version.rb +1 -1
- data/spec/ransack/nodes/value_spec.rb +115 -0
- metadata +5 -3
data/lib/ransack/nodes/value.rb
CHANGED
data/lib/ransack/version.rb
CHANGED
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Ransack
|
4
|
+
module Nodes
|
5
|
+
describe Value do
|
6
|
+
let(:context) { Context.for(Person) }
|
7
|
+
|
8
|
+
subject do
|
9
|
+
Value.new(context, raw_value)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with a date value" do
|
13
|
+
let(:raw_value) { "2022-05-23" }
|
14
|
+
|
15
|
+
[:date].each do |type|
|
16
|
+
it "should cast #{type} correctly" do
|
17
|
+
result = subject.cast(type)
|
18
|
+
|
19
|
+
expect(result).to be_a_kind_of(Date)
|
20
|
+
expect(result).to eq(Date.parse(raw_value))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with a timestamp value" do
|
26
|
+
let(:raw_value) { "2022-05-23 10:40:02 -0400" }
|
27
|
+
|
28
|
+
[:datetime, :timestamp, :time, :timestamptz].each do |type|
|
29
|
+
it "should cast #{type} correctly" do
|
30
|
+
result = subject.cast(type)
|
31
|
+
|
32
|
+
expect(result).to be_a_kind_of(Time)
|
33
|
+
expect(result).to eq(Time.zone.parse(raw_value))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Constants::TRUE_VALUES.each do |value|
|
39
|
+
context "with a true boolean value (#{value})" do
|
40
|
+
let(:raw_value) { value.to_s }
|
41
|
+
|
42
|
+
it "should cast boolean correctly" do
|
43
|
+
result = subject.cast(:boolean)
|
44
|
+
expect(result).to eq(true)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
Constants::FALSE_VALUES.each do |value|
|
50
|
+
context "with a false boolean value (#{value})" do
|
51
|
+
let(:raw_value) { value.to_s }
|
52
|
+
|
53
|
+
it "should cast boolean correctly" do
|
54
|
+
result = subject.cast(:boolean)
|
55
|
+
|
56
|
+
expect(result).to eq(false)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
["12", "101.5"].each do |value|
|
62
|
+
context "with an integer value (#{value})" do
|
63
|
+
let(:raw_value) { value }
|
64
|
+
|
65
|
+
it "should cast #{value} to integer correctly" do
|
66
|
+
result = subject.cast(:integer)
|
67
|
+
|
68
|
+
expect(result).to be_an(Integer)
|
69
|
+
expect(result).to eq(value.to_i)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
["12", "101.5"].each do |value|
|
75
|
+
context "with a float value (#{value})" do
|
76
|
+
let(:raw_value) { value }
|
77
|
+
|
78
|
+
it "should cast #{value} to float correctly" do
|
79
|
+
result = subject.cast(:float)
|
80
|
+
|
81
|
+
expect(result).to be_an(Float)
|
82
|
+
expect(result).to eq(value.to_f)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
["12", "101.5"].each do |value|
|
88
|
+
context "with a decimal value (#{value})" do
|
89
|
+
let(:raw_value) { value }
|
90
|
+
|
91
|
+
it "should cast #{value} to decimal correctly" do
|
92
|
+
result = subject.cast(:decimal)
|
93
|
+
|
94
|
+
expect(result).to be_a(BigDecimal)
|
95
|
+
expect(result).to eq(value.to_d)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
["12", "101.513"].each do |value|
|
101
|
+
context "with a money value (#{value})" do
|
102
|
+
let(:raw_value) { value }
|
103
|
+
|
104
|
+
it "should cast #{value} to money correctly" do
|
105
|
+
result = subject.cast(:money)
|
106
|
+
|
107
|
+
expect(result).to be_a(String)
|
108
|
+
expect(result).to eq(value.to_f.to_s)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2022-05-
|
15
|
+
date: 2022-05-25 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: activerecord
|
@@ -230,6 +230,7 @@ files:
|
|
230
230
|
- spec/ransack/helpers/form_helper_spec.rb
|
231
231
|
- spec/ransack/nodes/condition_spec.rb
|
232
232
|
- spec/ransack/nodes/grouping_spec.rb
|
233
|
+
- spec/ransack/nodes/value_spec.rb
|
233
234
|
- spec/ransack/predicate_spec.rb
|
234
235
|
- spec/ransack/search_spec.rb
|
235
236
|
- spec/ransack/translate_spec.rb
|
@@ -255,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
256
|
- !ruby/object:Gem::Version
|
256
257
|
version: '0'
|
257
258
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
259
|
+
rubygems_version: 3.3.14
|
259
260
|
signing_key:
|
260
261
|
specification_version: 4
|
261
262
|
summary: Object-based searching for Active Record.
|
@@ -279,6 +280,7 @@ test_files:
|
|
279
280
|
- spec/ransack/helpers/form_helper_spec.rb
|
280
281
|
- spec/ransack/nodes/condition_spec.rb
|
281
282
|
- spec/ransack/nodes/grouping_spec.rb
|
283
|
+
- spec/ransack/nodes/value_spec.rb
|
282
284
|
- spec/ransack/predicate_spec.rb
|
283
285
|
- spec/ransack/search_spec.rb
|
284
286
|
- spec/ransack/translate_spec.rb
|