algoliasearch-rails 1.10.2 → 1.10.3

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: 6196220d77f0814eb40d2b9bd099bca91a2324fa
4
- data.tar.gz: 63f5d687166324650b122dd41d3662bbdcfefa31
3
+ metadata.gz: 675a8f42e7841895e66f88e9f4d550b59222d4e5
4
+ data.tar.gz: f832cadef3b8bef0c50b4f49f474423d1c40e3b2
5
5
  SHA512:
6
- metadata.gz: d9487f03e8c3ff584f7765d912181cd91a1d2d114f331de301e5065d08a78d9dc9d52f8a0ec645a6c421a09d23e6cdbabd601638a6466268b8678184eef75a20
7
- data.tar.gz: cffab279a78865d7974113f629be7833ce1c7cd074ae56838336a67b2b6a55266089615faa817afe8e5fbabb1d084e02683edb024296d3ad23d1d48fef80485a
6
+ metadata.gz: 10324137c57a424b127bdf4440bcc326e5c44f3558411973b76a83083d22f514d78b354c6c47cfbfa876c537d067d91b8896a867ef6ae48874dbd6be258086f6
7
+ data.tar.gz: 1a717beffdfe5507c5bf954e2dd6e6f29f2a157a1d1799b20f523993496b2cd134205a0d73cf8d2fe1781236805f0e3f09a9293c3ba6fef09c52227d6f315fa7
data/.travis.yml CHANGED
@@ -8,7 +8,7 @@ rvm:
8
8
  - 2.0.0
9
9
  - 2.1.0
10
10
  - jruby
11
- - rbx
11
+ - rbx-2
12
12
  env:
13
13
  global:
14
14
  - secure: wRDLGbg+GS7Eo6KhjyAA6YNm6rFVo8j53b0oEZLBkJ2VzvLsKMnpEfopzc0W2wttgVwgkX8C/9adbd/BPsEYbpO+uJFt5DX3A2HVVXCZ2jP0TgLj2m4dOA4ohroYDcdeB0fuZM7a7hvFNswd9vSRLmes6vLQ0GcFTSz1rWQLf6U=
data/ChangeLog CHANGED
@@ -1,5 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-06-17 1.10.3
4
+
5
+ * Kaminari: pad the result array to match the options/offset parameters
6
+
3
7
  2014-05-09 1.10.2
4
8
 
5
9
  * Expose synoyms/placeholders features
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gem 'algoliasearch', '~> 1.2'
5
5
  gem 'rubysl', '~> 2.0', :platform => :rbx
6
6
 
7
7
  group :test do
8
- gem 'rspec', '>= 2.5.0'
8
+ gem 'rspec', '>= 2.5.0', '< 3.0'
9
9
  gem 'rails', '>= 3.2.0', '< 4.0'
10
10
  gem 'sqlite3', :platform => [:rbx, :ruby]
11
11
  gem 'jdbc-sqlite3', :platform => :jruby
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- ZenTest (4.9.5)
5
- actionmailer (3.2.17)
6
- actionpack (= 3.2.17)
4
+ ZenTest (4.10.0)
5
+ actionmailer (3.2.18)
6
+ actionpack (= 3.2.18)
7
7
  mail (~> 2.5.4)
8
- actionpack (3.2.17)
9
- activemodel (= 3.2.17)
10
- activesupport (= 3.2.17)
8
+ actionpack (3.2.18)
9
+ activemodel (= 3.2.18)
10
+ activesupport (= 3.2.18)
11
11
  builder (~> 3.0.0)
12
12
  erubis (~> 2.7.0)
13
13
  journey (~> 1.0.4)
@@ -15,23 +15,23 @@ GEM
15
15
  rack-cache (~> 1.2)
16
16
  rack-test (~> 0.6.1)
17
17
  sprockets (~> 2.2.1)
18
- activemodel (3.2.17)
19
- activesupport (= 3.2.17)
18
+ activemodel (3.2.18)
19
+ activesupport (= 3.2.18)
20
20
  builder (~> 3.0.0)
21
- activerecord (3.2.17)
22
- activemodel (= 3.2.17)
23
- activesupport (= 3.2.17)
21
+ activerecord (3.2.18)
22
+ activemodel (= 3.2.18)
23
+ activesupport (= 3.2.18)
24
24
  arel (~> 3.0.2)
25
25
  tzinfo (~> 0.3.29)
26
- activerecord-jdbc-adapter (1.3.6)
26
+ activerecord-jdbc-adapter (1.3.7)
27
27
  activerecord (>= 2.2)
28
- activerecord-jdbcsqlite3-adapter (1.3.6)
29
- activerecord-jdbc-adapter (~> 1.3.6)
28
+ activerecord-jdbcsqlite3-adapter (1.3.7)
29
+ activerecord-jdbc-adapter (~> 1.3.7)
30
30
  jdbc-sqlite3 (~> 3.7.2)
