typus 1.0.0.pre8 → 1.0.0.pre9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/CHANGELOG +4 -6
  2. data/Gemfile +16 -13
  3. data/Gemfile.lock +26 -2
  4. data/Rakefile +2 -3
  5. data/app/controllers/admin/base_controller.rb +3 -5
  6. data/app/controllers/admin/resources_controller.rb +24 -26
  7. data/app/helpers/admin/base_helper.rb +14 -22
  8. data/app/helpers/admin/dashboard_helper.rb +2 -5
  9. data/app/helpers/admin/filters_helper.rb +6 -8
  10. data/app/helpers/admin/form_helper.rb +3 -9
  11. data/app/helpers/admin/preview_helper.rb +4 -6
  12. data/app/helpers/admin/relationships_helper.rb +9 -11
  13. data/app/helpers/admin/resources_helper.rb +6 -24
  14. data/app/helpers/admin/search_helper.rb +1 -1
  15. data/app/helpers/admin/sidebar_helper.rb +12 -15
  16. data/app/helpers/admin/table_helper.rb +13 -13
  17. data/app/views/admin/dashboard/show.html.erb +1 -1
  18. data/app/views/admin/helpers/_apps.html.erb +4 -3
  19. data/app/views/admin/helpers/_header.html.erb +2 -2
  20. data/app/views/admin/helpers/dashboard/_applications.html.erb +3 -3
  21. data/app/views/admin/helpers/dashboard/_resources.html.erb +17 -13
  22. data/app/views/admin/helpers/filters/_filters.html.erb +9 -27
  23. data/app/views/admin/helpers/resources/_pagination.html.erb +8 -9
  24. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  25. data/app/views/admin/mailer/reset_password_link.text.erb +3 -0
  26. data/app/views/admin/resources/_form.html.erb +4 -4
  27. data/app/views/admin/resources/edit.html.erb +2 -3
  28. data/app/views/admin/resources/index.html.erb +15 -13
  29. data/app/views/admin/resources/new.html.erb +2 -2
  30. data/app/views/admin/resources/show.html.erb +1 -2
  31. data/app/views/admin/templates/_boolean.html.erb +1 -1
  32. data/app/views/admin/templates/_has_many.html.erb +2 -4
  33. data/app/views/admin/templates/_has_n.html.erb +1 -1
  34. data/app/views/admin/templates/_selector.html.erb +0 -1
  35. data/app/views/admin/templates/_string.html.erb +1 -1
  36. data/app/views/layouts/admin/session.html.erb +1 -1
  37. data/config/available_locales/ca.yml +3 -5
  38. data/config/available_locales/de.yml +2 -4
  39. data/config/available_locales/es.yml +2 -4
  40. data/config/available_locales/fr.yml +40 -39
  41. data/config/available_locales/fr_models.yml +2 -2
  42. data/config/available_locales/hu.yml +3 -5
  43. data/config/available_locales/it.yml +0 -4
  44. data/config/available_locales/language.yml.template +2 -4
  45. data/config/available_locales/pt-BR.yml +2 -4
  46. data/config/available_locales/ru.yml +2 -4
  47. data/config/routes.rb +1 -0
  48. data/lib/generators/templates/config/initializers/typus.rb +5 -5
  49. data/lib/generators/templates/config/initializers/typus_authentication.rb +5 -5
  50. data/lib/generators/templates/config/initializers/typus_resources.rb +7 -7
  51. data/lib/generators/templates/config/typus/README +11 -13
  52. data/lib/generators/templates/controller.rb +0 -2
  53. data/lib/generators/templates/functional_test.rb +4 -15
  54. data/lib/generators/typus/migration_generator.rb +0 -1
  55. data/lib/support/active_record.rb +18 -9
  56. data/lib/support/fake_user.rb +42 -0
  57. data/lib/support/object.rb +1 -0
  58. data/lib/support/string.rb +0 -32
  59. data/lib/tasks/typus.rake +0 -8
  60. data/lib/typus.rb +34 -18
  61. data/lib/typus/authentication/base.rb +26 -0
  62. data/lib/typus/authentication/http_basic.rb +22 -0
  63. data/lib/typus/authentication/none.rb +19 -0
  64. data/lib/typus/authentication/session.rb +190 -0
  65. data/lib/typus/format.rb +12 -19
  66. data/lib/typus/orm/active_record.rb +13 -51
  67. data/lib/typus/resources.rb +0 -9
  68. data/lib/typus/version.rb +1 -1
  69. data/test/factories.rb +43 -0
  70. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -1
  71. data/test/fixtures/rails_app/app/models/page.rb +0 -4
  72. data/test/fixtures/rails_app/config/application.rb +6 -3
  73. data/test/fixtures/rails_app/config/database.yml +12 -20
  74. data/test/fixtures/rails_app/config/typus/application.yml +4 -8
  75. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  76. data/test/fixtures/rails_app/log/test.log +227115 -0
  77. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +2 -0
  78. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +2 -0
  79. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +2 -0
  80. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +2 -0
  81. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +2 -0
  82. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +2 -0
  83. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +2 -0
  84. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +2 -0
  85. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +2 -0
  86. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +2 -0
  87. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +2 -0
  88. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +2 -0
  89. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +2 -0
  90. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +2 -0
  91. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +2 -0
  92. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +2 -0
  93. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +2 -0
  94. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +2 -0
  95. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +2 -0
  96. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +2 -0
  97. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +2 -0
  98. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +2 -0
  99. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +2 -0
  100. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +2 -0
  101. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +2 -0
  102. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +2 -0
  103. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +2 -0
  104. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +2 -0
  105. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +2 -0
  106. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +2 -0
  107. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +2 -0
  108. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +2 -0
  109. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +2 -0
  110. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +2 -0
  111. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +2 -0
  112. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +2 -0
  113. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +2 -0
  114. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +2 -0
  115. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +2 -0
  116. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +2 -0
  117. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +2 -0
  118. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +2 -0
  119. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +2 -0
  120. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +2 -0
  121. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +2 -0
  122. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +2 -0
  123. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +2 -0
  124. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +2 -0
  125. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +2 -0
  126. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +2 -0
  127. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +2 -0
  128. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +2 -0
  129. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +2 -0
  130. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +2 -0
  131. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +2 -0
  132. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +2 -0
  133. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +2 -0
  134. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +2 -0
  135. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +2 -0
  136. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +2 -0
  137. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +2 -0
  138. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +2 -0
  139. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +2 -0
  140. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +2 -0
  141. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +2 -0
  142. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +2 -0
  143. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +2 -0
  144. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +2 -0
  145. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +2 -0
  146. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +2 -0
  147. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +2 -0
  148. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +2 -0
  149. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +2 -0
  150. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +2 -0
  151. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +2 -0
  152. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +2 -0
  153. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +2 -0
  154. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +2 -0
  155. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +2 -0
  156. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +2 -0
  157. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +2 -0
  158. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +2 -0
  159. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +2 -0
  160. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +2 -0
  161. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +2 -0
  162. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +2 -0
  163. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +2 -0
  164. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +2 -0
  165. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +2 -0
  166. data/test/functional/admin/account_controller_test.rb +1 -1
  167. data/test/functional/admin/{resources_controller_assets_relationships.rb → assets_controller_test.rb} +12 -16
  168. data/test/functional/admin/categories_controller_test.rb +62 -0
  169. data/test/functional/admin/{resources_controller_comments_toggle_test.rb → comments_controller_test.rb} +0 -0
  170. data/test/functional/admin/dashboard_controller_test.rb +34 -2
  171. data/test/functional/admin/posts_controller_test.rb +548 -0
  172. data/test/functional/admin/session_controller_test.rb +2 -2
  173. data/test/functional/admin/{resources_controller_tableless_resource_test.rb → status_controller_test.rb} +0 -0
  174. data/test/functional/admin/{resources_controller_typus_users_test.rb → typus_users_controller_test.rb} +2 -2
  175. data/test/helpers/admin/base_helper_test.rb +35 -37
  176. data/test/helpers/admin/dashboard_helper_test.rb +4 -8
  177. data/test/helpers/admin/form_helper_test.rb +9 -34
  178. data/test/helpers/admin/resources_helper_test.rb +28 -16
  179. data/test/helpers/admin/sidebar_helper_test.rb +14 -27
  180. data/test/helpers/admin/table_helper_test.rb +24 -68
  181. data/test/integration/login_test.rb +13 -0
  182. data/test/integration_test_helper.rb +21 -0
  183. data/test/lib/support/active_record_test.rb +72 -21
  184. data/test/lib/support/array_test.rb +2 -6
  185. data/test/lib/support/string_test.rb +21 -30
  186. data/test/lib/typus/active_record_test.rb +162 -100
  187. data/test/lib/typus/resource_test.rb +2 -3
  188. data/test/lib/typus_test.rb +25 -22
  189. data/test/test_helper.rb +4 -17
  190. data/test/unit/admin/mailer_test.rb +2 -2
  191. data/test/unit/typus_user_roles_test.rb +23 -23
  192. data/test/unit/typus_user_test.rb +30 -24
  193. data/typus.gemspec +0 -1
  194. metadata +111 -60
  195. data/app/models/admin/fake_user.rb +0 -46
  196. data/lib/generators/templates/model.yml +0 -10
  197. data/lib/typus/authentication.rb +0 -241
  198. data/lib/vendor/paginator.rb +0 -143
  199. data/test/factories/assets.rb +0 -5
  200. data/test/factories/categories.rb +0 -3
  201. data/test/factories/comments.rb +0 -6
  202. data/test/factories/pages.rb +0 -5
  203. data/test/factories/pictures.rb +0 -7
  204. data/test/factories/posts.rb +0 -6
  205. data/test/factories/typus_users.rb +0 -8
  206. data/test/fixtures/rails_app/README +0 -244
  207. data/test/fixtures/rails_app/app/helpers/application_helper.rb +0 -2
  208. data/test/fixtures/rails_app/app/views/layouts/application.html.erb +0 -14
  209. data/test/fixtures/rails_app/config/environments/development.rb +0 -19
  210. data/test/fixtures/rails_app/config/environments/production.rb +0 -42
  211. data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +0 -258
  212. data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +0 -98
  213. data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  214. data/test/fixtures/rails_app/config/initializers/inflections.rb +0 -10
  215. data/test/fixtures/rails_app/config/initializers/mime_types.rb +0 -5
  216. data/test/fixtures/rails_app/config/locales/en.yml +0 -5
  217. data/test/fixtures/rails_app/db/seeds.rb +0 -7
  218. data/test/fixtures/rails_app/public/404.html +0 -26
  219. data/test/fixtures/rails_app/public/422.html +0 -26
  220. data/test/fixtures/rails_app/public/500.html +0 -26
  221. data/test/fixtures/rails_app/public/favicon.ico +0 -0
  222. data/test/fixtures/rails_app/public/images/rails.png +0 -0
  223. data/test/fixtures/rails_app/public/index.html +0 -279
  224. data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
  225. data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
  226. data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
  227. data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
  228. data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -4874
  229. data/test/fixtures/rails_app/public/javascripts/rails.js +0 -118
  230. data/test/fixtures/rails_app/public/robots.txt +0 -5
  231. data/test/fixtures/rails_app/script/rails +0 -9
  232. data/test/functional/admin/dashboard_controller_http_basic_test.rb +0 -24
  233. data/test/functional/admin/dashboard_controller_none_test.rb +0 -18
  234. data/test/functional/admin/resources_controller_categories_before_test.rb +0 -10
  235. data/test/functional/admin/resources_controller_categories_lists_test.rb +0 -44
  236. data/test/functional/admin/resources_controller_categories_views_test.rb +0 -10
  237. data/test/functional/admin/resources_controller_posts_before_test.rb +0 -10
  238. data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +0 -27
  239. data/test/functional/admin/resources_controller_posts_crud_test.rb +0 -44
  240. data/test/functional/admin/resources_controller_posts_formats_test.rb +0 -39
  241. data/test/functional/admin/resources_controller_posts_forms_test.rb +0 -58
  242. data/test/functional/admin/resources_controller_posts_permissions_test.rb +0 -100
  243. data/test/functional/admin/resources_controller_posts_relationships_test.rb +0 -91
  244. data/test/functional/admin/resources_controller_posts_roles.rb +0 -52
  245. data/test/functional/admin/resources_controller_posts_views_test.rb +0 -143
  246. data/test/lib/vendor/paginator_test.rb +0 -141
  247. data/typus-1.0.0.pre7.gem +0 -0
