admin_data 1.0.11 → 1.0.12

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.
Files changed (67) hide show
  1. data/README.md +25 -0
  2. data/app/controllers/admin_data/base_controller.rb +2 -7
  3. data/app/views/admin_data/main/edit.html.erb +1 -2
  4. data/app/views/admin_data/main/misc/_form.html.erb +9 -2
  5. data/app/views/admin_data/shared/_drop_down_klasses.html.erb +1 -1
  6. data/app/views/admin_data/shared/_powered_by.html.erb +3 -20
  7. data/lib/admin_data/helpers.rb +1 -1
  8. data/lib/admin_data/version.rb +1 -1
  9. data/lib/js/vendor/{code.jquery.com jquery-1.4.2.js → jquery-1.4.2.js} +0 -0
  10. metadata +9 -110
  11. data/README.textile +0 -21
  12. data/lib/js/vendor/jquery.lint.js +0 -604
  13. data/test/factories/article.rb +0 -9
  14. data/test/factories/car.rb +0 -4
  15. data/test/factories/city.rb +0 -4
  16. data/test/factories/comment.rb +0 -6
  17. data/test/factories/door.rb +0 -4
  18. data/test/factories/engine.rb +0 -4
  19. data/test/functional/base_controller_test.rb +0 -5
  20. data/test/functional/feed_controller_test.rb +0 -45
  21. data/test/functional/main_controller_authorization_test.rb +0 -91
  22. data/test/functional/main_controller_test.rb +0 -418
  23. data/test/functional/migration_controller_test.rb +0 -39
  24. data/test/functional/routes_test.rb +0 -59
  25. data/test/functional/search_controller_authorization_test.rb +0 -77
  26. data/test/functional/search_controller_test.rb +0 -811
  27. data/test/helper/view_helper_test.rb +0 -177
  28. data/test/misc_tests/date_validation_test.rb +0 -32
  29. data/test/misc_tests/settings_test.rb +0 -29
  30. data/test/misc_tests/util_test.rb +0 -83
  31. data/test/rails_root/Gemfile +0 -22
  32. data/test/rails_root/Gemfile.lock +0 -101
  33. data/test/rails_root/Rakefile +0 -7
  34. data/test/rails_root/app/controllers/application_controller.rb +0 -3
  35. data/test/rails_root/app/helpers/application_helper.rb +0 -2
  36. data/test/rails_root/app/models/article.rb +0 -25
  37. data/test/rails_root/app/models/city.rb +0 -15
  38. data/test/rails_root/app/models/comment.rb +0 -13
  39. data/test/rails_root/app/models/tech_magazine.rb +0 -2
  40. data/test/rails_root/app/models/vehicle/car.rb +0 -4
  41. data/test/rails_root/app/models/vehicle/door.rb +0 -3
  42. data/test/rails_root/app/models/vehicle/engine.rb +0 -3
  43. data/test/rails_root/app/views/layouts/application.html.erb +0 -14
  44. data/test/rails_root/config/application.rb +0 -42
  45. data/test/rails_root/config/boot.rb +0 -13
  46. data/test/rails_root/config/database.yml +0 -22
  47. data/test/rails_root/config/environment.rb +0 -5
  48. data/test/rails_root/config/environments/development.rb +0 -22
  49. data/test/rails_root/config/environments/production.rb +0 -49
  50. data/test/rails_root/config/environments/test.rb +0 -35
  51. data/test/rails_root/config/initializers/backtrace_silencers.rb +0 -7
  52. data/test/rails_root/config/initializers/inflections.rb +0 -10
  53. data/test/rails_root/config/initializers/mime_types.rb +0 -5
  54. data/test/rails_root/config/initializers/secret_token.rb +0 -7
  55. data/test/rails_root/config/initializers/session_store.rb +0 -8
  56. data/test/rails_root/config/locales/en.yml +0 -5
  57. data/test/rails_root/config/routes.rb +0 -58
  58. data/test/rails_root/config.ru +0 -4
  59. data/test/rails_root/db/migrate/20090809061114_create_tables.rb +0 -70
  60. data/test/rails_root/db/schema.rb +0 -74
  61. data/test/rails_root/db/seeds.rb +0 -7
  62. data/test/rails_root/db/test.sqlite3 +0 -0
  63. data/test/rails_root/script/rails +0 -6
  64. data/test/rails_root/test/performance/browsing_test.rb +0 -0
  65. data/test/rails_root/test/test_helper.rb +0 -13
  66. data/test/support/assertions.rb +0 -20
  67. data/test/test_helper.rb +0 -76
