ransack 1.8.3 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.travis.yml +26 -63
  4. data/CHANGELOG.md +187 -24
  5. data/CONTRIBUTING.md +9 -0
  6. data/Gemfile +5 -20
  7. data/README.md +163 -40
  8. data/Rakefile +1 -22
  9. data/lib/ransack/adapters/active_record/base.rb +11 -2
  10. data/lib/ransack/adapters/active_record/context.rb +178 -168
  11. data/lib/ransack/adapters/active_record/ransack/constants.rb +6 -3
  12. data/lib/ransack/adapters/active_record/ransack/context.rb +10 -16
  13. data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +3 -3
  14. data/lib/ransack/adapters/active_record/ransack/translate.rb +1 -5
  15. data/lib/ransack/adapters/active_record/ransack/visitor.rb +23 -0
  16. data/lib/ransack/adapters/active_record.rb +0 -9
  17. data/lib/ransack/adapters.rb +2 -0
  18. data/lib/ransack/configuration.rb +30 -4
  19. data/lib/ransack/constants.rb +4 -1
  20. data/lib/ransack/context.rb +29 -24
  21. data/lib/ransack/helpers/form_builder.rb +15 -3
  22. data/lib/ransack/helpers/form_helper.rb +8 -3
  23. data/lib/ransack/locale/ar.yml +70 -0
  24. data/lib/ransack/locale/az.yml +70 -0
  25. data/lib/ransack/locale/bg.yml +70 -0
  26. data/lib/ransack/locale/ca.yml +70 -0
  27. data/lib/ransack/locale/el.yml +70 -0
  28. data/lib/ransack/locale/es.yml +22 -22
  29. data/lib/ransack/locale/fa.yml +70 -0
  30. data/lib/ransack/locale/fi.yml +71 -0
  31. data/lib/ransack/locale/it.yml +70 -0
  32. data/lib/ransack/locale/nl.yml +4 -4
  33. data/lib/ransack/locale/ru.yml +70 -0
  34. data/lib/ransack/locale/tr.yml +70 -0
  35. data/lib/ransack/locale/zh-CN.yml +12 -12
  36. data/lib/ransack/nodes/attribute.rb +1 -1
  37. data/lib/ransack/nodes/grouping.rb +2 -7
  38. data/lib/ransack/nodes/value.rb +74 -68
  39. data/lib/ransack/predicate.rb +11 -19
  40. data/lib/ransack/search.rb +1 -1
  41. data/lib/ransack/translate.rb +115 -115
  42. data/lib/ransack/version.rb +1 -1
  43. data/lib/ransack/visitor.rb +1 -12
  44. data/lib/ransack.rb +5 -2
  45. data/logo/ransack-h.png +0 -0
  46. data/logo/ransack-h.svg +34 -0
  47. data/logo/ransack-v.png +0 -0
  48. data/logo/ransack-v.svg +34 -0
  49. data/logo/ransack.png +0 -0
  50. data/logo/ransack.svg +21 -0
  51. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_association.rb +2 -0
  52. data/polyamorous/lib/polyamorous/activerecord_5.0_ruby_2/join_dependency.rb +2 -0
  53. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_association.rb +31 -0
  54. data/polyamorous/lib/polyamorous/activerecord_5.1_ruby_2/join_dependency.rb +112 -0
  55. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_association.rb +31 -0
  56. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/join_dependency.rb +112 -0
  57. data/polyamorous/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb +12 -0
  58. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_association.rb +22 -0
  59. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb +81 -0
  60. data/polyamorous/lib/polyamorous/activerecord_5.2.1_ruby_2/reflection.rb +2 -0
  61. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +2 -0
  62. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +81 -0
  63. data/polyamorous/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +2 -0
  64. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +2 -0
  65. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +2 -0
  66. data/polyamorous/lib/polyamorous/activerecord_6.1_ruby_2/reflection.rb +2 -0
  67. data/polyamorous/lib/polyamorous/join.rb +70 -0
  68. data/polyamorous/lib/polyamorous/swapping_reflection_class.rb +11 -0
  69. data/polyamorous/lib/polyamorous/tree_node.rb +7 -0
  70. data/polyamorous/lib/polyamorous/version.rb +3 -0
  71. data/polyamorous/lib/polyamorous.rb +29 -0
  72. data/polyamorous/polyamorous.gemspec +35 -0
  73. data/ransack.gemspec +9 -10
  74. data/spec/helpers/polyamorous_helper.rb +28 -0
  75. data/spec/ransack/adapters/active_record/base_spec.rb +74 -0
  76. data/spec/ransack/adapters/active_record/context_spec.rb +44 -6
  77. data/spec/ransack/configuration_spec.rb +17 -2
  78. data/spec/ransack/helpers/form_builder_spec.rb +3 -15
  79. data/spec/ransack/helpers/form_helper_spec.rb +88 -151
  80. data/spec/ransack/join_association_spec.rb +28 -0
  81. data/spec/ransack/join_dependency_spec.rb +97 -0
  82. data/spec/ransack/join_spec.rb +19 -0
  83. data/spec/ransack/predicate_spec.rb +16 -2
  84. data/spec/ransack/search_spec.rb +32 -3
  85. data/spec/spec_helper.rb +5 -0
  86. data/spec/support/schema.rb +45 -21
  87. metadata +81 -67
  88. data/lib/ransack/adapters/active_record/3.0/compat.rb +0 -179
  89. data/lib/ransack/adapters/active_record/3.0/context.rb +0 -203
  90. data/lib/ransack/adapters/active_record/3.1/context.rb +0 -212
  91. data/lib/ransack/adapters/active_record/3.2/context.rb +0 -44
  92. data/lib/ransack/adapters/active_record/compat.rb +0 -14
  93. data/lib/ransack/adapters/mongoid/3.2/.gitkeep +0 -0
  94. data/lib/ransack/adapters/mongoid/attributes/attribute.rb +0 -37
  95. data/lib/ransack/adapters/mongoid/attributes/order_predications.rb +0 -17
  96. data/lib/ransack/adapters/mongoid/attributes/predications.rb +0 -141
  97. data/lib/ransack/adapters/mongoid/base.rb +0 -134
  98. data/lib/ransack/adapters/mongoid/context.rb +0 -212
  99. data/lib/ransack/adapters/mongoid/inquiry_hash.rb +0 -23
  100. data/lib/ransack/adapters/mongoid/ransack/constants.rb +0 -88
  101. data/lib/ransack/adapters/mongoid/ransack/context.rb +0 -60
  102. data/lib/ransack/adapters/mongoid/ransack/nodes/condition.rb +0 -27
  103. data/lib/ransack/adapters/mongoid/ransack/translate.rb +0 -13
  104. data/lib/ransack/adapters/mongoid/ransack/visitor.rb +0 -24
  105. data/lib/ransack/adapters/mongoid/table.rb +0 -35
  106. data/lib/ransack/adapters/mongoid.rb +0 -15
  107. data/spec/mongoid/adapters/mongoid/base_spec.rb +0 -314
  108. data/spec/mongoid/adapters/mongoid/context_spec.rb +0 -56
  109. data/spec/mongoid/configuration_spec.rb +0 -162
  110. data/spec/mongoid/dependencies_spec.rb +0 -8
  111. data/spec/mongoid/helpers/ransack_helper.rb +0 -11
  112. data/spec/mongoid/nodes/condition_spec.rb +0 -49
  113. data/spec/mongoid/nodes/grouping_spec.rb +0 -13
  114. data/spec/mongoid/predicate_spec.rb +0 -155
  115. data/spec/mongoid/search_spec.rb +0 -445
  116. data/spec/mongoid/support/mongoid.yml +0 -11
  117. data/spec/mongoid/support/schema.rb +0 -135
  118. data/spec/mongoid/translate_spec.rb +0 -14
  119. data/spec/mongoid_spec_helper.rb +0 -63
  120. data/spec/ransack/dependencies_spec.rb +0 -12
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "polyamorous/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "polyamorous"
7
+ s.version = Polyamorous::VERSION
8
+ s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack", "Xiang Li"]
9
+ s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com", "bigxiang@gmail.com"]
10
+ s.homepage = "https://github.com/activerecord-hackery/ransack/tree/master/polyamorous"
11
+ s.license = "MIT"
12
+ s.summary = %q{
13
+ Loves/is loved by polymorphic belongs_to associations, Ransack, Squeel, MetaSearch...
14
+ }
15
+ s.description = %q{
16
+ This is just an extraction from Ransack/Squeel. You probably don't want to use this
17
+ directly. It extends ActiveRecord's associations to support polymorphic belongs_to
18
+ associations.
19
+ }
20
+
21
+ s.add_dependency 'activerecord', '>= 5.0'
22
+ s.add_development_dependency 'rspec', '~> 3'
23
+ s.add_development_dependency 'machinist', '~> 1.0.6'
24
+ s.add_development_dependency 'faker', '~> 1.6.5'
25
+ s.add_development_dependency 'sqlite3', '~> 1.3.3'
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
29
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
30
+ s.require_paths = ["lib"]
31
+
32
+ # specify any dependencies here; for example:
33
+ # s.add_development_dependency "rspec"
34
+ # s.add_runtime_dependency "rest-client"
35
+ end
data/ransack.gemspec CHANGED
@@ -6,28 +6,27 @@ Gem::Specification.new do |s|
6
6
  s.name = "ransack"