@@ -58,7 +58,7 @@ class Admin::SessionControllerTest < ActionController::TestCase
58
58
 
59
59
  post :create, { :typus_user => { :email => typus_user.email, :password => "12345678" } }
60
60
 
61
- assert @request.session[:typus_user_id].nil?
61
+ assert_nil @request.session[:typus_user_id]
62
62
  assert_response :redirect
63
63
  assert_redirected_to new_admin_session_path
64
64
  end
@@ -74,7 +74,7 @@ class Admin::SessionControllerTest < ActionController::TestCase
74
74
  should "destroy" do
75
75
  delete :destroy
76
76
 
77
- assert @request.session[:typus_user_id].nil?
77
+ assert_nil @request.session[:typus_user_id]
78
78
  assert_response :redirect
79
79
  assert_redirected_to new_admin_session_path
80
80
  assert flash.empty?
@@ -35,7 +35,7 @@ class Admin::TypusUsersControllerTest < ActionController::TestCase
35
35
  end
36
36
 
37
37
  should "not be able to destroy herself" do
38
- assert_difference('TypusUser.count', 0) do
38
+ assert_no_difference('TypusUser.count') do
39
39
  delete :destroy, :id => @typus_user.id
40
40
  end
41
41
 
@@ -77,7 +77,7 @@ class Admin::TypusUsersControllerTest < ActionController::TestCase
77
77
 
