Permalink
Browse files

Convert integration specs to Cucumber stories and update RSpec.

  • Loading branch information...
seancribbs committed Apr 14, 2009
1 parent 343f9df commit c125dbf423dc84fbc9f5358e980a7b6ee6de7811
Showing with 709 additions and 461 deletions.
  1. +0 −3 .gitmodules
  2. +2 −0 CHANGELOG
  3. +5 −0 app/controllers/admin/extensions_controller.rb
  4. +9 −4 app/controllers/admin/pages_controller.rb
  5. +1 −1 app/helpers/admin/pages_helper.rb
  6. +1 −1 app/views/admin/pages/_popups.html.haml
  7. +6 −1 config/environments/test.rb
  8. +24 −0 features/admin/content_negotiation.feature
  9. +67 −0 features/admin/pages_management.feature
  10. +50 −0 features/admin/snippets_management.feature
  11. +149 −0 features/admin/user_permissions.feature
  12. +18 −0 features/admin/user_preferences.feature
  13. +59 −0 features/admin/users_management.feature
  14. +28 −0 features/page_serving.feature
  15. +30 −0 features/step_definitions/admin/admin_steps.rb
  16. +21 −0 features/step_definitions/admin/content_negotiation_steps.rb
  17. +14 −0 features/step_definitions/admin/pages_management_steps.rb
  18. +12 −0 features/step_definitions/admin/users_management_steps.rb
  19. +30 −0 features/step_definitions/page_serving_steps.rb
  20. +99 −0 features/step_definitions/webrat_steps.rb
  21. +23 −0 features/support/env.rb
  22. +14 −0 features/support/paths.rb
  23. +7 −0 lib/tasks/cucumber.rake
  24. +0 −3 lib/tasks/release.rake
  25. +5 −2 lib/tasks/rspec.rake
  26. +7 −0 script/cucumber
  27. +2 −2 spec/controllers/admin/pages_controller_spec.rb
  28. +11 −0 spec/datasets/config_dataset.rb
  29. +0 −27 spec/integration/admin/content_negotiation_spec.rb
  30. +0 −129 spec/integration/admin/pages_integration_spec.rb
  31. +0 −24 spec/integration/admin/permission_integration_spec.rb
  32. +0 −73 spec/integration/admin/snippets_integration_spec.rb
  33. +0 −80 spec/integration/admin/user_management_integration_spec.rb
  34. +0 −19 spec/integration/admin/user_preferences_integration_spec.rb
  35. +0 −37 spec/integration/page_serving_spec.rb
  36. +1 −1 spec/models/page_spec.rb
  37. +12 −44 spec/spec_helper.rb
  38. +0 −4 stories/all.rb
  39. +0 −3 stories/helper.rb
  40. +1 −1 vendor/plugins/dataset
  41. +0 −1 vendor/plugins/spec_integration
  42. +1 −1 vendor/plugins/vizres
