clearance 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

Files changed (133) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/README.md +15 -4
  3. data/VERSION +1 -1
  4. data/app/controllers/clearance/passwords_controller.rb +14 -6
  5. data/lib/clearance.rb +0 -3
  6. data/lib/clearance/shoulda_macros.rb +1 -176
  7. data/lib/rails/generators/clearance_features_templates/features/password_reset.feature +4 -3
  8. data/lib/rails/generators/clearance_features_templates/features/sign_in.feature +3 -2
  9. data/lib/rails/generators/clearance_features_templates/features/sign_out.feature +4 -3
  10. data/lib/rails/generators/clearance_features_templates/features/sign_up.feature +3 -2
  11. data/lib/rails/generators/clearance_features_templates/features/step_definitions/clearance_steps.rb +2 -10
  12. data/spec/rails_root/Gemfile.lock +143 -0
  13. data/spec/rails_root/app/views/passwords/edit.html.erb +21 -0
  14. data/spec/rails_root/app/views/passwords/new.html.erb +15 -0
  15. data/spec/rails_root/app/views/sessions/new.html.erb +21 -0
  16. data/spec/rails_root/app/views/users/_inputs.html.erb +6 -0
  17. data/spec/rails_root/app/views/users/new.html.erb +10 -0
  18. data/spec/rails_root/db/development.sqlite3 +0 -0
  19. data/spec/rails_root/db/migrate/20110209234521_clearance_create_users.rb +19 -0
  20. data/spec/rails_root/db/schema.rb +28 -0
  21. data/spec/rails_root/db/test.sqlite3 +0 -0
  22. data/spec/rails_root/features/password_reset.feature +40 -0
  23. data/spec/rails_root/features/sign_in.feature +28 -0
  24. data/spec/rails_root/features/sign_out.feature +16 -0
  25. data/spec/rails_root/features/sign_up.feature +21 -0
  26. data/spec/rails_root/features/step_definitions/clearance_steps.rb +109 -0
  27. data/spec/rails_root/log/development.log +536 -0
  28. data/spec/rails_root/log/test.log +7600 -0
  29. data/spec/rails_root/test/factories/clearance.rb +13 -0
  30. data/spec/rails_root/test/functional/accounts_controller_test.rb +22 -0
  31. data/spec/rails_root/test/performance/browsing_test.rb +9 -0
  32. data/spec/rails_root/test/test_helper.rb +13 -0
  33. data/spec/rails_root/vendor/Gemfile +17 -0
  34. data/spec/rails_root/vendor/Gemfile.lock +143 -0
  35. data/spec/rails_root/vendor/README +244 -0
  36. data/spec/rails_root/vendor/Rakefile +10 -0
  37. data/spec/rails_root/vendor/app/controllers/accounts_controller.rb +10 -0
  38. data/spec/rails_root/vendor/app/controllers/application_controller.rb +6 -0
  39. data/spec/rails_root/vendor/app/helpers/application_helper.rb +2 -0
  40. data/spec/rails_root/vendor/app/models/user.rb +3 -0
  41. data/spec/rails_root/vendor/app/views/accounts/edit.html.erb +0 -0
  42. data/spec/rails_root/vendor/app/views/layouts/application.html.erb +24 -0
  43. data/spec/rails_root/vendor/app/views/passwords/edit.html.erb +21 -0
  44. data/spec/rails_root/vendor/app/views/passwords/new.html.erb +15 -0
  45. data/spec/rails_root/vendor/app/views/sessions/new.html.erb +21 -0
  46. data/spec/rails_root/vendor/app/views/users/_inputs.html.erb +6 -0
  47. data/spec/rails_root/vendor/app/views/users/new.html.erb +10 -0
  48. data/spec/rails_root/vendor/config.ru +4 -0
  49. data/spec/rails_root/vendor/config/application.rb +46 -0
  50. data/spec/rails_root/vendor/config/boot.rb +6 -0
  51. data/spec/rails_root/vendor/config/cucumber.yml +8 -0
  52. data/spec/rails_root/vendor/config/database.yml +25 -0
  53. data/spec/rails_root/vendor/config/environment.rb +7 -0
  54. data/spec/rails_root/vendor/config/environments/development.rb +21 -0
  55. data/spec/rails_root/vendor/config/environments/production.rb +42 -0
  56. data/spec/rails_root/vendor/config/environments/test.rb +34 -0
  57. data/spec/rails_root/vendor/config/initializers/backtrace_silencers.rb +7 -0
  58. data/spec/rails_root/vendor/config/initializers/clearance.rb +3 -0
  59. data/spec/rails_root/vendor/config/initializers/inflections.rb +10 -0
  60. data/spec/rails_root/vendor/config/initializers/mime_types.rb +5 -0
  61. data/spec/rails_root/vendor/config/initializers/secret_token.rb +7 -0
  62. data/spec/rails_root/vendor/config/initializers/session_store.rb +8 -0
  63. data/spec/rails_root/vendor/config/locales/en.yml +5 -0
  64. data/spec/rails_root/vendor/config/routes.rb +61 -0
  65. data/spec/rails_root/vendor/db/development.sqlite3 +0 -0
  66. data/spec/rails_root/vendor/db/migrate/20101220184900_clearance_create_users.rb +20 -0
  67. data/spec/rails_root/vendor/db/schema.rb +29 -0
  68. data/spec/rails_root/vendor/db/test.sqlite3 +0 -0
  69. data/spec/rails_root/vendor/doc/README_FOR_APP +2 -0
  70. data/spec/rails_root/vendor/features/password_reset.feature +33 -0
  71. data/spec/rails_root/vendor/features/sign_in.feature +35 -0
  72. data/spec/rails_root/vendor/features/sign_out.feature +15 -0
  73. data/spec/rails_root/vendor/features/sign_up.feature +45 -0
  74. data/spec/rails_root/vendor/features/step_definitions/clearance_steps.rb +138 -0
  75. data/spec/rails_root/vendor/features/step_definitions/web_steps.rb +219 -0
  76. data/spec/rails_root/vendor/features/support/env.rb +57 -0
  77. data/spec/rails_root/vendor/features/support/paths.rb +45 -0
  78. data/spec/rails_root/vendor/lib/tasks/cucumber.rake +53 -0
  79. data/spec/rails_root/vendor/log/development.log +663 -0
  80. data/spec/rails_root/vendor/log/test.log +22745 -0
  81. data/spec/rails_root/vendor/public/404.html +26 -0
  82. data/spec/rails_root/vendor/public/422.html +26 -0
  83. data/spec/rails_root/vendor/public/500.html +26 -0
  84. data/spec/rails_root/vendor/public/favicon.ico +0 -0
  85. data/spec/rails_root/vendor/public/images/rails.png +0 -0
  86. data/spec/rails_root/vendor/public/javascripts/application.js +2 -0
  87. data/spec/rails_root/vendor/public/javascripts/controls.js +965 -0
  88. data/spec/rails_root/vendor/public/javascripts/dragdrop.js +974 -0
  89. data/spec/rails_root/vendor/public/javascripts/effects.js +1123 -0
  90. data/spec/rails_root/vendor/public/javascripts/prototype.js +4874 -0
  91. data/spec/rails_root/vendor/public/javascripts/rails.js +118 -0
  92. data/spec/rails_root/vendor/public/robots.txt +5 -0
  93. data/spec/rails_root/vendor/script/cucumber +10 -0
  94. data/spec/rails_root/vendor/script/rails +9 -0
  95. data/spec/rails_root/vendor/test/factories/clearance.rb +13 -0
  96. data/spec/rails_root/vendor/test/functional/accounts_controller_test.rb +22 -0
  97. data/spec/rails_root/vendor/test/performance/browsing_test.rb +9 -0
  98. data/spec/rails_root/vendor/test/test_helper.rb +13 -0
  99. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/MIT-LICENSE +20 -0
  100. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/README +13 -0
  101. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/Rakefile +10 -0
  102. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/init.rb +5 -0
  103. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/lib/action_view/helpers/dynamic_form.rb +300 -0
  104. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/lib/action_view/locale/en.yml +8 -0
  105. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
  106. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/dynamic_form_test.rb +370 -0
  107. data/spec/rails_root/vendor/vendor/plugins/dynamic_form/test/test_helper.rb +9 -0
  108. data/test/controllers/passwords_controller_test.rb +19 -0
  109. data/test/models/clearance_mailer_test.rb +1 -1
  110. data/test/rails_root/Gemfile.lock +145 -0
  111. data/test/rails_root/app/views/passwords/edit.html.erb +21 -0
  112. data/test/rails_root/app/views/passwords/new.html.erb +15 -0
  113. data/test/rails_root/app/views/sessions/new.html.erb +21 -0
  114. data/test/rails_root/app/views/users/_inputs.html.erb +6 -0
  115. data/test/rails_root/app/views/users/new.html.erb +10 -0
  116. data/test/rails_root/db/development.sqlite3 +0 -0
  117. data/test/rails_root/db/migrate/20110209234101_clearance_create_users.rb +19 -0
  118. data/test/rails_root/db/schema.rb +28 -0
  119. data/test/rails_root/db/test.sqlite3 +0 -0
  120. data/test/rails_root/features/password_reset.feature +40 -0
  121. data/test/rails_root/features/sign_in.feature +28 -0
  122. data/test/rails_root/features/sign_out.feature +16 -0
  123. data/test/rails_root/features/sign_up.feature +21 -0
  124. data/test/rails_root/features/step_definitions/clearance_steps.rb +109 -0
  125. data/test/rails_root/log/development.log +938 -0
  126. data/test/rails_root/log/test.log +20303 -0
  127. data/test/test_helper.rb +1 -0
  128. metadata +263 -42
  129. data/clearance.gemspec +0 -198
  130. data/cucumber.yml +0 -4
  131. data/init.rb +0 -1
  132. data/lib/clearance/extensions/errors.rb +0 -6
  133. data/lib/clearance/extensions/rescue.rb +0 -5
