thoughtbot-clearance 0.4.7 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.textile CHANGED
@@ -1,3 +1,11 @@
1
+ h2. 0.4.8 (2/16/2009)
2
+
3
+ * adding support paths for Cucumber (bmabey)
4
+ * adding documentation for the flash (bmabey)
5
+ * generators require "test_helper" instead of File.join. for rr compatibility. (Joe Ferris)
6
+ * removed interpolated email address from flash message to make i18n easier.
7
+ * standardized flash messages that refer to email delivery.
8
+
1
9
  h2. 0.4.7 (2/12/2009)
2
10
 
3
11
  * removed Clearance::Test::TestHelper. one less setup step. all test helpers now in shoulda_macros.
data/README.textile CHANGED
@@ -15,7 +15,7 @@ In config/environment.rb:
15
15
  config.gem "thoughtbot-clearance",
16
16
  :lib => 'clearance',
17
17
  :source => 'http://gems.github.com',
18
- :version => '>= 0.4.7'
18
+ :version => '>= 0.4.8'
19
19
 
20
20
  In config/environments/test.rb:
21
21
 
@@ -95,6 +95,20 @@ In config/environment.rb:
95
95
 
96
96
  DO_NOT_REPLY = "donotreply@example.com"
97
97
 
98
+ h2. The flash
99
+
100
+ You will need to display the success, failure, and notice flash messages in your layout. We recommend creating an app/layouts/_flashes.html.erb partial similar to the _flashes partial in Suspenders:
101
+
102
+ <div id="flash">
103
+ <% flash.each do |key, value| -%>
104
+ <div id="flash_<%= key -%>"><%= html_escape(value) %></div>
105
+ <% end -%>
106
+ </div>
107
+
108
+ which is then rendered inside the body tag of your application layout:
109
+
110
+ <%= render :partial => 'layouts/flashes' -%>
111
+
98
112
  h2. Tests
99
113
 
100
114
  The tests use "Shoulda":http://thoughtbot.com/projects/shoulda >= 2.9.1 and "Factory Girl":http://thoughtbot.com/projects/factory_girl >= 1.1.5.
@@ -102,6 +116,26 @@ The tests use "Shoulda":http://thoughtbot.com/projects/shoulda >= 2.9.1 and "Fac
102
116
  The generator will create a user factory in test/factories/clearance.rb unless
103
117
  you have it defined somewhere else.
104
118
 
119
+ h2. Features
120
+
121
+ If you are using Cucumber on your application Clearance comes with a feature generator:
122
+
123
+ script/generate clearance_features
124
+
125
+ All of the files generated should be new with the exception of the features/support/paths.rb file. If you have not modified your paths.rb then you will be okay to replace it with this one. If you need to keep your paths.rb file then you will need to add these locations in your paths.rb manually:
126
+
127
+ def path_to(page_name)
128
+ case page_name
129
+ ...
130
+ when /the sign up page/i
131
+ new_user_path
132
+ when /the sign in page/i
133
+ new_session_path
134
+ when /the password reset request page/i
135
+ new_password_path
136
+ ...
137
+ end
138
+
105
139
  h2. Usage: basic workflow
106
140
 
107
141
  Rails authentication with Clearance uses the standard approach thoughtbot and our clients have agreed upon.
data/Rakefile CHANGED
@@ -1,12 +1,13 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
3
  require 'cucumber/rake/task'
4
-
4
+
5
5
  test_files_pattern = 'test/rails_root/test/{unit,functional,other}/**/*_test.rb'
6
6
 
7
7
  namespace :test do
8
8
  Rake::TestTask.new(:all => ['generator:cleanup', 'generator:generate']) do |task|
9
9
  task.libs << 'lib'
10
+ task.libs << File.join(File.dirname(__FILE__), "test/rails_root/test")
10
11
  task.pattern = test_files_pattern
11
12
  task.verbose = false
12
13
  end
@@ -50,7 +51,7 @@ task :default => ['test:all', 'test:features']
50
51
 
51
52
  gem_spec = Gem::Specification.new do |gem_spec|
52
53
  gem_spec.name = "clearance"
53
- gem_spec.version = "0.4.7"
54
+ gem_spec.version = "0.4.8"
54
55
  gem_spec.summary = "Rails authentication for developers who write tests."
55
56
  gem_spec.email = "support@thoughtbot.com"
56
57
  gem_spec.homepage = "http://github.com/thoughtbot/clearance"
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class ConfirmationsControllerTest < ActionController::TestCase
4
4
  include Clearance::Test::Functional::ConfirmationsControllerTest
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class PasswordsControllerTest < ActionController::TestCase
4
4
  include Clearance::Test::Functional::PasswordsControllerTest
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class SessionsControllerTest < ActionController::TestCase
4
4
  include Clearance::Test::Functional::SessionsControllerTest
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class UsersControllerTest < ActionController::TestCase
4
4
  include Clearance::Test::Functional::UsersControllerTest
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class ClearanceMailerTest < ActionMailer::TestCase
4
4
  tests ClearanceMailer
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class UserTest < Test::Unit::TestCase
4
4
  include Clearance::Test::Unit::UserTest
@@ -1 +1 @@
1
- script/generate clearance_stories
1
+ script/generate clearance_features
@@ -5,6 +5,7 @@ class ClearanceFeaturesGenerator < Rails::Generator::Base
5
5
  m.directory File.join("features", "step_definitions")
6
6
 