View
@@ -1,6 +1,3 @@
[submodule "vendor/plugins/spec_integration"]
path = vendor/plugins/spec_integration
url = git://github.com/aiwilliams/spec_integration.git
[submodule "vendor/plugins/vizres"]
path = vendor/plugins/vizres
url = git://github.com/pelargir/vizres.git
View
@@ -2,6 +2,8 @@
=== Edge
* Convert integration specs to Cucumber stories and update RSpec. [Sean
Cribbs]
* Use ActionView::PathSet instead of normal arrays for view paths. [Pat
Allan]
* Don't raise exception on unauthenticated request to /admin/logout.
@@ -1,4 +1,9 @@
class Admin::ExtensionsController < ApplicationController
only_allow_access_to :index,
:when => :admin,
:denied_url => { :controller => 'pages', :action => 'index' },
:denied_message => 'You must have administrative privileges to perform this action.'
def index
@template_name = 'index' # for Admin::RegionsHelper
@extensions = Radiant::Extension.descendants.sort_by { |e| e.extension_name }
@@ -1,6 +1,7 @@
class Admin::PagesController < Admin::ResourceController
before_filter :initialize_meta_rows_and_buttons, :only => [:new, :edit, :create, :update]
before_filter :count_deleted_pages, :only => [:destroy]
responses do |r|
r.plural.js do
@level = params[:level].to_i
@@ -22,7 +23,7 @@ def new
end
response_for :singular
end
private
def model_class
if params[:page_id]
@@ -36,14 +37,18 @@ def announce_saved(message = nil)
flash[:notice] = message || "Your page has been saved below."
end
def announce_pages_removed(count)
flash[:notice] = if count > 1
def announce_removed
flash[:notice] = if @count > 0
"The pages were successfully removed from the site."
else
"The page was successfully removed from the site."
end
end
def count_deleted_pages
@count = model.children.count + 1
end
def initialize_meta_rows_and_buttons
@buttons_partials ||= []
@meta ||= []
@@ -7,7 +7,7 @@ def class_of_page
end
def filter
@page.parts.first.filter
@page.parts.empty? ? nil : @page.parts.first.filter
end
def meta_errors?
@@ -22,7 +22,7 @@
#filter-reference-popup.popup{ :style => "display:none;" }
%h3
%span#filter-type= filter.filter_name
%span#filter-type= default_filter_name
Reference
#filter-reference= filter_reference
%p
@@ -29,4 +29,9 @@
# Tell ActionMailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.action_mailer.delivery_method = :test
config.gem "rspec", :version => "1.2.2", :lib => false
config.gem "rspec-rails", :version => "1.2.2", :lib => false
config.gem "webrat", :version => "~>0.4.4", :lib => false
config.gem "cucumber", :version => "~>0.2.3", :lib => false
@@ -0,0 +1,24 @@
Feature: Proper content negotiation
In order to have a more rich and flexible editing and browsing experience
a content editor
wants to access the admin section with multiple content formats
Scenario: Default to HTML format
Given I am logged in as 'admin'
When I send an 'Accept' header of 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'
And I go to '/admin/pages'
Then I should not see 'Missing template'
Scenario: Requesting XML format via file-extension
Given I am logged in as 'admin'
When I send an 'Accept' header of 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*'
And I go to '/admin/pages.xml'
Then I should see '<\?xml'
Scenario: Requesting children via Ajax
Given I am logged in as 'admin'
When I send an 'Accept' header of 'text/javascript, text/html, application/xml, text/xml, */*'
And I send an 'X-Requested-With' header of 'XMLHttpRequest'
And I request the children of page 'home'
Then I should not see 'Radiant CMS'
And I should see '<tr'
@@ -0,0 +1,67 @@
Feature: Managing pages
In order to create, modify, and delete content from the website
a content editor
wants to manipulate pages in the admin interface
Background:
Given I am logged in as 'existing'
Scenario: Listing pages
When I go to '/admin/pages'
Then I should see 'Pages'
And I should see 'Home'
Scenario: No pages
Given there are no pages
When I go to '/admin/pages'
Then I should see 'No Pages'
Scenario: Creating a homepage
Given there are no pages
When I go to '/admin/pages'
And I follow 'New Homepage'
Then I should see 'New Page'
And there should be a 'body' part
And there should be an 'extended' part
When I fill in 'Page Title' with 'My site'
And I fill in 'Slug' with '/'
And I fill in 'Breadcrumb' with 'My site'
And I fill in the 'body' content with 'Under Construction'
And I fill in the 'extended' content with 'foobar'
And I select 'Published' from 'Status'
And I press 'Create page'
Then I should see 'Your page has been saved'
When I go to '/'
Then I should see 'Under Construction'
Scenario: Creating child pages
When I go to '/admin/pages'
And I follow 'Add child'
Then I should see 'New Page'
And there should be a 'body' part
And there should be an 'extended' part
When I fill in 'Page Title' with 'My child'
And I fill in 'Slug' with 'my-child'
And I fill in 'Breadcrumb' with 'My child'
And I fill in the 'body' content with 'Under Construction'
And I fill in the 'extended' content with 'foobar'
And I select 'Published' from 'Status'
And I press 'Save and Continue Editing'
Then I should see 'Your page has been saved'
And I should see 'Under Construction'
When I go to '/my-child'
Then I should see 'Under Construction'
Scenario: Delete page
When I go to '/admin/pages'
And I follow 'remove page'
Then I should see 'permanently remove'
When I press 'Delete Pages'
Then I should see 'successfully removed'
Scenario: Change page type
When I edit the 'virtual' page
And I select '&lt;normal&gt;' from 'Page type'
And I press 'Save and Continue Editing'
Then I should see 'Your page has been saved'
And '&lt;normal&gt;' should be selected for 'Page type'
@@ -0,0 +1,50 @@
Feature: Managing snippets
In order to remove the repetition of entering the same content
multiple times and allow applying the same block to small pieces of
content, as a content editor I want to manage a collection of snippets
Background:
Given I am logged in as 'existing'
Scenario: List snippets
When I follow 'Snippets'
Then I should see 'first'
And I should see 'another'
And I should see 'markdown'
# And a host of others
Scenario: Create a snippet
When I follow 'Snippets'
And I follow 'New Snippet'
And I fill in "Name" with "Mine"
And I fill in "Body" with "My snippet"
And I press "Create Snippet"
Then I should see "saved"
And I should see "Mine"
Scenario: Display form errors
When I follow 'Snippets'
And I follow 'New Snippet'
And I fill in "Body" with "My snippet"
And I press "Create Snippet"
Then I should see an error message
And I should see the form
Scenario: Continue editing
When I follow 'Snippets'
And I follow 'New Snippet'
And I fill in "Name" with "Mine"
And I fill in "Body" with "My snippet"
And I press "Save and Continue Editing"
Then I should see "saved"
And I should see the form
Scenario: Delete a snippet with confirmation
When I follow 'Snippets'
And I follow 'Remove'
Then I should see 'permanently remove'
And I should see 'another'
When I press 'Delete Snippet'
Then I should see 'has been deleted'
And I should see 'first'
@@ -0,0 +1,149 @@
Feature: User authentication and permissions
In order to protect design assets from unskilled modification
and user accounts from hijacking
users should be given different access permissions
Scenario Outline: Authentication-login
When I go to '/admin/login'
And I fill in "Username" with "<username>"
And I fill in "Password" with "password"
And I press "Login"
Then I should see "Pages"
Examples:
| username |
| admin |
| existing |
| developer |
Scenario Outline: Authentication-logout
Given I am logged in as '<username>'
When I follow 'Log out'
Then I should see 'You are now logged out.'
Examples:
| username |
| admin |
| existing |
| developer |
Scenario Outline: All users can edit pages
Given I am logged in as '<username>'
And I should see 'Pages'
When I go to '/admin/pages'
And I follow "Home"
Then I should see "Edit Page"
And I should see "Pages"
Examples:
| username |
| admin |
| existing |
| developer |
Scenario Outline: All users can see and edit snippets
Given I am logged in as '<username>'
And I should see 'Snippets'
When I go to '/admin/snippets'
And I should not see 'You must have developer privileges'
And I follow 'first'
Then I should see 'Edit Snippet'
Examples:
| username |
| admin |
| existing |
| developer |
Scenario Outline: Admins and developers can see and edit layouts
Given I am logged in as '<username>'
And I should see 'Layouts'
When I go to '/admin/layouts'
And I should not see 'You must have developer privileges'
And I follow 'Main'
Then I should see 'Edit Layout'
Examples:
| username |
| admin |
| developer |
Scenario Outline: Ordinary users cannot edit layouts
Given I am logged in as '<username>'
And I should not see 'Layouts'
When I go to '/admin/layouts'
Then I should see 'You must have developer privileges'
Examples:
| username |
| existing |
| another |
Scenario: Admins can see and edit users
Given I am logged in as 'admin'
And I should see 'Users'
When I go to '/admin/users'
And I should not see 'You must have administrative privileges'
And I follow 'Another'
Then I should see 'Edit User'
Scenario: Admins do not see preferences link
Given I am logged in as 'admin'
And I should see 'Users'
And I should not see 'Preferences'
Scenario Outline: Non-admins cannot see or edit users
Given I am logged in as '<username>'
And I should not see 'Users'
When I go to '/admin/users'
Then I should see 'You must have administrative privileges'
Examples:
| username |
| existing |
| another |
| developer |
Scenario Outline: Non-admins see preferences link
Given I am logged in as '<username>'
And I should see 'Preferences'
When I go to '/admin/preferences'
Then I should see 'User Preferences'
Examples:
| username |
| existing |
| another |
| developer |
Scenario: Admin users can see extensions
Given I am logged in as 'admin'
And I should see 'Extensions'
When I go to '/admin/extensions'
Then I should see 'Archive'
Scenario Outline: Non-admin users cannot see extensions
Given I am logged in as '<username>'
And I should not see 'Extensions'
When I go to '/admin/extensions'
Then I should see 'You must have administrative privileges'
Examples:
| username |
| existing |
| another |
| developer |
Scenario Outline: Anyone can export YAML
Given I am logged in as '<username>'
When I go to '/admin/export'
Then I should see 'id:'
Examples:
| username |
| admin |
| existing |
| another |
| developer |
Oops, something went wrong.

