ransack 1.6.4 → 1.6.5

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.
@@ -28,11 +28,10 @@ RSpec.configure do |config|
28
28
  config.alias_it_should_behave_like_to :it_has_behavior, 'has behavior'
29
29
 
30
30
  config.before(:suite) do
31
- puts '=' * 80
32
31
  connection_name = ActiveRecord::Base.connection.adapter_name
33
- puts "Running specs against #{connection_name}, ActiveRecord #{
34
- ActiveRecord::VERSION::STRING} and ARel #{Arel::VERSION}..."
35
- puts '=' * 80
32
+ message = "Running specs against #{connection_name}, Active Record #{
33
+ ActiveRecord::VERSION::STRING} and Arel #{Arel::VERSION}..."
34
+ puts '=' * message.length, message, '=' * message.length
36
35
  Schema.create
37
36
  end
38
37
 
@@ -1,21 +1,23 @@
1
1
  require 'active_record'
2
2
 
3
- case ENV['DB']
4
- when "mysql"
3
+ case ENV['DB'].try(:downcase)
4
+ when 'mysql', 'mysql2'
5
+ # To test with MySQL: `DB=mysql bundle exec rake spec`
5
6
  ActiveRecord::Base.establish_connection(
6
7
  adapter: 'mysql2',
7
8
  database: 'ransack',
8
9
  encoding: 'utf8'
9
10
  )
10
- when "postgres"
11
+ when 'pg', 'postgres', 'postgresql'
12
+ # To test with PostgreSQL: `DB=postgresql bundle exec rake spec`
11
13
  ActiveRecord::Base.establish_connection(
12
14
  adapter: 'postgresql',
13
15
  database: 'ransack',
14
- username: 'postgres',
16
+ # username: 'postgres', # Uncomment the username option if you have set one
15
17
  min_messages: 'warning'
16
18
  )
17
19
  else
18
- # Assume SQLite3
20
+ # Otherwise, assume SQLite3: `bundle exec rake spec`
19
21
  ActiveRecord::Base.establish_connection(
20
22
  adapter: 'sqlite3',
21
23
  database: ':memory:'
@@ -67,17 +69,17 @@ class Person < ActiveRecord::Base
67
69
  Arel.sql('people.id')
68
70
  end
69
71
 
70
- ransacker :with_passed_arguments, args: [:parent, :ransacker_args] do |parent, args|
71
- min_body, max_body = args
72
- sql = <<-SQL
72
+ ransacker :with_arguments, args: [:parent, :ransacker_args] do |parent, args|
73
+ min, max = args
74
+ query = <<-SQL
73
75
  (SELECT MAX(articles.title)
74
76
  FROM articles
75
77
  WHERE articles.person_id = people.id
76
- AND CHAR_LENGTH(articles.body) BETWEEN #{min_body} AND #{max_body}
78
+ AND LENGTH(articles.body) BETWEEN #{min} AND #{max}
77
79
  GROUP BY articles.person_id
78
80
  )
79
81
  SQL
80
- Arel.sql(sql.squish)
82
+ Arel.sql(query)
81
83
  end
82
84
 
83
85
  def self.ransackable_attributes(auth_object = nil)
@@ -111,6 +113,12 @@ class Article < ActiveRecord::Base
111
113
  end
112
114
  end
113
115
 
116
+ class Recommendation < ActiveRecord::Base
117
+ belongs_to :person
118
+ belongs_to :target_person, class_name: 'Person'
119
+ belongs_to :article
120
+ end
121
+
114
122
  module Namespace
115
123
  class Article < ::Article
116
124
 
@@ -159,33 +167,38 @@ module Schema
159
167
  end
160
168
 
161
169
  create_table :articles, :force => true do |t|
162
- t.integer :person_id
163
- t.string :title
164
- t.text :subject_header
165
- t.text :body
170
+ t.integer :person_id
171
+ t.string :title
172
+ t.text :subject_header
173
+ t.text :body
166
174
  end
167
175
 
168
176
  create_table :comments, :force => true do |t|
169
- t.integer :article_id
170
- t.integer :person_id
171
- t.text :body
177
+ t.integer :article_id
178
+ t.integer :person_id
179
+ t.text :body
172
180
  end
173
181
 
174
182
  create_table :tags, :force => true do |t|
175
- t.string :name
183
+ t.string :name
176
184
  end
177
185
 
178
186
  create_table :articles_tags, :force => true, :id => false do |t|
179
- t.integer :article_id
180
- t.integer :tag_id
187
+ t.integer :article_id
188
+ t.integer :tag_id
181
189
  end
182
190
 
183
191
  create_table :notes, :force => true do |t|
184
- t.integer :notable_id
185
- t.string :notable_type
186
- t.string :note
192
+ t.integer :notable_id
193
+ t.string :notable_type
194
+ t.string :note
187
195
  end
188
196
 
197
+ create_table :recommendations, :force => true do |t|
198
+ t.integer :person_id
199
+ t.integer :target_person_id
200
+ t.integer :article_id
201
+ end
189
202
  end
190
203
 
191
204
  10.times do
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.4
4
+ version: 1.6.5
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-03-20 00:00:00.000000000 Z
13
+ date: 2015-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: actionpack