ransack 2.4.1 → 2.6.0
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/workflows/cronjob.yml +102 -0
- data/.github/workflows/rubocop.yml +20 -0
- data/.github/workflows/test.yml +43 -18
- data/.rubocop.yml +44 -0
- data/CHANGELOG.md +22 -4
- data/CONTRIBUTING.md +6 -5
- data/Gemfile +4 -2
- data/README.md +76 -10
- 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 +17 -0
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_association.rb +20 -1
- data/lib/polyamorous/activerecord_6.0_ruby_2/join_dependency.rb +0 -1
- data/lib/polyamorous/activerecord_6.0_ruby_2/reflection.rb +11 -1
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_association.rb +0 -4
- data/lib/polyamorous/activerecord_6.1_ruby_2/join_dependency.rb +0 -1
- data/lib/polyamorous/activerecord_7.0_ruby_2/join_association.rb +1 -0
- data/lib/polyamorous/activerecord_7.0_ruby_2/join_dependency.rb +1 -0
- data/lib/polyamorous/activerecord_7.0_ruby_2/reflection.rb +1 -0
- data/lib/polyamorous/polyamorous.rb +1 -1
- data/lib/polyamorous.rb +1 -0
- data/lib/ransack/adapters/active_record/base.rb +1 -1
- data/lib/ransack/adapters/active_record/context.rb +9 -5
- data/lib/ransack/adapters/active_record/ransack/constants.rb +1 -1
- data/lib/ransack/adapters/active_record/ransack/nodes/condition.rb +10 -9
- data/lib/ransack/configuration.rb +16 -2
- data/lib/ransack/constants.rb +2 -3
- data/lib/ransack/helpers/form_builder.rb +3 -3
- data/lib/ransack/helpers/form_helper.rb +1 -1
- data/lib/ransack/helpers.rb +1 -1
- data/lib/ransack/locale/sv.yml +70 -0
- data/lib/ransack/nodes/attribute.rb +1 -1
- data/lib/ransack/nodes/condition.rb +0 -2
- data/lib/ransack/nodes/sort.rb +3 -3
- data/lib/ransack/nodes/value.rb +1 -1
- data/lib/ransack/search.rb +2 -1
- data/lib/ransack/translate.rb +1 -1
- data/lib/ransack/version.rb +1 -1
- data/lib/ransack.rb +2 -2
- data/ransack.gemspec +6 -5
- 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/ransack_helper.rb +1 -1
- data/spec/polyamorous/activerecord_compatibility_spec.rb +15 -0
- data/spec/polyamorous/join_association_spec.rb +1 -6
- data/spec/polyamorous/join_dependency_spec.rb +0 -16
- data/spec/ransack/adapters/active_record/base_spec.rb +20 -13
- data/spec/ransack/adapters/active_record/context_spec.rb +1 -2
- data/spec/ransack/configuration_spec.rb +14 -0
- data/spec/ransack/helpers/form_helper_spec.rb +17 -18
- data/spec/ransack/nodes/condition_spec.rb +13 -0
- data/spec/ransack/nodes/grouping_spec.rb +2 -2
- data/spec/ransack/predicate_spec.rb +1 -1
- data/spec/ransack/search_spec.rb +117 -27
- data/spec/spec_helper.rb +7 -6
- data/spec/support/schema.rb +33 -2
- metadata +25 -14
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb +0 -24
- data/lib/polyamorous/activerecord_5.2_ruby_2/join_dependency.rb +0 -79
- data/lib/polyamorous/activerecord_5.2_ruby_2/reflection.rb +0 -11
@@ -1 +1,20 @@
|
|
1
|
-
|
1
|
+
module Polyamorous
|
2
|
+
module JoinAssociationExtensions
|
3
|
+
include SwappingReflectionClass
|
4
|
+
def self.prepended(base)
|
5
|
+
base.class_eval { attr_reader :join_type }
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin)
|
9
|
+
@join_type = join_type
|
10
|
+
if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
|
11
|
+
swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
|
12
|
+
super(reflection, children)
|
13
|
+
self.reflection.options[:polymorphic] = true
|
14
|
+
end
|
15
|
+
else
|
16
|
+
super(reflection, children)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1 +1,11 @@
|
|
1
|
-
|
1
|
+
module Polyamorous
|
2
|
+
module ReflectionExtensions
|
3
|
+
def join_scope(table, foreign_table, foreign_klass)
|
4
|
+
if respond_to?(:polymorphic?) && polymorphic?
|
5
|
+
super.where!(foreign_table[foreign_type].eq(klass.name))
|
6
|
+
else
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'polyamorous/activerecord_6.1_ruby_2/join_association'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'polyamorous/activerecord_6.1_ruby_2/join_dependency'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'polyamorous/activerecord_6.1_ruby_2/reflection'
|
@@ -11,7 +11,7 @@ if defined?(::ActiveRecord)
|
|
11
11
|
require 'polyamorous/join'
|
12
12
|
require 'polyamorous/swapping_reflection_class'
|
13
13
|
|
14
|
-
ar_version = ::ActiveRecord::VERSION::STRING[0,3]
|
14
|
+
ar_version = ::ActiveRecord::VERSION::STRING[0, 3]
|
15
15
|
%w(join_association join_dependency reflection).each do |file|
|
16
16
|
require "polyamorous/activerecord_#{ar_version}_ruby_2/#{file}"
|
17
17
|
end
|
data/lib/polyamorous.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'polyamorous/polyamorous'
|
@@ -70,7 +70,7 @@ module Ransack
|
|
70
70
|
end
|
71
71
|
|
72
72
|
# ransack_scope_skip_sanitize_args, by default, returns an empty array.
|
73
|
-
# i.e. use the sanitize_scope_args setting to
|
73
|
+
# i.e. use the sanitize_scope_args setting to determine if args should be converted.
|
74
74
|
# For overriding with a list of scopes which should be passed the args as-is.
|
75
75
|
#
|
76
76
|
def ransackable_scopes_skip_sanitize_args
|
@@ -44,9 +44,13 @@ module Ransack
|
|
44
44
|
else
|
45
45
|
case Ransack.options[:postgres_fields_sort_option]
|
46
46
|
when :nulls_first
|
47
|
-
scope_or_sort = scope_or_sort.direction == :asc ? "#{scope_or_sort.to_sql} NULLS FIRST" : "#{scope_or_sort.to_sql} NULLS LAST"
|
47
|
+
scope_or_sort = scope_or_sort.direction == :asc ? Arel.sql("#{scope_or_sort.to_sql} NULLS FIRST") : Arel.sql("#{scope_or_sort.to_sql} NULLS LAST")
|
48
48
|
when :nulls_last
|
49
|
-
scope_or_sort = scope_or_sort.direction == :asc ? "#{scope_or_sort.to_sql} NULLS LAST" : "#{scope_or_sort.to_sql} NULLS FIRST"
|
49
|
+
scope_or_sort = scope_or_sort.direction == :asc ? Arel.sql("#{scope_or_sort.to_sql} NULLS LAST") : Arel.sql("#{scope_or_sort.to_sql} NULLS FIRST")
|
50
|
+
when :nulls_always_first
|
51
|
+
scope_or_sort = Arel.sql("#{scope_or_sort.to_sql} NULLS FIRST")
|
52
|
+
when :nulls_always_last
|
53
|
+
scope_or_sort = Arel.sql("#{scope_or_sort.to_sql} NULLS LAST")
|
50
54
|
end
|
51
55
|
|
52
56
|
relation = relation.order(scope_or_sort)
|
@@ -106,7 +110,7 @@ module Ransack
|
|
106
110
|
def join_sources
|
107
111
|
base, joins = begin
|
108
112
|
alias_tracker = ::ActiveRecord::Associations::AliasTracker.create(self.klass.connection, @object.table.name, [])
|
109
|
-
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::
|
113
|
+
constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_1)
|
110
114
|
@join_dependency.join_constraints(@object.joins_values, alias_tracker, @object.references_values)
|
111
115
|
elsif ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_0)
|
112
116
|
@join_dependency.join_constraints(@object.joins_values, alias_tracker)
|
@@ -334,7 +338,7 @@ module Ransack
|
|
334
338
|
@join_dependency.instance_variable_get(:@join_root).children.push found_association
|
335
339
|
|
336
340
|
# Builds the arel nodes properly for this association
|
337
|
-
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::
|
341
|
+
if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_1)
|
338
342
|
@tables_pot[found_association] = @join_dependency.construct_tables_for_association!(jd.instance_variable_get(:@join_root), found_association)
|
339
343
|
else
|
340
344
|
@join_dependency.send(:construct_tables!, jd.instance_variable_get(:@join_root))
|
@@ -348,7 +352,7 @@ module Ransack
|
|
348
352
|
def extract_joins(association)
|
349
353
|
parent = @join_dependency.instance_variable_get(:@join_root)
|
350
354
|
reflection = association.reflection
|
351
|
-
join_constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::
|
355
|
+
join_constraints = if ::Gem::Version.new(::ActiveRecord::VERSION::STRING) >= ::Gem::Version.new(Constants::RAILS_6_1)
|
352
356
|
association.join_constraints_with_tables(
|
353
357
|
parent.table,
|
354
358
|
parent.base_klass,
|
@@ -97,7 +97,7 @@ module Ransack
|
|
97
97
|
arel_predicate: proc { |v| v ? EQ : NOT_EQ },
|
98
98
|
compounds: false,
|
99
99
|
type: :boolean,
|
100
|
-
validator: proc { |v| BOOLEAN_VALUES.include?(v)},
|
100
|
+
validator: proc { |v| BOOLEAN_VALUES.include?(v) },
|
101
101
|
formatter: proc { |v| nil }
|
102
102
|
}
|
103
103
|
],
|
@@ -47,18 +47,19 @@ module Ransack
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def casted_array?(predicate)
|
50
|
-
(predicate.
|
51
|
-
(predicate.respond_to?(:val) && predicate.val.is_a?(Array)) # Rails 5.2, 6.0
|
50
|
+
value_from(predicate).is_a?(Array) && predicate.is_a?(Arel::Nodes::Casted)
|
52
51
|
end
|
53
52
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
def value_from(predicate)
|
54
|
+
if predicate.respond_to?(:value)
|
55
|
+
predicate.value # Rails 6.1
|
56
|
+
elsif predicate.respond_to?(:val)
|
57
|
+
predicate.val # Rails 6.0
|
58
|
+
end
|
59
|
+
end
|
60
60
|
|
61
|
-
|
61
|
+
def format_values_for(predicate)
|
62
|
+
value_from(predicate).map do |val|
|
62
63
|
val.is_a?(String) ? Arel::Nodes.build_quoted(val) : val
|
63
64
|
end
|
64
65
|
end
|
@@ -34,7 +34,8 @@ module Ransack
|
|
34
34
|
:down_arrow => '▲'.freeze,
|
35
35
|
:default_arrow => nil,
|
36
36
|
:sanitize_scope_args => true,
|
37
|
-
:postgres_fields_sort_option => nil
|
37
|
+
:postgres_fields_sort_option => nil,
|
38
|
+
:strip_whitespace => true
|
38
39
|
}
|
39
40
|
|
40
41
|
def configure
|
@@ -148,7 +149,7 @@ module Ransack
|
|
148
149
|
# User may want to configure it like this:
|
149
150
|
#
|
150
151
|
# Ransack.configure do |c|
|
151
|
-
# c.postgres_fields_sort_option = :nulls_first # or :
|
152
|
+
# c.postgres_fields_sort_option = :nulls_first # or e.g. :nulls_always_last
|
152
153
|
# end
|
153
154
|
#
|
154
155
|
# See this feature: https://www.postgresql.org/docs/13/queries-order.html
|
@@ -170,6 +171,19 @@ module Ransack
|
|
170
171
|
self.options[:hide_sort_order_indicators] = boolean
|
171
172
|
end
|
172
173
|
|
174
|
+
# By default, Ransack displays strips all whitespace when searching for a string.
|
175
|
+
# The default may be globally changed in an initializer file like
|
176
|
+
# `config/initializers/ransack.rb` as follows:
|
177
|
+
#
|
178
|
+
# Ransack.configure do |config|
|
179
|
+
# # Enable whitespace stripping for string searches
|
180
|
+
# config.strip_whitespace = true
|
181
|
+
# end
|
182
|
+
#
|
183
|
+
def strip_whitespace=(boolean)
|
184
|
+
self.options[:strip_whitespace] = boolean
|
185
|
+
end
|
186
|
+
|
173
187
|
def arel_predicate_with_suffix(arel_predicate, suffix)
|
174
188
|
if arel_predicate === Proc
|
175
189
|
proc { |v| "#{arel_predicate.call(v)}#{suffix}" }
|
data/lib/ransack/constants.rb
CHANGED
@@ -36,7 +36,7 @@ module Ransack
|
|
36
36
|
'lt'.freeze, 'lteq'.freeze,
|
37
37
|
'gt'.freeze, 'gteq'.freeze,
|
38
38
|
'in'.freeze, 'not_in'.freeze
|
39
|
-
|
39
|
+
].freeze
|
40
40
|
A_S_I = ['a'.freeze, 's'.freeze, 'i'.freeze].freeze
|
41
41
|
|
42
42
|
EQ = 'eq'.freeze
|
@@ -46,10 +46,9 @@ module Ransack
|
|
46
46
|
CONT = 'cont'.freeze
|
47
47
|
|
48
48
|
RAILS_6_0 = '6.0.0'.freeze
|
49
|
-
|
49
|
+
RAILS_6_1 = '6.1.0'.freeze
|
50
50
|
|
51
51
|
RANSACK_SLASH_SEARCHES = 'ransack/searches'.freeze
|
52
52
|
RANSACK_SLASH_SEARCHES_SLASH_SEARCH = 'ransack/searches/search'.freeze
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
@@ -45,9 +45,9 @@ module Ransack
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def attribute_select(options = nil, html_options = nil, action = nil)
|
48
|
-
options
|
49
|
-
html_options
|
50
|
-
action
|
48
|
+
options ||= {}
|
49
|
+
html_options ||= {}
|
50
|
+
action ||= Constants::SEARCH
|
51
51
|
default = options.delete(:default)
|
52
52
|
raise ArgumentError, formbuilder_error_message(
|
53
53
|
"#{action}_select") unless object.respond_to?(:context)
|
data/lib/ransack/helpers.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'ransack/helpers/form_builder'
|
2
|
-
require 'ransack/helpers/form_helper'
|
2
|
+
require 'ransack/helpers/form_helper'
|
@@ -0,0 +1,70 @@
|
|
1
|
+
sv:
|
2
|
+
ransack:
|
3
|
+
search: "sök"
|
4
|
+
predicate: "predikat"
|
5
|
+
and: "och"
|
6
|
+
or: "eller"
|
7
|
+
any: "vilken som"
|
8
|
+
all: "alla"
|
9
|
+
combinator: "kombinator"
|
10
|
+
attribute: "attribut"
|
11
|
+
value: "värde"
|
12
|
+
condition: "villkor"
|
13
|
+
sort: "sortera"
|
14
|
+
asc: "stigande"
|
15
|
+
desc: "fallande"
|
16
|
+
predicates:
|
17
|
+
eq: "lika med"
|
18
|
+
eq_any: "lika med vilket som"
|
19
|
+
eq_all: "lika med alla"
|
20
|
+
not_eq: "inte lika med"
|
21
|
+
not_eq_any: "inte lika med någon"
|
22
|
+
not_eq_all: "inte lika med alla"
|
23
|
+
matches: "matchar"
|
24
|
+
matches_any: "matchar någon"
|
25
|
+
matches_all: "matchar alla"
|
26
|
+
does_not_match: "matchar inte"
|
27
|
+
does_not_match_any: "matchar inte någon"
|
28
|
+
does_not_match_all: "matchar inte alla"
|
29
|
+
lt: "mindre än"
|
30
|
+
lt_any: "mindre än någon"
|
31
|
+
lt_all: "mindre än alla"
|
32
|
+
lteq: "mindre än eller lika med"
|
33
|
+
lteq_any: "mindre än eller lika med någon"
|
34
|
+
lteq_all: "mindre än eller lika med alla"
|
35
|
+
gt: "större än"
|
36
|
+
gt_any: "större än någon"
|
37
|
+
gt_all: "större än alla"
|
38
|
+
gteq: "större än eller lika med"
|
39
|
+
gteq_any: "större än eller lika med någon"
|
40
|
+
gteq_all: "större än eller lika med alla"
|
41
|
+
in: "i"
|
42
|
+
in_any: "i någon"
|
43
|
+
in_all: "i alla"
|
44
|
+
not_in: "inte i"
|
45
|
+
not_in_any: "inte i någon"
|
46
|
+
not_in_all: "inte i alla"
|
47
|
+
cont: "innehåller"
|
48
|
+
cont_any: "innehåller någon"
|
49
|
+
cont_all: "innehåller alla"
|
50
|
+
not_cont: "innehåller inte"
|
51
|
+
not_cont_any: "innehåller inte någon"
|
52
|
+
not_cont_all: "innehåller inte alla"
|
53
|
+
start: "börjar med"
|
54
|
+
start_any: "börjar med någon"
|
55
|
+
start_all: "börjar med alla"
|
56
|
+
not_start: "börjar inte med"
|
57
|
+
not_start_any: "börjar inte med någon"
|
58
|
+
not_start_all: "börjar inte med alla"
|
59
|
+
end: "slutar med"
|
60
|
+
end_any: "slutar med någon"
|
61
|
+
end_all: "slutar med alla"
|
62
|
+
not_end: "slutar inte med"
|
63
|
+
not_end_any: "slutar inte med någon"
|
64
|
+
not_end_all: "slutar inte med alla"
|
65
|
+
'true': "är sant"
|
66
|
+
'false': "är falskt"
|
67
|
+
present: "existerar"
|
68
|
+
blank: "är tom"
|
69
|
+
'null': "är null"
|
70
|
+
not_null: "är inte null"
|
@@ -127,7 +127,6 @@ module Ransack
|
|
127
127
|
alias :m= :combinator=
|
128
128
|
alias :m :combinator
|
129
129
|
|
130
|
-
|
131
130
|
# == build_attribute
|
132
131
|
#
|
133
132
|
# This method was originally called from Nodes::Grouping#new_condition
|
@@ -263,7 +262,6 @@ module Ransack
|
|
263
262
|
attr.attr
|
264
263
|
end
|
265
264
|
|
266
|
-
|
267
265
|
def default_type
|
268
266
|
predicate.type || (attributes.first && attributes.first.type)
|
269
267
|
end
|
data/lib/ransack/nodes/sort.rb
CHANGED
@@ -9,7 +9,7 @@ module Ransack
|
|
9
9
|
class << self
|
10
10
|
def extract(context, str)
|
11
11
|
return unless str
|
12
|
-
attr, direction = str.split(/\s+/,2)
|
12
|
+
attr, direction = str.split(/\s+/, 2)
|
13
13
|
self.new(context).build(name: attr, dir: direction)
|
14
14
|
end
|
15
15
|
end
|
@@ -31,8 +31,8 @@ module Ransack
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def name=(name)
|
34
|
-
@name = name
|
35
|
-
context.bind(self, name)
|
34
|
+
@name = context.ransackable_alias(name) || name
|
35
|
+
context.bind(self, @name)
|
36
36
|
end
|
37
37
|
|
38
38
|
def dir=(dir)
|
data/lib/ransack/nodes/value.rb
CHANGED
data/lib/ransack/search.rb
CHANGED
@@ -15,10 +15,11 @@ module Ransack
|
|
15
15
|
:translate, :to => :base
|
16
16
|
|
17
17
|
def initialize(object, params = {}, options = {})
|
18
|
+
strip_whitespace = options.fetch(:strip_whitespace, Ransack.options[:strip_whitespace])
|
18
19
|
params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h)
|
19
20
|
if params.is_a? Hash
|
20
21
|
params = params.dup
|
21
|
-
params = params.transform_values { |v| v.is_a?(String) ? v.strip : v }
|
22
|
+
params = params.transform_values { |v| v.is_a?(String) && strip_whitespace ? v.strip : v }
|
22
23
|
params.delete_if { |k, v| [*v].all?{ |i| i.blank? && i != false } }
|
23
24
|
else
|
24
25
|
params = {}
|
data/lib/ransack/translate.rb
CHANGED
@@ -32,6 +32,7 @@ module Ransack
|
|
32
32
|
defaults = base_ancestors.map do |klass|
|
33
33
|
"ransack.attributes.#{i18n_key(klass)}.#{original_name}".to_sym
|
34
34
|
end
|
35
|
+
defaults << options.delete(:default) if options[:default]
|
35
36
|
|
36
37
|
translated_names = attribute_names.map do |name|
|
37
38
|
attribute_name(context, name, options[:include_associations])
|
@@ -48,7 +49,6 @@ module Ransack
|
|
48
49
|
defaults << "%{attributes}".freeze
|
49
50
|
end
|
50
51
|
|
51
|
-
defaults << options.delete(:default) if options[:default]
|
52
52
|
options.reverse_merge! count: 1, default: defaults
|
53
53
|
I18n.translate(defaults.shift, **options.merge(interpolations))
|
54
54
|
end
|
data/lib/ransack/version.rb
CHANGED
data/lib/ransack.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'active_support/core_ext'
|
2
2
|
require 'ransack/configuration'
|
3
3
|
require 'ransack/adapters'
|
4
|
-
require 'polyamorous/polyamorous
|
4
|
+
require 'polyamorous/polyamorous'
|
5
5
|
|
6
6
|
Ransack::Adapters.object_mapper.require_constants
|
7
7
|
|
8
8
|
module Ransack
|
9
9
|
extend Configuration
|
10
|
-
class UntraversableAssociationError < StandardError; end
|
10
|
+
class UntraversableAssociationError < StandardError; end
|
11
11
|
end
|
12
12
|
|
13
13
|
Ransack.configure do |config|
|
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,16 +7,16 @@ 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 = '>= 2.
|
15
|
+
s.required_ruby_version = '>= 2.6'
|
15
16
|
s.license = 'MIT'
|
16
17
|
|
17
|
-
s.add_dependency 'activerecord', '>=
|
18
|
-
s.add_dependency 'activesupport', '>=
|
18
|
+
s.add_dependency 'activerecord', '>= 6.0.4'
|
19
|
+
s.add_dependency 'activesupport', '>= 6.0.4'
|
19
20
|
s.add_dependency 'i18n'
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
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
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Polyamorous
|
4
|
+
describe "ActiveRecord Compatibility" do
|
5
|
+
it 'works with self joins and includes' do
|
6
|
+
trade_account = Account.create!
|
7
|
+
Account.create!(trade_account: trade_account)
|
8
|
+
|
9
|
+
accounts = Account.joins(:trade_account).includes(:trade_account, :agent_account)
|
10
|
+
account = accounts.first
|
11
|
+
|
12
|
+
expect(account.agent_account).to be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -12,12 +12,7 @@ module Polyamorous
|
|
12
12
|
|
13
13
|
subject { new_join_association(reflection, parent.children, Person) }
|
14
14
|
|
15
|
-
it '
|
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
|
-
|
20
|
-
it 'leaves the orginal reflection intact for thread safety' do
|
15
|
+
it 'leaves the original reflection intact for thread safety' do
|
21
16
|
reflection.instance_variable_set(:@klass, Article)
|
22
17
|
join_association
|
23
18
|
.swapping_reflection_klass(reflection, Person) do |new_reflection|
|
@@ -77,21 +77,5 @@ module Polyamorous
|
|
77
77
|
specify { expect(subject.send(:join_root).drop(1)[1].table_name)
|
78
78
|
.to eq 'comments' }
|
79
79
|
end
|
80
|
-
|
81
|
-
context '#left_outer_join in Rails 5 overrides join type specified',
|
82
|
-
if: ActiveRecord::VERSION::MAJOR >= 5 && ActiveRecord::VERSION::MAJOR < 6 && ActiveRecord::VERSION::MINOR < 2 do
|
83
|
-
|
84
|
-
let(:join_type_class) do
|
85
|
-
new_join_dependency(
|
86
|
-
Person,
|
87
|
-
new_join(:articles)
|
88
|
-
).join_constraints(
|
89
|
-
[],
|
90
|
-
Arel::Nodes::OuterJoin
|
91
|
-
).first.joins.map(&:class)
|
92
|
-
end
|
93
|
-
|
94
|
-
specify { expect(join_type_class).to eq [Arel::Nodes::OuterJoin] }
|
95
|
-
end
|
96
80
|
end
|
97
81
|
end
|