31
- activeresource (3.2.17)
32
- activemodel (= 3.2.17)
33
- activesupport (= 3.2.17)
34
- activesupport (3.2.17)
31
+ activeresource (3.2.18)
32
+ activemodel (= 3.2.18)
33
+ activesupport (= 3.2.18)
34
+ activesupport (3.2.18)
35
35
  i18n (~> 0.6, >= 0.6.4)
36
36
  multi_json (~> 1.0)
37
37
  addressable (2.3.6)
@@ -51,10 +51,10 @@ GEM
51
51
  erubis (2.7.0)
52
52
  ethon (0.7.0)
53
53
  ffi (>= 1.3.0)
54
- faraday (0.8.9)
55
- multipart-post (~> 1.2.0)
56
- faraday_middleware (0.9.0)
57
- faraday (>= 0.7.4, < 0.9)
54
+ faraday (0.9.0)
55
+ multipart-post (>= 1.2, < 3)
56
+ faraday_middleware (0.9.1)
57
+ faraday (>= 0.7.4, < 0.10)
58
58
  ffi (1.9.3)
59
59
  ffi (1.9.3-java)
60
60
  ffi2-generators (0.1.1)
@@ -73,7 +73,7 @@ GEM
73
73
  journey (1.0.4)
74
74
  json (1.8.1)
75
75
  json (1.8.1-java)
76
- kaminari (0.15.1)
76
+ kaminari (0.16.1)
77
77
  actionpack (>= 3.0.0)
78
78
  activesupport (>= 3.0.0)
79
79
  launchy (2.4.2)
@@ -86,11 +86,11 @@ GEM
86
86
  treetop (~> 1.4.8)
87
87
  method_source (0.8.2)
88
88
  mime-types (1.25.1)
89
- multi_json (1.9.2)
90
- multipart-post (1.2.0)
89
+ multi_json (1.10.1)
90
+ multipart-post (2.0.0)
91
91
  net-http-persistent (2.9.4)
92
92
  net-http-pipeline (1.0.1)
93
- polyglot (0.3.4)
93
+ polyglot (0.3.5)
94
94
  pry (0.9.12.6)
95
95
  coderay (~> 1.0)
96
96
  method_source (~> 0.8)
@@ -100,8 +100,9 @@ GEM
100
100
  method_source (~> 0.8)
101
101
  slop (~> 3.4)
102
102
  spoon (~> 0.0)
103
- pusher-client (0.4.0)
104
- websocket (~> 1.0.0)
103
+ pusher-client (0.6.0)
104
+ json
105
+ websocket (~> 1.0)
105
106
  rack (1.4.5)
106
107
  rack-cache (1.2)
107
108
  rack (>= 0.4)
@@ -109,17 +110,17 @@ GEM
109
110
  rack
110
111
  rack-test (0.6.2)
111
112
  rack (>= 1.0)
112
- rails (3.2.17)
113
- actionmailer (= 3.2.17)
114
- actionpack (= 3.2.17)
115
- activerecord (= 3.2.17)
116
- activeresource (= 3.2.17)
117
- activesupport (= 3.2.17)
113
+ rails (3.2.18)
114
+ actionmailer (= 3.2.18)
115
+ actionpack (= 3.2.18)
116
+ activerecord (= 3.2.18)
117
+ activeresource (= 3.2.18)
118
+ activesupport (= 3.2.18)
118
119
  bundler (~> 1.0)
119
- railties (= 3.2.17)
120
- railties (3.2.17)
121
- actionpack (= 3.2.17)
122
- activesupport (= 3.2.17)
120
+ railties (= 3.2.18)
121
+ railties (3.2.18)
122
+ actionpack (= 3.2.18)
123
+ activesupport (= 3.2.18)
123
124
  rack-ssl (~> 1.3.2)
124
125
  rake (>= 0.8.7)
125
126
  rdoc (~> 3.4)
@@ -128,14 +129,14 @@ GEM
128
129
  rdoc (3.12.2)
129
130
  json (~> 1.4)
130
131
  redgreen (1.2.2)
131
- rspec (2.14.1)
132
- rspec-core (~> 2.14.0)
133
- rspec-expectations (~> 2.14.0)
134
- rspec-mocks (~> 2.14.0)
135
- rspec-core (2.14.8)
136
- rspec-expectations (2.14.5)
132
+ rspec (2.99.0)
133
+ rspec-core (~> 2.99.0)
134
+ rspec-expectations (~> 2.99.0)
135
+ rspec-mocks (~> 2.99.0)
136
+ rspec-core (2.99.0)
137
+ rspec-expectations (2.99.0)
137
138
  diff-lcs (>= 1.1.3, < 2.0)
138
- rspec-mocks (2.14.6)
139
+ rspec-mocks (2.99.0)
139
140
  rubysl (2.0.15)
140
141
  rubysl-abbrev (~> 2.0)
141
142
  rubysl-base64 (~> 2.0)
@@ -351,24 +352,24 @@ GEM
351
352
  ffi (>= 1.0.0)
352
353
  thor (0.19.1)
353
354
  tilt (1.4.1)
354
- travis (1.6.8)
355
+ travis (1.6.11)
355
356
  addressable (~> 2.3)