7
7
  ["features/step_definitions/clearance_steps.rb",
8
+ "features/support/paths.rb",
8
9
  "features/sign_in.feature",
9
10
  "features/sign_out.feature",
10
11
  "features/sign_up.feature",
@@ -11,7 +11,7 @@ Fature: Password Reset
11
11
  Scenario: User requests password reset
12
12
  Given I am signed up and confirmed as "email@person.com/password"
13
13
  When I request password reset link to be sent to "email@person.com"
14
- Then I should see "Details for changing your password have been sent to email@person.com"
14
+ Then I should see "instructions for changing your password"
15
15
  And a password reset message should be sent to "email@person.com"
16
16
 
17
17
  Scenario: User updated his password and types wrong confirmation
@@ -17,7 +17,7 @@ Feature: Sign up
17
17
  And I fill in "Password" with "password"
18
18
  And I fill in "Verify Password" with "password"
19
19
  And I press "Sign Up"
20
- Then I should see "You will receive an email within the next few minutes"
20
+ Then I should see "instructions for confirming"
21
21
  And a confirmation message should be sent to "email@person.com"
22
22
 
23
23
  Scenario: User confirms his account
@@ -44,7 +44,7 @@ Then /^a confirmation message should be sent to "(.*)"$/ do |email|
44
44
  user = User.find_by_email(email)
45
45
  sent = ActionMailer::Base.deliveries.first
46
46
  assert_equal [user.email], sent.to
47
- assert_equal 'Account confirmation', sent.subject
47
+ assert_match /confirm/i, sent.subject
48
48
  assert !user.token.blank?
49
49
  assert_match /#{user.token}/, sent.body
50
50
  end
@@ -58,7 +58,7 @@ Then /^a password reset message should be sent to "(.*)"$/ do |email|
58
58
  user = User.find_by_email(email)
59
59
  sent = ActionMailer::Base.deliveries.first
60
60
  assert_equal [user.email], sent.to
61
- assert_equal 'Change your password', sent.subject
61
+ assert_match /password/i, sent.subject
62
62
  assert !user.token.blank?
63
63
  assert_match /#{user.token}/, sent.body
64
64
  end
@@ -0,0 +1,26 @@
1
+ module NavigationHelpers
2
+ def path_to(page_name)
3
+ case page_name
4
+
5
+ when /the homepage/i
6
+ root_path
7
+ when /the sign up page/i
8
+ new_user_path
9
+ when /the sign in page/i
10
+ new_session_path
11
+ when /the password reset request page/i
12
+ new_password_path
13
+
14
+
15
+ # Add more page name => path mappings here
16
+
17
+ else
18
+ raise "Can't find mapping from \"#{page_name}\" to a path."
19
+ end
20
+ end
21
+ end
22
+
23
+ World do |world|
24
+ world.extend NavigationHelpers
25
+ world
26
+ end
@@ -25,8 +25,8 @@ module Clearance
25
25
  else
26
26
  user.forgot_password!
27
27
  ClearanceMailer.deliver_change_password user
28
- flash[:notice] = "Details for changing your password " <<
29
- "have been sent to #{user.email}"
28
+ flash[:notice] = "You will receive an email within the next few minutes. " <<
29
+ "It contains instructions for changing your password."
30
30
  redirect_to url_after_create
31
31
  end
32
32
  end
@@ -24,11 +24,11 @@ module Clearance
24
24
  if @user.email_confirmed?
25
25
  remember(@user) if remember?
26
26
  sign_user_in(@user)
27
- flash[:notice] = "Signed in successfully"
27
+ flash[:notice] = "Signed in successfully."
28
28
  redirect_back_or url_after_create
29
29
  else
30
30
  ClearanceMailer.deliver_confirmation(@user)
31
- deny_access("User has not confirmed email. Confirmation email will be resent.")
31
+ deny_access("User has not confirmed email. Confirmation email will be resent.")
32
32
  end
33
33
  end
34
34
  end
@@ -23,7 +23,7 @@ module Clearance
23
23
  if @user.save
24
24
  ClearanceMailer.deliver_confirmation @user
25
25
  flash[:notice] = "You will receive an email within the next few minutes. " <<
26
- "It contains instructions for you to confirm your account."
26
+ "It contains instructions for confirming your account."
27
27
  redirect_to url_after_create
28
28
  else
29
29
  render :action => "new"
@@ -30,11 +30,7 @@ module Clearance
30
30
  end
31
31
 
32
32
  should_send_the_change_your_password_email
33
-
34
- should "set a :notice flash with the user email address" do
35
- assert_match /#{@user.email}/, flash[:notice]
36
- end
37
-
33
+ should_set_the_flash_to /password/i
38
34
  should_redirect_to_url_after_create
39
35
  end
40
36
 
@@ -29,7 +29,7 @@ module Clearance
29
29
  :password => @user.password }
30
30
  end
31
31
 
32
- should_deny_access(:flash => /User has not confirmed email. Confirmation email will be resent./i)
32
+ should_deny_access(:flash => /User has not confirmed email. Confirmation email will be resent./i)
33
33
 
34
34
  should "send the confirmation email" do
35
35
  assert_not_nil email = ActionMailer::Base.deliveries[0]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thoughtbot-clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - thoughtbot, inc.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2009-02-11 21:00:00 -08:00
18
+ date: 2009-02-15 21:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -89,6 +89,8 @@ files:
89
89
  - generators/clearance_features/templates/features/sign_up.feature
90
90
  - generators/clearance_features/templates/features/step_definitions
91
91
  - generators/clearance_features/templates/features/step_definitions/clearance_steps.rb
92
+ - generators/clearance_features/templates/features/support
93
+ - generators/clearance_features/templates/features/support/paths.rb
92
94
  - generators/clearance_features/USAGE
93
95
  - lib/clearance
94
96
  - lib/clearance/app