7
7
  s.version = Ransack::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Ernie Miller", "Ryan Bigg", "Jon Atack"]
10
- s.email = ["ernie@erniemiller.org", "radarlistener@gmail.com", "jonnyatack@gmail.com"]
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"]
11
11
  s.homepage = "https://github.com/activerecord-hackery/ransack"
12
12
  s.summary = %q{Object-based searching for Active Record and Mongoid (currently).}
13
13
  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
14
  s.required_ruby_version = '>= 1.9'
15
15
  s.license = 'MIT'
16
16
 
17
- s.rubyforge_project = "ransack"
18
-
19
- s.add_dependency 'actionpack', '>= 3.0'
20
- s.add_dependency 'activerecord', '>= 3.0'
21
- s.add_dependency 'activesupport', '>= 3.0'
17
+ s.add_dependency 'actionpack', '>= 5.0'
18
+ s.add_dependency 'activerecord', '>= 5.0'
19
+ s.add_dependency 'activesupport', '>= 5.0'
22
20
  s.add_dependency 'i18n'
23
- s.add_dependency 'polyamorous', '~> 1.3'
21
+ s.add_dependency 'polyamorous', Ransack::VERSION.to_s
24
22
  s.add_development_dependency 'rspec', '~> 3'
25
23
  s.add_development_dependency 'machinist', '~> 1.0.6'
