searchgasm 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.rdoc +11 -0
  2. data/Manifest +12 -3
  3. data/README.rdoc +11 -0
  4. data/TODO.rdoc +4 -1
  5. data/lib/searchgasm/active_record/associations.rb +25 -14
  6. data/lib/searchgasm/active_record/base.rb +49 -0
  7. data/lib/searchgasm/active_record/connection_adapters/mysql_adapter.rb +20 -0
  8. data/lib/searchgasm/active_record/connection_adapters/postgresql_adapter.rb +20 -0
  9. data/lib/searchgasm/active_record/connection_adapters/sqlite_adapter.rb +21 -0
  10. data/lib/searchgasm/condition/base.rb +31 -10
  11. data/lib/searchgasm/condition/inclusive_descendant_of.rb +1 -1
  12. data/lib/searchgasm/condition/not_begin_with.rb +1 -1
  13. data/lib/searchgasm/condition/not_blank.rb +17 -0
  14. data/lib/searchgasm/condition/not_end_with.rb +1 -1
  15. data/lib/searchgasm/condition/not_equal.rb +1 -1
  16. data/lib/searchgasm/condition/not_have_keywords.rb +1 -1
  17. data/lib/searchgasm/condition/not_like.rb +1 -1
  18. data/lib/searchgasm/condition/not_nil.rb +17 -0
  19. data/lib/searchgasm/condition/sibling_of.rb +1 -1
  20. data/lib/searchgasm/conditions/base.rb +9 -7
  21. data/lib/searchgasm/conditions/protection.rb +1 -1
  22. data/lib/searchgasm/helpers/control_types/select.rb +1 -1
  23. data/lib/searchgasm/helpers/utilities.rb +1 -1
  24. data/lib/searchgasm/modifiers/lower.rb +15 -0
  25. data/lib/searchgasm/modifiers/ltrim.rb +15 -0
  26. data/lib/searchgasm/modifiers/rtrim.rb +15 -0
  27. data/lib/searchgasm/modifiers/trim.rb +15 -0
  28. data/lib/searchgasm/modifiers/upper.rb +15 -0
  29. data/lib/searchgasm/search/base.rb +44 -40
  30. data/lib/searchgasm/search/conditions.rb +0 -16
  31. data/lib/searchgasm/search/ordering.rb +0 -8
  32. data/lib/searchgasm/search/searching.rb +0 -6
  33. data/lib/searchgasm/version.rb +2 -2
  34. data/lib/searchgasm.rb +2 -2
  35. data/searchgasm.gemspec +22 -6
  36. data/test/fixtures/cats.yml +3 -0
  37. data/test/fixtures/dogs.yml +3 -0
  38. data/test/test_active_record_base.rb +4 -0
  39. data/test/test_condition_base.rb +4 -4
  40. data/test/test_condition_types.rb +27 -27
  41. data/test/test_conditions_base.rb +22 -1
  42. data/test/test_helper.rb +24 -5
  43. data/test/test_search_base.rb +12 -19
  44. data/test/test_search_conditions.rb +1 -11
  45. data/test/test_search_ordering.rb +3 -4
  46. data/{test/libs → test_libs}/acts_as_tree.rb +0 -0
  47. data/{test/libs → test_libs}/ordered_hash.rb +0 -0
  48. data/{test/libs → test_libs}/rexml_fix.rb +0 -0
  49. metadata +21 -5
@@ -30,7 +30,7 @@ class TestSearchBase < Test::Unit::TestCase
30
30
  def test_setting_first_level_options
31
31
  search = Account.new_search!(:include => :users, :joins => :users, :offset => 5, :limit => 20, :order => "name ASC", :select => "name", :readonly => true, :group => "name", :from => "accounts", :lock => true)
32
32
  assert_equal :users, search.include
33
- assert_equal " LEFT OUTER JOIN \"users\" ON users.account_id = accounts.id ", search.joins
33
+ assert_equal :users, search.joins
34
34
  assert_equal 5, search.offset
35
35
  assert_equal 20, search.limit
36
36
  assert_equal "name ASC", search.order
@@ -98,7 +98,7 @@ class TestSearchBase < Test::Unit::TestCase
98
98
  search.lock = true
99
99
  assert_equal search.lock, true
100
100
  end
101
-
101
+ =begin
102
102
  def test_auto_joins
103
103
  search = Account.new_search
104
104
  assert_equal nil, search.auto_joins
@@ -114,7 +114,7 @@ class TestSearchBase < Test::Unit::TestCase
114
114
  search.conditions.reset_users!
115
115
  assert_equal nil, search.auto_joins
116
116
  end
117
-
117
+ =end
118
118
  def test_limit
119
119
  search = Account.new_search
120
120
  search.limit = 10
@@ -141,7 +141,7 @@ class TestSearchBase < Test::Unit::TestCase
141
141
  search.conditions.users.id_greater_than = 2
142
142
  search.page = 3
143
143
  search.readonly = true