@@ -19,7 +19,7 @@ class ClearanceMailerTest < ActiveSupport::TestCase
19
19
  should "contain a link to edit the user's password" do
20
20
  host = ActionMailer::Base.default_url_options[:host]
21
21
  regexp = %r{http://#{host}/users/#{@user.id}/password/edit\?token=#{@user.confirmation_token}}
22
- assert_match regexp, @email.body
22
+ assert_match regexp, @email.body.to_s
23
23
  end
24
24
 
25
25
  should "set its subject" do
@@ -0,0 +1,145 @@
1
+ PATH
2
+ remote: ../..
3
+ specs:
4
+ clearance (0.10.0)
5
+ rails (~> 3.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.0)
12
+ actionpack (= 3.0.0)
13
+ mail (~> 2.2.5)
14
+ actionpack (3.0.0)
15
+ activemodel (= 3.0.0)
16
+ activesupport (= 3.0.0)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4.1)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.12)
22
+ rack-test (~> 0.5.4)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.0)
25
+ activesupport (= 3.0.0)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4.1)
28
+ activerecord (3.0.0)
29
+ activemodel (= 3.0.0)
30
+ activesupport (= 3.0.0)
31
+ arel (~> 1.0.0)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.0)
34
+ activemodel (= 3.0.0)
35
+ activesupport (= 3.0.0)
36
+ activesupport (3.0.0)
37
+ arel (1.0.1)
38
+ activesupport (~> 3.0.0)
39
+ builder (2.1.2)
40
+ capybara (0.4.0)
41
+ celerity (>= 0.7.9)
42
+ culerity (>= 0.2.4)
43
+ mime-types (>= 1.16)
44
+ nokogiri (>= 1.3.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (>= 0.5.4)
47
+ selenium-webdriver (>= 0.0.27)
48
+ xpath (~> 0.1.2)
49
+ celerity (0.8.7)
50
+ childprocess (0.1.6)
51
+ ffi (~> 0.6.3)
52
+ configuration (1.2.0)
53
+ cucumber (0.10.0)
54
+ builder (>= 2.1.2)
55
+ diff-lcs (~> 1.1.2)
56
+ gherkin (~> 2.3.2)
57
+ json (~> 1.4.6)
58
+ term-ansicolor (~> 1.0.5)
59
+ cucumber-rails (0.3.2)
60
+ cucumber (>= 0.8.0)
61
+ culerity (0.2.14)
62
+ diff-lcs (1.1.2)
63
+ erubis (2.6.6)
64
+ abstract (>= 1.0.0)
65
+ factory_girl (1.3.3)
66
+ factory_girl_rails (1.0)
67
+ factory_girl (~> 1.3)
68
+ rails (>= 3.0.0.beta4)
69
+ ffi (0.6.3)
70
+ rake (>= 0.8.7)
71
+ formtastic (1.1.0.beta)
72
+ actionpack (>= 2.3.0)
73
+ activesupport (>= 2.3.0)
74
+ i18n (>= 0.4.0)
75
+ gherkin (2.3.3)
76
+ json (~> 1.4.6)
77
+ i18n (0.4.2)
78
+ json (1.4.6)
79
+ json_pure (1.4.6)
80
+ launchy (0.3.7)
81
+ configuration (>= 0.0.5)
82
+ rake (>= 0.8.1)
83
+ mail (2.2.14)
84
+ activesupport (>= 2.3.6)
85
+ i18n (>= 0.4.0)
86
+ mime-types (~> 1.16)
87
+ treetop (~> 1.4.8)
88
+ mime-types (1.16)
89
+ mocha (0.9.8)
90
+ rake
91
+ nokogiri (1.4.1)
92
+ polyglot (0.3.1)
93
+ rack (1.2.1)
94
+ rack-mount (0.6.13)
95
+ rack (>= 1.0.0)
96
+ rack-test (0.5.7)
97
+ rack (>= 1.0)
98
+ rails (3.0.0)
99
+ actionmailer (= 3.0.0)
100
+ actionpack (= 3.0.0)
101
+ activerecord (= 3.0.0)
102
+ activeresource (= 3.0.0)
103
+ activesupport (= 3.0.0)
104
+ bundler (~> 1.0.0)
105
+ railties (= 3.0.0)
106
+ railties (3.0.0)
107
+ actionpack (= 3.0.0)
108
+ activesupport (= 3.0.0)
109
+ rake (>= 0.8.4)
110
+ thor (~> 0.14.0)
111
+ rake (0.8.7)
112
+ rubyzip (0.9.4)
113
+ selenium-webdriver (0.1.2)
114
+ childprocess (~> 0.1.5)
115
+ ffi (~> 0.6.3)
116
+ json_pure
117
+ rubyzip
118
+ shoulda (2.11.3)
119
+ sqlite3 (1.3.3)
120
+ sqlite3-ruby (1.3.3)
121
+ sqlite3 (>= 1.3.3)
122
+ term-ansicolor (1.0.5)
123
+ thor (0.14.6)
124
+ treetop (1.4.9)
125
+ polyglot (>= 0.3.1)
126
+ tzinfo (0.3.24)
127
+ xpath (0.1.3)
128
+ nokogiri (~> 1.3)
129
+
130
+ PLATFORMS
131
+ ruby
132
+
133
+ DEPENDENCIES
134
+ capybara (= 0.4.0)
135
+ clearance!
136
+ cucumber (= 0.10.0)
137
+ cucumber-rails (= 0.3.2)
138
+ factory_girl_rails (= 1.0)
139
+ formtastic (= 1.1.0.beta)
140
+ launchy (= 0.3.7)
141
+ mocha (= 0.9.8)
142
+ nokogiri (= 1.4.1)
143
+ rails (= 3.0.0)
144
+ shoulda (= 2.11.3)
145
+ sqlite3-ruby
@@ -0,0 +1,21 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <p>
4
+ Your password has been reset. Choose a new password below.
5
+ </p>
6
+
7
+ <%= semantic_form_for(:user,
8
+ :url => user_password_path(@user, :token => @user.confirmation_token),
9
+ :html => { :method => :put }) do |form| %>
10
+ <%= form.error_messages %>
11
+ <%= form.inputs do -%>
12
+ <%= form.input :password, :as => :password,
13
+ :label => "Choose password" %>
14
+ <%= form.input :password_confirmation, :as => :password,
15
+ :label => "Confirm password" %>
16
+ <% end -%>
17
+ <%= form.buttons do -%>
18
+ <%= form.commit_button "Save this password" %>
19
+ <% end -%>
20
+ <% end %>
21
+
@@ -0,0 +1,15 @@
1
+ <h2>Reset your password</h2>
2
+
3
+ <p>
4
+ We will email you a link to reset your password.
5
+ </p>
6
+
7
+ <%= semantic_form_for :password, :url => passwords_path do |form| -%>
8
+ <%= form.inputs do -%>
9
+ <%= form.input :email, :label => "Email address" %>
10
+ <% end -%>
11
+ <%= form.buttons do -%>
12
+ <%= form.commit_button "Reset password" %>
13
+ <% end -%>
14
+ <% end -%>
15
+
@@ -0,0 +1,21 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%= semantic_form_for :session, :url => session_path do |form| %>
4
+ <%= form.inputs do %>
5
+ <%= form.input :email %>
6
+ <%= form.input :password, :as => :password %>
7
+ <% end %>
8
+ <%= form.buttons do %>
9
+ <%= form.commit_button "Sign in" %>
10
+ <% end %>
11
+ <% end %>
12
+
13
+ <ul>
14
+ <li>
15
+ <%= link_to "Sign up", sign_up_path %>
16
+ </li>
17
+ <li>
18
+ <%= link_to "Forgot password?", new_password_path %>
19
+ </li>
20
+ </ul>
21
+
@@ -0,0 +1,6 @@
1
+ <%= form.inputs do %>
2
+ <%= form.input :email %>
3
+ <%= form.input :password %>
4
+ <%= form.input :password_confirmation, :label => "Confirm password" %>
5
+ <% end %>
6
+
@@ -0,0 +1,10 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%= semantic_form_for @user do |form| %>
4
+ <%= form.error_messages %>
5
+ <%= render :partial => "/users/inputs", :locals => { :form => form } %>
6
+ <%= form.buttons do %>
7
+ <%= form.commit_button "Sign up" %>
8
+ <% end %>
9
+ <% end %>
10
+
@@ -0,0 +1,19 @@
1
+ class ClearanceCreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:users) do |t|
4
+ t.string :email
5
+ t.string :encrypted_password, :limit => 128
6
+ t.string :salt, :limit => 128
7
+ t.string :confirmation_token, :limit => 128
8
+ t.string :remember_token, :limit => 128
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :users, :email
13
+ add_index :users, :remember_token
14
+ end
15
+
16
+ def self.down
17
+ drop_table :users
18
+ end
19
+ end
@@ -0,0 +1,28 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended to check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(:version => 20110209234101) do
14
+
15
+ create_table "users", :force => true do |t|
16
+ t.string "email"
17
+ t.string "encrypted_password", :limit => 128
18
+ t.string "salt", :limit => 128
19
+ t.string "confirmation_token", :limit => 128
20
+ t.string "remember_token", :limit => 128
21
+ t.datetime "created_at"
22
+ t.datetime "updated_at"
23
+ end
24
+
25
+ add_index "users", ["email"], :name => "index_users_on_email"
26
+ add_index "users", ["remember_token"], :name => "index_users_on_remember_token"
27
+
28
+ end
Binary file
@@ -0,0 +1,40 @@
1
+ Feature: Password reset
2
+
3
+ In order to sign in even if I forgot my password
4
+ As a user
5
+ I want to reset my password
6
+
7
+ Scenario: User is not signed up
8
+ Given no user exists with an email of "email@person.com"
9
+ When I request password reset link to be sent to "email@person.com"
10
+ Then I should see "Unknown email"
11
+
12
+ Scenario: User is signed up and requests password reset
13
+ Given I signed up with "email@person.com/password"
14
+ When I request password reset link to be sent to "email@person.com"
15
+ Then I should see "instructions for changing your password"
16
+ And a password reset message should be sent to "email@person.com"
17
+
18
+ Scenario: User is signed up updated his password and types wrong confirmation
19
+ Given I signed up with "email@person.com/password"
20
+ And I go to the password reset request page
21
+ And I fill in "Email address" with "email@person.com"
22
+ And I press "Reset password"
23
+ When I follow the password reset link sent to "email@person.com"
24
+ And I update my password with "newpassword/wrongconfirmation"
25
+ Then I should see an error message
26
+ And I should be signed out
27
+
28
+ Scenario: User is signed up and updates his password
29
+ Given I signed up with "email@person.com/password"
30
+ And I go to the password reset request page
31
+ And I fill in "Email address" with "email@person.com"
32
+ And I press "Reset password"
33
+ When I follow the password reset link sent to "email@person.com"
34
+ And I update my password with "newpassword/newpassword"
35
+ Then I should be signed in
36
+ When I sign out
37
+ Then I should be signed out
38
+ And I sign in as "email@person.com/newpassword"
39
+ Then I should be signed in
40
+
@@ -0,0 +1,28 @@
1
+ Feature: Sign in
2
+
3
+ In order to get access to protected sections of the site
4
+ As a user
5
+ I want to sign in
6
+
7
+ Scenario: User is not signed up
8
+ Given no user exists with an email of "email@person.com"
9
+ When I go to the sign in page
10
+ And I sign in as "email@person.com/password"
11
+ Then I should see "Bad email or password"
12
+ And I should be signed out
13
+
14
+ Scenario: User enters wrong password
15
+ Given I am signed up as "email@person.com/password"
16
+ When I go to the sign in page
17
+ And I sign in as "email@person.com/wrongpassword"
18
+ Then I should see "Bad email or password"
19
+ And I should be signed out
20
+
21
+ Scenario: User signs in successfully
22
+ Given I am signed up as "email@person.com/password"
23
+ When I go to the sign in page
24
+ And I sign in as "email@person.com/password"
25
+ Then I should see "Signed in"
26
+ And I should be signed in
27
+ When I return next time
28
+ Then I should be signed in
@@ -0,0 +1,16 @@
1
+ Feature: Sign out
2
+
3
+ In order to protect my account from unauthorized access
4
+ As a signed in user
5
+ I want to sign out
6
+
7
+ Scenario: User signs out
8
+ Given I am signed up as "email@person.com/password"
9
+ When I sign in as "email@person.com/password"
10
+ Then I should be signed in
11
+ And I sign out
12
+ Then I should see "Signed out"
13
+ And I should be signed out
14
+ When I return next time
15
+ Then I should be signed out
16
+
@@ -0,0 +1,21 @@
1
+ Feature: Sign up
2
+
3
+ In order to get access to protected sections of the site
4
+ As a user
5
+ I want to sign up
6
+
7
+ Scenario: User signs up with invalid data
8
+ When I go to the sign up page
9
+ And I fill in "Email" with "invalidemail"
10
+ And I fill in "Password" with "password"
11
+ And I fill in "Confirm password" with ""
12
+ And I press "Sign up"
13
+ Then I should see error messages
14
+
15
+ Scenario: User signs up with valid data
16
+ When I go to the sign up page
17
+ And I fill in "Email" with "email@person.com"
18
+ And I fill in "Password" with "password"
19
+ And I fill in "Confirm password" with "password"
20
+ And I press "Sign up"
21
+ Then I should see "signed up"
@@ -0,0 +1,109 @@
1
+ # General
2
+
3
+ Then /^I should see error messages$/ do
4
+ Then %{I should see "errors prohibited"}
5
+ end
6
+
7
+ Then /^I should see an error message$/ do
8
+ Then %{I should see "error prohibited"}
9
+ end
10
+
11
+ # Database
12
+
13
+ Given /^no user exists with an email of "(.*)"$/ do |email|
14
+ assert_nil User.find_by_email(email)
15
+ end
16
+
17
+ Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)\/(.*)"$/ do |email, password|
18
+ Factory(:user,
19
+ :email => email,
20
+ :password => password,
21
+ :password_confirmation => password)
22
+ end
23
+
24
+ # Session
25
+
26
+ Then /^I should be signed in$/ do
27
+ Given %{I am on the homepage}
28
+ Then %{I should see "Sign out"}
29
+ end
30
+
31
+ Then /^I should be signed out$/ do
32
+ Given %{I am on the homepage}
33
+ Then %{I should see "Sign in"}
34
+ end
35
+
36
+ When /^session is cleared$/ do
37
+ # TODO: This doesn't work with Capybara
38
+ # TODO: I tried Capybara.reset_sessions! but that didn't work
39
+ #request.reset_session
40
+ #controller.instance_variable_set(:@_current_user, nil)
41
+ end
42
+
43
+ Given /^(?:I am|I have|I) signed in (?:with|as) "(.*)\/(.*)"$/ do |email, password|
44
+ Given %{I am signed up as "#{email}/#{password}"}
45
+ And %{I sign in as "#{email}/#{password}"}
46
+ end
47
+
48
+ Given /^I sign in$/ do
49
+ email = Factory.next(:email)
50
+ Given %{I have signed in with "#{email}/password"}
51
+ end
52
+
53
+ # Emails
54
+
55
+ Then /^a password reset message should be sent to "(.*)"$/ do |email|
56
+ user = User.find_by_email(email)
57
+ assert !user.confirmation_token.blank?
58
+ assert !ActionMailer::Base.deliveries.empty?
59
+ result = ActionMailer::Base.deliveries.any? do |email|
60
+ email.to == [user.email] &&
61
+ email.subject =~ /password/i &&
62
+ email.body =~ /#{user.confirmation_token}/
63
+ end
64
+ assert result
65
+ end
66
+
67
+ When /^I follow the password reset link sent to "(.*)"$/ do |email|
68
+ user = User.find_by_email(email)
69
+ visit edit_user_password_path(:user_id => user,
70
+ :token => user.confirmation_token)
71
+ end
72
+
73
+ When /^I try to change the password of "(.*)" without token$/ do |email|
74
+ user = User.find_by_email(email)
75
+ visit edit_user_password_path(:user_id => user)
76
+ end
77
+
78
+ # Actions
79
+
80
+ When /^I sign in as "(.*)\/(.*)"$/ do |email, password|
81
+ When %{I go to the sign in page}
82
+ And %{I fill in "Email" with "#{email}"}
83
+ And %{I fill in "Password" with "#{password}"}
84
+ And %{I press "Sign in"}
85
+ end
86
+
87
+ When "I sign out" do
88
+ steps %{
89
+ When I go to the homepage
90
+ And I follow "Sign out"
91
+ }
92
+ end
93
+
94
+ When /^I request password reset link to be sent to "(.*)"$/ do |email|
95
+ When %{I go to the password reset request page}
96
+ And %{I fill in "Email address" with "#{email}"}
97
+ And %{I press "Reset password"}
98
+ end
99
+
100
+ When /^I update my password with "(.*)\/(.*)"$/ do |password, confirmation|
101
+ And %{I fill in "Choose password" with "#{password}"}
102
+ And %{I fill in "Confirm password" with "#{confirmation}"}
103
+ And %{I press "Save this password"}
104
+ end
105
+
106
+ When /^I return next time$/ do
107
+ When %{session is cleared}
108
+ And %{I go to the homepage}
109
+ end