78
78
  assert_response :redirect
79
79
  assert_redirected_to @request.env['HTTP_REFERER']
80
- assert_equal "Editor can't perform action. (new)", flash[:notice].to_s
80
+ assert_equal "Editor can't perform action. (new)", flash[:notice]
81
81
  end
82
82
 
83
83
  end
@@ -8,62 +8,60 @@ class Admin::BaseHelperTest < ActiveSupport::TestCase
8
8
  include ActionView::Helpers::TextHelper
9
9
 
10
10
  def render(*args); args; end
11
+ # include ActionView::Rendering
12
+ # include ActionView::Partials
11
13
 
12
- =begin
14
+ context "header" do
13
15
 
14
- def test_header_with_root_path
16
+ should_eventually "render with root_path" do
15
17
 
16
- # ActionView::Helpers::UrlHelper does not support strings, which are returned by named routes
17
- # link root_path
18
- self.stubs(:link_to).returns(%(<a href="/">View site</a>))
19
- self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
18
+ # ActionView::Helpers::UrlHelper does not support strings, which are
19
+ # returned by named routes link root_path
20
+ self.stubs(:link_to).returns(%(<a href="/">View site</a>))
21
+ self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
20
22
 
21
- output = header
23
+ output = header
22
24
 
23
- partial = "admin/helpers/header"
24
- options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
25
- %(<a href="/admin/dashboard">Dashboard</a>),
26
- %(<a href="/">View site</a>) ] }
25
+ partial = "admin/helpers/header"
26
+ options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
27
+ %(<a href="/admin/dashboard">Dashboard</a>),
28
+ %(<a href="/">View site</a>) ] }
27
29
 
