ransack 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +30 -0
- data/lib/polyamorous.rb +2 -1
- data/lib/ransack/adapters/active_record/base.rb +1 -0
- data/lib/ransack/locale/ar.yml +70 -0
- data/lib/ransack/locale/zh-CN.yml +12 -12
- data/lib/ransack/version.rb +1 -1
- data/spec/ransack/adapters/active_record/base_spec.rb +5 -5
- data/spec/ransack/helpers/form_helper_spec.rb +51 -51
- data/spec/support/schema.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2eab955e89328399bcb163a575725ea51969653edb1edd66773b6f60554fd12
|
4
|
+
data.tar.gz: 1e6d34f5d87238a18c7ae2194cd0d5320d9460b97b8d8c30ec79d82de6aa139a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52c4a46725d9bb474fbb229c39d9638c730d77bd53211f00f639b78690fcd72aaaa2418b56704c30024c36c39ca7cebde0e86b76cba13704a26f4416791ad141
|
7
|
+
data.tar.gz: bd6880992a977511ea37df47d0828e8ee1e855dff39e2620eaed89bc043ffde2960e3006ebcc0609c9738af10faea6947a1db1f91f1f3eebc65b631d97137054
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
##
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## Version 2.1.1 - 2018-12-05
|
6
|
+
|
7
|
+
* Add `arabic` translation
|
8
|
+
https://github.com/activerecord-hackery/ransack/pull/979
|
9
|
+
|
10
|
+
* Deprecate #search
|
11
|
+
PR [975](https://github.com/activerecord-hackery/ransack/pull/975)
|
12
|
+
|
13
|
+
## Version 2.1.0 - 2018-10-26
|
4
14
|
|
5
15
|
* Add support for sorting by scopes
|
6
16
|
PR [973](https://github.com/activerecord-hackery/ransack/pull/973)
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/activerecord-hackery/ransack.svg)](https://travis-ci.org/activerecord-hackery/ransack)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/ransack.svg)](http://badge.fury.io/rb/ransack)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/activerecord-hackery/ransack/badges/gpa.svg)](https://codeclimate.com/github/activerecord-hackery/ransack)
|
6
|
+
[![Backers on Open Collective](https://opencollective.com/ransack/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ransack/sponsors/badge.svg)](#sponsors)
|
6
7
|
|
7
8
|
Ransack is a rewrite of [MetaSearch](https://github.com/activerecord-hackery/meta_search)
|
8
9
|
created by [Ernie Miller](http://twitter.com/erniemiller)
|
@@ -933,3 +934,32 @@ directly related to bug reports, pull requests, or documentation improvements.
|
|
933
934
|
* Spread the word on Twitter, Facebook, and elsewhere if Ransack's been useful
|
934
935
|
to you. The more people who are using the project, the quicker we can find and
|
935
936
|
fix bugs!
|
937
|
+
|
938
|
+
## Contributors
|
939
|
+
|
940
|
+
This project exists thanks to all the people who contribute. <img src="https://opencollective.com/ransack/contributors.svg?width=890&button=false" />
|
941
|
+
|
942
|
+
|
943
|
+
## Backers
|
944
|
+
|
945
|
+
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/ransack#backer)]
|
946
|
+
|
947
|
+
<a href="https://opencollective.com/ransack#backers" target="_blank"><img src="https://opencollective.com/ransack/backers.svg?width=890"></a>
|
948
|
+
|
949
|
+
|
950
|
+
## Sponsors
|
951
|
+
|
952
|
+
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/ransack#sponsor)]
|
953
|
+
|
954
|
+
<a href="https://opencollective.com/ransack/sponsor/0/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/0/avatar.svg"></a>
|
955
|
+
<a href="https://opencollective.com/ransack/sponsor/1/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/1/avatar.svg"></a>
|
956
|
+
<a href="https://opencollective.com/ransack/sponsor/2/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/2/avatar.svg"></a>
|
957
|
+
<a href="https://opencollective.com/ransack/sponsor/3/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/3/avatar.svg"></a>
|
958
|
+
<a href="https://opencollective.com/ransack/sponsor/4/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/4/avatar.svg"></a>
|
959
|
+
<a href="https://opencollective.com/ransack/sponsor/5/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/5/avatar.svg"></a>
|
960
|
+
<a href="https://opencollective.com/ransack/sponsor/6/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/6/avatar.svg"></a>
|
961
|
+
<a href="https://opencollective.com/ransack/sponsor/7/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/7/avatar.svg"></a>
|
962
|
+
<a href="https://opencollective.com/ransack/sponsor/8/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/8/avatar.svg"></a>
|
963
|
+
<a href="https://opencollective.com/ransack/sponsor/9/website" target="_blank"><img src="https://opencollective.com/ransack/sponsor/9/avatar.svg"></a>
|
964
|
+
|
965
|
+
|
data/lib/polyamorous.rb
CHANGED
@@ -12,7 +12,8 @@ if defined?(::ActiveRecord)
|
|
12
12
|
require 'polyamorous/swapping_reflection_class'
|
13
13
|
|
14
14
|
ar_version = ::ActiveRecord::VERSION::STRING[0,3]
|
15
|
-
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >=
|
15
|
+
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= "5.2"
|
16
|
+
ar_version = "5.2.1" if ::ActiveRecord::VERSION::STRING >= "5.2.1"
|
16
17
|
|
17
18
|
%w(join_association join_dependency).each do |file|
|
18
19
|
require "polyamorous/activerecord_#{ar_version}_ruby_2/#{file}"
|
@@ -0,0 +1,70 @@
|
|
1
|
+
ar:
|
2
|
+
ransack:
|
3
|
+
search: "بحث"
|
4
|
+
predicate: "فاعل"
|
5
|
+
and: "و"
|
6
|
+
or: "أو"
|
7
|
+
any: "أيُّ"
|
8
|
+
all: "كل"
|
9
|
+
combinator: "دالة توافقية"
|
10
|
+
attribute: "خاصية"
|
11
|
+
value: "قيمة"
|
12
|
+
condition: "شرط"
|
13
|
+
sort: "ترتيب"
|
14
|
+
asc: "تصاعدي"
|
15
|
+
desc: "تنازلي"
|
16
|
+
predicates:
|
17
|
+
eq: "معادل"
|
18
|
+
eq_any: "معادل على اﻷقل لواحد"
|
19
|
+
eq_all: "معادل للجميع"
|
20
|
+
not_eq: "ليس معادلا لـ"
|
21
|
+
not_eq_any: "ليس معادلا على اﻷقل لواحد"
|
22
|
+
not_eq_all: "ليس معادلا للجميع"
|
23
|
+
matches: "موائم"
|
24
|
+
matches_any: "موائم لواحد على اﻷقل"
|
25
|
+
matches_all: "موائم للجميع"
|
26
|
+
does_not_match: "لا يتواءم"
|
27
|
+
does_not_match_any: "لا يتواءم مع واحد على اﻷقل"
|
28
|
+
does_not_match_all: "لا يتواءم مع الجميع"
|
29
|
+
lt: "أصغر من"
|
30
|
+
lt_any: "أصغر لواحد على اﻷقل"
|
31
|
+
lt_all: "أصغر من الجميع"
|
32
|
+
lteq: "أصغر أو مساو لـ"
|
33
|
+
lteq_any: "أصغر أو مساو لواحد على اﻷقل"
|
34
|
+
lteq_all: "أصغر أو مساو للجميع"
|
35
|
+
gt: "أكبر من"
|
36
|
+
gt_any: "أكبر من واحد على اﻷقل"
|
37
|
+
gt_all: "أكبر من الجميع"
|
38
|
+
gteq: "أكبر أو مساو لـ"
|
39
|
+
gteq_any: "أكبر أو مساو لواحد على اﻷقل"
|
40
|
+
gteq_all: "أكبر أو مساو للجميع"
|
41
|
+
in: "متضمن لـ"
|
42
|
+
in_any: "متضمن لواحد على اﻷقل"
|
43
|
+
in_all: "متضمن للجميع"
|
44
|
+
not_in: "غير متضمن"
|
45
|
+
not_in_any: "غير متضمن لواحد على اﻷقل"
|
46
|
+
not_in_all: "غير متضمن للجميع"
|
47
|
+
cont: "محتو"
|
48
|
+
cont_any: "محتو لواحد على اﻷقل"
|
49
|
+
cont_all: "محتو لجميع"
|
50
|
+
not_cont: "غير محتو"
|
51
|
+
not_cont_any: "غير محتو لواحد على اﻷقل"
|
52
|
+
not_cont_all: "غير محتو للجميع"
|
53
|
+
start: "يبدأ بـ"
|
54
|
+
start_any: "يبدأ بواحد على اﻷقل"
|
55
|
+
start_all: "يبدأ بالجميع"
|
56
|
+
not_start: "لا يبدأ بـ"
|
57
|
+
not_start_any: "لا يبدأ بواحد على اﻷقل"
|
58
|
+
not_start_all: "لا يبدأ بالجميع"
|
59
|
+
end: "ينتهي بـ"
|
60
|
+
end_any: "ينتهي بواحد على اﻷقل"
|
61
|
+
end_all: "ينتهي بالجميع"
|
62
|
+
not_end: "لا ينتهي بـ"
|
63
|
+
not_end_any: "لا ينتهي بواحد على اﻷقل"
|
64
|
+
not_end_all: "لا ينتهي بالجميع"
|
65
|
+
'true': "صحيح"
|
66
|
+
'false': "خطأ"
|
67
|
+
present: "مستقبل"
|
68
|
+
blank: "فراغ"
|
69
|
+
'null': "عدم"
|
70
|
+
not_null: "غير مساو لقيمة عدم"
|
@@ -50,18 +50,18 @@ zh-CN:
|
|
50
50
|
not_cont: "不包含"
|
51
51
|
not_cont_any: "不包含任意一个值"
|
52
52
|
not_cont_all: "不包含所有值"
|
53
|
-
start: "
|
54
|
-
start_any: "
|
55
|
-
start_all: "
|
56
|
-
not_start: "
|
57
|
-
not_start_any: "
|
58
|
-
not_start_all: "
|
59
|
-
end: "
|
60
|
-
end_any: "
|
61
|
-
end_all: "
|
62
|
-
not_end: "
|
63
|
-
not_end_any: "
|
64
|
-
not_end_all: "
|
53
|
+
start: "始于"
|
54
|
+
start_any: "始于任一值"
|
55
|
+
start_all: "始于任意值"
|
56
|
+
not_start: "非始于"
|
57
|
+
not_start_any: "非始于任一值"
|
58
|
+
not_start_all: "非始于任意值"
|
59
|
+
end: "止于"
|
60
|
+
end_any: "止于任一值"
|
61
|
+
end_all: "止于任意值"
|
62
|
+
not_end: "非止于"
|
63
|
+
not_end_any: "非止于任一值"
|
64
|
+
not_end_all: "非止于任意值"
|
65
65
|
'true': "等于true"
|
66
66
|
'false': "等于false"
|
67
67
|
present: "有值"
|
data/lib/ransack/version.rb
CHANGED
@@ -584,31 +584,31 @@ module Ransack
|
|
584
584
|
|
585
585
|
context 'case insensitive sorting' do
|
586
586
|
it 'allows sort by desc' do
|
587
|
-
search = Person.
|
587
|
+
search = Person.ransack(sorts: ['name_case_insensitive desc'])
|
588
588
|
expect(search.result.to_sql).to match /ORDER BY LOWER(.*) DESC/
|
589
589
|
end
|
590
590
|
|
591
591
|
it 'allows sort by asc' do
|
592
|
-
search = Person.
|
592
|
+
search = Person.ransack(sorts: ['name_case_insensitive asc'])
|
593
593
|
expect(search.result.to_sql).to match /ORDER BY LOWER(.*) ASC/
|
594
594
|
end
|
595
595
|
end
|
596
596
|
|
597
597
|
context 'regular sorting' do
|
598
598
|
it 'allows sort by desc' do
|
599
|
-
search = Person.
|
599
|
+
search = Person.ransack(sorts: ['name desc'])
|
600
600
|
expect(search.result.to_sql).to match /ORDER BY .* DESC/
|
601
601
|
end
|
602
602
|
|
603
603
|
it 'allows sort by asc' do
|
604
|
-
search = Person.
|
604
|
+
search = Person.ransack(sorts: ['name asc'])
|
605
605
|
expect(search.result.to_sql).to match /ORDER BY .* ASC/
|
606
606
|
end
|
607
607
|
end
|
608
608
|
|
609
609
|
context 'sorting by a scope' do
|
610
610
|
it 'applies the correct scope' do
|
611
|
-
search = Person.
|
611
|
+
search = Person.ransack(sorts: ['reverse_name asc'])
|
612
612
|
expect(search.result.to_sql).to include("ORDER BY REVERSE(name) ASC")
|
613
613
|
end
|
614
614
|
end
|
@@ -25,7 +25,7 @@ module Ransack
|
|
25
25
|
describe '#sort_link with default search_key' do
|
26
26
|
subject { @controller.view_context
|
27
27
|
.sort_link(
|
28
|
-
[:main_app, Person.
|
28
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
29
29
|
:name,
|
30
30
|
controller: 'people'
|
31
31
|
)
|
@@ -38,7 +38,7 @@ module Ransack
|
|
38
38
|
describe '#sort_url with default search_key' do
|
39
39
|
subject { @controller.view_context
|
40
40
|
.sort_url(
|
41
|
-
[:main_app, Person.
|
41
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
42
42
|
:name,
|
43
43
|
controller: 'people'
|
44
44
|
)
|
@@ -49,7 +49,7 @@ module Ransack
|
|
49
49
|
describe '#sort_link with default search_key defined as symbol' do
|
50
50
|
subject { @controller.view_context
|
51
51
|
.sort_link(
|
52
|
-
Person.
|
52
|
+
Person.ransack({ sorts: ['name desc'] }, search_key: :people_search),
|
53
53
|
:name, controller: 'people'
|
54
54
|
)
|
55
55
|
}
|
@@ -59,7 +59,7 @@ module Ransack
|
|
59
59
|
describe '#sort_url with default search_key defined as symbol' do
|
60
60
|
subject { @controller.view_context
|
61
61
|
.sort_url(
|
62
|
-
Person.
|
62
|
+
Person.ransack({ sorts: ['name desc'] }, search_key: :people_search),
|
63
63
|
:name, controller: 'people'
|
64
64
|
)
|
65
65
|
}
|
@@ -69,7 +69,7 @@ module Ransack
|
|
69
69
|
describe '#sort_link desc through association table defined as symbol' do
|
70
70
|
subject { @controller.view_context
|
71
71
|
.sort_link(
|
72
|
-
Person.
|
72
|
+
Person.ransack({ sorts: 'comments_body asc' }),
|
73
73
|
:comments_body,
|
74
74
|
controller: 'people'
|
75
75
|
)
|
@@ -82,7 +82,7 @@ module Ransack
|
|
82
82
|
describe '#sort_url desc through association table defined as symbol' do
|
83
83
|
subject { @controller.view_context
|
84
84
|
.sort_url(
|
85
|
-
Person.
|
85
|
+
Person.ransack({ sorts: 'comments_body asc' }),
|
86
86
|
:comments_body,
|
87
87
|
controller: 'people'
|
88
88
|
)
|
@@ -93,7 +93,7 @@ module Ransack
|
|
93
93
|
describe '#sort_link through association table defined as a string' do
|
94
94
|
subject { @controller.view_context
|
95
95
|
.sort_link(
|
96
|
-
Person.
|
96
|
+
Person.ransack({ sorts: 'comments.body desc' }),
|
97
97
|
'comments.body',
|
98
98
|
controller: 'people'
|
99
99
|
)
|
@@ -106,7 +106,7 @@ module Ransack
|
|
106
106
|
describe '#sort_url through association table defined as a string' do
|
107
107
|
subject { @controller.view_context
|
108
108
|
.sort_url(
|
109
|
-
Person.
|
109
|
+
Person.ransack({ sorts: 'comments.body desc' }),
|
110
110
|
'comments.body',
|
111
111
|
controller: 'people'
|
112
112
|
)
|
@@ -119,7 +119,7 @@ module Ransack
|
|
119
119
|
specify {
|
120
120
|
expect { @controller.view_context
|
121
121
|
.sort_link(
|
122
|
-
Person.
|
122
|
+
Person.ransack(@controller.view_context.params[:q]),
|
123
123
|
:name,
|
124
124
|
controller: 'people'
|
125
125
|
)
|
@@ -132,7 +132,7 @@ module Ransack
|
|
132
132
|
specify {
|
133
133
|
expect { @controller.view_context
|
134
134
|
.sort_url(
|
135
|
-
Person.
|
135
|
+
Person.ransack(@controller.view_context.params[:q]),
|
136
136
|
:name,
|
137
137
|
controller: 'people'
|
138
138
|
)
|
@@ -143,7 +143,7 @@ module Ransack
|
|
143
143
|
describe '#sort_link with search_key defined as a string' do
|
144
144
|
subject { @controller.view_context
|
145
145
|
.sort_link(
|
146
|
-
Person.
|
146
|
+
Person.ransack(
|
147
147
|
{ sorts: ['name desc'] }, search_key: 'people_search'
|
148
148
|
),
|
149
149
|
:name,
|
@@ -156,7 +156,7 @@ module Ransack
|
|
156
156
|
describe '#sort_link with default_order defined with a string key' do
|
157
157
|
subject { @controller.view_context
|
158
158
|
.sort_link(
|
159
|
-
[:main_app, Person.
|
159
|
+
[:main_app, Person.ransack()],
|
160
160
|
:name,
|
161
161
|
controller: 'people',
|
162
162
|
default_order: 'desc'
|
@@ -168,7 +168,7 @@ module Ransack
|
|
168
168
|
describe '#sort_url with default_order defined with a string key' do
|
169
169
|
subject { @controller.view_context
|
170
170
|
.sort_url(
|
171
|
-
[:main_app, Person.
|
171
|
+
[:main_app, Person.ransack()],
|
172
172
|
:name,
|
173
173
|
controller: 'people',
|
174
174
|
default_order: 'desc'
|
@@ -180,7 +180,7 @@ module Ransack
|
|
180
180
|
describe '#sort_link with multiple search_keys defined as an array' do
|
181
181
|
subject { @controller.view_context
|
182
182
|
.sort_link(
|
183
|
-
[:main_app, Person.
|
183
|
+
[:main_app, Person.ransack(sorts: ['name desc', 'email asc'])],
|
184
184
|
:name, [:name, 'email DESC'],
|
185
185
|
controller: 'people'
|
186
186
|
)
|
@@ -196,7 +196,7 @@ module Ransack
|
|
196
196
|
describe '#sort_url with multiple search_keys defined as an array' do
|
197
197
|
subject { @controller.view_context
|
198
198
|
.sort_url(
|
199
|
-
[:main_app, Person.
|
199
|
+
[:main_app, Person.ransack(sorts: ['name desc', 'email asc'])],
|
200
200
|
:name, [:name, 'email DESC'],
|
201
201
|
controller: 'people'
|
202
202
|
)
|
@@ -210,7 +210,7 @@ module Ransack
|
|
210
210
|
describe '#sort_link with multiple search_keys does not break on nil values & ignores them' do
|
211
211
|
subject { @controller.view_context
|
212
212
|
.sort_link(
|
213
|
-
[:main_app, Person.
|
213
|
+
[:main_app, Person.ransack(sorts: ['name desc', nil, 'email', nil])],
|
214
214
|
:name, [nil, :name, nil, 'email DESC', nil],
|
215
215
|
controller: 'people'
|
216
216
|
)
|
@@ -226,7 +226,7 @@ module Ransack
|
|
226
226
|
describe '#sort_url with multiple search_keys does not break on nil values & ignores them' do
|
227
227
|
subject { @controller.view_context
|
228
228
|
.sort_url(
|
229
|
-
[:main_app, Person.
|
229
|
+
[:main_app, Person.ransack(sorts: ['name desc', nil, 'email', nil])],
|
230
230
|
:name, [nil, :name, nil, 'email DESC', nil],
|
231
231
|
controller: 'people'
|
232
232
|
)
|
@@ -240,7 +240,7 @@ module Ransack
|
|
240
240
|
describe '#sort_link with multiple search_keys should allow a label to be specified' do
|
241
241
|
subject { @controller.view_context
|
242
242
|
.sort_link(
|
243
|
-
[:main_app, Person.
|
243
|
+
[:main_app, Person.ransack(sorts: ['name desc', 'email asc'])],
|
244
244
|
:name, [:name, 'email DESC'],
|
245
245
|
'Property Name',
|
246
246
|
controller: 'people'
|
@@ -252,7 +252,7 @@ module Ransack
|
|
252
252
|
describe '#sort_link with multiple search_keys should flip multiple fields specified without a direction' do
|
253
253
|
subject { @controller.view_context
|
254
254
|
.sort_link(
|
255
|
-
[:main_app, Person.
|
255
|
+
[:main_app, Person.ransack(sorts: ['name desc', 'email asc'])],
|
256
256
|
:name, [:name, :email],
|
257
257
|
controller: 'people'
|
258
258
|
)
|
@@ -268,7 +268,7 @@ module Ransack
|
|
268
268
|
describe '#sort_url with multiple search_keys should flip multiple fields specified without a direction' do
|
269
269
|
subject { @controller.view_context
|
270
270
|
.sort_url(
|
271
|
-
[:main_app, Person.
|
271
|
+
[:main_app, Person.ransack(sorts: ['name desc', 'email asc'])],
|
272
272
|
:name, [:name, :email],
|
273
273
|
controller: 'people'
|
274
274
|
)
|
@@ -282,7 +282,7 @@ module Ransack
|
|
282
282
|
describe '#sort_link with multiple search_keys and default_order specified as a string' do
|
283
283
|
subject { @controller.view_context
|
284
284
|
.sort_link(
|
285
|
-
[:main_app, Person.
|
285
|
+
[:main_app, Person.ransack()],
|
286
286
|
:name, [:name, :email],
|
287
287
|
controller: 'people',
|
288
288
|
default_order: 'desc'
|
@@ -299,7 +299,7 @@ module Ransack
|
|
299
299
|
describe '#sort_url with multiple search_keys and default_order specified as a string' do
|
300
300
|
subject { @controller.view_context
|
301
301
|
.sort_url(
|
302
|
-
[:main_app, Person.
|
302
|
+
[:main_app, Person.ransack()],
|
303
303
|
:name, [:name, :email],
|
304
304
|
controller: 'people',
|
305
305
|
default_order: 'desc'
|
@@ -314,7 +314,7 @@ module Ransack
|
|
314
314
|
describe '#sort_link with multiple search_keys and default_order specified as a symbol' do
|
315
315
|
subject { @controller.view_context
|
316
316
|
.sort_link(
|
317
|
-
[:main_app, Person.
|
317
|
+
[:main_app, Person.ransack()],
|
318
318
|
:name, [:name, :email],
|
319
319
|
controller: 'people',
|
320
320
|
default_order: :desc
|
@@ -331,7 +331,7 @@ module Ransack
|
|
331
331
|
describe '#sort_url with multiple search_keys and default_order specified as a symbol' do
|
332
332
|
subject { @controller.view_context
|
333
333
|
.sort_url(
|
334
|
-
[:main_app, Person.
|
334
|
+
[:main_app, Person.ransack],
|
335
335
|
:name, [:name, :email],
|
336
336
|
controller: 'people',
|
337
337
|
default_order: :desc
|
@@ -346,7 +346,7 @@ module Ransack
|
|
346
346
|
describe '#sort_link with multiple search_keys should allow multiple default_orders to be specified' do
|
347
347
|
subject { @controller.view_context
|
348
348
|
.sort_link(
|
349
|
-
[:main_app, Person.
|
349
|
+
[:main_app, Person.ransack],
|
350
350
|
:name, [:name, :email],
|
351
351
|
controller: 'people',
|
352
352
|
default_order: { name: 'desc', email: 'asc' }
|
@@ -363,7 +363,7 @@ module Ransack
|
|
363
363
|
describe '#sort_url with multiple search_keys should allow multiple default_orders to be specified' do
|
364
364
|
subject { @controller.view_context
|
365
365
|
.sort_url(
|
366
|
-
[:main_app, Person.
|
366
|
+
[:main_app, Person.ransack],
|
367
367
|
:name, [:name, :email],
|
368
368
|
controller: 'people',
|
369
369
|
default_order: { name: 'desc', email: 'asc' }
|
@@ -378,7 +378,7 @@ module Ransack
|
|
378
378
|
describe '#sort_link with multiple search_keys with multiple default_orders should not override a specified order' do
|
379
379
|
subject { @controller.view_context
|
380
380
|
.sort_link(
|
381
|
-
[:main_app, Person.
|
381
|
+
[:main_app, Person.ransack],
|
382
382
|
:name, [:name, 'email desc'],
|
383
383
|
controller: 'people',
|
384
384
|
default_order: { name: 'desc', email: 'asc' }
|
@@ -395,7 +395,7 @@ module Ransack
|
|
395
395
|
describe '#sort_url with multiple search_keys with multiple default_orders should not override a specified order' do
|
396
396
|
subject { @controller.view_context
|
397
397
|
.sort_url(
|
398
|
-
[:main_app, Person.
|
398
|
+
[:main_app, Person.ransack],
|
399
399
|
:name, [:name, 'email desc'],
|
400
400
|
controller: 'people',
|
401
401
|
default_order: { name: 'desc', email: 'asc' }
|
@@ -410,7 +410,7 @@ module Ransack
|
|
410
410
|
describe "#sort_link on polymorphic association should preserve association model name case" do
|
411
411
|
subject { @controller.view_context
|
412
412
|
.sort_link(
|
413
|
-
[:main_app, Note.
|
413
|
+
[:main_app, Note.ransack],
|
414
414
|
:notable_of_Person_type_name, "Notable",
|
415
415
|
controller: 'notes'
|
416
416
|
)
|
@@ -423,7 +423,7 @@ module Ransack
|
|
423
423
|
describe "#sort_url on polymorphic association should preserve association model name case" do
|
424
424
|
subject { @controller.view_context
|
425
425
|
.sort_link(
|
426
|
-
[:main_app, Note.
|
426
|
+
[:main_app, Note.ransack],
|
427
427
|
:notable_of_Person_type_name, "Notable",
|
428
428
|
controller: 'notes'
|
429
429
|
)
|
@@ -439,7 +439,7 @@ module Ransack
|
|
439
439
|
|
440
440
|
subject {
|
441
441
|
@controller.view_context.sort_link(
|
442
|
-
Person.
|
442
|
+
Person.ransack(
|
443
443
|
{ sorts: ['name desc'] },
|
444
444
|
search_key: 'people_search'
|
445
445
|
),
|
@@ -457,7 +457,7 @@ module Ransack
|
|
457
457
|
|
458
458
|
subject {
|
459
459
|
@controller.view_context.sort_url(
|
460
|
-
Person.
|
460
|
+
Person.ransack(
|
461
461
|
{ sorts: ['name desc'] },
|
462
462
|
search_key: 'people_search'
|
463
463
|
),
|
@@ -473,7 +473,7 @@ module Ransack
|
|
473
473
|
if: ::ActiveRecord::VERSION::MAJOR > 3 do
|
474
474
|
|
475
475
|
describe 'with symbol q:, #sort_link should include search params' do
|
476
|
-
subject { @controller.view_context.sort_link(Person.
|
476
|
+
subject { @controller.view_context.sort_link(Person.ransack, :name) }
|
477
477
|
let(:params) { ActionController::Parameters.new(
|
478
478
|
{ :q => { name_eq: 'TEST' }, controller: 'people' }
|
479
479
|
) }
|
@@ -488,7 +488,7 @@ module Ransack
|
|
488
488
|
end
|
489
489
|
|
490
490
|
describe 'with symbol q:, #sort_url should include search params' do
|
491
|
-
subject { @controller.view_context.sort_url(Person.
|
491
|
+
subject { @controller.view_context.sort_url(Person.ransack, :name) }
|
492
492
|
let(:params) { ActionController::Parameters.new(
|
493
493
|
{ :q => { name_eq: 'TEST' }, controller: 'people' }
|
494
494
|
) }
|
@@ -503,7 +503,7 @@ module Ransack
|
|
503
503
|
end
|
504
504
|
|
505
505
|
describe "with string 'q', #sort_link should include search params" do
|
506
|
-
subject { @controller.view_context.sort_link(Person.
|
506
|
+
subject { @controller.view_context.sort_link(Person.ransack, :name) }
|
507
507
|
let(:params) {
|
508
508
|
ActionController::Parameters.new(
|
509
509
|
{ 'q' => { name_eq: 'Test2' }, controller: 'people' }
|
@@ -519,7 +519,7 @@ module Ransack
|
|
519
519
|
end
|
520
520
|
|
521
521
|
describe "with string 'q', #sort_url should include search params" do
|
522
|
-
subject { @controller.view_context.sort_url(Person.
|
522
|
+
subject { @controller.view_context.sort_url(Person.ransack, :name) }
|
523
523
|
let(:params) {
|
524
524
|
ActionController::Parameters.new(
|
525
525
|
{ 'q' => { name_eq: 'Test2' }, controller: 'people' }
|
@@ -539,7 +539,7 @@ module Ransack
|
|
539
539
|
describe '#sort_link with hide order indicator set to true' do
|
540
540
|
subject { @controller.view_context
|
541
541
|
.sort_link(
|
542
|
-
[:main_app, Person.
|
542
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
543
543
|
:name,
|
544
544
|
controller: 'people',
|
545
545
|
hide_indicator: true
|
@@ -552,7 +552,7 @@ module Ransack
|
|
552
552
|
describe '#sort_link with hide order indicator set to false' do
|
553
553
|
subject { @controller.view_context
|
554
554
|
.sort_link(
|
555
|
-
[:main_app, Person.
|
555
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
556
556
|
:name,
|
557
557
|
controller: 'people',
|
558
558
|
hide_indicator: false
|
@@ -572,7 +572,7 @@ module Ransack
|
|
572
572
|
|
573
573
|
subject { @controller.view_context
|
574
574
|
.sort_link(
|
575
|
-
[:main_app, Person.
|
575
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
576
576
|
:name,
|
577
577
|
controller: 'people',
|
578
578
|
hide_indicator: false
|
@@ -593,7 +593,7 @@ module Ransack
|
|
593
593
|
|
594
594
|
subject { @controller.view_context
|
595
595
|
.sort_link(
|
596
|
-
[:main_app, Person.
|
596
|
+
[:main_app, Person.ransack(sorts: ['name asc'])],
|
597
597
|
:name,
|
598
598
|
controller: 'people',
|
599
599
|
hide_indicator: false
|
@@ -614,7 +614,7 @@ module Ransack
|
|
614
614
|
|
615
615
|
subject { @controller.view_context
|
616
616
|
.sort_link(
|
617
|
-
[:main_app, Person.
|
617
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
618
618
|
:name,
|
619
619
|
controller: 'people'
|
620
620
|
)
|
@@ -630,7 +630,7 @@ module Ransack
|
|
630
630
|
|
631
631
|
subject { @controller.view_context
|
632
632
|
.sort_link(
|
633
|
-
[:main_app, Person.
|
633
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
634
634
|
:name,
|
635
635
|
controller: 'people'
|
636
636
|
)
|
@@ -655,7 +655,7 @@ module Ransack
|
|
655
655
|
|
656
656
|
subject { @controller.view_context
|
657
657
|
.sort_link(
|
658
|
-
[:main_app, Person.
|
658
|
+
[:main_app, Person.ransack],
|
659
659
|
:name,
|
660
660
|
controller: 'people'
|
661
661
|
)
|
@@ -681,7 +681,7 @@ module Ransack
|
|
681
681
|
|
682
682
|
subject { @controller.view_context
|
683
683
|
.sort_link(
|
684
|
-
[:main_app, Person.
|
684
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
685
685
|
:name,
|
686
686
|
controller: 'people'
|
687
687
|
)
|
@@ -707,7 +707,7 @@ module Ransack
|
|
707
707
|
|
708
708
|
subject { @controller.view_context
|
709
709
|
.sort_link(
|
710
|
-
[:main_app, Person.
|
710
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
711
711
|
:name,
|
712
712
|
controller: 'people'
|
713
713
|
)
|
@@ -719,7 +719,7 @@ module Ransack
|
|
719
719
|
describe '#sort_link with a block' do
|
720
720
|
subject { @controller.view_context
|
721
721
|
.sort_link(
|
722
|
-
[:main_app, Person.
|
722
|
+
[:main_app, Person.ransack(sorts: ['name desc'])],
|
723
723
|
:name,
|
724
724
|
controller: 'people'
|
725
725
|
) { 'Block label' }
|
@@ -729,14 +729,14 @@ module Ransack
|
|
729
729
|
|
730
730
|
describe '#search_form_for with default format' do
|
731
731
|
subject { @controller.view_context
|
732
|
-
.search_form_for(Person.
|
732
|
+
.search_form_for(Person.ransack) {} }
|
733
733
|
it { should match /action="\/people"/ }
|
734
734
|
end
|
735
735
|
|
736
736
|
describe '#search_form_for with pdf format' do
|
737
737
|
subject {
|
738
738
|
@controller.view_context
|
739
|
-
.search_form_for(Person.
|
739
|
+
.search_form_for(Person.ransack, format: :pdf) {}
|
740
740
|
}
|
741
741
|
it { should match /action="\/people.pdf"/ }
|
742
742
|
end
|
@@ -744,7 +744,7 @@ module Ransack
|
|
744
744
|
describe '#search_form_for with json format' do
|
745
745
|
subject {
|
746
746
|
@controller.view_context
|
747
|
-
.search_form_for(Person.
|
747
|
+
.search_form_for(Person.ransack, format: :json) {}
|
748
748
|
}
|
749
749
|
it { should match /action="\/people.json"/ }
|
750
750
|
end
|
@@ -752,7 +752,7 @@ module Ransack
|
|
752
752
|
describe '#search_form_for with an array of routes' do
|
753
753
|
subject {
|
754
754
|
@controller.view_context
|
755
|
-
.search_form_for([:admin, Comment.
|
755
|
+
.search_form_for([:admin, Comment.ransack]) {}
|
756
756
|
}
|
757
757
|
it { should match /action="\/admin\/comments"/ }
|
758
758
|
end
|
@@ -763,7 +763,7 @@ module Ransack
|
|
763
763
|
end
|
764
764
|
subject {
|
765
765
|
@controller.view_context
|
766
|
-
.search_form_for(Person.
|
766
|
+
.search_form_for(Person.ransack) { |f| f.text_field :name_eq }
|
767
767
|
}
|
768
768
|
it { should match /example_name_eq/ }
|
769
769
|
end
|
data/spec/support/schema.rb
CHANGED
@@ -43,7 +43,7 @@ class Person < ActiveRecord::Base
|
|
43
43
|
of_age ? where("age >= ?", 18) : where("age < ?", 18)
|
44
44
|
}
|
45
45
|
|
46
|
-
scope :sort_by_reverse_name_asc, lambda { order("REVERSE(name) ASC") }
|
46
|
+
scope :sort_by_reverse_name_asc, lambda { order(Arel.sql("REVERSE(name) ASC")) }
|
47
47
|
scope :sort_by_reverse_name_desc, lambda { order("REVERSE(name) DESC") }
|
48
48
|
|
49
49
|
alias_attribute :full_name, :name
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Miller
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: actionpack
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/ransack/helpers.rb
|
215
215
|
- lib/ransack/helpers/form_builder.rb
|
216
216
|
- lib/ransack/helpers/form_helper.rb
|
217
|
+
- lib/ransack/locale/ar.yml
|
217
218
|
- lib/ransack/locale/az.yml
|
218
219
|
- lib/ransack/locale/bg.yml
|
219
220
|
- lib/ransack/locale/cs.yml
|