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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -11
- data/CHANGELOG.md +50 -10
- data/CONTRIBUTING.md +29 -18
- data/README.md +9 -31
- data/lib/ransack/adapters/active_record/context.rb +22 -17
- data/lib/ransack/adapters/active_record/ransack/context.rb +1 -1
- data/lib/ransack/predicate.rb +2 -2
- data/lib/ransack/translate.rb +0 -5
- data/lib/ransack/version.rb +1 -1
- data/spec/mongoid/configuration_spec.rb +36 -0
- data/spec/ransack/adapters/active_record/base_spec.rb +7 -6
- data/spec/ransack/configuration_spec.rb +36 -0
- data/spec/ransack/helpers/form_helper_spec.rb +65 -58
- data/spec/ransack/search_spec.rb +134 -104
- data/spec/spec_helper.rb +3 -4
- data/spec/support/schema.rb +36 -23
- metadata +2 -2
data/spec/spec_helper.rb
CHANGED
@@ -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
|
-
|
34
|
-
|
35
|
-
|
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
|
|
data/spec/support/schema.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
|
3
|
-
case ENV['DB']
|
4
|
-
when
|
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
|
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
|
-
|
16
|
+
# username: 'postgres', # Uncomment the username option if you have set one
|
15
17
|
min_messages: 'warning'
|
16
18
|
)
|
17
19
|
else
|
18
|
-
#
|
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 :
|
71
|
-
|
72
|
-
|
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
|
78
|
+
AND LENGTH(articles.body) BETWEEN #{min} AND #{max}
|
77
79
|
GROUP BY articles.person_id
|
78
80
|
)
|
79
81
|
SQL
|
80
|
-
Arel.sql(
|
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
|
163
|
-
t.string
|
164
|
-
t.text
|
165
|
-
t.text
|
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
|
170
|
-
t.integer
|
171
|
-
t.text
|
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
|
183
|
+
t.string :name
|
176
184
|
end
|
177
185
|
|
178
186
|
create_table :articles_tags, :force => true, :id => false do |t|
|
179
|
-
t.integer
|
180
|
-
t.integer
|
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
|
185
|
-
t.string
|
186
|
-
t.string
|
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
|
+
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-
|
13
|
+
date: 2015-03-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: actionpack
|