@@ -1,811 +0,0 @@
1
- require 'test_helper'
2
-
3
- pwd = File.dirname(__FILE__)
4
- f = File.join(pwd, '..', '..', 'app', 'views')
5
- AdminData::MainController.prepend_view_path(f)
6
- AdminData::SearchController.prepend_view_path(f)
7
-
8
- class AdminData::SearchControllerTest < ActionController::TestCase
9
-
10
- def setup
11
- AdminData::Config.set = { :adapter_name => ActiveRecord::Base.connection.adapter_name }
12
- @controller = AdminData::SearchController.new
13
- @request = ActionController::TestRequest.new
14
- @response = ActionController::TestResponse.new
15
- @article = Factory(:article)
16
- @car = Factory(:car, :year => 2000, :brand => 'bmw')
17
- grant_read_only_access
18
- end
19
-
20
- context 'GET quick_search' do
21
- context 'GET quick_search with wrong children class' do
22
- setup do
23
- get :quick_search, { :base => 'article',
24
- :klass => 'comment',
25
- :model_id => @article.id,
26
- :children => 'wrong_children_name' }
27
- end
28
- should_respond_with :not_found
29
- end
30
-
31
- context 'with no klass param' do
32
- setup do
33
- assert_raises ActionController::RoutingError do
34
- get :quick_search
35
- end
36
- end
37
- end
38
-
39
- context 'with no search query' do
40
- setup do
41
- get :quick_search, {:klass => Article.name.underscore}
42
- end
43
- should_respond_with :success
44
- should_assign_to :records
45
- end
46
- context 'with has_many association' do
47
- context 'for a nested model' do
48
- setup do
49
- Vehicle::Door.delete_all
50
- @door1 = Factory(:door, :color => 'black', :car => @car)
51
- @door2 = Factory(:door, :color => 'green', :car => @car)
52
- get :quick_search, { :klass => @door1.class.name.underscore,
53
- :base => @car.class.name.underscore,
54
- :model_id => @car.id,
55
- :children => 'doors'}
56
- end
57
- #should_respond_with :success
58
- #should_assign_to :records
59
- #should 'have 2 records' do
60
- #assert_equal 2, assigns(:records).size
61
- #end
62
- #should 'have 2 as total number of children' do
63
- #assert_equal 2, assigns(:total_num_of_children)
64
- #end
65
- #should 'contain text' do
66
- #assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /has 2/m)
67
- #end
68
- end
69
-
70
- context 'for a standard model' do
71
- setup do
72
- @comment1 = Factory(:comment, :article => @article)
73
- @comment2 = Factory(:comment, :article => @article)
74
- get :quick_search, { :klass => Comment.name.underscore,
75
- :base => 'article',
76
- :model_id => @article.id.to_s,
77
- :children => 'comments' }
78
- end
79
- should_respond_with :success
80
- should_assign_to :records
81
- should 'have 2 records' do
82
- assert_equal 2, assigns(:records).size
83
- end
84
- should 'contain text' do
85
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /has 2 comments/ )
86
- end
87
- end
88
- end
89
- end
90
-
91
-
92
- context 'GET quick_search' do
93
- context 'for a standard model' do
94
- setup do
95
- @comment = Factory(:comment)
96
- @comment = Factory(:comment)
97
- get :quick_search, {:klass => @comment.class.name.underscore}
98
- end
99
- should_respond_with :success
100
- should 'contain valid link at header breadcrum' do
101
- assert_tag( :tag => 'div', :attributes => {:class => 'breadcrum rounded'},
102
- :descendant => {:tag => 'a',
103
- :attributes => {:href => '/admin_data/quick_search/comment'}})
104
- end
105
- should 'contain proper link at table listing' do
106
- url = "/admin_data/klass/comment/#{Comment.last.id}"
107
- assert_tag( :tag => 'td', :descendant => {:tag => 'a', :attributes => {:href => url}})
108
- end
109
- end
110
-
111
- context 'for a nested model' do
112
- setup do
113
- get :quick_search, {:klass => @car.class.name.underscore}
114
- end
115
- #should_respond_with :success
116
- #should 'contain proper link at header breadcum' do
117
- #s = CGI.escape('vehicle/car')
118
- #assert_tag( :tag => 'div',
119
- #:attributes => {:class => 'breadcrum rounded'},
120
- #:descendant => {:tag => 'a', :attributes => {:href => "/admin_data/quick_search/#{s}" }})
121
- #end
122
- #should 'contain proper link at table listing' do
123
- #s = CGI.escape("vehicle/car")
124
- #url = "/admin_data/klass/#{s}/#{@car.class.last.id}"
125
- #assert_tag(:tag => 'td', :descendant => {:tag => 'a', :attributes => {:href => url}})
126
- #end
127
- #should 'have proper action name for search form' do
128
- #url = admin_data_search_path(:klass=>Vehicle::Car)
129
- #assert_tag( :tag => 'form', :attributes => {:action => url})
130
- #end
131
- end
132
- end
133
-
134
- context 'GET quick_search with search term' do
135
- setup do
136
- Article.delete_all
137
- @python_beginner_book = Factory(:article, :title => 'python for beginners')
138
- @python_book = Factory(:article, :title => 'python')
139
- @java_book = Factory(:article, :title => 'java')
140
- @clojure_book = Factory(:article, :title => 'clojure')
141
- end
142
- context 'with default order' do
143
- setup do
144
- get :quick_search, {:klass => 'Article', :query => 'python'}
145
- end
146
- should_respond_with :success
147
- should_assign_to :records
148
- should 'have only two records' do
149
- assert_equal 2, assigns(:records).size
150
- end
151
- should 'have python beginner book as the first book' do
152
- assert_equal @python_beginner_book.id, assigns(:records).last.id
153
- end
154
- should 'have python book as the last book' do
155
- assert_equal @python_book.id, assigns(:records).first.id
156
- end
157
- end
158
-
159
- context 'with article_id ascending order' do
160
- setup do
161
- get :quick_search, { :klass => 'Article', :query => 'python', :sortby => 'article_id asc'}
162
- end
163
- should_respond_with :success
164
- should_assign_to :records
165
- should 'have only two records' do
166
- assert_equal 2, assigns(:records).size
167
- end
168
- should 'have python beginner book as the first book' do
169
- assert_equal @python_beginner_book.id, assigns(:records).first.id
170
- end
171
- should 'have python book as the last book' do
172
- assert_equal @python_book.id, assigns(:records).last.id
173
- end
174
- end
175
- end
176
-
177
- context 'GET advance_search' do
178
- context 'with no klass param' do
179
- setup do
180
- assert_raises ActionController::RoutingError do
181
- get :advance_search
182
- end
183
- end
184
- end
185
-
186
- context 'with klass param' do
187
- setup do
188
- get :advance_search, {:klass => Article.name.underscore}
189
- end
190
- should_respond_with :success
191
- should_not_assign_to :records
192
- should 'have proper action for advance search form' do
193
- url = admin_data_advance_search_path(:klass => Article)
194
- assert_tag( :tag => 'form', :attributes => {:action => url})
195
- end
196
- end
197
- end
198
-
199
-
200
- context 'xhr advance_search with does_not_contain first one' do
201
- setup do
202
- Article.delete_all
203
- AdminData::Config.set = ({ :is_allowed_to_update => lambda {|controller| return false} })
204
- Factory(:article, :short_desc => 'ruby')
205
- Factory(:article, :short_desc => 'rails')
206
- Factory(:article, :short_desc => nil)
207
- xml_http_request :post,
208
- :advance_search,
209
- { :klass => Article.name.underscore,
210
- :sortby => 'article_id desc',
211
- :adv_search => {'1_row' => {:col1 => 'short_desc',
212
- :col2 => 'does_not_contain',
213
- :col3 => 'ruby'} } }
214
- end
215
- should_respond_with :success
216
- should 'contain text' do
217
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 2 records found/ )
218
- end
219
- should 'not contain delete all link' do
220
- assert_no_tag( :tag => 'a', :attributes => {:id => 'advance_search_delete_all'})
221
- end
222
- should 'not contain destroy all link' do
223
- assert_no_tag( :tag => 'a', :attributes => {:id => 'advance_search_destroy_all'})
224
- end
225
- end
226
-
227
- context 'xhr advance_search with delete_all action' do
228
- setup do
229
- Article.delete_all
230
- AdminData::Config.set = ({ :is_allowed_to_update => lambda {|controller| return true} })
231
- Factory(:article, :short_desc => 'ruby')
232
- Factory(:article, :short_desc => 'rails')
233
- so = {'1_row' => {:col1 => 'short_desc', :col2 => 'contains', :col3 => 'ruby'} }
234
- h = { :klass => Article.name.underscore,
235
- :sortby => 'article_id desc',
236
- :admin_data_advance_search_action_type => 'delete',
237
- :adv_search => so }
238
- xml_http_request :post, :advance_search, h
239
- @json = JSON.parse(@response.body)
240
- end
241
- should_respond_with :success
242
- should 'have only one record' do
243
- assert_equal 1, Article.count
244
- end
245
- should 'have success key in the response message' do
246
- assert @json.has_key?('success')
247
- end
248
- should 'have success message in the response message' do
249
- assert_equal '1 record deleted', @json.fetch('success')
250
- end
251
- end
252
-
253
- context 'xhr advance_search with destroy_all action' do
254
- setup do
255
- Article.delete_all
256
- AdminData::Config.set = ({ :is_allowed_to_update => lambda {|controller| return true} })
257
- Factory(:article, :short_desc => 'ruby')
258
- Factory(:article, :short_desc => 'rails')
259
- xml_http_request :post,
260
- :advance_search,
261
- {:klass => Article.name.underscore,
262
- :sortby => 'article_id desc',
263
- :admin_data_advance_search_action_type => 'destroy',
264
- :adv_search => {'1_row' => {:col1 => 'short_desc', :col2 => 'contains', :col3 => 'ruby'} } }
265
- @json = JSON.parse(@response.body)
266
- end
267
- should_respond_with :success
268
- should 'have only one record' do
269
- assert_equal 1, Article.count
270
- end
271
- should 'have success key in the response message' do
272
- assert @json.has_key?('success')
273
- end
274
- should 'have success message in the response message' do
275
- assert_equal '1 record destroyed', @json.fetch('success')
276
- end
277
- end
278
-
279
- context 'xhr advance_search with does_not_contain' do
280
- setup do
281
- AdminData::Config.set = ({ :is_allowed_to_update => lambda {|controller| return true } })
282
- Article.delete_all
283
- Factory(:article, :short_desc => 'ruby')
284
- Factory(:article, :short_desc => 'rails')
285
- Factory(:article, :short_desc => nil)
286
- xml_http_request :post,
287
- :advance_search,
288
- {:klass => Article.name.underscore,
289
- :sortby => 'article_id desc',
290
- :adv_search => {'1_row' => {:col1 => 'short_desc',
291
- :col2 => 'does_not_contain',
292
- :col3 => 'ruby'} } }
293
- end
294
- should_respond_with :success
295
- should 'contain search result' do
296
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 2 records found/ )
297
- end
298
- should 'contain delete all link' do
299
- assert_tag( :tag => 'a', :attributes => {:id => 'advance_search_delete_all'})
300
- end
301
- should 'contain destroy all link' do
302
- assert_tag( :tag => 'a', :attributes => {:id => 'advance_search_destroy_all'})
303
- end
304
- end
305
-
306
- context 'xhr advance_search with contains option with 2 records' do
307
- setup do
308
- Article.delete_all
309
- @python_book = Factory(:article, :title => 'python')
310
- @python_beginner_book = Factory(:article, :title => 'python for beginners')
311
- @java_book = Factory(:article, :title => 'java')
312
- @clojure_book = Factory(:article, :title => 'clojure')
313
- xml_http_request :post,
314
- :advance_search,
315
- {:klass => Article.name.underscore,
316
- :sortby => 'article_id desc',
317
- :adv_search => {'1_row' => {:col1 => 'title', :col2 => 'contains', :col3 => 'python'} } }
318
- end
319
- should_respond_with :success
320
- should 'contain text' do
321
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 2 records found/ )
322
- end
323
- end
324
-
325
- context 'xhr advance_search with 1 result' do
326
- setup do
327
- Article.delete_all
328
- @python_book = Factory(:article, :title => 'python')
329
- @python_beginner_book = Factory(:article, :title => 'python for beginners')
330
- @java_book = Factory(:article, :title => 'java')
331
- @clojure_book = Factory(:article, :title => 'clojure')
332
- xml_http_request :post,
333
- :advance_search,
334
- { :klass => Article.name.underscore,
335
- :sortby => 'article_id desc',
336
- :adv_search => {'1_row' => {:col1 => 'title', :col2 => 'contains', :col3 => 'clojure'} } }
337
- end
338
- should_respond_with :success
339
- should 'contain text' do
340
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 1 record found/ )
341
- end
342
- end
343
-
344
- context 'xhr advance_search with empty query term with contains option' do
345
- setup do
346
- Article.delete_all
347
- @python_book = Factory(:article, :title => 'python')
348
- @python_beginner_book = Factory(:article, :title => 'python for beginners')
349
- @java_book = Factory(:article, :title => 'java')
350
- @clojure_book = Factory(:article, :title => 'clojure')
351
- xml_http_request :post,
352
- :advance_search,
353
- { :klass => Article.name.underscore,
354
- :sortby => 'article_id desc',
355
- :adv_search => {'1_row' => {:col1 => 'title', :col2 => 'contains', :col3 => ''} } }
356
- end
357
- should_respond_with :success
358
- should 'contain text' do
359
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 4 records found/ )
360
- end
361
- end
362
-
363
- context 'xhr advance_search with empty col2' do
364
- setup do
365
- Article.delete_all
366
- @python_book = Factory(:article, :title => 'python')
367
- @python_beginner_book = Factory(:article, :title => 'python for beginners')
368
- xml_http_request :post,
369
- :advance_search,
370
- { :klass => Article.name.underscore,
371
- :sortby => 'article_id desc',
372
- :adv_search => {'1_row' => {:col1 => 'title', :col2 => nil, :col3 => nil} } }
373
- end
374
- should_respond_with :success
375
- should 'contain text' do
376
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 2 records found/ )
377
- end
378
- end
379
-
380
- context 'xhr advance_search with two search terms' do
381
- setup do
382
- Article.delete_all
383
- @python_book = Factory(:article, :title => 'python')
384
- @python_beginner_book = Factory(:article, :title => 'python for beginners', :body => 'for beginners')
385
- @java_book = Factory(:article, :title => 'java')
386
- @clojure_book = Factory(:article, :title => 'clojure', :body => 'not for beginners')
387
- adv_search = { '1_row' => { :col1 => 'title',
388
- :col2 => 'contains',
389
- :col3 => 'python'},
390
- '2_row' => {:col1 => 'body',
391
- :col2 => 'contains',
392
- :col3 => 'beginners'} }
393
- xml_http_request :post,
394
- :advance_search,
395
- { :klass => Article.name.underscore, :sortby => 'article_id desc', :adv_search => adv_search }
396
- end
397
- should_respond_with :success
398
- should 'contain text' do
399
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 1 record found/ )
400
- end
401
- end
402
-
403
- context 'advance search conditions' do
404
- setup do
405
- @klass = Object.const_get('Article')
406
- @proc = Proc.new do
407
- @controller.send(:build_advance_search_conditions, @klass, { '429440_row' => @hash })
408
- end
409
- end
410
-
411
- context 'with col2 as null' do
412
- should 'have sql as body is not null' do
413
- @hash = { :col1 => 'body', :col2 => 'is_not_null'}
414
- output = @proc.call
415
- expected = %Q{ SELECT "articles".* FROM "articles" WHERE (articles.body IS NOT NULL) }
416
- assert_equal_sql expected, @proc.call[:cond].to_sql
417
- end
418
- end
419
-
420
- context 'with col2 contains' do
421
- should 'have sql with like' do
422
- @hash = { :col1 => 'body', :col2 => 'contains', :col3 => 'python'}
423
- expected = %{ SELECT "articles".* FROM "articles" WHERE (articles.body LIKE '%python%') }
424
- assert_equal_sql expected, @proc.call[:cond].to_sql
425
- end
426
- end
427
-
428
- context 'with col2 as exactly' do
429
- should 'have sql as body equals' do
430
- @hash = { :col1 => 'body', :col2 => 'is_exactly', :col3 => 'python'}
431
- expected = %{ SELECT "articles".* FROM "articles" WHERE (articles.body = 'python') }
432
- assert_equal_sql expected , @proc.call[:cond].to_sql
433
- end
434
- end
435
-
436
- context 'with does not contain' do
437
- should 'have sql as body is null or not like' do
438
- @hash = { :col1 => 'body', :col2 => 'does_not_contain', :col3 => 'python'}
439
- expected = %Q{SELECT "articles".* FROM "articles" WHERE (articles.body IS NULL OR articles.body NOT LIKE '%python%')}
440
- assert_equal_sql expected, @proc.call[:cond].to_sql
441
- end
442
- end
443
-
444
- context 'with col2 as false' do
445
- should 'have sql with body as false' do
446
- @hash = { :col1 => 'body', :col2 => 'is_false', :col3 => 'python'}
447
- expected = %{ SELECT "articles".* FROM "articles" WHERE (articles.body = 'f') }
448
- assert_equal_sql expected, @proc.call[:cond].to_sql
449
- end
450
- end
451
- end
452
-
453
-
454
- context 'XHR advance_search' do
455
- setup do
456
- Article.delete_all
457
- @proc = Proc.new do
458
- @hash_big = { :klass => Article.name.underscore, :adv_search => {'2_row' => @hash } }
459
- end
460
- end
461
- context 'with col2 contains' do
462
- setup do
463
- Factory(:article, :title => 'python')
464
- @hash = {:col1 => 'title', :col2 => 'contains', :col3 => 'python'}
465
- xml_http_request :post, :advance_search, @proc.call
466
- end
467
- should_respond_with :success
468
- should 'contain content' do
469
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
470
- end
471
- end
472
-
473
- context 'with col2 contains with no search result' do
474
- setup do
475
- Factory(:article, :title => 'ruby')
476
- @hash = { :col1 => 'title', :col2 => 'contains', :col3 => 'python'}
477
- xml_http_request :post, :advance_search, @proc.call
478
- end
479
- should 'contain text' do
480
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 0 records found/ )
481
- end
482
- end
483
-
484
- context 'with col2 is_exactly' do
485
- setup do
486
- Factory(:article, :title => 'python')
487
- @hash = { :col1 => 'title', :col2 => 'is_exactly', :col3 => 'python'}
488
- xml_http_request :post, :advance_search, @proc.call
489
- end
490
- should 'contain text' do
491
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
492
- end
493
- end
494
-
495
- context 'with col2 is_exactly negative case' do
496
- setup do
497
- Factory(:article, :title => 'ruby')
498
- @hash = {:col1 => 'title', :col2 => 'is_exactly', :col3 => 'python'}
499
- xml_http_request :post, :advance_search, @proc.call
500
- end
501
- should 'contain text' do
502
- assert_tag( :tag => 'h2', :attributes => { :id => 'search_result_title'}, :content => /Search result: 0 records found/ )
503
- end
504
- end
505
-
506
- context 'with col2 does_not_contain' do
507
- setup do
508
- Factory(:article, :title => 'python')
509
- @hash = {:col1 => 'title', :col2 => 'does_not_contain', :col3 => 'ruby'}
510
- xml_http_request :post, :advance_search, @proc.call
511
- end
512
- should 'contain text' do
513
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
514
- end
515
- end
516
-
517
- context 'with col2 does_not_conatin negative case' do
518
- setup do
519
- Factory(:article, :title => 'ruby')
520
- @hash = {:col1 => 'title', :col2 => 'does_not_contain', :col3 => 'ruby'}
521
- xml_http_request :post, :advance_search, @proc.call
522
- end
523
- should 'contain text' do
524
- assert_tag( :tag => 'h2', :attributes =>{ :class => 'title'}, :content => /Search result: 0 records found/ )
525
- end
526
- end
527
-
528
- context 'with col2 is_false' do
529
- setup do
530
- Factory(:article, :approved => false)
531
- @hash = {:col1 => 'approved', :col2 => 'is_false'}
532
- xml_http_request :post, :advance_search, @proc.call
533
- end
534
- should 'contain text' do
535
- assert_tag( :tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 1 record found/ )
536
- end
537
- end
538
-
539
- context 'with col2 is_false negative case' do
540
- setup do
541
- Factory(:article, :approved => true)
542
- @hash = {:col1 => 'approved', :col2 => 'is_false'}
543
- xml_http_request :post, :advance_search, @proc.call
544
- end
545
- should 'contain text' do
546
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 0 records found/ )
547
- end
548
- end
549
-
550
- context 'with col2 is_true' do
551
- setup do
552
- Factory(:article, :approved => true)
553
- @hash = {:col1 => 'approved', :col2 => 'is_true'}
554
- xml_http_request :post, :advance_search, @proc.call
555
- end
556
- should 'contain text' do
557
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
558
- end
559
- end
560
-
561
- context 'with col2 is_true negative case' do
562
- setup do
563
- Factory(:article, :approved => false)
564
- @hash = {:col1 => 'approved', :col2 => 'is_true'}
565
- xml_http_request :post, :advance_search, @proc.call
566
- end
567
- should 'contain text' do
568
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 0 records found/ )
569
- end
570
- end
571
-
572
- context 'with col2 is_null' do
573
- setup do
574
- Factory(:article, :status => nil)
575
- @hash = {:col1 => 'status', :col2 => 'is_null'}
576
- xml_http_request :post, :advance_search, @proc.call
577
- end
578
- should 'contain text' do
579
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 1 record found/ )
580
- end
581
- end
582
-
583
- context 'with col2 is_null negative case' do
584
- setup do
585
- Factory(:article, :status => 'something')
586
- @hash = {:col1 => 'status', :col2 => 'is_null'}
587
- xml_http_request :post, :advance_search, @proc.call
588
- end
589
- should 'contain text' do
590
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 0 records found/ )
591
- end
592
- end
593
-
594
- context 'with col2 is_not_null' do
595
- setup do
596
- Factory(:article, :status => 'something')
597
- @hash = {:col1 => 'status', :col2 => 'is_not_null'}
598
- xml_http_request :post, :advance_search, @proc.call
599
- end
600
- should 'contain text' do
601
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
602
- end
603
- end
604
-
605
- context 'with col2 is_not_null negative case' do
606
- setup do
607
- Factory(:article, :status => nil)
608
- @hash = {:col1 => 'status', :col2 => 'is_not_null'}
609
- xml_http_request :post, :advance_search, @proc.call
610
- end
611
- should 'contain text' do
612
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 0 records found/ )
613
- end
614
- end
615
-
616
- context 'with col2 is_equal_to' do
617
- setup do
618
- Factory(:article, :hits_count => 100)
619
- @hash = {:col1 => 'hits_count', :col2 => 'is_equal_to', :col3 => 100.to_s}
620
- xml_http_request :post, :advance_search, @proc.call
621
- end
622
- should 'contain text' do
623
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 1 record found/ )
624
- end
625
- end
626
-
627
- context 'with col2 is_equal_to negative case' do
628
- setup do
629
- Factory(:article, :hits_count => 100)
630
- @hash = {:col1 => 'hits_count', :col2 => 'is_equal_to', :col3 => 101.to_s}
631
- xml_http_request :post, :advance_search, @proc.call
632
- end
633
- should 'contain text' do
634
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 0 records found/ )
635
- end
636
- end
637
-
638
- context 'with col2 greater_than' do
639
- setup do
640
- Factory(:article, :hits_count => 100)
641
- @hash = {:col1 => 'hits_count', :col2 => 'greater_than', :col3 => 99.to_s}
642
- xml_http_request :post, :advance_search, @proc.call
643
- end
644
- should 'contain text' do
645
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
646
- end
647
- end
648
-
649
- context 'with col2 greater_than negative case' do
650
- setup do
651
- Factory(:article, :hits_count => 100)
652
- @hash = {:col1 => 'hits_count', :col2 => 'greater_than', :col3 => 101.to_s}
653
- xml_http_request :post, :advance_search, @proc.call
654
- end
655
- should 'contain text' do
656
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 0 records found/ )
657
- end
658
- end
659
-
660
- context 'with col2 less_than' do
661
- setup do
662
- Factory(:article, :hits_count => 100)
663
- @hash = {:col1 => 'hits_count', :col2 => 'less_than', :col3 => 101.to_s}
664
- xml_http_request :post, :advance_search, @proc.call
665
- end
666
- should 'contain text' do
667
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 1 record found/ )
668
- end
669
- end
670
-
671
- context 'with col2 less_than negative case' do
672
- setup do
673
- Factory(:article, :hits_count => 100)
674
- @hash = {:col1 => 'hits_count', :col2 => 'less_than', :col3 => 99.to_s}
675
- xml_http_request :post, :advance_search, @proc.call
676
- end
677
- should 'contain text' do
678
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 0 records found/ )
679
- end
680
- end
681
-
682
- context 'with col2 is_on' do
683
- setup do
684
- Factory(:article, :published_at => Time.now)
685
- d = Time.now.strftime('%d-%B-%Y')
686
- @hash = {:col1 => 'published_at', :col2 => 'is_on', :col3 => d}
687
- xml_http_request :post, :advance_search, @proc.call
688
- end
689
- should 'contain text' do
690
- assert_tag( :tag => 'h2', :attributes =>{ :class => 'title'}, :content => /Search result: 1 record found/ )
691
- end
692
- end
693
-
694
- context 'with col2 is_on negative case' do
695
- setup do
696
- Factory(:article, :published_at => Time.now)
697
- d = 1.year.ago.strftime('%d-%B-%Y')
698
- @hash = {:col1 => 'published_at', :col2 => 'is_on', :col3 => d}
699
- xml_http_request :post, :advance_search, @proc.call
700
- end
701
- should 'contain text' do
702
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 0 records found/ )
703
- end
704
- end
705
-
706
- context 'with col2 is_on_or_after_date' do
707
- setup do
708
- Factory(:article, :published_at => Time.now)
709
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_after_date', :col3 => 1.month.ago.strftime('%d-%B-%Y') }
710
- xml_http_request :post, :advance_search, @proc.call
711
- end
712
- should 'contain text' do
713
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :descendant => /Search result: 1 record found/ )
714
- end
715
- end
716
-
717
- context 'with col2 is_on_or_after_date negative case' do
718
- setup do
719
- Factory(:article, :published_at => Time.now)
720
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_after_date', :col3 => 1.month.from_now.strftime('%d-%B-%Y') }
721
- xml_http_request :post, :advance_search, @proc.call
722
- end
723
- should 'contain text' do
724
- assert_tag( :tag => 'h2', :attributes => { :class => 'title' }, :content => /Search result: 0 records found/ )
725
- end
726
- end
727
-
728
- context 'with col2 is_on_or_before_date' do
729
- setup do
730
- Factory(:article, :published_at => Time.now)
731
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_before_date', :col3 => 1.month.from_now.strftime('%d-%B-%Y') }
732
- xml_http_request :post, :advance_search, @proc.call
733
- end
734
- should 'contain text' do
735
- assert_tag( :tag => 'h2', :attributes => { :class => 'title'}, :content => /Search result: 1 record found/ )
736
- end
737
- end
738
-
739
- context 'with col2 is_on_or_before_date negative case' do
740
- setup do
741
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_before_date', :col3 => 1.year.ago.strftime('%d-%B-%Y') }
742
- xml_http_request :post, :advance_search, @proc.call
743
- end
744
- should 'does contain text' do
745
- assert_tag(:tag => 'h2', :attributes => {:class => 'title'}, :content => /Search result: 0 records found/ )
746
- end
747
- end
748
-
749
- context 'with col2 is_on_or_before_date with invalid_date input' do
750
- setup do
751
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_before_date', :col3 => 'invalid_date'}
752
- xml_http_request :post, :advance_search, @proc.call
753
- end
754
- should 'contain text' do
755
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid date/ )
756
- end
757
- end
758
-
759
- context 'with col2 is_on_or_after_date with invalid_date input' do
760
- setup do
761
- @hash = {:col1 => 'published_at', :col2 => 'is_on_or_after_date', :col3 => 'invalid_date'}
762
- xml_http_request :post, :advance_search, @proc.call
763
- end
764
- should 'contain text' do
765
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid date/ )
766
- end
767
- end
768
-
769
- context 'is_on invalid date' do
770
- setup do
771
- @hash = {:col1 => 'published_at', :col2 => 'is_on', :col3 => 'invalid_date'}
772
- xml_http_request :post, :advance_search, @proc.call
773
- end
774
- should 'contain text' do
775
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid date/ )
776
- end
777
- end
778
-
779
- context 'with col2 is_equal_to with invalid input' do
780
- setup do
781
- @hash = {:col1 => 'hits_count', :col2 => 'is_equal_to', :col3 => 'invalid_integer'}
782
- xml_http_request :post, :advance_search, @proc.call
783
- end
784
- should 'contain text' do
785
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid integer/ )
786
- end
787
- end
788
-
789
- context 'with col2 less_than invalid_integer' do
790
- setup do
791
- @hash = {:col1 => 'hits_count', :col2 => 'less_than', :col3 => 'invalid_integer'}
792
- xml_http_request :post, :advance_search, @proc.call
793
- end
794
- should 'contain text' do
795
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid integer/ )
796
- end
797
- end
798
-
799
- context 'with col2 greater_than invalid integer' do
800
- setup do
801
- @hash = {:col1 => 'hits_count', :col2 => 'greater_than', :col3 => 'invalid_integer'}
802
- xml_http_request :post, :advance_search, @proc.call
803
- end
804
- should 'contain text' do
805
- assert_tag(:tag => 'p', :attributes => {:class => 'error'}, :content => /is not a valid integer/ )
806
- end
807
- end
808
-
809
- end
810
-
811
- end