28
- assert_equal [ partial, options ], output
30
+ assert_equal [ partial, options ], output
29
31
 
30
- end
31
-
32
- =end
32
+ end
33
33
 
34
- =begin
34
+ should_eventually "render without root_path" do
35
35
 
36
- def test_header_without_root_path
36
+ Rails.application.routes.named_routes.routes.reject! { |key, route| key == :root }
37
37
 
38
- Rails.application.routes.named_routes.routes.reject! { |key, route| key == :root }
38
+ self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
39
39
 
40
- self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
40
+ output = header
41
+ partial = "admin/helpers/header"
42
+ options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
43
+ %(<a href="/admin/dashboard">Dashboard</a>) ] }
41
44
 
42
- output = header
43
- partial = "admin/helpers/header"
44
- options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
45
- %(<a href="/admin/dashboard">Dashboard</a>) ] }
45
+ assert_equal [ partial, options ], output
46
46
 
47
- assert_equal [ partial, options ], output
47
+ end
48
48
 
49
49
  end
50
50
 
51
- =end
51
+ context "display_flash_message" do
52
52
 
53
- should "display_flash_message" do
54
- message = { :test => "This is the message." }
55
- output = display_flash_message(message)
53
+ should "be displayed" do
54
+ message = { :test => "This is the message." }
55
+ output = display_flash_message(message)
56
+ expected = ["admin/helpers/flash_message",
57
+ { :flash_type => :test, :message => { :test => "This is the message." } }]
58
+ assert_equal expected, output
59
+ end
56
60
 