26
24
  s.add_development_dependency 'faker', '~> 0.9.5'
27
- s.add_development_dependency 'sqlite3', '~> 1.3.3'
28
- s.add_development_dependency 'pg'
25
+ s.add_development_dependency 'sqlite3', ::Gem::Version.new(ENV['RAILS'].gsub(/^v/, '')) >= ::Gem::Version.new('6-0-stable') ? '~> 1.4.1' : '~> 1.3.3'
26
+ s.add_development_dependency 'pg', '~> 0.21'
29
27
  s.add_development_dependency 'mysql2', '0.3.20'
30
28
  s.add_development_dependency 'pry', '0.10'
29
+ s.add_development_dependency 'byebug'
31
30
 
32
31
  s.files = `git ls-files`.split("\n")
33
32
 
@@ -0,0 +1,28 @@
1
+ module PolyamorousHelper
2
+ def new_join_association(reflection, children, klass)
3
+ Polyamorous::JoinAssociation.new reflection, children, klass
4
+ end
5
+
6
+ if ActiveRecord.version >= ::Gem::Version.new("6.0.0.rc1")
7
+ def new_join_dependency(klass, associations = {})
8
+ Polyamorous::JoinDependency.new klass, klass.arel_table, associations, Polyamorous::InnerJoin
9
+ end
10
+ elsif ActiveRecord.version > ::Gem::Version.new("5.2.0")
11
+ def new_join_dependency(klass, associations = {})
12
+ Polyamorous::JoinDependency.new klass, klass.arel_table, associations
13
+ end
14
+ elsif ActiveRecord.version == ::Gem::Version.new("5.2.0")
15
+ def new_join_dependency(klass, associations = {})
16
+ alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(klass.connection, klass.table_name, [])
17
+ Polyamorous::JoinDependency.new klass, klass.arel_table, associations, alias_tracker
18
+ end
19
+ else
20
+ def new_join_dependency(klass, associations = {})
21
+ Polyamorous::JoinDependency.new klass, associations, []
22
+ end
23
+ end
24
+
25
+ def new_join(name, type = Polyamorous::InnerJoin, klass = nil)
26
+ Polyamorous::Join.new name, type, klass
27
+ end
28
+ end
@@ -18,6 +18,13 @@ module Ransack
18
18
  expect(subject.object).to be_an ::ActiveRecord::Relation
