adva 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/adva.gemspec +3 -0
  3. data/app/assets/config/manifest.js +6 -0
  4. data/app/assets/javascripts/adva_cms/ckeditor.js.erb +12 -0
  5. data/app/assets/javascripts/adva_cms/concat_main_menus.js +13 -0
  6. data/app/assets/javascripts/adva_cms/jquery.table_tree.js +704 -0
  7. data/app/assets/javascripts/adva_cms.js +7 -0
  8. data/app/assets/javascripts/ckeditor/config.js.erb +94 -0
  9. data/app/assets/stylesheets/adva_cms/admin/common.scss +15 -1
  10. data/app/assets/stylesheets/adva_cms/admin/projection.scss +2 -5
  11. data/app/assets/stylesheets/adva_cms/admin/sidebar.scss +30 -9
  12. data/app/assets/stylesheets/adva_cms/admin.scss +1 -1
  13. data/app/controllers/admin/base_controller.rb +10 -24
  14. data/app/controllers/admin/page/articles_controller.rb +8 -27
  15. data/app/controllers/admin/page/categories_controller.rb +6 -9
  16. data/app/controllers/admin/page/links_controller.rb +6 -9
  17. data/app/controllers/admin/sections_controller.rb +7 -9
  18. data/app/controllers/admin/sites_controller.rb +9 -12
  19. data/app/controllers/admin/users_controller.rb +6 -9
  20. data/app/controllers/articles_controller.rb +30 -52
  21. data/app/controllers/base_controller.rb +8 -8
  22. data/app/controllers/password_controller.rb +3 -5
  23. data/app/controllers/session_controller.rb +3 -5
  24. data/app/helpers/activities_helper.rb +9 -20
  25. data/app/helpers/admin/base_helper.rb +4 -22
  26. data/app/helpers/base_helper.rb +1 -1
  27. data/app/helpers/content_helper.rb +7 -5
  28. data/app/helpers/resource_helper.rb +4 -5
  29. data/app/helpers/users_helper.rb +1 -1
  30. data/app/models/activity.rb +3 -0
  31. data/app/models/article.rb +0 -11
  32. data/app/models/category.rb +3 -3
  33. data/app/models/content.rb +10 -39
  34. data/app/models/link.rb +0 -1
  35. data/app/models/password_mailer.rb +6 -9
  36. data/app/models/section.rb +6 -7
  37. data/app/models/site.rb +0 -2
  38. data/app/models/user.rb +1 -2
  39. data/app/views/activity_notifier/new_content_notification.html.erb +5 -5
  40. data/app/views/admin/activities/_activities.html.erb +4 -4
  41. data/app/views/admin/activities/_comment.html.erb +21 -21
  42. data/app/views/admin/activities/_content.html.erb +4 -3
  43. data/app/views/admin/activities/_topic.html.erb +5 -5
  44. data/app/views/admin/install/confirmation.html.erb +3 -3
  45. data/app/views/admin/install/index.html.erb +14 -14
  46. data/app/views/admin/page/articles/_form.html.erb +28 -25
  47. data/app/views/admin/page/articles/_options.html.erb +3 -4
  48. data/app/views/admin/page/articles/edit.html.erb +3 -3
  49. data/app/views/admin/page/articles/new.html.erb +4 -4
  50. data/app/views/admin/page/categories/edit.html.erb +9 -9
  51. data/app/views/admin/page/categories/index.html.erb +16 -16
  52. data/app/views/admin/page/categories/new.html.erb +5 -3
  53. data/app/views/admin/page/contents/index.html.erb +3 -18
  54. data/app/views/admin/page/links/_form.html.erb +17 -17
  55. data/app/views/admin/page/links/_options.html.erb +16 -19
  56. data/app/views/admin/page/links/edit.html.erb +3 -3
  57. data/app/views/admin/page/links/new.html.erb +3 -3
  58. data/app/views/admin/sections/_form.html.haml +5 -5
  59. data/app/views/admin/sections/edit.html.haml +2 -2
  60. data/app/views/admin/sections/index.html.erb +18 -18
  61. data/app/views/admin/sections/new.html.erb +15 -13
  62. data/app/views/admin/sections/settings/_page.html.haml +4 -6
  63. data/app/views/admin/shared/_header.html.erb +5 -4
  64. data/app/views/admin/shared/_section_tree.html.erb +2 -2
  65. data/app/views/admin/sites/_email_notifications.html.erb +6 -7
  66. data/app/views/admin/sites/_form.html.erb +7 -7
  67. data/app/views/admin/sites/_recent_users.html.erb +4 -2
  68. data/app/views/admin/sites/_unapproved_comments.html.erb +1 -1
  69. data/app/views/admin/sites/index.html.erb +1 -1
  70. data/app/views/admin/sites/new.html.erb +2 -2
  71. data/app/views/admin/sites/show.html.erb +7 -8
  72. data/app/views/admin/users/edit.html.erb +1 -1
  73. data/app/views/admin/users/index.html.erb +10 -10
  74. data/app/views/admin/users/new.html.erb +1 -1
  75. data/app/views/admin/users/show.html.erb +7 -7
  76. data/app/views/layouts/admin.html.haml +3 -5
  77. data/app/views/layouts/login.html.erb +1 -1
  78. data/app/views/password/edit.html.erb +12 -5
  79. data/app/views/password/new.html.erb +7 -7
  80. data/app/views/password_mailer/reset_password_email.html.erb +21 -1
  81. data/app/views/password_mailer/updated_password_email.html.erb +3 -1
  82. data/app/views/session/new.html.erb +9 -9
  83. data/app/views/shared/_flash.html.erb +2 -2
  84. data/app/views/shared/_sidebar.html.erb +2 -2
  85. data/config/initializers/ckeditor.rb +61 -0
  86. data/config/initializers/time_format.rb +2 -0
  87. data/lib/adva/authenticate_user.rb +193 -0
  88. data/lib/{active_record → adva}/belongs_to_author.rb +4 -4
  89. data/lib/adva/event.rb +34 -0
  90. data/lib/adva/extensible_forms.rb +285 -0
  91. data/lib/{has_options.rb → adva/has_options.rb} +5 -7
  92. data/lib/adva/has_permalink.rb +36 -0
  93. data/lib/adva/version.rb +1 -1
  94. data/lib/adva.rb +10 -36
  95. data/lib/rails_ext/action_controller/event_helper.rb +1 -1
  96. data/lib/rails_ext.rb +0 -9
  97. data/vendor/gems/cacheable_flash/.gitignore +8 -0
  98. data/vendor/gems/cacheable_flash/Gemfile +8 -0
  99. data/vendor/gems/cacheable_flash/README.md +35 -0
  100. data/vendor/gems/cacheable_flash/Rakefile +4 -0
  101. data/vendor/gems/cacheable_flash/bin/console +15 -0
  102. data/vendor/gems/cacheable_flash/bin/setup +8 -0
  103. data/vendor/gems/cacheable_flash/cacheable_flash.gemspec +38 -0
  104. data/vendor/gems/cacheable_flash/lib/cacheable_flash/controller.rb +29 -0
  105. data/vendor/gems/cacheable_flash/lib/cacheable_flash/javascript.js +19 -0
  106. data/vendor/gems/cacheable_flash/lib/cacheable_flash/middleware.rb +30 -0
  107. data/vendor/gems/cacheable_flash/lib/cacheable_flash/version.rb +5 -0
  108. data/vendor/gems/cacheable_flash/lib/cacheable_flash.rb +12 -0
  109. data/vendor/gems/simple_taggable/lib/tag_list.rb +1 -1
  110. data/vendor/gems/tags/lib/menu.rb +1 -1
  111. data/vendor/gems/tags/lib/tags/tag.rb +1 -1
  112. metadata +71 -144
  113. data/app/assets/javascripts/adva_cms/admin/jquery.admin.js +0 -23
  114. data/app/assets/javascripts/adva_cms/admin/jquery.article.js +0 -22
  115. data/app/assets/javascripts/adva_cms/admin/jquery.cached_pages.js +0 -14
  116. data/app/assets/javascripts/adva_cms/admin/jquery.table_tree.js +0 -7
  117. data/app/assets/javascripts/adva_cms/application.js +0 -13
  118. data/app/assets/javascripts/adva_cms/base.js +0 -4
  119. data/app/assets/javascripts/adva_cms/cookie.js +0 -49
  120. data/app/assets/javascripts/adva_cms/jquery/jquery-lowpro.js +0 -224
  121. data/app/assets/javascripts/adva_cms/jquery/jquery.qtip.js +0 -2085
  122. data/app/assets/javascripts/adva_cms/jquery/jquery.table_tree.js +0 -307
  123. data/app/assets/javascripts/adva_cms/jquery/jquery.tablednd_0_5.js +0 -386
  124. data/app/assets/javascripts/adva_cms/jquery.common.js +0 -41
  125. data/app/assets/javascripts/adva_cms/jquery.dates.js +0 -51
  126. data/app/assets/javascripts/adva_cms/jquery.flash.js +0 -59
  127. data/app/assets/javascripts/adva_cms/jquery.roles.js +0 -25
  128. data/app/assets/javascripts/adva_cms/json.js +0 -139
  129. data/app/controllers/admin/base_account_controller.rb +0 -13
  130. data/app/controllers/admin/install_controller.rb +0 -61
  131. data/app/controllers/admin/plugins_controller.rb +0 -38
  132. data/app/helpers/meta_tags_helper.rb +0 -30
  133. data/app/models/account.rb +0 -7
  134. data/app/models/event.rb +0 -34
  135. data/app/views/admin/articles/_meta_tags.html.erb +0 -7
  136. data/app/views/admin/cached_pages/_filter.html.erb +0 -8
  137. data/app/views/admin/cached_pages/destroy.js.erb +0 -18
  138. data/app/views/admin/cached_pages/index.html.erb +0 -26
  139. data/app/views/admin/plugins/_form.html.erb +0 -11
  140. data/app/views/admin/plugins/index.html.erb +0 -16
  141. data/app/views/admin/plugins/show.html.erb +0 -43
  142. data/app/views/admin/shared/_language_select.html.erb +0 -6
  143. data/app/views/admin/shared/_section_summary.html.erb +0 -23
  144. data/app/views/admin/sites/_meta_tags.html.erb +0 -15
  145. data/app/views/layouts/default.html.erb +0 -38
  146. data/app/views/layouts/simple.html.erb +0 -22
  147. data/app/views/shared/_footer.html.erb +0 -4
  148. data/app/views/shared/messages/insufficient_permissions.html.erb +0 -4
  149. data/config/initializers/article.rb +0 -8
  150. data/config/initializers/has_options.rb +0 -2
  151. data/config/initializers/has_permalink.rb +0 -2
  152. data/config/initializers/site.rb +0 -8
  153. data/config/locales/en.yml +0 -1319
  154. data/lib/action_controller/authenticate_anonymous.rb +0 -69
  155. data/lib/action_controller/authenticate_user.rb +0 -203
  156. data/lib/core_ext.rb +0 -7
  157. data/lib/extensible_forms.rb +0 -284
  158. data/lib/has_permalink.rb +0 -33
  159. data/lib/login/helper_integration.rb +0 -11
  160. data/lib/login/mail_config.rb +0 -39
  161. data/lib/rails_ext/action_controller/cacheable_flash.rb +0 -30
  162. data/lib/rails_ext/action_controller/content_for_assignments.rb +0 -106
  163. data/lib/rails_ext/action_controller/page_caching.rb +0 -23
  164. data/lib/rails_ext/action_controller/responds_to_parent.rb +0 -46
  165. data/lib/rails_ext/active_record/exists.rb +0 -5
  166. data/lib/rails_ext/active_record/sti_instantiation.rb +0 -35
  167. data/lib/rails_ext/active_record/sticky_changes.rb +0 -30
  168. data/lib/rails_ext/railties/plugin.rb +0 -58
  169. data/lib/rails_ext/railties/plugin_configuration.rb +0 -72
  170. data/lib/registry.rb +0 -49
  171. data/lib/tasks/translation.rake +0 -69
  172. data/lib/time_hacks.rb +0 -57
  173. data/lib/webrat_patch.rb +0 -11
  174. data/test/meta_tags_test.rb +0 -42
  175. data/vendor/gems/has_counter/.gitignore +0 -17
  176. data/vendor/gems/has_counter/Gemfile +0 -4
  177. data/vendor/gems/has_counter/LICENSE +0 -22
  178. data/vendor/gems/has_counter/MIT-LICENSE +0 -20
  179. data/vendor/gems/has_counter/README.markdown +0 -64
  180. data/vendor/gems/has_counter/README.md +0 -29
  181. data/vendor/gems/has_counter/Rakefile +0 -2
  182. data/vendor/gems/has_counter/db/migrate/20080601194338_create_counters_table.rb.rb +0 -13
  183. data/vendor/gems/has_counter/has_counter.gemspec +0 -17
  184. data/vendor/gems/has_counter/lib/active_record/has_counter.rb +0 -67
  185. data/vendor/gems/has_counter/lib/counter.rb +0 -23
  186. data/vendor/gems/has_counter/lib/has_counter/version.rb +0 -3
  187. data/vendor/gems/has_counter/lib/has_counter.rb +0 -4
  188. data/vendor/gems/has_counter/spec/has_counter.sqlite3.db +0 -0
  189. data/vendor/gems/has_counter/spec/has_counter_spec.rb +0 -55
  190. data/vendor/gems/has_counter/spec/spec_helper.rb +0 -117
  191. data/vendor/gems/has_filter/.gitignore +0 -17
  192. data/vendor/gems/has_filter/Gemfile +0 -4
  193. data/vendor/gems/has_filter/LICENSE +0 -22
  194. data/vendor/gems/has_filter/README.md +0 -29
  195. data/vendor/gems/has_filter/Rakefile +0 -2
  196. data/vendor/gems/has_filter/app/assets/images/has_filter/filter_add.png +0 -0
  197. data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_left.png +0 -0
  198. data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_right.png +0 -0
  199. data/vendor/gems/has_filter/app/assets/images/has_filter/filter_remove.png +0 -0
  200. data/vendor/gems/has_filter/app/assets/javascripts/has_filter/filter.js +0 -35
  201. data/vendor/gems/has_filter/app/assets/javascripts/has_filter/jquery.filter.js +0 -23
  202. data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/alternate/filter.scss +0 -102
  203. data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/filter.scss +0 -100
  204. data/vendor/gems/has_filter/app/helpers/filter_helper.rb +0 -3
  205. data/vendor/gems/has_filter/has_filter.gemspec +0 -17
  206. data/vendor/gems/has_filter/init.rb +0 -3
  207. data/vendor/gems/has_filter/lib/has_filter/active_record/act_macro.rb +0 -102
  208. data/vendor/gems/has_filter/lib/has_filter/filter/base.rb +0 -67
  209. data/vendor/gems/has_filter/lib/has_filter/filter/categorized.rb +0 -24
  210. data/vendor/gems/has_filter/lib/has_filter/filter/chain.rb +0 -45
  211. data/vendor/gems/has_filter/lib/has_filter/filter/set.rb +0 -80
  212. data/vendor/gems/has_filter/lib/has_filter/filter/state.rb +0 -25
  213. data/vendor/gems/has_filter/lib/has_filter/filter/tagged.rb +0 -22
  214. data/vendor/gems/has_filter/lib/has_filter/filter/text.rb +0 -55
  215. data/vendor/gems/has_filter/lib/has_filter/filter.rb +0 -17
  216. data/vendor/gems/has_filter/lib/has_filter/version.rb +0 -3
  217. data/vendor/gems/has_filter/lib/has_filter.rb +0 -22
  218. data/vendor/gems/has_filter/test/db/setup.rb +0 -45
  219. data/vendor/gems/has_filter/test/db/test.sqlite3.db +0 -0
  220. data/vendor/gems/has_filter/test/fixtures.rb +0 -15
  221. data/vendor/gems/has_filter/test/has_filter/filter_chain_test.rb +0 -41
  222. data/vendor/gems/has_filter/test/has_filter/filter_scopes_test.rb +0 -102
  223. data/vendor/gems/has_filter/test/has_filter/filter_tags_test.rb +0 -113
  224. data/vendor/gems/has_filter/test/has_filter/integration.rb +0 -15
  225. data/vendor/gems/has_filter/test/has_filter/scopes_test.rb +0 -48
  226. data/vendor/gems/has_filter/test/log/test.log +0 -34346
  227. data/vendor/gems/has_filter/test/models.rb +0 -23
  228. data/vendor/gems/has_filter/test/templates/has_filter/test/index.html.erb +0 -5
  229. data/vendor/gems/has_filter/test/test_helper.rb +0 -66
  230. data/vendor/gems/xss_terminate/.gitignore +0 -17
  231. data/vendor/gems/xss_terminate/Gemfile +0 -4
  232. data/vendor/gems/xss_terminate/LICENSE +0 -22
  233. data/vendor/gems/xss_terminate/MIT-LICENSE +0 -20
  234. data/vendor/gems/xss_terminate/README +0 -94
  235. data/vendor/gems/xss_terminate/README.md +0 -29
  236. data/vendor/gems/xss_terminate/Rakefile +0 -23
  237. data/vendor/gems/xss_terminate/lib/html5lib_sanitize.rb +0 -2453
  238. data/vendor/gems/xss_terminate/lib/rails_sanitize.rb +0 -8
  239. data/vendor/gems/xss_terminate/lib/xss_terminate/version.rb +0 -3
  240. data/vendor/gems/xss_terminate/lib/xss_terminate.rb +0 -141
  241. data/vendor/gems/xss_terminate/tasks/xss_terminate_tasks.rake +0 -7
  242. data/vendor/gems/xss_terminate/test/models/comment.rb +0 -5
  243. data/vendor/gems/xss_terminate/test/models/entry.rb +0 -7
  244. data/vendor/gems/xss_terminate/test/models/message.rb +0 -3
  245. data/vendor/gems/xss_terminate/test/models/person.rb +0 -5
  246. data/vendor/gems/xss_terminate/test/models/review.rb +0 -5
  247. data/vendor/gems/xss_terminate/test/schema.rb +0 -34
  248. data/vendor/gems/xss_terminate/test/setup_test.rb +0 -16
  249. data/vendor/gems/xss_terminate/test/xss_terminate_test.rb +0 -50
  250. data/vendor/gems/xss_terminate/xss_terminate.gemspec +0 -17
  251. /data/lib/tasks/{adva_cms.rake → adva.rake} +0 -0