57
- partial = "admin/helpers/flash_message"
58
- options = { :flash_type => :test,
59
- :message => { :test => "This is the message." } }
60
-
61
- assert_equal partial, output.first
62
- assert_equal options, output.last
63
- end
61
+ should "not be displayed when message is empty" do
62
+ assert_nil display_flash_message(Hash.new)
63
+ end
64
64
 
65
- should "not display_flash_message with empty message" do
66
- assert display_flash_message(Hash.new).nil?
67
65
  end
68
66
 
69
67
  end
@@ -10,14 +10,10 @@ class Admin::DashboardHelperTest < ActiveSupport::TestCase
10
10
  def render(*args); args; end
11
11
 
12
12
  should "render resources" do
13
- @current_user = Factory(:typus_user)
14
-
15
- output = resources
16
- partial = "admin/helpers/dashboard/resources"
17
- options = { :resources => ["Git", "Status", "WatchDog"] }
18
-
19
- assert_equal partial, output.first
20
- assert_equal options, output.last
13
+ current_user = Factory(:typus_user)
14
+ output = resources(current_user)
15
+ expected = ["admin/helpers/dashboard/resources", { :resources => ["Git", "Status", "WatchDog"] }]
16
+ assert_equal expected, output
21
17
  end
22
18
 
23
19
  end
@@ -5,16 +5,13 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
5
5
  include Admin::FormHelper
6
6
  include Admin::ResourcesHelper
7
7
 
8
- =begin
9
-
10
- # FIXME: Problem with params number. A form option has to be sent.
11
- def test_typus_belongs_to_field
8
+ should_eventually "verify_belongs_to_field" do
12
9
 
13
10
  params = { :controller => 'admin/post', :id => 1, :action => :create }
14
11
  self.stubs(:params).returns(params)
15
12
 
16
- @current_user = mock()
17
- @current_user.stubs(:can?).with('create', Post).returns(false)
13
+ current_user = mock()
14
+ current_user.stubs(:can?).with('create', Post).returns(false)
18
15
  @resource = Comment
19
16
 
20
17
  expected = <<-HTML
@@ -32,18 +29,13 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
32
29
 
33
30
  end
34
31
 
35
- =end
36
-
37
- =begin
38
-
39
- # FIXME: Problem with the number of attributes.
40
- def test_typus_belongs_to_field_with_different_attribute_name
32
+ should_eventually "test_typus_belongs_to_field_with_different_attribute_name" do
41
33
 
42
34
  params = { :controller => 'admin/post', :id => 1, :action => :edit }
43
35
  self.stubs(:params).returns(params)
44
36
 
45
- @current_user = mock()
46
- @current_user.stubs(:can?).with('create', Comment).returns(true)
37
+ current_user = mock()
38
+ current_user.stubs(:can?).with('create', Comment).returns(true)
47
39
  @resource = Post
48
40
 
49
41
  expected = <<-HTML
@@ -61,12 +53,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
61
53
 
62
54
  end
63
55
 
64
- =end
65
-
66
- =begin
67
-
68
- # FIXME: Problem with the number of params.
69
- def test_typus_tree_field
56
+ should_eventually "test_typus_tree_field" do
70
57
 
71
58
  self.stubs(:expand_tree_into_select_field).returns('expand_tree_into_select_field')
72
59
 
@@ -84,13 +71,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
84
71
 
85
72
  end
86
73
 
87
- =end
88
-
89
- =begin
90
-
91
- # FIXME: Attribute disabled
92
-
93
- should "verify attribute_disabled" do
74
+ should_eventually "verify_attribute_disabled" do
94
75
  @resource = Post
95
76
  assert !attribute_disabled?('test')
96
77
  Post.expects(:accessible_attributes).returns(['test'])
@@ -99,11 +80,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
99
80
  assert attribute_disabled?('test')
100
81
  end
101
82
 
102
- =end
103
-
104
- =begin
105
-
106
- def test_expand_tree_into_select_field
83
+ should_eventually "test_expand_tree_into_select_field" do
107
84
 
108
85
  items = Page.roots
109
86
 
@@ -137,6 +114,4 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
137
114
 
138
115
  end
139
116
 
140
- =end
141
-
142
117
  end