144
- assert_equal({:joins => " LEFT OUTER JOIN \"users\" ON users.account_id = accounts.id ", :offset => 4, :readonly => true, :conditions => ["(\"accounts\".\"name\" LIKE ?) AND (\"users\".\"id\" > ?)", "%Binary%", 2], :limit => 2 }, search.sanitize)
144
+ assert_equal({:joins => :users, :offset => 4, :readonly => true, :conditions => ["(\"accounts\".\"name\" LIKE ?) AND (\"users\".\"id\" > ?)", "%Binary%", 2], :limit => 2 }, search.sanitize)
145
145
  end
146
146
 
147
147
  def test_scope
@@ -186,7 +186,10 @@ class TestSearchBase < Test::Unit::TestCase
186
186
  search.select = "id, name"
187
187
  assert_equal Account.all, search.all
188
188
 
189
- assert_equal [Account.find(1)], Account.scope1.new_search(:conditions => {:users => {:first_name_starts_with => "Ben"}}).all
189
+ search = Account.scope1.new_search!(:conditions => {:users => {:first_name_starts_with => "Ben"}})
190
+ assert_equal [Account.find(1)], search.all
191
+ search2 = search.dup
192
+ assert_equal [Account.find(1)], search2.all
190
193
  end
191
194
 
192
195
  def test_calculations
@@ -213,22 +216,12 @@ class TestSearchBase < Test::Unit::TestCase
213
216
  assert_equal 1, search.count
214
217
  end
215
218
 
216
- def test_method_creation_in_scope
217
- # test ot make sure methods are not created across the board for all models
218
- end
219
-
220
- =begin
221
- # AR desont handle this problem either
222
- def test_specifying_includes
223
- search = Account.new_search
224
- search.include = :users
225
- search.conditions.users.first_name_like = "Ben"
226
- assert_nothing_raised { search.all }
227
- end
228
- =end
229
-
230
219
  def test_inspect
231
220
  search = Account.new_search
232
221
  assert_nothing_raised { search.inspect }
233
222
  end
223
+
224
+ def test_sti
225
+
226
+ end
234
227
  end
@@ -12,17 +12,7 @@ class TestSearchConditions < Test::Unit::TestCase
12
12
  search = Account.new_search(:conditions => {:name_like => "Ben"})
13
13
  assert_equal({:name_like => "Ben"}, search.conditions.conditions)
14
14
  end
15
-
16
- def test_auto_joins
17
- search = Account.new_search
18
- search.conditions = {:name_like => "Binary"}
19
- assert_equal nil, search.auto_joins
20
- search.conditions.users.first_name_like = "Ben"
21
- assert_equal :users, search.auto_joins
22
- search.conditions.reset_users!
23
- assert_equal nil, search.auto_joins
24
- end
25
-
15
+
26
16
  def test_sanitize
27
17
  # This is tested in test_search_base
28
18
  end
@@ -99,7 +99,7 @@ class TestSearchOrdering < Test::Unit::TestCase
99
99
 
100
100
  assert_raise(ArgumentError) { search.order_as = "awesome" }
101
101
  end
102
-
102
+
103
103
  def test_order_by_auto_joins
104
104
  search = Account.new_search
105
105
  assert_equal nil, search.order_by_auto_joins
@@ -113,9 +113,8 @@ class TestSearchOrdering < Test::Unit::TestCase
113
113
  assert_equal [:users, :orders, {:users => :user_groups}], search.order_by_auto_joins
114
114
  search.priority_order_by = {:users => {:orders => :total}}
115
115
  assert_equal({:users => :orders}, search.priority_order_by_auto_joins)
116
- assert_equal [:users, :orders, {:users => :user_groups}, {:users => :orders}], search.auto_joins
117
116
  end
118
-
117
+
119
118
  def test_priority_order_by
120
119
  search = Account.new_search
121
120
  assert_equal nil, search.priority_order
@@ -159,7 +158,7 @@ class TestSearchOrdering < Test::Unit::TestCase
159
158
  end
160
159
 
161
160
  def test_ordering_includes_blank
162
- search = User.new_search
161
+ search = User.new_search!
163
162
  search.order_by = {:account => :name}
164
163
  assert_equal 4, search.count
165
164
  end
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchgasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-08 00:00:00 -04:00
12
+ date: 2008-10-15 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,10 +71,12 @@ extra_rdoc_files:
71
71
  - lib/searchgasm/condition/like.rb
72
72
  - lib/searchgasm/condition/nil.rb
73
73
  - lib/searchgasm/condition/not_begin_with.rb
74
+ - lib/searchgasm/condition/not_blank.rb
74
75
  - lib/searchgasm/condition/not_end_with.rb
75
76
  - lib/searchgasm/condition/not_equal.rb
76
77
  - lib/searchgasm/condition/not_have_keywords.rb
77
78
  - lib/searchgasm/condition/not_like.rb
79
+ - lib/searchgasm/condition/not_nil.rb
78
80
  - lib/searchgasm/condition/sibling_of.rb
79
81
  - lib/searchgasm/condition/tree.rb
80
82
  - lib/searchgasm/conditions/base.rb