19
19
  end
20
20
 
21
+ context "multiple database connection" do
22
+ it "does not raise error" do
23
+ expect { Person.ransack(name_cont: "test") }.not_to raise_error
24
+ expect { SubDB::OperationHistory.ransack(people_id_eq: 1) }.not_to raise_error
25
+ end
26
+ end
27
+
21
28
  context 'with scopes' do
22
29
  before do
23
30
  allow(Person)
@@ -90,6 +97,25 @@ module Ransack
90
97
  expect(s.result.to_sql).to (include 'age > 0')
91
98
  end
92
99
  end
100
+
101
+ context "with ransackable_scopes_skip_sanitize_args enabled for scope" do
102
+ before do
103
+ allow(Person)
104
+ .to receive(:ransackable_scopes_skip_sanitize_args)
105
+ .and_return([:over_age])
106
+ end
107
+
108
+ it 'passes true values to scopes' do
109
+ s = Person.ransack('over_age' => 1)
110
+ expect(s.result.to_sql).to (include 'age > 1')
111
+ end
112
+
113
+ it 'passes false values to scopes' do
114
+ s = Person.ransack('over_age' => 0)
115
+ expect(s.result.to_sql).to (include 'age > 0')
116
+ end
117
+ end
118
+
93
119
  end
94
120
 
95
121
  it 'does not raise exception for string :params argument' do
@@ -429,6 +455,16 @@ module Ransack
429
455
  end
430
456
  end
431
457
 
458
+ it 'sorts with different join variants' do
459
+ comments = [
460
+ Comment.create(article: Article.create(title: 'Avenger'), person: Person.create(salary: 100_000)),
461
+ Comment.create(article: Article.create(title: 'Avenge'), person: Person.create(salary: 50_000)),
462
+ ]
463
+ expect(Comment.ransack(article_title_cont: 'aven',s: 'person_salary desc').result).to eq(comments)
464
+ 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)
466
+ end
467
+
432
468
  it 'allows sort by `only_sort` field' do
433
469
  s = Person.ransack(
434
470
  's' => { '0' => { 'dir' => 'asc', 'name' => 'only_sort' } }
@@ -505,6 +541,7 @@ module Ransack
505
541
  )
506
542
  end
507
543
 
544
+
508
545
  it 'should allow passing ransacker arguments to a ransacker' do
