forked from technoweenie/restful-authentication
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved stories over to features with minimal munging
- Loading branch information
Showing
15 changed files
with
712 additions
and
828 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
generators/authenticated/templates/features/accounts.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
Visitors should be in control of creating an account and of proving their | ||
essential humanity/accountability or whatever it is people think the | ||
id-validation does. We should be fairly skeptical about this process, as the | ||
identity+trust chain starts here. | ||
|
||
Story: Creating an account | ||
As an anonymous user | ||
I want to be able to create an account | ||
So that I can be one of the cool kids | ||
|
||
# | ||
# Account Creation: Get entry form | ||
# | ||
Scenario: Anonymous user can start creating an account | ||
Given an anonymous user | ||
When she goes to /signup | ||
Then she should be at the 'users/new' page | ||
And the page should look AWESOME | ||
And she should see a <form> containing a textfield: Login, textfield: Email, password: Password, password: 'Confirm Password', submit: 'Sign up' | ||
|
||
# | ||
# Account Creation | ||
# | ||
Scenario: Anonymous user can create an account | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account as the preloaded 'Oona' | ||
Then she should be redirected to the home page | ||
When she follows that redirect! | ||
Then she should see a notice message 'Thanks for signing up!' | ||
And a user with login: 'oona' should exist | ||
And the user should have login: 'oona', and email: 'unactivated@example.com' | ||
|
||
And oona should be logged in | ||
|
||
|
||
# | ||
# Account Creation Failure: Account exists | ||
# | ||
|
||
|
||
Scenario: Anonymous user can not create an account replacing an activated account | ||
Given an anonymous user | ||
And an activated user named 'Reggie' | ||
And we try hard to remember the user's updated_at, and created_at | ||
When she registers an account with login: 'reggie', password: 'monkey', and email: 'reggie@example.com' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Login has already been taken' | ||
And she should not see an errorExplanation message 'Email has already been taken' | ||
And a user with login: 'reggie' should exist | ||
And the user should have email: 'registered@example.com' | ||
|
||
And the user's created_at should stay the same under to_s | ||
And the user's updated_at should stay the same under to_s | ||
And she should not be logged in | ||
|
||
# | ||
# Account Creation Failure: Incomplete input | ||
# | ||
Scenario: Anonymous user can not create an account with incomplete or incorrect input | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account with login: '', password: 'monkey', password_confirmation: 'monkey' and email: 'unactivated@example.com' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Login can't be blank' | ||
And no user with login: 'oona' should exist | ||
|
||
Scenario: Anonymous user can not create an account with no password | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account with login: 'oona', password: '', password_confirmation: 'monkey' and email: 'unactivated@example.com' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Password can't be blank' | ||
And no user with login: 'oona' should exist | ||
|
||
Scenario: Anonymous user can not create an account with no password_confirmation | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account with login: 'oona', password: 'monkey', password_confirmation: '' and email: 'unactivated@example.com' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Password confirmation can't be blank' | ||
And no user with login: 'oona' should exist | ||
|
||
Scenario: Anonymous user can not create an account with mismatched password & password_confirmation | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkeY' and email: 'unactivated@example.com' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Password doesn't match confirmation' | ||
And no user with login: 'oona' should exist | ||
|
||
Scenario: Anonymous user can not create an account with bad email | ||
Given an anonymous user | ||
And no user with login: 'Oona' exists | ||
When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkey' and email: '' | ||
Then she should be at the 'users/new' page | ||
And she should see an errorExplanation message 'Email can't be blank' | ||
And no user with login: 'oona' should exist | ||
When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkey' and email: 'unactivated@example.com' | ||
Then she should be redirected to the home page | ||
When she follows that redirect! | ||
Then she should see a notice message 'Thanks for signing up!' | ||
And a user with login: 'oona' should exist | ||
And the user should have login: 'oona', and email: 'unactivated@example.com' | ||
|
||
And oona should be logged in | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
generators/authenticated/templates/features/step_definitions/ra_env.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
Before do | ||
Fixtures.reset_cache | ||
fixtures_folder = File.join(RAILS_ROOT, 'spec', 'fixtures') | ||
Fixtures.create_fixtures(fixtures_folder, "users") | ||
end | ||
|
||
# Make visible for testing | ||
ApplicationController.send(:public, :logged_in?, :current_user, :authorized?) |
48 changes: 48 additions & 0 deletions
48
generators/authenticated/templates/features/step_definitions/ra_navigation_steps.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# Where to go | ||
# | ||
|
||
# | ||
# GET | ||
# Go to a given page. | ||
When "$actor goes to $path" do |actor, path| | ||
case path | ||
when 'the home page' then get '/' | ||
else get path | ||
end | ||
end | ||
|
||
# POST -- Ex: | ||
# When she creates a book with ISBN: '0967539854' and comment: 'I love this book' and rating: '4' | ||
# When she creates a singular session with login: 'reggie' and password: 'i_haxxor_joo' | ||
# Since I'm not smart enough to do it right, explicitly specify singular resources | ||
When /^(\w+) creates an? ([\w ]+) with ([\w: \',]+)$/ do |actor, resource, attributes| | ||
attributes = attributes.to_hash_from_story | ||
if resource =~ %r{singular ([\w/]+)} | ||
resource = $1.downcase.singularize | ||
post "/#{resource}", attributes | ||
else | ||
post "/#{resource.downcase.pluralize}", { resource.downcase.singularize => attributes } | ||
end | ||
end | ||
|
||
# PUT | ||
When %r{$actor asks to update '$resource' with $attributes} do |_, resource, attributes| | ||
attributes = attributes.to_hash_from_story | ||
put "#{resource}", attributes | ||
dump_response | ||
end | ||
|
||
# DELETE -- Slap together the POST-form-as-fake-HTTP-DELETE submission | ||
When %r{$actor asks to delete '$resource'} do |_, resource| | ||
post "/#{resource.downcase.pluralize}", { :_method => :delete } | ||
dump_response | ||
end | ||
|
||
|
||
# Redirect -- | ||
# Rather than coding in get/get_via_redirect's and past/p_v_r's, | ||
# let's just demand that in the story itself. | ||
When "$actor follows that redirect!" do |actor| | ||
follow_redirect! | ||
end |
Oops, something went wrong.