ransack 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f794e84fb4595e61da2a692b091c475698170fda
4
- data.tar.gz: 3c74ff882fc59a32b25c83155c0e7ab4922b013c
3
+ metadata.gz: 1ed8cd2219b1b16fb129d708c135405bcc3cd1e1
4
+ data.tar.gz: 08ee652b2fcbbf30f40ee7d7370d9d3fb4a97207
5
5
  SHA512:
6
- metadata.gz: f70a119cfb73857c715feafa11ed85ad862f4439653e266586e2bcccf6523c5374229483f273e7aa5d2a8ecc8973a1b3cab221393d6cb5e240723db1d63b16ff
7
- data.tar.gz: d16a78c96996d5b28ff151ea89a6eb1729743c185e6a88d002b25f03b8326e7fa395fe523a885a02298867e65c80d3a7ad190c3e16e14a89f70314b25db6d03d
6
+ metadata.gz: 3e1fb6f045a7f24db09af20e541d502f70793adea5f1ae5518f5ebdac9f22e8d60c884693a2858c35bf08b577ef32f6fafd412d046c2450d7b5b23935088bdd5
7
+ data.tar.gz: c4886f5a0a91bd50df8336eb7cbe971ffdeae7cd36b4a3441d509676267f7236c1c3d10602c8fb7cd780ff0873216566240b27001012a77beecaca1cd21c0d27
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 1.6.1 - 2015-01-14
4
+
5
+ * Fix a regression with using `in` predicates caused by PR [#488](https://github.com/activerecord-hackery/ransack/pull/488)). Add a test.
6
+
7
+ * README improvements to clarify `sort_link` syntax with associations and
8
+ Ransack#search vs #ransack.
9
+
10
+ * Default the Gemfile to Rails 4-2-stable.
11
+
12
+ *Jon Atack*
13
+
14
+
3
15
  ## Version 1.6.0 - 2015-01-12
4
16
  ### Added
5
17
 
@@ -89,6 +101,7 @@
89
101
 
90
102
  *Jon Atack*
91
103
 
104
+
92
105
  ## Version 1.5.1 - 2014-10-30
93
106
  ### Fixed
94
107
 
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ gemspec
3
3
 
4
4
  gem 'rake'
5
5
 
6
- rails = ENV['RAILS'] || 'master'
6
+ rails = ENV['RAILS'] || '4-2-stable'
7
7
 
8
8
  if rails == 'master'
9
9
  gem 'arel', github: 'rails/arel'
data/README.md CHANGED
@@ -27,7 +27,7 @@ instead.
27
27
  If you're viewing this at
28
28
  [github.com/activerecord-hackery/ransack](https://github.com/activerecord-hackery/ransack),
29
29
  you're reading the documentation for the master branch with the latest features.
30
- [View documentation for the last release (1.6.0).](https://github.com/activerecord-hackery/ransack/tree/v.1.6.0)
30
+ [View documentation for the last release (1.6.0).](https://github.com/activerecord-hackery/ransack/tree/v1.6.1)
31
31
 
32
32
  ## Getting started
33
33
 
@@ -265,17 +265,18 @@ construct much more complex search forms, such as the one on the
265
265
 
266
266
  ### Ransack #search method
267
267
 
268
- Ransack will try to to make `#search` available in your models, but in the case
269
- that `#search` has already been defined, you can always use the default
270
- `#ransack` method. For example, the following would be equivalent:
268
+ Ransack will try to to make the class method `#search` available in your
269
+ models, but if `#search` has already been defined elsewhere, you can always use
270
+ the default `#ransack` class method. So the following are equivalent:
271
271
 
272
272
  ```ruby
273
273
  Article.ransack(params[:q])
274
274
  Article.search(params[:q])
275
275
  ```
276
276
 
277
- Users have reported issues of name conflicts with other gems, so `#search` may
278
- possibly be deprecated in the next major version of Ransack (2.0).
277
+ Users have reported issues of `#search` name conflicts with other gems, so
278
+ the `#search` method alias might be deprecated in the next major version of
279
+ Ransack (2.0). It's advisable to use the default `#ransack` instead.
279
280
 
280
281
  For now, if Ransack's `#search` method conflicts with the name of another
281
282
  method named `search` in your code or another gem, you may resolve it either by
@@ -293,7 +294,7 @@ Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
293
294
  You can easily use Ransack to search for objects in `has_many` and `belongs_to`
294
295
  associations.
295
296
 
296
- Given you have these associations ...
297
+ Given these associations...
297
298
 
298
299
  ```ruby
299
300
  class Employee < ActiveRecord::Base
@@ -316,7 +317,7 @@ class Supervisor < ActiveRecord::Base
316
317
  end
317
318
  ```
318
319
 
319
- ... and a controller ...
320
+ ... and a controller...
320
321
 
321
322
  ```ruby
322
323
  class SupervisorsController < ApplicationController
@@ -327,7 +328,7 @@ class SupervisorsController < ApplicationController
327
328
  end
328
329
  ```
329
330
 
330
- ... you might set up your form like this ...
331
+ ... you might set up your form like this...
331
332
 
332
333
  ```erb
333
334
  <%= search_form_for @q do |f| %>
@@ -350,6 +351,11 @@ end
350
351
  <% end %>
351
352
  ```
352
353
 
354
+ Please note that in a sort link, the association is expressed as an SQL string
355
+ (`'employees.last_name'`) with a pluralized table name, instead of the symbol
356
+ `:employee_last_name` syntax with a class#underscore table name used for
357
+ Ransack objects elsewhere.
358
+
353
359
  ### Using Ransackers to add custom search functions via Arel
354
360
 
355
361
  The main premise behind Ransack is to provide access to
@@ -24,7 +24,7 @@ module Ransack
24
24
 
25
25
  private
26
26
 
27
- # FIXME: Improve this edge case patch for Arel >= 6.0 (Rails >= 4.2)
27
+ # TODO: Improve this edge case patch for Arel >= 6.0 (Rails >= 4.2)
28
28
  # that adds several conditionals to handle changing Arel API.
29
29
  # Related to Ransack issue #472 and pull requests #486-488.
30
30
  #
@@ -39,8 +39,7 @@ module Ransack
39
39
  def casted_array_with_in_predicate?(predicate)
40
40
  return unless defined?(Arel::Nodes::Casted)
41
41
  predicate.class == Arel::Nodes::In &&
42
- predicate.right.is_a?(Array) &&
43
- predicate.right[0].class == Arel::Nodes::Casted
42
+ predicate.right[0].val.is_a?(Array)
44
43
  end
45
44
 
46
45
  end
@@ -1,3 +1,3 @@
1
1
  module Ransack
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -80,6 +80,14 @@ module Ransack
80
80
  end
81
81
  end
82
82
 
83
+ context "search on an `in` predicate with an array" do
84
+ it "should function correctly when passing an array of ids" do
85
+ array = Person.all.map(&:id)
86
+ s = Person.ransack(id_in: array)
87
+ expect(s.result.count).to eq array.size
88
+ end
89
+ end
90
+
83
91
  describe '#ransacker' do
84
92
  # For infix tests
85
93
  def self.sane_adapter?
@@ -161,16 +169,16 @@ module Ransack
161
169
  expect(s.result.to_a).to eq [p]
162
170
  end
163
171
 
164
- context "search using an `in` predicate and an array passed to a ransacker" do
172
+ context "search on an `in` predicate with an array to a ransacker" do
165
173
  it "should function correctly when passing an array of ids" do
166
174
  s = Person.ransack(array_users_in: true)
167
- expect(s.result.length).to be > 0
175
+ expect(s.result.count).to be > 0
168
176
  end
169
177
 
170
178
  it "should function correctly when passing an array of strings" do
171
179
  p = Person.create!(name: Person.first.id.to_s)
172
180
  s = Person.ransack(array_names_in: true)
173
- expect(s.result.length).to be > 0
181
+ expect(s.result.count).to be > 0
174
182
  end
175
183
  end
176
184
 
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: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernie Miller
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-01-13 00:00:00.000000000 Z
13
+ date: 2015-01-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack