sidebar_sections.feature 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. Feature: Sidebar Sections
  2. Creating and Configuring sidebar sections
  3. Background:
  4. Given I am logged in
  5. And a post with the title "Hello World" exists
  6. Scenario: Create a sidebar for all actions
  7. Given a configuration of:
  8. """
  9. ActiveAdmin.register Post do
  10. sidebar :help do
  11. "Need help? Email us at help@example.com"
  12. end
  13. end
  14. """
  15. When I am on the index page for posts
  16. Then I should see a sidebar titled "Help"
  17. Then I should see /Need help/ within the "Help" sidebar
  18. When I follow "View"
  19. Then I should see a sidebar titled "Help"
  20. When I follow "Edit Post"
  21. Then I should see a sidebar titled "Help"
  22. When I am on the index page for posts
  23. When I follow "New Post"
  24. Then I should see a sidebar titled "Help"
  25. Scenario: Create a sidebar for only one action
  26. Given a configuration of:
  27. """
  28. ActiveAdmin.register Post do
  29. sidebar :help, :only => :index do
  30. "Need help? Email us at help@example.com"
  31. end
  32. end
  33. """
  34. When I am on the index page for posts
  35. Then I should see a sidebar titled "Help"
  36. Then I should see /Need help/ within the "Help" sidebar
  37. When I follow "View"
  38. Then I should not see a sidebar titled "Help"
  39. When I follow "Edit Post"
  40. Then I should not see a sidebar titled "Help"
  41. When I am on the index page for posts
  42. When I follow "New Post"
  43. Then I should not see a sidebar titled "Help"
  44. Scenario: Create a sidebar for all except one action
  45. Given a configuration of:
  46. """
  47. ActiveAdmin.register Post do
  48. sidebar :help, :except => :index do
  49. "Need help? Email us at help@example.com"
  50. end
  51. end
  52. """
  53. When I am on the index page for posts
  54. Then I should not see a sidebar titled "Help"
  55. When I follow "View"
  56. Then I should see a sidebar titled "Help"
  57. When I follow "Edit Post"
  58. Then I should see a sidebar titled "Help"
  59. When I am on the index page for posts
  60. When I follow "New Post"
  61. Then I should see a sidebar titled "Help"
  62. Scenario: Create a sidebar for only one action with if clause that returns false
  63. Given a configuration of:
  64. """
  65. ActiveAdmin.register Post do
  66. sidebar :help, :only => :index, :if => proc{ current_active_admin_user.nil? } do
  67. "Need help? Email us at help@example.com"
  68. end
  69. end
  70. """
  71. When I am on the index page for posts
  72. Then I should not see a sidebar titled "Help"
  73. When I follow "View"
  74. Then I should not see a sidebar titled "Help"
  75. When I follow "Edit Post"
  76. Then I should not see a sidebar titled "Help"
  77. When I am on the index page for posts
  78. When I follow "New Post"
  79. Then I should not see a sidebar titled "Help"
  80. Scenario: Create a sidebar for only one action with if clause that returns true
  81. Given a configuration of:
  82. """
  83. ActiveAdmin.register Post do
  84. sidebar :help, :only => :show, :if => proc{ !current_active_admin_user.nil? } do
  85. "Need help? Email us at help@example.com"
  86. end
  87. end
  88. """
  89. When I am on the index page for posts
  90. Then I should not see a sidebar titled "Help"
  91. When I follow "View"
  92. Then I should see a sidebar titled "Help"
  93. Then I should see /Need help/ within the "Help" sidebar
  94. When I follow "Edit Post"
  95. Then I should not see a sidebar titled "Help"
  96. When I am on the index page for posts
  97. When I follow "New Post"
  98. Then I should not see a sidebar titled "Help"
  99. Scenario: Create a sidebar with deep content
  100. Given a configuration of:
  101. """
  102. ActiveAdmin.register Post do
  103. sidebar :help do
  104. ul do
  105. li "First List First Item"
  106. li "First List Second Item"
  107. end
  108. ul do
  109. li "Second List First Item"
  110. li "Second List Second Item"
  111. end
  112. end
  113. end
  114. """
  115. When I am on the index page for posts
  116. Then I should see a sidebar titled "Help"
  117. And I should see "First List First Item" within the "Help" sidebar
  118. And I should see "Second List Second Item" within the "Help" sidebar
  119. Scenario: Rendering sidebar by default without a block or partial name
  120. Given "app/views/admin/posts/_help_sidebar.html.erb" contains:
  121. """
  122. <p>Hello World from a partial</p>
  123. """
  124. Given a configuration of:
  125. """
  126. ActiveAdmin.register Post do
  127. sidebar :help
  128. end
  129. """
  130. When I am on the index page for posts
  131. Then I should see "Hello World from a partial" within the "Help" sidebar
  132. Scenario: Rendering a partial as the sidebar content
  133. Given "app/views/admin/posts/_custom_help_partial.html.erb" contains:
  134. """
  135. <p>Hello World from a custom partial</p>
  136. """
  137. Given a configuration of:
  138. """
  139. ActiveAdmin.register Post do
  140. sidebar :help, :partial => "custom_help_partial"
  141. end
  142. """
  143. When I am on the index page for posts
  144. Then I should see "Hello World from a custom partial" within the "Help" sidebar