ransack 2.1.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +3 -0
- data/.github/SECURITY.md +12 -0
- data/.github/workflows/cronjob.yml +105 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.github/workflows/test.yml +154 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +44 -0
- data/CHANGELOG.md +55 -1
- data/CONTRIBUTING.md +13 -11
- data/Gemfile +23 -17
- data/README.md +119 -52
- data/bug_report_templates/test-ransack-scope-and-column-same-name.rb +78 -0
- data/bug_report_templates/test-ransacker-arel-present-predicate.rb +71 -0
- data/docs/img/create_release.png +0 -0
- data/docs/release_process.md +20 -0
- data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_association.rb +2 -9
- data/lib/polyamorous/{activerecord_5.2.1_ruby_2 → activerecord_5.2_ruby_2}/join_dependency.rb +25 -3
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +11 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +80 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +74 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +93 -0
- data/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/activerecord_6.2_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_6.2_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_6.2_ruby_2/reflection.rb +1 -0
- data/lib/{polyamorous.rb → polyamorous/polyamorous.rb} +4 -5
- data/lib/ransack.rb +3 -3
- data/lib/ransack/adapters/active_record/base.rb +4 -0
- data/lib/ransack/adapters/active_record/context.rb +67 -68
- data/lib/ransack/adapters/active_record/ransack/constants.rb +18 -3
- data/lib/ransack/adapters/active_record/ransack/context.rb +2 -6
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +12 -5
- data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -1
- data/lib/ransack/configuration.rb +17 -1
- data/lib/ransack/constants.rb +3 -5
- data/lib/ransack/context.rb +19 -18
- data/lib/ransack/helpers.rb +1 -1
- data/lib/ransack/helpers/form_builder.rb +8 -14
- data/lib/ransack/helpers/form_helper.rb +1 -1
- data/lib/ransack/locale/az.yml +1 -1
- data/lib/ransack/locale/ca.yml +70 -0
- data/lib/ransack/locale/es.yml +22 -22
- data/lib/ransack/locale/fa.yml +70 -0
- data/lib/ransack/locale/fi.yml +71 -0
- data/lib/ransack/locale/sk.yml +70 -0
- data/lib/ransack/nodes/attribute.rb +1 -1
- data/lib/ransack/nodes/condition.rb +7 -1
- data/lib/ransack/nodes/grouping.rb +1 -1
- data/lib/ransack/nodes/sort.rb +1 -1
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/predicate.rb +2 -1
- data/lib/ransack/search.rb +3 -1
- data/lib/ransack/translate.rb +115 -115
- data/lib/ransack/version.rb +1 -1
- data/ransack.gemspec +8 -23
- data/spec/blueprints/articles.rb +1 -1
- data/spec/blueprints/comments.rb +1 -1
- data/spec/blueprints/notes.rb +1 -1
- data/spec/blueprints/tags.rb +1 -1
- data/spec/console.rb +5 -5
- data/spec/helpers/polyamorous_helper.rb +3 -8
- data/spec/helpers/ransack_helper.rb +1 -1
- data/spec/{ransack → polyamorous}/join_association_spec.rb +7 -0
- data/spec/{ransack → polyamorous}/join_dependency_spec.rb +18 -7
- data/spec/{ransack → polyamorous}/join_spec.rb +0 -0
- data/spec/ransack/adapters/active_record/base_spec.rb +9 -6
- data/spec/ransack/adapters/active_record/context_spec.rb +60 -18
- data/spec/ransack/configuration_spec.rb +10 -0
- data/spec/ransack/helpers/form_helper_spec.rb +16 -16
- data/spec/ransack/nodes/grouping_spec.rb +2 -2
- data/spec/ransack/predicate_spec.rb +54 -2
- data/spec/ransack/search_spec.rb +127 -15
- data/spec/spec_helper.rb +10 -5
- data/spec/support/schema.rb +14 -3
- metadata +41 -137
- data/.travis.yml +0 -37
- data/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +0 -2
- data/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +0 -2
- data/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +0 -32
- data/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +0 -112
- data/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +0 -32
- data/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +0 -113
data/lib/ransack/version.rb
CHANGED
data/ransack.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
|
2
3
|
$:.push File.expand_path("../lib", __FILE__)
|
3
4
|
require "ransack/version"
|
4
5
|
|
@@ -6,36 +7,20 @@ Gem::Specification.new do |s|
|
|
6
7
|
s.name = "ransack"
|
7
8
|
s.version = Ransack::VERSION
|
8
9
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack","Sean Carroll"]
|
10
|
-
s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com","sfcarroll@gmail.com"]
|
10
|
+
s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack", "Sean Carroll"]
|
11
|
+
s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com", "sfcarroll@gmail.com"]
|
11
12
|
s.homepage = "https://github.com/activerecord-hackery/ransack"
|
12
13
|
s.summary = %q{Object-based searching for Active Record and Mongoid (currently).}
|
13
14
|
s.description = %q{Ransack is the successor to the MetaSearch gem. It improves and expands upon MetaSearch's functionality, but does not have a 100%-compatible API.}
|
14
|
-
s.required_ruby_version = '>=
|
15
|
+
s.required_ruby_version = '>= 2.6'
|
15
16
|
s.license = 'MIT'
|
16
17
|
|
17
|
-
s.
|
18
|
-
|
19
|
-
s.add_dependency 'actionpack', '>= 5.0'
|
20
|
-
s.add_dependency 'activerecord', '>= 5.0'
|
21
|
-
s.add_dependency 'activesupport', '>= 5.0'
|
18
|
+
s.add_dependency 'activerecord', '>= 5.2.4'
|
19
|
+
s.add_dependency 'activesupport', '>= 5.2.4'
|
22
20
|
s.add_dependency 'i18n'
|
23
|
-
s.add_development_dependency 'rspec', '~> 3'
|
24
|
-
s.add_development_dependency 'machinist', '~> 1.0.6'
|
25
|
-
s.add_development_dependency 'faker', '~> 0.9.5'
|
26
|
-
s.add_development_dependency 'sqlite3', '~> 1.3.3'
|
27
|
-
s.add_development_dependency 'pg', '~> 0.21'
|
28
|
-
s.add_development_dependency 'mysql2', '0.3.20'
|
29
|
-
s.add_development_dependency 'pry', '0.10'
|
30
21
|
|
31
22
|
s.files = `git ls-files`.split("\n")
|
32
|
-
|
33
|
-
s.
|
34
|
-
.split("\n")
|
35
|
-
|
36
|
-
s.executables = `git ls-files -- bin/*`
|
37
|
-
.split("\n")
|
38
|
-
.map { |f| File.basename(f) }
|
39
|
-
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
40
25
|
s.require_paths = ["lib"]
|
41
26
|
end
|
data/spec/blueprints/articles.rb
CHANGED
data/spec/blueprints/comments.rb
CHANGED
data/spec/blueprints/notes.rb
CHANGED
data/spec/blueprints/tags.rb
CHANGED
data/spec/console.rb
CHANGED
@@ -14,11 +14,11 @@ Sham.define do
|
|
14
14
|
title { Faker::Lorem.sentence }
|
15
15
|
body { Faker::Lorem.paragraph }
|
16
16
|
salary { |index| 30000 + (index * 1000) }
|
17
|
-
tag_name { Faker::Lorem.words(3).join(' ') }
|
18
|
-
note { Faker::Lorem.words(7).join(' ') }
|
19
|
-
only_admin { Faker::Lorem.words(3).join(' ') }
|
20
|
-
only_search { Faker::Lorem.words(3).join(' ') }
|
21
|
-
only_sort { Faker::Lorem.words(3).join(' ') }
|
17
|
+
tag_name { Faker::Lorem.words(number: 3).join(' ') }
|
18
|
+
note { Faker::Lorem.words(number: 7).join(' ') }
|
19
|
+
only_admin { Faker::Lorem.words(number: 3).join(' ') }
|
20
|
+
only_search { Faker::Lorem.words(number: 3).join(' ') }
|
21
|
+
only_sort { Faker::Lorem.words(number: 3).join(' ') }
|
22
22
|
notable_id { |id| id }
|
23
23
|
end
|
24
24
|
|
@@ -3,18 +3,13 @@ module PolyamorousHelper
|
|
3
3
|
Polyamorous::JoinAssociation.new reflection, children, klass
|
4
4
|
end
|
5
5
|
|
6
|
-
if ActiveRecord::
|
6
|
+
if ActiveRecord.version >= ::Gem::Version.new("6.0.0.rc1")
|
7
7
|
def new_join_dependency(klass, associations = {})
|
8
|
-
Polyamorous::JoinDependency.new klass, klass.arel_table, associations
|
9
|
-
end
|
10
|
-
elsif ActiveRecord::VERSION::STRING == "5.2.0"
|
11
|
-
def new_join_dependency(klass, associations = {})
|
12
|
-
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(klass.connection, klass.table_name, [])
|
13
|
-
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, alias_tracker
|
8
|
+
Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin
|
14
9
|
end
|
15
10
|
else
|
16
11
|
def new_join_dependency(klass, associations = {})
|
17
|
-
Polyamorous::JoinDependency.new klass,
|
12
|
+
Polyamorous::JoinDependency.new klass, klass.arel_table, associations
|
18
13
|
end
|
19
14
|
end
|
20
15
|
|
@@ -10,6 +10,13 @@ module Polyamorous
|
|
10
10
|
new_join_association(reflection, parent.children, Article)
|
11
11
|
}
|
12
12
|
|
13
|
+
subject { new_join_association(reflection, parent.children, Person) }
|
14
|
+
|
15
|
+
it 'respects polymorphism on equality test' do
|
16
|
+
expect(subject).to eq new_join_association(reflection, parent.children, Person)
|
17
|
+
expect(subject).not_to eq new_join_association(reflection, parent.children, Article)
|
18
|
+
end
|
19
|
+
|
13
20
|
it 'leaves the orginal reflection intact for thread safety' do
|
14
21
|
reflection.instance_variable_set(:@klass, Article)
|
15
22
|
join_association
|
@@ -8,8 +8,8 @@ module Polyamorous
|
|
8
8
|
|
9
9
|
specify { expect(subject.send(:join_root).drop(1).size)
|
10
10
|
.to eq(2) }
|
11
|
-
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
|
12
|
-
.to
|
11
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
12
|
+
.to eq [Polyamorous::InnerJoin] }
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'with has_many :through association' do
|
@@ -38,8 +38,8 @@ module Polyamorous
|
|
38
38
|
.to eq 2 }
|
39
39
|
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
|
40
40
|
.to eq [Polyamorous::OuterJoin, Polyamorous::OuterJoin] }
|
41
|
-
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
|
42
|
-
.to
|
41
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
42
|
+
.to eq [Polyamorous::OuterJoin] }
|
43
43
|
end
|
44
44
|
|
45
45
|
context 'with polymorphic belongs_to join' do
|
@@ -59,8 +59,19 @@ module Polyamorous
|
|
59
59
|
|
60
60
|
specify { expect(subject.send(:join_root).drop(1).size)
|
61
61
|
.to eq 2 }
|
62
|
-
specify { expect(subject.send(:join_root).drop(1).map(&:join_type))
|
63
|
-
.to
|
62
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type).uniq)
|
63
|
+
.to eq [Polyamorous::InnerJoin] }
|
64
|
+
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
65
|
+
.to eq 'people' }
|
66
|
+
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
|
67
|
+
.to eq 'comments' }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'with polymorphic belongs_to join and nested join' do
|
71
|
+
subject { new_join_dependency Note,
|
72
|
+
new_join(:notable, :outer, Person) => :comments }
|
73
|
+
specify { expect(subject.send(:join_root).drop(1).size).to eq 2 }
|
74
|
+
specify { expect(subject.send(:join_root).drop(1).map(&:join_type)).to eq [Polyamorous::OuterJoin, Polyamorous::InnerJoin] }
|
64
75
|
specify { expect(subject.send(:join_root).drop(1).first.table_name)
|
65
76
|
.to eq 'people' }
|
66
77
|
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
|
@@ -68,7 +79,7 @@ module Polyamorous
|
|
68
79
|
end
|
69
80
|
|
70
81
|
context '#left_outer_join in Rails 5 overrides join type specified',
|
71
|
-
if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MINOR < 2 do
|
82
|
+
if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MAJOR < 6 && ActiveRecord::VERSION::MINOR < 2 do
|
72
83
|
|
73
84
|
let(:join_type_class) do
|
74
85
|
new_join_dependency(
|
File without changes
|
@@ -122,6 +122,10 @@ module Ransack
|
|
122
122
|
expect { Person.ransack('') }.to_not raise_error
|
123
123
|
end
|
124
124
|
|
125
|
+
it 'raises exception if ransack! called with unknown condition' do
|
126
|
+
expect { Person.ransack!(unknown_attr_eq: 'Ernie') }.to raise_error
|
127
|
+
end
|
128
|
+
|
125
129
|
it 'does not modify the parameters' do
|
126
130
|
params = { name_eq: '' }
|
127
131
|
expect { Person.ransack(params) }.not_to change { params }
|
@@ -143,14 +147,12 @@ module Ransack
|
|
143
147
|
it 'removes redundant joins from top query' do
|
144
148
|
s = Article.ransack(tags_name_not_eq: "Fantasy")
|
145
149
|
sql = s.result.to_sql
|
146
|
-
|
147
150
|
expect(sql).to_not include('LEFT OUTER JOIN')
|
148
151
|
end
|
149
152
|
|
150
153
|
it 'handles != for single values' do
|
151
154
|
s = Article.ransack(tags_name_not_eq: "Fantasy")
|
152
155
|
articles = s.result.to_a
|
153
|
-
|
154
156
|
expect(articles).to include marco
|
155
157
|
expect(articles).to_not include arthur
|
156
158
|
end
|
@@ -267,10 +269,12 @@ module Ransack
|
|
267
269
|
# end
|
268
270
|
|
269
271
|
it 'creates ransack attributes' do
|
272
|
+
person = Person.create!(name: 'Aric Smith')
|
273
|
+
|
270
274
|
s = Person.ransack(reversed_name_eq: 'htimS cirA')
|
271
275
|
expect(s.result.size).to eq(1)
|
272
276
|
|
273
|
-
expect(s.result.first).to eq
|
277
|
+
expect(s.result.first).to eq person
|
274
278
|
end
|
275
279
|
|
276
280
|
it 'can be accessed through associations' do
|
@@ -460,9 +464,9 @@ module Ransack
|
|
460
464
|
Comment.create(article: Article.create(title: 'Avenger'), person: Person.create(salary: 100_000)),
|
461
465
|
Comment.create(article: Article.create(title: 'Avenge'), person: Person.create(salary: 50_000)),
|
462
466
|
]
|
463
|
-
expect(Comment.ransack(article_title_cont: 'aven',s: 'person_salary desc').result).to eq(comments)
|
467
|
+
expect(Comment.ransack(article_title_cont: 'aven', s: 'person_salary desc').result).to eq(comments)
|
464
468
|
expect(Comment.joins(:person).ransack(s: 'persons_salarydesc', article_title_cont: 'aven').result).to eq(comments)
|
465
|
-
expect(Comment.joins(:person).ransack(article_title_cont: 'aven',s: 'persons_salary desc').result).to eq(comments)
|
469
|
+
expect(Comment.joins(:person).ransack(article_title_cont: 'aven', s: 'persons_salary desc').result).to eq(comments)
|
466
470
|
end
|
467
471
|
|
468
472
|
it 'allows sort by `only_sort` field' do
|
@@ -541,7 +545,6 @@ module Ransack
|
|
541
545
|
)
|
542
546
|
end
|
543
547
|
|
544
|
-
|
545
548
|
it 'should allow passing ransacker arguments to a ransacker' do
|
546
549
|
s = Person.ransack(
|
547
550
|
c: [{
|
@@ -9,7 +9,6 @@ module Ransack
|
|
9
9
|
describe Context do
|
10
10
|
subject { Context.new(Person) }
|
11
11
|
|
12
|
-
|
13
12
|
it 'has an Active Record alias tracker method' do
|
14
13
|
expect(subject.alias_tracker)
|
15
14
|
.to be_an ::ActiveRecord::Associations::AliasTracker
|
@@ -40,6 +39,66 @@ module Ransack
|
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
42
|
+
describe '#build_correlated_subquery' do
|
43
|
+
it 'build correlated subquery for Root STI model' do
|
44
|
+
search = Search.new(Person, { articles_title_not_eq: 'some_title' }, context: subject)
|
45
|
+
attribute = search.conditions.first.attributes.first
|
46
|
+
constraints = subject.build_correlated_subquery(attribute.parent).constraints
|
47
|
+
constraint = constraints.first
|
48
|
+
|
49
|
+
expect(constraints.length).to eql 1
|
50
|
+
expect(constraint.left.name).to eql 'person_id'
|
51
|
+
expect(constraint.left.relation.name).to eql 'articles'
|
52
|
+
expect(constraint.right.name).to eql 'id'
|
53
|
+
expect(constraint.right.relation.name).to eql 'people'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'build correlated subquery for Child STI model when predicate is not_eq' do
|
57
|
+
search = Search.new(Person, { story_articles_title_not_eq: 'some_title' }, context: subject)
|
58
|
+
attribute = search.conditions.first.attributes.first
|
59
|
+
constraints = subject.build_correlated_subquery(attribute.parent).constraints
|
60
|
+
constraint = constraints.first
|
61
|
+
|
62
|
+
expect(constraints.length).to eql 1
|
63
|
+
expect(constraint.left.relation.name).to eql 'articles'
|
64
|
+
expect(constraint.left.name).to eql 'person_id'
|
65
|
+
expect(constraint.right.relation.name).to eql 'people'
|
66
|
+
expect(constraint.right.name).to eql 'id'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'build correlated subquery for Child STI model when predicate is eq' do
|
70
|
+
search = Search.new(Person, { story_articles_title_not_eq: 'some_title' }, context: subject)
|
71
|
+
attribute = search.conditions.first.attributes.first
|
72
|
+
constraints = subject.build_correlated_subquery(attribute.parent).constraints
|
73
|
+
constraint = constraints.first
|
74
|
+
|
75
|
+
expect(constraints.length).to eql 1
|
76
|
+
expect(constraint.left.relation.name).to eql 'articles'
|
77
|
+
expect(constraint.left.name).to eql 'person_id'
|
78
|
+
expect(constraint.right.relation.name).to eql 'people'
|
79
|
+
expect(constraint.right.name).to eql 'id'
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'build correlated subquery for multiple conditions (default scope)' do
|
83
|
+
search = Search.new(Person, { comments_body_not_eq: 'some_title' })
|
84
|
+
|
85
|
+
# Was
|
86
|
+
# SELECT "people".* FROM "people" WHERE "people"."id" NOT IN (
|
87
|
+
# SELECT "comments"."disabled" FROM "comments"
|
88
|
+
# WHERE "comments"."disabled" = "people"."id"
|
89
|
+
# AND NOT ("comments"."body" != 'some_title')
|
90
|
+
# ) ORDER BY "people"."id" DESC
|
91
|
+
# Should Be
|
92
|
+
# SELECT "people".* FROM "people" WHERE "people"."id" NOT IN (
|
93
|
+
# SELECT "comments"."person_id" FROM "comments"
|
94
|
+
# WHERE "comments"."person_id" = "people"."id"
|
95
|
+
# AND NOT ("comments"."body" != 'some_title')
|
96
|
+
# ) ORDER BY "people"."id" DESC
|
97
|
+
|
98
|
+
expect(search.result.to_sql).to match /.comments.\..person_id. = .people.\..id./
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
43
102
|
describe 'sharing context across searches' do
|
44
103
|
let(:shared_context) { Context.for(Person) }
|
45
104
|
|
@@ -50,23 +109,6 @@ module Ransack
|
|
50
109
|
context: shared_context)
|
51
110
|
end
|
52
111
|
|
53
|
-
describe '#join_associations', if: AR_version <= '4.0' do
|
54
|
-
it 'returns dependent join associations for all searches run
|
55
|
-
against the context' do
|
56
|
-
parents, children = shared_context.join_associations
|
57
|
-
|
58
|
-
expect(children.aliased_table_name).to eq "children_people"
|
59
|
-
expect(parents.aliased_table_name).to eq "parents_people"
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'can be rejoined to execute a valid query' do
|
63
|
-
parents, children = shared_context.join_associations
|
64
|
-
|
65
|
-
expect { Person.joins(parents).joins(children).to_a }
|
66
|
-
.to_not raise_error
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
112
|
describe '#join_sources' do
|
71
113
|
it 'returns dependent arel join nodes for all searches run against
|
72
114
|
the context' do
|
@@ -173,5 +173,15 @@ module Ransack
|
|
173
173
|
.to eq false
|
174
174
|
end
|
175
175
|
end
|
176
|
+
|
177
|
+
it "PG's sort option", if: ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" do
|
178
|
+
default = Ransack.options.clone
|
179
|
+
|
180
|
+
Ransack.configure { |c| c.postgres_fields_sort_option = :nulls_first }
|
181
|
+
|
182
|
+
expect(Ransack.options[:postgres_fields_sort_option]).to eq :nulls_first
|
183
|
+
|
184
|
+
Ransack.options = default
|
185
|
+
end
|
176
186
|
end
|
177
187
|
end
|
@@ -186,7 +186,7 @@ module Ransack
|
|
186
186
|
)
|
187
187
|
}
|
188
188
|
it {
|
189
|
-
should match(
|
189
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
190
190
|
)
|
191
191
|
}
|
192
192
|
it { should match /sort_link desc/ }
|
@@ -202,7 +202,7 @@ module Ransack
|
|
202
202
|
)
|
203
203
|
}
|
204
204
|
it {
|
205
|
-
should match(
|
205
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
206
206
|
)
|
207
207
|
}
|
208
208
|
end
|
@@ -216,7 +216,7 @@ module Ransack
|
|
216
216
|
)
|
217
217
|
}
|
218
218
|
it {
|
219
|
-
should match(
|
219
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
220
220
|
)
|
221
221
|
}
|
222
222
|
it { should match /sort_link desc/ }
|
@@ -232,7 +232,7 @@ module Ransack
|
|
232
232
|
)
|
233
233
|
}
|
234
234
|
it {
|
235
|
-
should match(
|
235
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
236
236
|
)
|
237
237
|
}
|
238
238
|
end
|
@@ -258,7 +258,7 @@ module Ransack
|
|
258
258
|
)
|
259
259
|
}
|
260
260
|
it {
|
261
|
-
should match(
|
261
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
262
262
|
)
|
263
263
|
}
|
264
264
|
it { should match /sort_link desc/ }
|
@@ -274,7 +274,7 @@ module Ransack
|
|
274
274
|
)
|
275
275
|
}
|
276
276
|
it {
|
277
|
-
should match(
|
277
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+asc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
278
278
|
)
|
279
279
|
}
|
280
280
|
end
|
@@ -289,7 +289,7 @@ module Ransack
|
|
289
289
|
)
|
290
290
|
}
|
291
291
|
it {
|
292
|
-
should match(
|
292
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
293
293
|
)
|
294
294
|
}
|
295
295
|
it { should match /sort_link/ }
|
@@ -306,7 +306,7 @@ module Ransack
|
|
306
306
|
)
|
307
307
|
}
|
308
308
|
it {
|
309
|
-
should match(
|
309
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
310
310
|
)
|
311
311
|
}
|
312
312
|
end
|
@@ -321,7 +321,7 @@ module Ransack
|
|
321
321
|
)
|
322
322
|
}
|
323
323
|
it {
|
324
|
-
should match(
|
324
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
325
325
|
)
|
326
326
|
}
|
327
327
|
it { should match /sort_link/ }
|
@@ -338,7 +338,7 @@ module Ransack
|
|
338
338
|
)
|
339
339
|
}
|
340
340
|
it {
|
341
|
-
should match(
|
341
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
342
342
|
)
|
343
343
|
}
|
344
344
|
end
|
@@ -353,7 +353,7 @@ module Ransack
|
|
353
353
|
)
|
354
354
|
}
|
355
355
|
it {
|
356
|
-
should match(
|
356
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+asc/
|
357
357
|
)
|
358
358
|
}
|
359
359
|
it { should match /sort_link/ }
|
@@ -370,7 +370,7 @@ module Ransack
|
|
370
370
|
)
|
371
371
|
}
|
372
372
|
it {
|
373
|
-
should match(
|
373
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+asc/
|
374
374
|
)
|
375
375
|
}
|
376
376
|
end
|
@@ -385,7 +385,7 @@ module Ransack
|
|
385
385
|
)
|
386
386
|
}
|
387
387
|
it {
|
388
|
-
should match(
|
388
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
389
389
|
)
|
390
390
|
}
|
391
391
|
it { should match /sort_link/ }
|
@@ -402,7 +402,7 @@ module Ransack
|
|
402
402
|
)
|
403
403
|
}
|
404
404
|
it {
|
405
|
-
should match(
|
405
|
+
should match(/people\?q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=name\+desc&q(%5B|\[)s(%5D|\])(%5B|\[)(%5D|\])=email\+desc/
|
406
406
|
)
|
407
407
|
}
|
408
408
|
end
|
@@ -643,13 +643,13 @@ module Ransack
|
|
643
643
|
before do
|
644
644
|
Ransack.configure do |c|
|
645
645
|
c.hide_sort_order_indicators = false
|
646
|
-
c.custom_arrows = { default_arrow: "defaultarrow"}
|
646
|
+
c.custom_arrows = { default_arrow: "defaultarrow" }
|
647
647
|
end
|
648
648
|
end
|
649
649
|
|
650
650
|
after do
|
651
651
|
Ransack.configure do |c|
|
652
|
-
c.custom_arrows = { default_arrow: nil}
|
652
|
+
c.custom_arrows = { default_arrow: nil }
|
653
653
|
end
|
654
654
|
end
|
655
655
|
|