@@ -9,23 +9,32 @@ class Admin::ResourcesHelperTest < ActiveSupport::TestCase
9
9
 
10
10
  def render(*args); args; end
11
11
 
12
- should "verify display_link_to_previous" do
13
- @resource = Post
14
- params = { :action => "edit", :back_to => "/back_to_param" }
15
- self.expects(:params).at_least_once.returns(params)
12
+ context "display_link_to_previous" do
16
13
 
17
- partial = "admin/helpers/resources/display_link_to_previous"
18
- options = { :message => "You're updating a Post." }
14
+ should "verify display_link_to_previous" do
15
+ @resource = Post
16
+ params = { :action => "edit", :back_to => "/back_to_param" }
17
+ self.expects(:params).at_least_once.returns(params)
19
18
 
20
- assert_equal [ partial, options ], display_link_to_previous
19
+ expected = [ "admin/helpers/resources/display_link_to_previous", { :message => "You're updating a Post." } ]
20
+ output = display_link_to_previous
21
+
22
+ assert_equal expected, output
23
+ end
21
24
  end
22
25
 
23
- should "remove_filter_link" do
24
- output = remove_filter_link("")
25
- assert output.nil?
26
+ context "remove_filter_link" do
27
+
28
+ should "return nil when blank" do
29
+ output = remove_filter_link("")
30
+ assert_nil output
31
+ end
32
+
33
+ should "return link when it's present"
34
+
26
35
  end
27
36
 
28
- context "Build list" do
37
+ context "build_list" do
29
38
 
30
39
  setup do
31
40
  @model = TypusUser
@@ -34,17 +43,20 @@ class Admin::ResourcesHelperTest < ActiveSupport::TestCase
34
43
  @resource = "typus_users"
35
44
  end
36
45
 
37
- should "verify build_list_when_returns_a_table" do
38
- self.stubs(:build_table).returns("a_list_with_items")
46
+ should "return a table" do
47
+ expected = [ "admin/typus_users/list", { :items => [] } ]
39
48
  output = build_list(@model, @fields, @items, @resource)
40
- assert_equal "a_list_with_items", output
49
+ assert_equal expected, output
41
50
  end
42
51
 
43
- should "verify build_list_when_returns_a_template" do
52
+ should "return a template" do
44
53
  self.stubs(:render).returns("a_template")
45
54
  File.stubs(:exist?).returns(true)
55
+
56
+ expected = "a_template"
46
57
  output = build_list(@model, @fields, @items, @resource)
47
- assert_equal "a_template", output
58
+
59
+ assert_equal expected, output
48
60
  end
49
61
 
50
62
  end
@@ -16,12 +16,9 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
16
16
  default_url_options[:host] = 'test.host'
17
17
  end
18
18
 
19
- =begin
19
+ should "test_actions"
20
20
 
21
- def test_actions
22
- end
23
-
24
- def test_export
21
+ should_eventually "test_export" do
25
22
  @resource = Post
26
23
 
27
24
  params = { :controller => 'admin/posts', :action => 'index' }
@@ -35,12 +32,12 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
35
32
  assert_equal expected, output
36
33
  end
37
34
 
38
- def test_build_typus_list_with_empty_content_and_empty_header
35
+ should_eventually "test_build_typus_list_with_empty_content_and_empty_header" do
39
36
  output = build_typus_list([], :header => nil)
40
37
  assert output.empty?
41
38
  end
42
39
 
43
- def test_build_typus_list_with_content_and_header
40
+ should_eventually "test_build_typus_list_with_content_and_header" do
44
41
  output = build_typus_list(['item1', 'item2'], :header => "Chunky Bacon")
45
42
  assert !output.empty?
46
43
 
@@ -51,7 +48,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
51
48
  assert_equal expected, output
52
49
  end
53
50
 
54
- def test_build_typus_list_with_content_without_header
51
+ should_eventually "test_build_typus_list_with_content_without_header" do
55
52
  output = build_typus_list(['item1', 'item2'])
