fesplugas-typus 0.9.0

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 (154) hide show
  1. data/.gitignore +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +80 -0
  4. data/Rakefile +61 -0
  5. data/VERSION +1 -0
  6. data/app/controllers/admin/master_controller.rb +324 -0
  7. data/app/controllers/typus_controller.rb +127 -0
  8. data/app/helpers/admin/form_helper.rb +351 -0
  9. data/app/helpers/admin/master_helper.rb +99 -0
  10. data/app/helpers/admin/public_helper.rb +24 -0
  11. data/app/helpers/admin/sidebar_helper.rb +259 -0
  12. data/app/helpers/admin/table_helper.rb +227 -0
  13. data/app/helpers/typus_helper.rb +169 -0
  14. data/app/models/typus_mailer.rb +14 -0
  15. data/app/models/typus_user.rb +5 -0
  16. data/app/views/admin/dashboard/_sidebar.html.erb +9 -0
  17. data/app/views/admin/resources/edit.html.erb +29 -0
  18. data/app/views/admin/resources/index.html.erb +28 -0
  19. data/app/views/admin/resources/new.html.erb +27 -0
  20. data/app/views/admin/resources/show.html.erb +21 -0
  21. data/app/views/admin/shared/_footer.html.erb +1 -0
  22. data/app/views/admin/shared/_pagination.html.erb +28 -0
  23. data/app/views/layouts/admin.html.erb +72 -0
  24. data/app/views/layouts/typus.html.erb +29 -0
  25. data/app/views/typus/dashboard.html.erb +13 -0
  26. data/app/views/typus/recover_password.html.erb +7 -0
  27. data/app/views/typus/reset_password.html.erb +13 -0
  28. data/app/views/typus/sign_in.html.erb +9 -0
  29. data/app/views/typus/sign_up.html.erb +7 -0
  30. data/app/views/typus_mailer/reset_password_link.erb +11 -0
  31. data/config/locales/es.yml +106 -0
  32. data/config/locales/pt-BR.yml +108 -0
  33. data/config/locales/typus_hacks.yml +14 -0
  34. data/config/routes.rb +14 -0
  35. data/generators/typus/templates/config/initializers/typus.rb +27 -0
  36. data/generators/typus/templates/config/typus/application.yml +45 -0
  37. data/generators/typus/templates/config/typus/application_roles.yml +23 -0
  38. data/generators/typus/templates/config/typus/typus.yml +14 -0
  39. data/generators/typus/templates/config/typus/typus_roles.yml +2 -0
  40. data/generators/typus/templates/db/create_typus_users.rb +21 -0
  41. data/generators/typus/templates/public/images/admin/arrow_down.gif +0 -0
  42. data/generators/typus/templates/public/images/admin/arrow_up.gif +0 -0
  43. data/generators/typus/templates/public/images/admin/spinner.gif +0 -0
  44. data/generators/typus/templates/public/images/admin/status_false.gif +0 -0
  45. data/generators/typus/templates/public/images/admin/status_true.gif +0 -0
  46. data/generators/typus/templates/public/images/admin/trash.gif +0 -0
  47. data/generators/typus/templates/public/javascripts/admin/application.js +14 -0
  48. data/generators/typus/templates/public/stylesheets/admin/reset.css +68 -0
  49. data/generators/typus/templates/public/stylesheets/admin/screen.css +709 -0
  50. data/generators/typus/typus_generator.rb +141 -0
  51. data/generators/typus_update_schema_to_01/templates/config/typus.yml +14 -0
  52. data/generators/typus_update_schema_to_01/templates/migration.rb +11 -0
  53. data/generators/typus_update_schema_to_01/typus_update_schema_to_01_generator.rb +19 -0
  54. data/init.rb +19 -0
  55. data/lib/typus/active_record.rb +298 -0
  56. data/lib/typus/authentication.rb +155 -0
  57. data/lib/typus/configuration.rb +92 -0
  58. data/lib/typus/format.rb +56 -0
  59. data/lib/typus/generator.rb +173 -0
  60. data/lib/typus/hash.rb +10 -0
  61. data/lib/typus/locale.rb +17 -0
  62. data/lib/typus/object.rb +22 -0
  63. data/lib/typus/quick_edit.rb +33 -0
  64. data/lib/typus/reloader.rb +17 -0
  65. data/lib/typus/string.rb +11 -0
  66. data/lib/typus/user.rb +137 -0
  67. data/lib/typus.rb +133 -0
  68. data/lib/vendor/active_record.rb +15 -0
  69. data/lib/vendor/paginator.rb +143 -0
  70. data/tasks/typus_tasks.rake +26 -0
  71. data/test/config/broken/application.yml +68 -0
  72. data/test/config/broken/application_roles.yml +20 -0
  73. data/test/config/broken/empty.yml +0 -0
  74. data/test/config/broken/empty_roles.yml +0 -0
  75. data/test/config/broken/undefined.yml +3 -0
  76. data/test/config/broken/undefined_roles.yml +6 -0
  77. data/test/config/default/typus.yml +14 -0
  78. data/test/config/default/typus_roles.yml +2 -0
  79. data/test/config/empty/empty_01.yml +0 -0
  80. data/test/config/empty/empty_01_roles.yml +0 -0
  81. data/test/config/empty/empty_02.yml +0 -0
  82. data/test/config/empty/empty_02_roles.yml +0 -0
  83. data/test/config/locales/es.yml +10 -0
  84. data/test/config/ordered/001_roles.yml +2 -0
  85. data/test/config/ordered/002_roles.yml +2 -0
  86. data/test/config/unordered/app_one_roles.yml +2 -0
  87. data/test/config/unordered/app_two_roles.yml +2 -0
  88. data/test/config/working/application.yml +67 -0
  89. data/test/config/working/application_roles.yml +22 -0
  90. data/test/config/working/typus.yml +14 -0
  91. data/test/config/working/typus_roles.yml +2 -0
  92. data/test/fixtures/app/controllers/admin/assets_controller.rb +2 -0
  93. data/test/fixtures/app/controllers/admin/categories_controller.rb +2 -0
  94. data/test/fixtures/app/controllers/admin/comments_controller.rb +2 -0
  95. data/test/fixtures/app/controllers/admin/pages_controller.rb +2 -0
  96. data/test/fixtures/app/controllers/admin/posts_controller.rb +2 -0
  97. data/test/fixtures/app/controllers/admin/status_controller.rb +6 -0
  98. data/test/fixtures/app/controllers/admin/typus_users_controller.rb +2 -0
  99. data/test/fixtures/app/controllers/admin/watch_dog_controller.rb +6 -0
  100. data/test/fixtures/app/views/admin/comments/_edit_bottom.html.erb +1 -0
  101. data/test/fixtures/app/views/admin/comments/_edit_sidebar.html.erb +1 -0
  102. data/test/fixtures/app/views/admin/comments/_edit_top.html.erb +1 -0
  103. data/test/fixtures/app/views/admin/comments/_index_bottom.html.erb +1 -0
  104. data/test/fixtures/app/views/admin/comments/_index_sidebar.html.erb +1 -0
  105. data/test/fixtures/app/views/admin/comments/_index_top.html.erb +1 -0
  106. data/test/fixtures/app/views/admin/comments/_new_bottom.html.erb +1 -0
  107. data/test/fixtures/app/views/admin/comments/_new_sidebar.html.erb +1 -0
  108. data/test/fixtures/app/views/admin/comments/_new_top.html.erb +1 -0
  109. data/test/fixtures/app/views/admin/comments/_show_bottom.html.erb +1 -0
  110. data/test/fixtures/app/views/admin/comments/_show_sidebar.html.erb +1 -0
  111. data/test/fixtures/app/views/admin/comments/_show_top.html.erb +1 -0
  112. data/test/fixtures/app/views/admin/dashboard/_bottom.html.erb +1 -0
  113. data/test/fixtures/app/views/admin/dashboard/_sidebar.html.erb +1 -0
  114. data/test/fixtures/app/views/admin/dashboard/_top.html.erb +1 -0
  115. data/test/fixtures/app/views/admin/shared/_footer.html.erb +1 -0
  116. data/test/fixtures/app/views/admin/status/index.html.erb +1 -0
  117. data/test/fixtures/app/views/admin/templates/_datepicker.html.erb +1 -0
  118. data/test/fixtures/assets.yml +11 -0
  119. data/test/fixtures/categories.yml +14 -0
  120. data/test/fixtures/comments.yml +27 -0
  121. data/test/fixtures/pages.yml +41 -0
  122. data/test/fixtures/posts.yml +37 -0
  123. data/test/fixtures/typus_users.yml +54 -0
  124. data/test/functional/admin/assets_controller_test.rb +57 -0
  125. data/test/functional/admin/categories_controller_test.rb +106 -0
  126. data/test/functional/admin/comments_controller_test.rb +121 -0
  127. data/test/functional/admin/master_controller_test.rb +5 -0
  128. data/test/functional/admin/posts_controller_test.rb +278 -0
  129. data/test/functional/admin/status_controller_test.rb +43 -0
  130. data/test/functional/admin/typus_users_controller_test.rb +239 -0
  131. data/test/functional/typus_controller_test.rb +315 -0
  132. data/test/helper.rb +51 -0
  133. data/test/helpers/admin/form_helper_test.rb +316 -0
  134. data/test/helpers/admin/master_helper_test.rb +65 -0
  135. data/test/helpers/admin/public_helper_test.rb +22 -0
  136. data/test/helpers/admin/sidebar_helper_test.rb +351 -0
  137. data/test/helpers/admin/table_helper_test.rb +255 -0
  138. data/test/helpers/typus_helper_test.rb +106 -0
  139. data/test/lib/active_record_test.rb +372 -0
  140. data/test/lib/configuration_test.rb +91 -0
  141. data/test/lib/hash_test.rb +11 -0
  142. data/test/lib/routes_test.rb +82 -0
  143. data/test/lib/string_test.rb +25 -0
  144. data/test/lib/typus_test.rb +105 -0
  145. data/test/models.rb +51 -0
  146. data/test/schema.rb +64 -0
  147. data/test/unit/typus_mailer_test.rb +33 -0
  148. data/test/unit/typus_test.rb +17 -0
  149. data/test/unit/typus_user_roles_test.rb +90 -0
  150. data/test/unit/typus_user_test.rb +177 -0
  151. data/test/vendor/active_record_test.rb +18 -0
  152. data/test/vendor/paginator_test.rb +138 -0
  153. data/typus.gemspec +225 -0
  154. metadata +241 -0