@@ -1,41 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- module HasFilter
4
- class FilterChainTest < ActiveSupport::TestCase
5
- include HasFilter
6
- include HasFilter::TestHelper
7
-
8
- def setup
9
- @chain = HasFilterArticle.filter_chain
10
- end
11
-
12
- test 'builds a filter chain with an initial set' do
13
- assert_equal 'Set', @chain.first.class.name.demodulize
14
- end
15
-
16
- test 'properly duplicates instances when adjusting its size' do
17
- @chain.send :adjust_size, 2
18
- first, second = *@chain[0, 2]
19
- assert_not_equal first.object_id, second.object_id
20
- assert_not_equal first.first.object_id, second.first.object_id
21
- assert_equal first.object_id, first.first.set.object_id
22
- assert_equal second.object_id, second.first.set.object_id
23
- end
24
- end
25
-
26
- class FilterSetTest < ActiveSupport::TestCase
27
- def setup
28
- @chain = HasFilterArticle.filter_chain
29
- end
30
-
31
- test 'set has a text filter for each attribute' do
32
- set = HasFilterArticle.filter_chain.first
33
- assert_equal %w(body excerpt title), set[0..2].map(&:attribute).map(&:to_s).sort
34
- end
35
-
36
- test 'sorts text filters to the top, not changing their order, followed by the rest ordered by priority' do
37
- expected = ['Text', 'Text', 'Text', 'Tagged', 'State', 'Categorized']
38
- assert_equal expected, @chain.first.map{ |filter| filter.class.name.demodulize }
39
- end
40
- end
41
- end
@@ -1,102 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- module HasFilter
4
- class FilterScopesTest < ActiveSupport::TestCase
5
- include HasFilter
6
- include HasFilter::TestHelper
7
-
8
- def setup
9
- @first = HasFilterArticle.find_by_title 'first'
10
- @second = HasFilterArticle.find_by_title 'second'
11
- @third = HasFilterArticle.find_by_title 'third'
12
- @upcase = HasFilterArticle.find_by_title 'UPCASE'
13
- end
14
-
15
- test 'text filter applies scopes to an attribute' do
16
- params = [{ :title => { :scope => 'contains', :query => 'i' },
17
- :body => { :scope => 'contains', :query => 'x' },
18
- :excerpt => { :scope => 'contains', :query => 'x' },
19
- :tagged => 'x',
20
- :selected => 'title' }]
21
- assert_equal [@first, @third], HasFilterArticle.filter_chain.select(params).scope
22
- end
23
-
24
- test 'text filter works with translated columns' do
25
- params = [{ :title => { :scope => 'is', :query => 'UPCASE' },
26
- :body => { :scope => 'is', :query => 'x' },
27
- :excerpt => { :scope => 'is', :query => 'x' },
28
- :tagged => 'x',
29
- :selected => 'title' }]
30
- assert_equal [@upcase], HasFilterArticle.filter_chain.select(params).scope
31
- end
32
-
33
- test 'text filter works with upcase letters' do
34
- HasFilterArticle.stubs(:translated?).with(:title).returns true
35
- scope = HasFilterArticle.send(:filter_scope, :title, ["first"], "=")
36
- expected_scope = {:conditions=>["title = ? AND current = ?", "first", true],
37
- :joins=>:globalize_translations,
38
- :group=>"has_filter_articles.id"}
39
- assert_equal expected_scope, scope
40
- end
41
-
42
- test 'text filter applies scopes to multiple attributes' do
43
- params = [{ :title => { :scope => 'starts_with', :query => 'x' },
44
- :body => { :scope => 'starts_with', :query => 'f' },
45
- :excerpt => { :scope => 'starts_with', :query => 'x' },
46
- :tagged => 'x',
47
- :selected => 'body' },
48
- { :title => { :scope => 'contains', :query => 'i' },
49
- :body => { :scope => 'contains', :query => 'x' },
50
- :excerpt => { :scope => 'contains', :query => 'x' },
51
- :tagged => 'x',
52
- :selected => 'title' }]
53
- assert_equal [@first], HasFilterArticle.filter_chain.select(params).scope
54
- end
55
-
56
- test 'text filter applies multiple scopes to the same attribute' do
57
- params = [{ :title => { :scope => 'starts_with', :query => 'f' },
58
- :body => { :scope => 'starts_with', :query => 'x' },
59
- :excerpt => { :scope => 'starts_with', :query => 'x' },
60
- :tagged => 'x',
61
- :selected => 'title' },
62
- { :title => { :scope => 'contains', :query => 'i' },
63
- :body => { :scope => 'contains', :query => 'x' },
64
- :excerpt => { :scope => 'contains', :query => 'x' },
65
- :tagged => 'x',
66
- :selected => 'title' }]
67
- assert_equal [@first], HasFilterArticle.filter_chain.select(params).scope
68
- end
69
-
70
- test 'state filter applies multiple state scopes from the same filter' do
71
- params = [{ :state => [:published, :approved], :selected => 'state' }] # should in theory be an OR join
72
- assert_equal [@second], HasFilterArticle.filter_chain.select(params).scope
73
- end
74
-
75
- test 'state filter applies multiple state scopes from different filters' do
76
- params = [{ :state => [:published], :selected => 'state' },
77
- { :state => [:approved], :selected => 'state' }]
78
- assert_equal [@second], HasFilterArticle.filter_chain.select(params).scope
79
- end
80
-
81
- test 'tags filter applies tags scope' do
82
- params = [{ :tagged => ['bar'], :selected => 'tagged' }]
83
- assert_equal [@first, @second], HasFilterArticle.filter_chain.select(params).scope
84
- end
85
-
86
- test 'categories filter applies categorized scope (1)' do
87
- params = [{ :categorized => @first.categories.map(&:id), :selected => 'categorized' }]
88
- assert_equal [@first], HasFilterArticle.filter_chain.select(params).scope
89
- end
90
-
91
- test 'categories filter applies categorized scope (2)' do
92
- params = [{ :categorized => @second.categories.map(&:id), :selected => 'categorized' }]
93
- assert_equal [@first, @second], HasFilterArticle.filter_chain.select(params).scope
94
- end
95
-
96
- test 'categories filter applies categorized scope (3)' do
97
- category = HasFilterCategory.create!(:title => 'new')
98
- params = [{ :categorized => category.id, :selected => 'categorized' }]
99
- assert_equal [], HasFilterArticle.filter_chain.select(params).scope
100
- end
101
- end
102
- end
@@ -1,113 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- module HasFilter
4
- class FilterTagsTest < ActiveSupport::TestCase
5
- include HasFilter
6
- include HasFilter::TestHelper
7
-
8
- def setup
9
- params = [{ :title => { :scope => 'starts_with', :query => 'foo' },
10
- :body => { :scope => 'starts_with', :query => '' },
11
- :excerpt => { :scope => 'starts_with', :query => '' },
12
- :tagged => '',
13
- :selected => 'title' },
14
- { :title => { :scope => 'contains', :query => '' },
15
- :body => { :scope => 'contains', :query => 'bar' },
16
- :excerpt => { :scope => 'contains', :query => '' },
17
- :tagged => '',
18
- :selected => 'body' },
19
- { :title => { :scope => 'contains', :query => '' },
20
- :body => { :scope => 'contains', :query => '' },
21
- :excerpt => { :scope => 'contains', :query => '' },
22
- :tagged => 'baz',
23
- :selected => 'tagged' },
24
- { :title => { :scope => 'contains', :query => '' },
25
- :body => { :scope => 'contains', :query => '' },
26
- :excerpt => { :scope => 'contains', :query => '' },
27
- :state => [ :published ],
28
- :tagged => '',
29
- :selected => 'state' },
30
- { :title => { :scope => 'contains', :query => '' },
31
- :body => { :scope => 'contains', :query => '' },
32
- :excerpt => { :scope => 'contains', :query => '' },
33
- :state => [ :published ],
34
- :tagged => '',
35
- :categorized => [HasFilterCategory.first.id],
36
- :selected => 'categorized' }]
37
-
38
- @categories = HasFilterCategory.all
39
- view = ActionView::Base.new
40
- @html = HasFilterArticle.filter_chain.select(params).to_form_fields(view, :categories => @categories).join("\n")
41
- end
42
-
43
- test 'the chain has two fieldsets with filters' do
44
- assert_html @html, 'fieldset[class=set]', 5
45
- end
46
-
47
- test 'one fieldset has the :title filter selected, one has the :body, one has the :tagged filter selected (from params)' do
48
- assert_html @html, 'fieldset[class=set] select[id=selected_filter_0] option[value=title][selected=selected]'
49
- assert_html @html, 'fieldset[class=set] select[id=selected_filter_1] option[value=body][selected=selected]'
50
- assert_html @html, 'fieldset[class=set] select[id=selected_filter_2] option[value=tagged][selected=selected]'
51
- end
52
-
53
- test 'fieldsets have a select box for selecting the filter' do
54
- assert_html @html, 'select[id=selected_filter_0]' do
55
- assert_select 'option[value=title]'
56
- assert_select 'option[value=body]'
57
- assert_select 'option[value=excerpt]'
58
- assert_select 'option[value=tagged]'
59
- assert_select 'option[value=state]'
60
- end
61
- end
62
-
63
- test 'fieldsets have a nested fieldset for each filter' do
64
- assert_html @html, 'fieldset[class=set] fieldset[class~=filter][id=filter_title_0]'
65
- assert_html @html, 'fieldset[class=set] fieldset[class~=filter][id=filter_tagged_0]'
66
- assert_html @html, 'fieldset[class=set] fieldset[class~=filter][id=filter_state_0]'
67
- assert_html @html, 'fieldset[class=set] fieldset[class~=filter][id=filter_categorized_0]'
68
- end
69
-
70
- test 'one fieldset has the :title fieldset selected, one has the :body fieldset selected (from params)' do
71
- assert_html @html, 'fieldset[class=set] fieldset[class~=selected][id=filter_title_0]'
72
- assert_html @html, 'fieldset[class=set] fieldset[class~=selected][id=filter_body_1]'
73
- end
74
-
75
- test 'text filter has a select box for selecting the scope and a query input' do
76
- assert_html @html, 'select[id=filter_body_scope_0][name=?]', 'filters[][body][scope]' do
77
- assert 'option[value=contains]'
78
- assert 'option[value=starts_with]'
79
- assert 'option[value=ends_with]'
80
- assert 'option[value=is]'
81
- assert 'option[value=is_not]'
82
- end
83
- assert_html @html, 'input[id=filter_body_query_0][name=?]', 'filters[][body][query]'
84
- end
85
-
86
- test 'title text filter has the :starts_with scope selected and query set to "foo" (from params)' do
87
- assert_html @html, 'select[id=filter_title_scope_0] option[value=starts_with][selected=selected]'
88
- assert_html @html, 'input[id=filter_title_query_0][value=foo]'
89
- end
90
-
91
- test 'body text filter has the :contains scope selected and query set to "bar" (from params)' do
92
- assert_html @html, 'select[id=filter_body_scope_1] option[value=contains][selected=selected]'
93
- assert_html @html, 'input[id=filter_body_query_1][value=bar]'
94
- end
95
-
96
- test 'tag filter has a query input set to "baz"' do
97
- assert_html @html, 'input[id=filter_tagged_query_2][name=?][value=baz]', 'filters[][tagged]'
98
- end
99
-
100
- test 'state filter has checkboxes for possible states' do
101
- assert_html @html, 'input[type=checkbox][id=?][name=?][value=?][checked=checked]',
102
- "filter_state_published_3", 'filters[][state][]', 'published'
103
- assert_html @html, 'input[type=checkbox][id=?][name=?][value=?]',
104
- "filter_state_unpublished_3", 'filters[][state][]', 'unpublished'
105
- end
106
-
107
- test 'categorized filter has a select box selecting a category' do
108
- assert_html @html, 'select[id=filter_categorized_id_4][name=?]', 'filters[][categorized][]' do
109
- assert_select 'option[value=?][selected=selected]', @categories.first.id, @categories.first.title
110
- end
111
- end
112
- end
113
- end
@@ -1,15 +0,0 @@
1
- # require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper' ))
2
- #
3
- # module HasFilter
4
- # class IntegrationTest < ActionController::IntegrationTest
5
- # def setup
6
- # end
7
- #
8
- # test "foo" do
9
- # visit 'has_filter'
10
- # # puts @response.body
11
- # click_button 'submit'
12
- # # p @request.params[:filters]
13
- # end
14
- # end
15
- # end
@@ -1,48 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- module HasFilter
4
- class ScopesTest < ActiveSupport::TestCase
5
- def setup
6
- @first = HasFilterArticle.find_by_title 'first'
7
- @second = HasFilterArticle.find_by_title 'second'
8
- @third = HasFilterArticle.find_by_title 'third'
9
- @upcase = HasFilterArticle.find_by_title 'UPCASE'
10
- end
11
-
12
- test 'scope :is' do
13
- assert_equal [@first], HasFilterArticle.is(:title, 'first')
14
- end
15
-
16
- test 'scope :is_not' do
17
- assert_equal [@second, @third, @upcase], HasFilterArticle.is_not(:title, 'first')
18
- end
19
-
20
- test 'scope :contains' do
21
- assert_equal [@first, @third], HasFilterArticle.contains(:title, 'ir')
22
- end
23
-
24
- test 'scope :does_not_contain' do
25
- assert_equal [@second, @upcase], HasFilterArticle.does_not_contain(:title, 'ir')
26
- end
27
-
28
- test 'scope :starts_with' do
29
- assert_equal [@first], HasFilterArticle.starts_with(:title, 'fi')
30
- end
31
-
32
- test 'scope :does_not_start_with' do
33
- assert_equal [@second, @third, @upcase], HasFilterArticle.does_not_start_with(:title, 'fi')
34
- end
35
-
36
- test 'scope :ends_with' do
37
- assert_equal [@first], HasFilterArticle.ends_with(:title, 'st')
38
- end
39
-
40
- test 'scope :does_not_end_with' do
41
- assert_equal [@second, @third, @upcase], HasFilterArticle.does_not_end_with(:title, 'st')
42
- end
43
-
44
- test 'scope :contains_all' do
45
- assert_equal [@first], HasFilterArticle.contains_all(:title, %w(i r s))
46
- end
47
- end
48
- end