2012-04-16 18:17:11 +00:00
|
|
|
Feature: Pages
|
|
|
|
In order to ensure pages are not tampered with
|
|
|
|
As an admin, designer or author
|
|
|
|
I will be restricted based on my role
|
|
|
|
|
|
|
|
Background:
|
|
|
|
Given I have the site: "test site" set up
|
|
|
|
And I have a custom model named "Projects" with
|
|
|
|
| label | type | required |
|
|
|
|
| Name | string | true |
|
|
|
|
| Description | text | false |
|
|
|
|
And I have a designer and an author
|
|
|
|
And a page named "hello-world" with id "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And a page named "goodbye-world" with id "4f832c2cb0d86d3f42ffffff"
|
|
|
|
|
|
|
|
Scenario: As an unauthenticated user
|
|
|
|
Given I am not authenticated
|
|
|
|
When I do an API GET to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "error" should be "You need to sign in or sign up before continuing."
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
# listing pages
|
|
|
|
|
|
|
|
Scenario: Accessing pages as an Admin
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "admin" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Accessing pages as a Designer
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "designer" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Accessing pages as an Author
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "author" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
|
2012-04-16 18:36:39 +00:00
|
|
|
# showing page
|
|
|
|
|
|
|
|
Scenario: Accessing page as an Admin
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "admin" API token
|
2012-04-16 18:36:39 +00:00
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "slug" should be "hello-world"
|
2012-04-16 18:36:39 +00:00
|
|
|
|
|
|
|
Scenario: Accessing page as a Designer
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "designer" API token
|
2012-04-16 18:36:39 +00:00
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "slug" should be "hello-world"
|
2012-04-16 18:36:39 +00:00
|
|
|
|
|
|
|
Scenario: Accessing page as an Author
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "author" API token
|
2012-04-16 18:36:39 +00:00
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "slug" should be "hello-world"
|
2012-04-16 18:36:39 +00:00
|
|
|
|
2012-04-16 18:17:11 +00:00
|
|
|
# create page
|
|
|
|
|
|
|
|
Scenario: Creating new page as an Admin
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "admin" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API POST to pages.json with:
|
|
|
|
"""
|
|
|
|
{
|
|
|
|
"page": {
|
|
|
|
"title": "New Page",
|
|
|
|
"slug": "new-page",
|
|
|
|
"parent_id": "4f832c2cb0d86d3f42fffffe"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 5 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Creating new page as a Designer
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "designer" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API POST to pages.json with:
|
|
|
|
"""
|
|
|
|
{
|
|
|
|
"page": {
|
|
|
|
"title": "New Page",
|
|
|
|
"slug": "new-page",
|
|
|
|
"parent_id": "4f832c2cb0d86d3f42fffffe"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 5 entries
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Creating new page as an Author
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "author" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API POST to pages.json with:
|
|
|
|
"""
|
|
|
|
{
|
|
|
|
"page": {
|
|
|
|
"title": "New Page",
|
|
|
|
"slug": "new-page",
|
|
|
|
"parent_id": "4f832c2cb0d86d3f42fffffe"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
2012-04-24 16:36:25 +00:00
|
|
|
Then an access denied error should occur
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
# update page
|
|
|
|
|
|
|
|
Scenario: Updating page as an Admin
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "admin" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API PUT to pages/4f832c2cb0d86d3f42fffffe.json with:
|
|
|
|
"""
|
|
|
|
{
|
2012-04-16 18:36:39 +00:00
|
|
|
"page": {
|
|
|
|
"title": "Brand new updated title"
|
|
|
|
}
|
2012-04-16 18:17:11 +00:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "title" should be "Brand new updated title"
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Updating page as a Designer
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "designer" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API PUT to pages/4f832c2cb0d86d3f42fffffe.json with:
|
|
|
|
"""
|
|
|
|
{
|
2012-04-16 18:36:39 +00:00
|
|
|
"page": {
|
|
|
|
"title": "Brand new updated title"
|
|
|
|
}
|
2012-04-16 18:17:11 +00:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "title" should be "Brand new updated title"
|
2012-04-16 18:17:11 +00:00
|
|
|
|
|
|
|
Scenario: Updating page as an Author
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "author" API token
|
2012-04-16 18:17:11 +00:00
|
|
|
When I do an API PUT to pages/4f832c2cb0d86d3f42fffffe.json with:
|
|
|
|
"""
|
|
|
|
{
|
2012-04-16 18:36:39 +00:00
|
|
|
"page": {
|
|
|
|
"title": "Brand new updated title"
|
|
|
|
}
|
2012-04-16 18:17:11 +00:00
|
|
|
}
|
|
|
|
"""
|
2012-04-17 15:02:29 +00:00
|
|
|
When I do an API GET request to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response at "id" should be "4f832c2cb0d86d3f42fffffe"
|
|
|
|
And the JSON response at "title" should be "Brand new updated title"
|
2012-04-24 15:04:24 +00:00
|
|
|
|
|
|
|
# destroy page
|
|
|
|
|
|
|
|
Scenario: Destroying page as an Admin
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have an "admin" API token
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API DELETE to pages/4f832c2cb0d86d3f42fffffe.json
|
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 3 entries
|
2012-04-24 15:04:24 +00:00
|
|
|
|
|
|
|
Scenario: Destroying page as a Designer
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "designer" API token
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API DELETE to pages/4f832c2cb0d86d3f42fffffe.json
|
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 3 entries
|
2012-04-24 15:04:24 +00:00
|
|
|
|
|
|
|
Scenario: Deleting page as an Author
|
2012-04-24 16:36:25 +00:00
|
|
|
Given I have a "author" API token
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API GET request to pages.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then the JSON response should be an array
|
|
|
|
And the JSON response should have 4 entries
|
2012-04-24 15:04:24 +00:00
|
|
|
When I do an API DELETE to pages/4f832c2cb0d86d3f42fffffe.json
|
2012-04-24 16:36:25 +00:00
|
|
|
Then an access denied error should occur
|