56
53
  expected = [ "admin/helpers/list", { :header => nil,
57
54
  :options => {},
@@ -59,7 +56,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
59
56
  assert_equal expected, output
60
57
  end
61
58
 
62
- def test_search
59
+ should_eventually "test_search" do
63
60
 
64
61
  @resource = TypusUser
65
62
 
@@ -82,23 +79,18 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
82
79
 
83
80
  end
84
81
 
85
- def test_filters
82
+ should_eventually "test_filters" do
86
83
  @resource = TypusUser
87
84
  @resource.expects(:typus_filters).returns(Array.new)
88
85
  output = filters
89
86
  assert output.nil?
90
87
  end
91
88
 
92
- def test_filters_with_filters
93
- end
89
+ should "test_filters_with_filters"
94
90
 
95
- def test_relationship_filter
96
- end
91
+ should "test_relationship_filter"
97
92
 
98
- def test_date_filter
99
-
100
- # FIXME
101
- return
93
+ should_eventually "test_date_filter" do
102
94
 
103
95
  @resource = TypusUser
104
96
  filter = 'created_at'
@@ -138,10 +130,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
138
130
 
139
131
  end
140
132
 
141
- def test_boolean_filter
142
-
143
- # FIXME
144
- return
133
+ should_eventually "test_boolean_filter" do
145
134
 
146
135
  @resource = TypusUser
147
136
  filter = 'status'
@@ -177,7 +166,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
177
166
 
178
167
  end
179
168
 
180
- def test_string_filter_when_values_are_strings
169
+ should_eventually "test_string_filter_when_values_are_strings" do
181
170
 
182
171
  @resource = TypusUser
183
172
  filter = 'role'
@@ -235,7 +224,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
235
224
 
236
225
  end
237
226
 
238
- def test_string_filter_when_values_are_arrays_of_strings
227
+ should_eventually "test_string_filter_when_values_are_arrays_of_strings" do
239
228
 
240
229
  @resource = TypusUser
241
230
  filter = 'role'
@@ -272,7 +261,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
272
261
 
273
262
  end
274
263
 
275
- def test_string_filter_when_empty_values
264
+ should_eventually "test_string_filter_when_empty_values" do
276
265
  @resource = TypusUser
277
266
  filter = 'role'
278
267
  request = 'role=admin&page=1'
@@ -282,6 +271,4 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
282
271
  assert output.empty?
283
272
  end
284
273
 
285
- =end
286
-
287
274
  end
@@ -15,12 +15,9 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
15
15
  default_url_options[:host] = "test.host"
16
16
  end
17
17
 
18
- =begin
18
+ should_eventually "test_build_table" do
19
19
 
20
- # FIXME
21
- def test_build_table
22
-
23
- @current_user = Factory(:typus_user)
20
+ current_user = Factory(:typus_user)
24
21
 
25
22
  params = { :controller => 'admin/typus_users', :action => 'index' }
26
23
  self.expects(:params).at_least_once.returns(params)
@@ -41,14 +38,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
41
38
 
42
39
  end
43
40
 
44
- =end
45
-
46
- =begin
41
+ should_eventually "test_table_header" do
47
42
 
48
- def test_table_header
49
-
50
- @current_user = mock()
51
- @current_user.expects(:can?).with("delete", TypusUser).returns(true)
43
+ current_user = mock()
44
+ current_user.expects(:can?).with("delete", TypusUser).returns(true)
52
45
 
53
46
  fields = TypusUser.typus_fields_for(:list)
54
47
 
@@ -66,14 +59,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
66
59
 
67
60
  end
68
61
 
69
- =end
70
-
71
- =begin
62
+ should_eventually "test_table_header_with_params" do
72
63
 
73
- def test_table_header_with_params
74
-
75
- @current_user = mock()
76
- @current_user.expects(:can?).with("delete", TypusUser).returns(true)
64
+ current_user = mock()
65
+ current_user.expects(:can?).with("delete", TypusUser).returns(true)
77
66
 
78
67
  fields = TypusUser.typus_fields_for(:list)
79
68
 
@@ -92,14 +81,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
92
81
 
93
82
  end
94
83
 
95
- =end
96
-
97
- =begin
98
-
99
- def test_table_header_when_user_cannot_delete_items
84
+ should_eventually "test_table_header_when_user_cannot_delete_items" do
100
85
 
101
- @current_user = mock()
102
- @current_user.expects(:can?).with("delete", TypusUser).returns(false)
86
+ current_user = mock()
87
+ current_user.expects(:can?).with("delete", TypusUser).returns(false)
103
88
 
104
89
  fields = TypusUser.typus_fields_for(:list)
105
90
 
@@ -117,14 +102,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
117
102
 
118
103
  end
119
104
 
120
- =end
105
+ should_eventually "test_table_header_when_user_cannot_delete_items_with_params" do
121
106
 
122
- =begin
123
-
124
- def test_table_header_when_user_cannot_delete_items_with_params
125
-
126
- @current_user = mock()
127
- @current_user.expects(:can?).with("delete", TypusUser).returns(false)
107
+ current_user = mock()
108
+ current_user.expects(:can?).with("delete", TypusUser).returns(false)
128
109
 
129
110
  fields = TypusUser.typus_fields_for(:list)
130
111
 
@@ -141,13 +122,9 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
141
122
 
142
123
  end
143
124
 
144
- =end
145
-
146
- =begin
125
+ should_eventually "test_table_belongs_to_field" do
147
126
 
148
- def test_table_belongs_to_field
149
-
150
- @current_user = Factory(:typus_user)
127
+ current_user = Factory(:typus_user)
151
128
 
152
129
  comment = comments(:without_post_id)
153
130
  output = table_belongs_to_field("post", comment)
@@ -164,58 +141,42 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
164
141
 
165
142
  end
166
143
 
167
- =end
168
-
169
- =begin
170
-
171
- def test_table_has_and_belongs_to_many_field
144
+ should_eventually "test_table_has_and_belongs_to_many_field" do
172
145
  post = Factory(:post)
173
-
174
146
  output = table_has_and_belongs_to_many_field("comments", post)
175
147
  expected = %(<td>John, Me, Me</td>)
176
-
177
148
  assert_equal expected.strip, output
178
149
  end
179
150
 
180
- =end
181
-
182
- should "test_table_string_field" do
151
+ should_eventually "test_table_string_field" do
183
152
  post = Factory(:post)
184
-
185
153
  output = table_string_field(:title, post, :created_at)
186
154
  expected = %(<td class="title">#{post.title}</td>)
187
-
188
155
  assert_equal expected.strip, output
189
156
  end
190
157
 
191
- should "test_table_string_field_with_link" do
158
+ should_eventually "test_table_string_field_with_link" do
192
159
  post = Factory(:post)
193
-
194
160
  output = table_string_field(:title, post, :title)
195
161
  expected = %(<td class="title">#{post.title}</td>)
196
-
197
162
  assert_equal expected.strip, output
198
163
  end
199
164
 
200
- should "table_tree_field_when_displays_a_parent" do
165
+ should_eventually "table_tree_field_when_displays_a_parent" do
201
166
  page = Factory(:page)
202
-
203
167
  output = table_tree_field("test", page)
204
168
  expected = "<td>&#151;</td>"
205
-
206
169
  assert_equal expected, output
207
170
  end
208
171
 
209
- should "table_tree_field_when_displays_a_children" do
172
+ should_eventually "table_tree_field_when_displays_a_children" do
210
173
  page = Factory(:page, :status => "unpublished")
211
-
212
174
  output = table_tree_field("test", page)
213
175
  expected = "<td>&#151;</td>"
214
-
215
176
  assert_equal expected, output
216
177
  end
217
178
 
218
- should "test_table_datetime_field" do
179
+ should_eventually "test_table_datetime_field" do
219
180
  post = Factory(:post)
220
181
  Time::DATE_FORMATS[:post_short] = "%m/%y"
221
182
 
@@ -225,7 +186,7 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
225
186
  assert_equal expected.strip, output
226
187
  end
227
188
 
228
- should "test_table_datetime_field_with_link" do
189
+ should_eventually "test_table_datetime_field_with_link" do
229
190
  post = Factory(:post)
230
191
  Time::DATE_FORMATS[:post_short] = "%m/%y"
231
192
 
@@ -235,10 +196,7 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
235
196
  assert_equal expected.strip, output
236
197
  end
237
198
 
238
- =begin
239
-
240
- # FIXME: NameError: undefined local variable or method `controller' for
241
- def test_table_boolean_field
199
+ should_eventually "test_table_boolean_field" do
242
200
 
243
201
  post = Factory(:typus_user)
244
202
  output = table_boolean_field("status", post)
@@ -258,6 +216,4 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
258
216
 
259
217
  end
260
218
 
261
- =end
262
-
263
219
  end