509
546
  s = Person.ransack(
510
547
  c: [{
@@ -544,6 +581,37 @@ module Ransack
544
581
  /BETWEEN 2 AND 6 GROUP BY articles.person_id \) DESC/
545
582
  )
546
583
  end
584
+
585
+ context 'case insensitive sorting' do
586
+ it 'allows sort by desc' do
587
+ search = Person.ransack(sorts: ['name_case_insensitive desc'])
588
+ expect(search.result.to_sql).to match /ORDER BY LOWER(.*) DESC/
589
+ end
590
+
591
+ it 'allows sort by asc' do
592
+ search = Person.ransack(sorts: ['name_case_insensitive asc'])
593
+ expect(search.result.to_sql).to match /ORDER BY LOWER(.*) ASC/
594
+ end
595
+ end
596
+
597
+ context 'regular sorting' do
598
+ it 'allows sort by desc' do
599
+ search = Person.ransack(sorts: ['name desc'])
600
+ expect(search.result.to_sql).to match /ORDER BY .* DESC/
601
+ end
602
+
603
+ it 'allows sort by asc' do
604
+ search = Person.ransack(sorts: ['name asc'])
605
+ expect(search.result.to_sql).to match /ORDER BY .* ASC/
606
+ end
607
+ end
608
+
609
+ context 'sorting by a scope' do
610
+ it 'applies the correct scope' do
611
+ search = Person.ransack(sorts: ['reverse_name asc'])
612
+ expect(search.result.to_sql).to include("ORDER BY REVERSE(name) ASC")
613
+ end
614
+ end
547
615
  end
548
616
 
549
617
  describe '#ransackable_attributes' do
@@ -613,6 +681,12 @@ module Ransack
613
681
  it { should eq [] }
614
682
  end
615
683
 
684
+ describe '#ransackable_scopes_skip_sanitize_args' do
685
+ subject { Person.ransackable_scopes_skip_sanitize_args }
686
+
687
+ it { should eq [] }
688
+ end
689
+
616
690
  end
617
691
  end
618
692
  end
@@ -10,8 +10,7 @@ module Ransack
10
10
  subject { Context.new(Person) }
11
11
 
12
12
 
13
- it 'has an Active Record alias tracker method',
14
- if: AR_version >= '3.1' do
13
+ it 'has an Active Record alias tracker method' do
15
14
  expect(subject.alias_tracker)
16
15
  .to be_an ::ActiveRecord::Associations::AliasTracker
17
16
  end
@@ -41,6 +40,47 @@ module Ransack
41
40
  end
42
41
  end
43
42
 
43
+ describe '#build_correlated_subquery' do
44
+ it 'build correlated subquery for Root STI model' do
45
+ search = Search.new(Person, { articles_title_not_eq: 'some_title' }, context: subject)
46
+ attribute = search.conditions.first.attributes.first
47
+ constraints = subject.build_correlated_subquery(attribute.parent).constraints
48
+ constraint = constraints.first
49
+
50
+ expect(constraints.length).to eql 1
51
+ expect(constraint.left.name).to eql 'person_id'
52
+ expect(constraint.left.relation.name).to eql 'articles'
53
+ expect(constraint.right.name).to eql 'id'
54
+ expect(constraint.right.relation.name).to eql 'people'
55
+ end
56
+
57
+ it 'build correlated subquery for Child STI model when predicate is not_eq' do
58
+ search = Search.new(Person, { story_articles_title_not_eq: 'some_title' }, context: subject)
59
+ attribute = search.conditions.first.attributes.first
60
+ constraints = subject.build_correlated_subquery(attribute.parent).constraints
61
+ constraint = constraints.first
62
+
63
+ expect(constraints.length).to eql 1
64
+ expect(constraint.left.relation.name).to eql 'articles'
65
+ expect(constraint.left.name).to eql 'person_id'
66
+ expect(constraint.right.relation.name).to eql 'people'
67
+ expect(constraint.right.name).to eql 'id'
68
+ end
69
+
70
+ it 'build correlated subquery for Child STI model when predicate is eq' do
71
+ search = Search.new(Person, { story_articles_title_not_eq: 'some_title' }, context: subject)
72
+ attribute = search.conditions.first.attributes.first
73
+ constraints = subject.build_correlated_subquery(attribute.parent).constraints
74
+ constraint = constraints.first
75
+
76
+ expect(constraints.length).to eql 1
77
+ expect(constraint.left.relation.name).to eql 'articles'
78
+ expect(constraint.left.name).to eql 'person_id'
79
+ expect(constraint.right.relation.name).to eql 'people'
80
+ expect(constraint.right.name).to eql 'id'
81
+ end
82
+ end
83
+
44
84
  describe 'sharing context across searches' do
45
85
  let(:shared_context) { Context.for(Person) }
46
86
 
@@ -69,16 +109,14 @@ module Ransack
69
109
  end
70
110
 
71
111
  describe '#join_sources' do
72
- # FIXME: fix this test for Rails 4.2 and 5.0.
73
112
  it 'returns dependent arel join nodes for all searches run against
74
- the context', if: %w(3.1 3.2 4.0 4.1).include?(AR_version) do
113
+ the context' do
75
114
  parents, children = shared_context.join_sources
76
115
  expect(children.left.name).to eq "children_people"
77
116
  expect(parents.left.name).to eq "parents_people"
78
117
  end
79
118
 
80
- it 'can be rejoined to execute a valid query',
81
- if: AR_version >= '3.1' do
119
+ it 'can be rejoined to execute a valid query' do
82
120
  parents, children = shared_context.join_sources
83
121
 
84
122
  expect { Person.joins(parents).joins(children).to_a }
@@ -48,6 +48,7 @@ module Ransack
48
48
  it 'should have default values for arrows' do
49
49
  expect(Ransack.options[:up_arrow]).to eq '▼'
50
50
  expect(Ransack.options[:down_arrow]).to eq '▲'
51
+ expect(Ransack.options[:default_arrow]).to eq nil
51
52
  end
52
53
 
53
54
  it 'changes the default value for the up arrow only' do
@@ -72,17 +73,31 @@ module Ransack
72
73
  Ransack.options = default
73
74
  end
74
75
 
75
- it 'changes the default value for both arrows' do
76
+ it 'changes the default value for the default arrow only' do
77
+ default, new_default_arrow = Ransack.options.clone, '<i class="default"></i>'
78
+
79
+ Ransack.configure { |c| c.custom_arrows = { default_arrow: new_default_arrow } }
80
+
81
+ expect(Ransack.options[:up_arrow]).to eq default[:up_arrow]
82
+ expect(Ransack.options[:down_arrow]).to eq default[:down_arrow]
83
+ expect(Ransack.options[:default_arrow]).to eq new_default_arrow
84
+
85
+ Ransack.options = default
86
+ end
87
+
88
+ it 'changes the default value for all arrows' do
76
89
  default = Ransack.options.clone
77
90
  new_up_arrow = '<i class="fa fa-long-arrow-up"></i>'
78
91
  new_down_arrow = 'U+02193'
92
+ new_default_arrow = 'defaultarrow'
79
93
 
80
94
  Ransack.configure do |c|
81
- c.custom_arrows = { up_arrow: new_up_arrow, down_arrow: new_down_arrow }
95
+ c.custom_arrows = { up_arrow: new_up_arrow, down_arrow: new_down_arrow, default_arrow: new_default_arrow }
82
96
  end
83
97
 
84
98
  expect(Ransack.options[:up_arrow]).to eq new_up_arrow
85
99
  expect(Ransack.options[:down_arrow]).to eq new_down_arrow
100
+ expect(Ransack.options[:default_arrow]).to eq new_default_arrow
86
101
 
87
102
  Ransack.options = default
88
103
  end
@@ -21,11 +21,7 @@ module Ransack
21
21
  @controller.view_context.search_form_for(@s) { |f| @f = f }
22
22
  end
23
23
 
24
- it 'selects previously-entered time values with datetime_select',
25
- unless: (
26
- RUBY_VERSION >= '2.3' &&
27
- ::ActiveRecord::VERSION::STRING.first(3) < '3.2'
28
- ) do
24
+ it 'selects previously-entered time values with datetime_select' do
29
25
  date_values = %w(2011 1 2 03 04 05)
30
26
  # @s.created_at_eq = date_values # This works in Rails 4.x but not 3.x
31
27
  @s.created_at_eq = [2011, 1, 2, 3, 4, 5] # so we have to do this
@@ -75,11 +71,7 @@ module Ransack
75
71
  describe '#sort_link' do
76
72
  it 'sort_link for ransack attribute' do
77
73
  sort_link = @f.sort_link :name, :controller => 'people'
78
- if ActiveRecord::VERSION::STRING =~ /^3\.[1-2]\./
79
- expect(sort_link).to match /people\?q%5Bs%5D=name\+asc/
80
- else
81
- expect(sort_link).to match /people\?q(%5B|\[)s(%5D|\])=name\+asc/
82
- end
74
+ expect(sort_link).to match /people\?q(%5B|\[)s(%5D|\])=name\+asc/
83
75
  expect(sort_link).to match /sort_link/
84
76
  expect(sort_link).to match /Full Name<\/a>/
85
77
  end
@@ -171,11 +163,7 @@ module Ransack
171
163
  # Starting from Rails 4.2, the date_select html attributes are no longer
172
164
  # `sort`ed (for a speed gain), so the tests have to be different:
173
165
  def date_select_html(val)
174
- if ::ActiveRecord::VERSION::STRING >= '4.2'
175
- %(<option value="#{val}" selected="selected">#{val}</option>)
176
- else
177
- %(<option selected="selected" value="#{val}">#{val}</option>)
178
- end
166
+ %(<option value="#{val}" selected="selected">#{val}</option>)
179
167
  end
180
168
 
181
169
  end