356
357
  backports
357
- faraday (~> 0.8.7)
358
+ faraday (~> 0.9)
358
359
  faraday_middleware (~> 0.9)
359
360
  gh (~> 0.13)
360
361
  highline (~> 1.6)
361
362
  launchy (~> 2.1)
362
363
  pry (~> 0.9)
363
364
  pusher-client (~> 0.4)
364
- typhoeus (~> 0.6)
365
+ typhoeus (~> 0.6, >= 0.6.8)
365
366
  treetop (1.4.15)
366
367
  polyglot
367
368
  polyglot (>= 0.3.1)
368
369
  typhoeus (0.6.8)
369
370
  ethon (>= 0.7.0)
370
371
  tzinfo (0.3.39)
371
- websocket (1.0.7)
372
+ websocket (1.1.4)
372
373
  will_paginate (3.0.5)
373
374
 
374
375
  PLATFORMS
@@ -389,7 +390,7 @@ DEPENDENCIES
389
390
  rake (~> 10.1.0)
390
391
  rdoc
391
392
  redgreen
392
- rspec (>= 2.5.0)
393
+ rspec (>= 2.5.0, < 3.0)
393
394
  rubysl (~> 2.0)
394
395
  sqlite3
395
396
  travis
data/README.md CHANGED
@@ -25,6 +25,7 @@ Table of Content
25
25
  1. [Faceting](#faceting)
26
26
  1. [Geo-search](#geo-search)
27
27
  1. [Typeahead UI](#typeahead-ui)
28
+ 1. [Caveats](#caveats)
28
29
  1. [Note on testing](#note-on-testing)
29
30
 
30
31
  Install
@@ -567,8 +568,35 @@ Turns any ```input[type="text"]``` element into a typeahead, for example:
567
568
  </script>
568
569
  ```
569
570
 
571
+ Caveats
572
+ --------
573
+
574
+ This gem makes intensive use of Rails' callbacks to trigger the indexing tasks. If you're using methods bypassing ```after_validation```, ```before_save``` or ```after_save``` callbacks, it will not index your changes. For example: ```update_attribute``` doesn't perform validations checks, to perform validations when updating use ```update_attributes```.
570
575
 
571
576
  Note on testing
572
577
  -----------------
573
578
 
574
579
  To run the specs, please set the <code>ALGOLIA_APPLICATION_ID</code> and <code>ALGOLIA_API_KEY</code> environment variables. Since the tests are creating and removing indexes, DO NOT use your production account.
580
+
581
+ You may want to mock Algolia's API calls. We provide a [WebMock](https://github.com/bblimke/webmock) configuration that you can use including `algolia/webmock`:
582
+
583
+ ```ruby
584
+ require 'algolia/webmock'
585
+
586
+ describe 'With a mocked client' do
587
+
588
+ before(:each) do
589
+ WebMock.enable!
590
+ end
591
+
592
+ it "shouldn't perform any API calls here" do
593
+ User.create(name: 'My Indexed User') # mocked, no API call performed
594
+ User.search('').should == {} # mocked, no API call performed
595
+ end
596
+
597
+ after(:each) do
598
+ WebMock.disable!
599
+ end
600
+
601
+ end
602
+ ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.2
1
+ 1.10.3
@@ -6,11 +6,11 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-rails"
9
- s.version = "1.10.2"
9
+ s.version = "1.10.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Algolia"]
13
- s.date = "2014-04-29"
13
+ s.date = "2014-06-17"
14
14
  s.description = "AlgoliaSearch integration to your favorite ORM"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -24,7 +24,15 @@ module AlgoliaSearch
24
24
 
25
25
  class << self
26
26
  def create(results, total_hits, options = {})
27
- new results, :offset => ((options[:page] - 1) * options[:per_page]), :limit => options[:per_page], :total_count => total_hits
27
+ offset = ((options[:page] - 1) * options[:per_page])
28
+ array = new results, :offset => offset, :limit => options[:per_page], :total_count => total_hits
29
+ if array.empty? and !results.empty?
30
+ # since Kaminari 0.16.0, you need to pad the results with nil values so it matches the offset param
31
+ # otherwise you'll get an empty array: https://github.com/amatsuda/kaminari/commit/29fdcfa8865f2021f710adaedb41b7a7b081e34d
32
+ results = ([nil] * offset) + results
33
+ array = new results, :offset => offset, :limit => options[:per_page], :total_count => total_hits
34
+ end
35
+ array
28
36
  end
29
37
  end
30
38
  end
@@ -175,7 +175,7 @@ module AlgoliaSearch
175
175
  attr_accessor :highlight_result
176
176
 
177
177
  if options[:synchronous] == true
178
- after_validation :algolia_mark_synchronous if respond_to?(:before_validation)
178
+ after_validation :algolia_mark_synchronous if respond_to?(:after_validation)
179
179
  end
180
180
  unless options[:auto_index] == false
181
181
  after_validation :algolia_mark_must_reindex if respond_to?(:after_validation)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: algoliasearch-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-29 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json