commenting.feature 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. Feature: Commenting
  2. As a user
  3. In order to document changes and have a discussion
  4. I want to store and view comments on a resource
  5. Background:
  6. Given a post with the title "Hello World" written by "Jane Doe" exists
  7. Scenario: View a resource with no comments
  8. Given a show configuration of:
  9. """
  10. ActiveAdmin.register Post
  11. """
  12. Then I should see "Comments (0)"
  13. And I should see "No comments yet."
  14. Scenario: Create a new comment
  15. Given a show configuration of:
  16. """
  17. ActiveAdmin.register Post
  18. """
  19. When I add a comment "Hello from Comment"
  20. Then I should see a flash with "Comment was successfully created"
  21. And I should be in the resource section for posts
  22. And I should see "Comments (1)"
  23. And I should see "Hello from Comment"
  24. And I should see a comment by "admin@example.com"
  25. Scenario: View resource with comments turned off
  26. Given a show configuration of:
  27. """
  28. ActiveAdmin.register Post do
  29. config.comments = false
  30. end
  31. """
  32. Then I should not see "Comments"
  33. Scenario: View a resource in a namespace that doesn't have comments
  34. Given a configuration of:
  35. """
  36. post_config = ActiveAdmin.register Post, :namespace => :new_namespace
  37. post_config.namespace.allow_comments = false
  38. """
  39. Given I am logged in
  40. When I am on the index page for posts in the new_namespace namespace
  41. And I follow "View"
  42. Then I should not see "Comments"
  43. Scenario: Creating a comment in one namespace does not create it in another
  44. Given a show configuration of:
  45. """
  46. ActiveAdmin.register Post
  47. ActiveAdmin.register Post, :namespace => :public
  48. """
  49. When I add a comment "Hello world in admin namespace"
  50. Then I should see "Hello world in admin namespace"
  51. When I am on the index page for posts in the public namespace
  52. And I follow "View"
  53. Then I should not see "Hello world in admin namespace"
  54. And I should see "Comments (0)"
  55. When I add a comment "Hello world in public namespace"
  56. Then I should see "Hello world in public namespace"
  57. When I am on the index page for posts in the admin namespace
  58. And I follow "View"
  59. Then I should not see "Hello world in public namespace"
  60. And I should see "Comments (1)"
  61. Scenario: Creating a comment on an aliased resource
  62. Given a configuration of:
  63. """
  64. ActiveAdmin.register Post, :as => "Article"
  65. """
  66. Given I am logged in
  67. When I am on the index page for articles
  68. And I follow "View"
  69. When I add a comment "Hello from Comment"
  70. Then I should see a flash with "Comment was successfully created"
  71. And I should be in the resource section for articles
  72. Scenario: Create an empty comment
  73. Given a show configuration of:
  74. """
  75. ActiveAdmin.register Post
  76. """
  77. When I add a comment ""
  78. Then I should see a flash with "Comment wasn't saved, text was empty."
  79. And I should see "Comments (0)"
  80. Scenario: Viewing all comments for a namespace
  81. Given a show configuration of:
  82. """
  83. ActiveAdmin.register Post
  84. """
  85. When I add a comment "Hello from Comment"
  86. When I am on the index page for comments
  87. Then I should see a table header with "Body"
  88. And I should see "Hello from Comment"
  89. Scenario: Commenting on a STI subclass
  90. Given a configuration of:
  91. """
  92. ActiveAdmin.register User
  93. """
  94. Given I am logged in
  95. And a publisher named "Pragmatic Publishers" exists
  96. When I am on the index page for users
  97. And I follow "View"
  98. When I add a comment "Hello World"
  99. Then I should see a flash with "Comment was successfully created"
  100. And I should be in the resource section for users
  101. Scenario: Commenting on a class with string id
  102. Given a tag with the name "coolness" exists
  103. Given a configuration of:
  104. """
  105. ActiveAdmin.register Tag
  106. """
  107. Given I am logged in
  108. When I am on the index page for tags
  109. And I follow "View"
  110. When I add a comment "Tag Comment"
  111. Then I should see a flash with "Comment was successfully created"
  112. And I should be in the resource section for tags