@@ -109,6 +111,8 @@ extra_rdoc_files:
109
111
  - lib/searchgasm/modifiers/log.rb
110
112
  - lib/searchgasm/modifiers/log10.rb
111
113
  - lib/searchgasm/modifiers/log2.rb
114
+ - lib/searchgasm/modifiers/lower.rb
115
+ - lib/searchgasm/modifiers/ltrim.rb
112
116
  - lib/searchgasm/modifiers/md5.rb
113
117
  - lib/searchgasm/modifiers/microseconds.rb
114
118
  - lib/searchgasm/modifiers/milliseconds.rb
@@ -117,11 +121,14 @@ extra_rdoc_files:
117
121
  - lib/searchgasm/modifiers/octal.rb
118
122
  - lib/searchgasm/modifiers/radians.rb
119
123
  - lib/searchgasm/modifiers/round.rb
124
+ - lib/searchgasm/modifiers/rtrim.rb
120
125
  - lib/searchgasm/modifiers/second.rb
121
126
  - lib/searchgasm/modifiers/sign.rb
122
127
  - lib/searchgasm/modifiers/sin.rb
123
128
  - lib/searchgasm/modifiers/square_root.rb
124
129
  - lib/searchgasm/modifiers/tan.rb
130
+ - lib/searchgasm/modifiers/trim.rb
131
+ - lib/searchgasm/modifiers/upper.rb
125
132
  - lib/searchgasm/modifiers/week.rb
126
133
  - lib/searchgasm/modifiers/year.rb
127
134
  - lib/searchgasm/search/base.rb
@@ -161,10 +168,12 @@ files:
161
168
  - lib/searchgasm/condition/like.rb
162
169
  - lib/searchgasm/condition/nil.rb
163
170
  - lib/searchgasm/condition/not_begin_with.rb
171
+ - lib/searchgasm/condition/not_blank.rb
164
172
  - lib/searchgasm/condition/not_end_with.rb
165
173
  - lib/searchgasm/condition/not_equal.rb
166
174
  - lib/searchgasm/condition/not_have_keywords.rb
167
175
  - lib/searchgasm/condition/not_like.rb
176
+ - lib/searchgasm/condition/not_nil.rb
168
177
  - lib/searchgasm/condition/sibling_of.rb
169
178
  - lib/searchgasm/condition/tree.rb
170
179
  - lib/searchgasm/conditions/base.rb
@@ -199,6 +208,8 @@ files:
199
208
  - lib/searchgasm/modifiers/log.rb
200
209
  - lib/searchgasm/modifiers/log10.rb
201
210
  - lib/searchgasm/modifiers/log2.rb
211
+ - lib/searchgasm/modifiers/lower.rb
212
+ - lib/searchgasm/modifiers/ltrim.rb
202
213
  - lib/searchgasm/modifiers/md5.rb
203
214
  - lib/searchgasm/modifiers/microseconds.rb
204
215
  - lib/searchgasm/modifiers/milliseconds.rb
@@ -207,11 +218,14 @@ files:
207
218
  - lib/searchgasm/modifiers/octal.rb
208
219
  - lib/searchgasm/modifiers/radians.rb
209
220
  - lib/searchgasm/modifiers/round.rb
221
+ - lib/searchgasm/modifiers/rtrim.rb
210
222
  - lib/searchgasm/modifiers/second.rb
211
223
  - lib/searchgasm/modifiers/sign.rb
212
224
  - lib/searchgasm/modifiers/sin.rb
213
225
  - lib/searchgasm/modifiers/square_root.rb
214
226
  - lib/searchgasm/modifiers/tan.rb
227
+ - lib/searchgasm/modifiers/trim.rb
228
+ - lib/searchgasm/modifiers/upper.rb
215
229
  - lib/searchgasm/modifiers/week.rb
216
230
  - lib/searchgasm/modifiers/year.rb
217
231
  - lib/searchgasm/search/base.rb
@@ -229,12 +243,11 @@ files:
229
243
  - Rakefile
230
244
  - README.rdoc
231
245
  - test/fixtures/accounts.yml
246
+ - test/fixtures/cats.yml
247
+ - test/fixtures/dogs.yml
232
248
  - test/fixtures/orders.yml
233
249
  - test/fixtures/user_groups.yml
234
250
  - test/fixtures/users.yml
235
- - test/libs/acts_as_tree.rb
236
- - test/libs/ordered_hash.rb
237
- - test/libs/rexml_fix.rb
238
251
  - test/test_active_record_associations.rb
239
252
  - test/test_active_record_base.rb
240
253
  - test/test_condition_base.rb
@@ -248,6 +261,9 @@ files:
248
261
  - test/test_search_ordering.rb
249
262
  - test/test_search_pagination.rb
250
263
  - test/test_search_protection.rb
264
+ - test_libs/acts_as_tree.rb
265
+ - test_libs/ordered_hash.rb
266
+ - test_libs/rexml_fix.rb
251
267
  - TODO.rdoc
252
268
  - searchgasm.gemspec
253
269
  has_rdoc: true