3 comments on commit c125dbf

@saturnflyer

This comment has been minimized.

Show comment
Hide comment
@saturnflyer

saturnflyer Apr 14, 2009

Member

woohoo! nice work

Member

saturnflyer replied Apr 14, 2009

woohoo! nice work

@seancribbs

This comment has been minimized.

Show comment
Hide comment
@seancribbs

seancribbs Apr 14, 2009

Contributor

Thanks, Jim! It got feeling really good toward the end — easy to write new stories. Unfortunately webrat is kind of broken on nested attributes, so I have to wait for my patch to get accepted there.

Contributor

seancribbs replied Apr 14, 2009

Thanks, Jim! It got feeling really good toward the end — easy to write new stories. Unfortunately webrat is kind of broken on nested attributes, so I have to wait for my patch to get accepted there.

@aiwilliams

This comment has been minimized.

Show comment
Hide comment
@aiwilliams

aiwilliams Apr 14, 2009

Contributor

Sean, this is most excellent work. I am committed to not using spec_integration in the future, and hope to even begin writing Cucumber tests here forward for current applications.

Contributor

aiwilliams replied Apr 14, 2009

Sean, this is most excellent work. I am committed to not using spec_integration in the future, and hope to even begin writing Cucumber tests here forward for current applications.

Please sign in to comment.