@@ -0,0 +1 @@
1
+ _top.html.erb
@@ -0,0 +1 @@
1
+ _footer.html.erb
@@ -0,0 +1 @@
1
+ index.html.erb
@@ -0,0 +1 @@
1
+ datepicker_template_<%= attribute %>
@@ -0,0 +1,11 @@
1
+ first:
2
+ id: 1
3
+ caption: This is the caption.
4
+ resource_type: Post
5
+ resource_id: 1
6
+
7
+ second:
8
+ id: 2
9
+ caption: This is the second caption.
10
+ resource_type: Post
11
+ resource_id: 1
@@ -0,0 +1,14 @@
1
+ first:
2
+ id: 3
3
+ name: First Category
4
+ position: 1
5
+
6
+ second:
7
+ id: 1
8
+ name: Second Category
9
+ position: 2
10
+
11
+ third:
12
+ id: 2
13
+ name: Third Category
14
+ position: 3
@@ -0,0 +1,27 @@
1
+ first:
2
+ id: 1
3
+ name: John
4
+ email: john@example.com
5
+ body: Body of the comment
6
+ post_id: 1
7
+
8
+ second:
9
+ id: 2
10
+ name: Me
11
+ email: me@example.com
12
+ body: Body of the comment
13
+ post_id: 1
14
+
15
+ without_post_id:
16
+ id: 3
17
+ name: John
18
+ email: john@example.com
19
+ body: Body of the comment
20
+ post_id:
21
+
22
+ with_post_id:
23
+ id: 4
24
+ name: Me
25
+ email: me@example.com
26
+ body: Body of the comment
27
+ post_id: 1
@@ -0,0 +1,41 @@
1
+ published:
2
+ id: 1
3
+ title: Published Page
4
+ body: Content of the published page.
5
+ is_published: true
6
+ parent_id:
7
+
8
+ unpublished:
9
+ id: 2
10
+ title: Unpublished Page
11
+ body: Content of the unpublished page.
12
+ is_published: false
13
+ parent_id: 1
14
+
15
+ section:
16
+ id: 3
17
+ title: Section
18
+ body: This is a section.
19
+ is_published: true
20
+ parent_id:
21
+
22
+ subsection_1:
23
+ id: 4
24
+ title: Subsection 1
25
+ body: This is a subsection.
26
+ is_published: true
27
+ parent_id: 3
28
+
29
+ subsection_2:
30
+ id: 5
31
+ title: Subsection 2
32
+ body: This is a subsection.
33
+ is_published: true
34
+ parent_id: 3
35
+
36
+ subsubsection:
37
+ id: 6
38
+ title: Subsubsection
39
+ body: This is a subsubsection.
40
+ is_published: true
41
+ parent_id: 5
@@ -0,0 +1,37 @@
1
+ # Belongs to admin.
2
+ published:
3
+ id: 1
4
+ title: Title One
5
+ body: This is the body.
6
+ created_at: <%= 7.days.ago.to_s(:db) %>
7
+ updated_at: <%= 7.days.ago.to_s(:db) %>
8
+ status: true
9
+ typus_user_id: 1
10
+
11
+ # Belongs to editor.
12
+ unpublished:
13
+ id: 2
14
+ title: Title Two
15
+ body: This is the body.
16
+ created_at: <%= 6.days.ago.to_s(:db) %>
17
+ updated_at: <%= 6.days.ago.to_s(:db) %>
18
+ status: false
19
+ typus_user_id: 1
20
+
21
+ owned_by_admin:
22
+ id: 3
23
+ title: Owned by admin
24
+ body: This is the body.
25
+ created_at: <%= 5.days.ago.to_s(:db) %>
26
+ updated_at: <%= 5.days.ago.to_s(:db) %>
27
+ status: false
28
+ typus_user_id: 1
29
+
30
+ owned_by_editor:
31
+ id: 4
32
+ title: Owned by editor
33
+ body: This is the body.
34
+ created_at: <%= 4.days.ago.to_s(:db) %>
35
+ updated_at: <%= 4.days.ago.to_s(:db) %>
36
+ status: false
37
+ typus_user_id: 2
@@ -0,0 +1,54 @@
1
+ admin:
2
+ id: 1
3
+ first_name: Admin
4
+ last_name: Example
5
+ role: admin
6
+ email: admin@example.com
7
+ status: true
8
+ token: 1A2B3C4D5E6F
9
+ salt: admin
10
+ crypted_password: <%= Digest::SHA1.hexdigest("--admin--#{12345678}") %>
11
+
12
+ editor:
13
+ id: 2
14
+ first_name: Editor
15
+ last_name: Example
16
+ role: editor
17
+ email: editor@example.com
18
+ status: true
19
+ token: A2B3C4D5E6F1
20
+ salt: editor
21
+ crypted_password: <%= Digest::SHA1.hexdigest("--editor--#{12345678}") %>
22
+
23
+ disabled_user:
24
+ id: 3
25
+ first_name: Typus
26
+ last_name: User
27
+ role: editor
28
+ email: disabled_user@example.com
29
+ status: false
30
+ token: 2B3C4D5E6F1A
31
+ salt: disabled_user
32
+ crypted_password: <%= Digest::SHA1.hexdigest("--disabled_user--#{12345678}") %>
33
+
34
+ designer:
35
+ id: 4
36
+ first_name: Designer
37
+ last_name: Example
38
+ role: designer
39
+ email: designer@example.com
40
+ status: true
41
+ token: B3C4D5E6F1A2
42
+ salt: designer
43
+ crypted_password: <%= Digest::SHA1.hexdigest("--designer--#{12345678}") %>
44
+
45
+ removed_role:
46
+ id: 5
47
+ first_name: Removed
48
+ last_name: Example
49
+ role: removed
50
+ email: removed@example.com
51
+ status: true
52
+ token: 3C4D5E6F1A2B
53
+ salt: removed_role
54
+ crypted_password: <%= Digest::SHA1.hexdigest("--removed_role--#{12345678}") %>
@@ -0,0 +1,57 @@
1
+ require 'test/helper'
2
+
3
+ ##
4
+ # Test polimorphic relationships using the relate & unrelate actions.
5
+ #
6
+ class Admin::AssetsControllerTest < ActionController::TestCase
7
+
8
+ def setup
9
+ typus_user = typus_users(:admin)
10
+ @request.session[:typus_user_id] = typus_user.id
11
+ end
12
+
13
+ def test_should_test_polymorphic_relationship_message
14
+ post_ = posts(:published)
15
+ get :new, { :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id }
16
+ assert_match "You're adding a new Asset to Post.", @response.body
17
+ end
18
+
19
+ def test_should_create_a_polymorphic_relationship
20
+
21
+ post_ = posts(:published)
22
+
23
+ assert_difference('post_.assets.count') do
24
+ post :create, { :back_to => "/admin/posts/edit/#{post_.id}", :resource => post_.class.name, :resource_id => post_.id }
25
+ end
26
+
27
+ assert_response :redirect
28
+ assert_redirected_to '/admin/posts/edit/1#assets'
29
+ assert flash[:success]
30
+ assert_equal 'Asset successfully assigned to Post.', flash[:success]
31
+
32
+ end
33
+
34
+ def test_should_test_polymorphic_relationship_edit_message
35
+ post_ = posts(:published)
36
+ asset_ = assets(:first)
37
+ get :edit, { :id => asset_.id, :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id }
38
+ assert_match "You're updating a Asset for Post.", @response.body
39
+ end
40
+
41
+ def test_should_return_to_back_to_url
42
+
43
+ options = Typus::Configuration.options.merge(:index_after_save => true)
44
+ Typus::Configuration.stubs(:options).returns(options)
45
+
46
+ post_ = posts(:published)
47
+ asset_ = assets(:first)
48
+
49
+ post :update, { :back_to => "/admin/posts/#{post_.id}/edit", :resource => post_.class.name, :resource_id => post_.id, :id => asset_.id }
50
+ assert_response :redirect
51
+ assert_redirected_to '/admin/posts/1/edit#assets'
52
+ assert flash[:success]
53
+ assert_equal 'Asset successfully updated.', flash[:success]
54
+
55
+ end
56
+
57
+ end
@@ -0,0 +1,106 @@
1
+ require 'test/helper'
2
+
3
+ ##
4
+ # Test position action if acts as list is installed.
5
+ #
6
+ class Admin::CategoriesControllerTest < ActionController::TestCase
7
+
8
+ def setup
9
+ user = typus_users(:editor)
10
+ @request.session[:typus_user_id] = user.id
11
+ @request.env['HTTP_REFERER'] = '/admin/categories'
12
+ end
13
+
14
+ def test_should_position_item_one_step_down
15
+ return if !defined?(ActiveRecord::Acts::List)
16
+ first_category = categories(:first)
17
+ assert_equal 1, first_category.position
18
+ second_category = categories(:second)
19
+ assert_equal 2, second_category.position
20
+ get :position, { :id => first_category.id, :go => 'move_lower' }
21
+ assert flash[:success]
22
+ assert_match /Record moved lower./, flash[:success]
23
+ assert_equal 2, first_category.reload.position
24
+ assert_equal 1, second_category.reload.position
25
+ end
26
+
27
+ def test_should_position_item_one_step_up
28
+ return if !defined?(ActiveRecord::Acts::List)
29
+ first_category = categories(:first)
30
+ assert_equal 1, first_category.position
31
+ second_category = categories(:second)
32
+ assert_equal 2, second_category.position
33
+ get :position, { :id => second_category.id, :go => 'move_higher' }
34
+ assert flash[:success]
35
+ assert_match /Record moved higher./, flash[:success]
36
+ assert_equal 2, first_category.reload.position
37
+ assert_equal 1, second_category.reload.position
38
+ end
39
+
40
+ def test_should_position_top_item_to_bottom
41
+ return if !defined?(ActiveRecord::Acts::List)
42
+ first_category = categories(:first)
43
+ assert_equal 1, first_category.position
44
+ get :position, { :id => first_category.id, :go => 'move_to_bottom' }
45
+ assert flash[:success]
46
+ assert_match /Record moved to bottom./, flash[:success]
47
+ assert_equal 3, first_category.reload.position
48
+ end
49
+
50
+ def test_should_position_bottom_item_to_top
51
+ return if !defined?(ActiveRecord::Acts::List)
52
+ third_category = categories(:third)
53
+ assert_equal 3, third_category.position
54
+ get :position, { :id => third_category.id, :go => 'move_to_top' }
55
+ assert flash[:success]
56
+ assert_match /Record moved to top./, flash[:success]
57
+ assert_equal 1, third_category.reload.position
58
+ end
59
+
60
+ def test_should_verify_items_are_sorted_by_position_on_list
61
+ get :index
62
+ assert_response :success
63
+ assert_equal [ 1, 2, 3 ], assigns['items'].items.map(&:position)
64
+ assert_equal [ 2, 3, 1 ], Category.find(:all, :order => "id ASC").map(&:position)
65
+ end
66
+
67
+ def test_should_allow_admin_to_add_a_category
68
+ admin = typus_users(:admin)
69
+ @request.session[:typus_user_id] = admin.id
70
+ assert admin.can_perform?('Category', 'create')
71
+ end
72
+
73
+ def test_should_not_allow_designer_to_add_a_category
74
+ designer = typus_users(:designer)
75
+ @request.session[:typus_user_id] = designer.id
76
+ category = categories(:first)
77
+ get :new
78
+ assert_response :redirect
79
+ assert flash[:notice]
80
+ assert_equal "Designer can't perform action (new).", flash[:notice]
81
+ assert_redirected_to :action => :index
82
+ end
83
+
84
+ def test_should_allow_admin_to_destroy_a_category
85
+ admin = typus_users(:admin)
86
+ @request.session[:typus_user_id] = admin.id
87
+ category = categories(:first)
88
+ get :destroy, { :id => category.id }
89
+ assert_response :redirect
90
+ assert flash[:success]
91
+ assert_match /Category successfully removed./, flash[:success]
92
+ assert_redirected_to :action => :index
93
+ end
94
+
95
+ def test_should_not_allow_designer_to_destroy_a_category
96
+ designer = typus_users(:designer)
97
+ @request.session[:typus_user_id] = designer.id
98
+ category = categories(:first)
99
+ get :destroy, { :id => category.id, :method => :delete }
100
+ assert_response :redirect
101
+ assert flash[:notice]
102
+ assert_match /Designer can't delete this item/, flash[:notice]
103
+ assert_redirected_to :action => :index
104
+ end
105
+
106
+ end
@@ -0,0 +1,121 @@
1
+ require 'test/helper'
2
+
3
+ ##
4
+ # Test template extensions rendering and things related to views.
5
+ #
6
+ class Admin::CommentsControllerTest < ActionController::TestCase
7
+
8
+ def setup
9
+ @typus_user = typus_users(:admin)
10
+ @request.session[:typus_user_id] = @typus_user.id
11
+ @comment = comments(:first)
12
+ end
13
+
14
+ def test_should_render_posts_extensions_on_index
15
+ get :index
16
+ assert_response :success
17
+ partials = %w( _index_sidebar.html.erb _index_top.html.erb _index_bottom.html.erb )
18
+ partials.each { |p| assert_match p, @response.body }
19
+ end
20
+
21
+ def test_should_render_posts_extensions_on_edit
22
+ get :edit, { :id => @comment.id }
23
+ assert_response :success
24
+ partials = %w( _edit_sidebar.html.erb _edit_top.html.erb _edit_bottom.html.erb )
25
+ partials.each { |p| assert_match p, @response.body }
26
+ end
27
+
28
+ def test_should_render_posts_extensions_on_show
29
+ get :show, { :id => @comment.id }
30
+ assert_response :success
31
+ partials = %w( _show_sidebar.html.erb _show_top.html.erb _show_bottom.html.erb )
32
+ partials.each { |p| assert_match p, @response.body }
33
+ end
34
+
35
+ def test_should_verify_page_title_on_index
36
+ get :index
37
+ assert_select 'title', /#{Typus::Configuration.options[:app_name]}/
38
+ assert_select 'title', /Comments/
39
+ assert_select 'title', /&rsaquo;/
40
+ end
41
+
42
+ def test_should_verify_page_title_on_new
43
+ get :new
44
+ assert_select 'title', /#{Typus::Configuration.options[:app_name]}/
45
+ assert_select 'title', /Comments/
46
+ assert_select 'title', /New/
47
+ assert_select 'title', /&rsaquo;/
48
+ end
49
+
50
+ def test_should_verify_page_title_on_edit
51
+ comment = comments(:first)
52
+ get :edit, :id => comment.id
53
+ assert_select 'title', /#{Typus::Configuration.options[:app_name]}/
54
+ assert_select 'title', /Comments/
55
+ assert_select 'title', /Edit/
56
+ assert_select 'title', /&rsaquo;/
57
+ end
58
+
59
+ def test_should_show_add_new_link_in_index
60
+ get :index
61
+ assert_response :success
62
+ assert_match 'Add entry', @response.body
63
+ end
64
+
65
+ def test_should_not_show_add_new_link_in_index
66
+
67
+ typus_user = typus_users(:designer)
68
+ @request.session[:typus_user_id] = typus_user.id
69
+
70
+ get :index
71
+ assert_response :success
72
+ assert_no_match /Add comment/, @response.body
73
+
74
+ end
75
+
76
+ def test_should_show_trash_item_image_and_link_in_index
77
+ get :index
78
+ assert_response :success
79
+ assert_match /trash.gif/, @response.body
80
+ end
81
+
82
+ def test_should_not_show_remove_item_link_in_index
83
+
84
+ typus_user = typus_users(:designer)
85
+ @request.session[:typus_user_id] = typus_user.id
86
+
87
+ get :index
88
+ assert_response :success
89
+ assert_no_match /trash.gif/, @response.body
90
+
91
+ end
92
+
93
+ def test_should_verify_new_comment_contains_a_link_to_add_a_new_post
94
+ get :new
95
+ match = '/admin/posts/new?back_to=%2Fadmin%2Fcomments%2Fnew&amp;selected=post_id'
96
+ assert_match match, @response.body
97
+ end
98
+
99
+ def test_should_verify_edit_comment_contains_a_link_to_add_a_new_post
100
+ comment = comments(:first)
101
+ get :edit, :id => comment.id
102
+ match = "/admin/posts/new?back_to=%2Fadmin%2Fcomments%2Fedit%2F#{comment.id}&amp;selected=post_id"
103
+ assert_match match, @response.body
104
+ end
105
+
106
+ def test_should_generate_csv
107
+
108
+ expected = <<-CSV
109
+ Email,Post
110
+ john@example.com,1
111
+ me@example.com,1
112
+ john@example.com,
113
+ me@example.com,1
114
+ CSV
115
+
116
+ get :index, :format => 'csv'
117
+ assert_equal expected, @response.body
118
+
119
+ end
120
+
121
+ end
@@ -0,0 +1,5 @@
1
+ require 'test/helper'
2
+
3
+ class Admin::MasterControllerTest < ActionController::TestCase
4
+
5
+ end