clearance 1.0.0.rc2 → 1.0.0.rc3

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 (50) hide show
  1. data/Gemfile.lock +2 -5
  2. data/NEWS.md +4 -1
  3. data/README.md +10 -10
  4. data/Rakefile +0 -1
  5. data/app/controllers/clearance/passwords_controller.rb +1 -10
  6. data/clearance.gemspec +0 -1
  7. data/features/add_migrations_to_project.feature +65 -0
  8. data/features/integration_with_rspec.feature +21 -0
  9. data/features/step_definitions/configuration_steps.rb +21 -0
  10. data/features/step_definitions/gem_file_steps.rb +7 -0
  11. data/features/support/env.rb +8 -18
  12. data/gemfiles/3.0.17.gemfile.lock +1 -4
  13. data/gemfiles/3.1.8.gemfile.lock +1 -4
  14. data/gemfiles/3.2.8.gemfile.lock +1 -4
  15. data/{features/support/clearance.rb → lib/clearance/testing/app/controllers/application_controller.rb} +0 -9
  16. data/lib/clearance/testing/application.rb +46 -0
  17. data/lib/clearance/testing/config/database.yml +11 -0
  18. data/lib/clearance/testing/config/routes.rb +3 -0
  19. data/lib/clearance/version.rb +1 -1
  20. data/lib/generators/clearance/install/install_generator.rb +103 -22
  21. data/lib/generators/clearance/install/templates/README +14 -7
  22. data/lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb +21 -0
  23. data/lib/generators/clearance/install/templates/db/migrate/create_users.rb +18 -0
  24. data/lib/generators/clearance/specs/USAGE +5 -0
  25. data/lib/generators/clearance/specs/specs_generator.rb +13 -0
  26. data/lib/generators/clearance/specs/templates/factories/clearance.rb +10 -0
  27. data/lib/generators/clearance/specs/templates/integration/clearance/user_signs_out_spec.rb +10 -0
  28. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_resets_password_spec.rb +28 -0
  29. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_in_spec.rb +42 -0
  30. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_up_spec.rb +21 -0
  31. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_updates_password_spec.rb +47 -0
  32. data/lib/generators/clearance/specs/templates/support/action_mailer.rb +3 -0
  33. data/lib/generators/clearance/specs/templates/support/clearance.rb +1 -0
  34. data/lib/generators/clearance/specs/templates/support/factory_girl.rb +5 -0
  35. data/lib/generators/clearance/specs/templates/support/integration.rb +4 -0
  36. data/lib/generators/clearance/specs/templates/support/integration/action_mailer_helpers.rb +19 -0
  37. data/lib/generators/clearance/specs/templates/support/integration/clearance_helpers.rb +49 -0
  38. data/lib/generators/clearance/views/USAGE +15 -0
  39. data/lib/generators/clearance/views/views_generator.rb +23 -2
  40. data/spec/controllers/passwords_controller_spec.rb +1 -2
  41. data/spec/spec_helper.rb +5 -3
  42. metadata +30 -35
  43. data/features/engine/visitor_resets_password.feature +0 -34
  44. data/features/engine/visitor_signs_in.feature +0 -33
  45. data/features/engine/visitor_signs_out.feature +0 -12
  46. data/features/engine/visitor_signs_up.feature +0 -17
  47. data/features/integration.feature +0 -50
  48. data/features/step_definitions/engine/clearance_steps.rb +0 -124
  49. data/lib/generators/clearance/features/features_generator.rb +0 -8
  50. data/lib/generators/clearance/install/templates/db/migrate/upgrade_clearance_to_diesel.rb +0 -37
@@ -0,0 +1,49 @@
1
+ module Integration
2
+ module ClearanceHelpers
3
+ def sign_up_with(email, password)
4
+ visit sign_up_path
5
+ fill_in 'Email', :with => email
6
+ fill_in 'Password', :with => password
7
+ click_button 'Sign up'
8
+ end
9
+
10
+ def sign_in_with(email, password)
11
+ visit sign_in_path
12
+ fill_in 'Email', :with => email
13
+ fill_in 'Password', :with => password
14
+ click_button 'Sign in'
15
+ end
16
+
17
+ def signed_in_user
18
+ password = 'password'
19
+ user = create(:user, :password => password)
20
+ sign_in_with user.email, password
21
+ user
22
+ end
23
+
24
+ def user_should_be_signed_in
25
+ visit root_path
26
+ page.should have_content('Sign out')
27
+ end
28
+
29
+ def sign_out
30
+ click_link 'Sign out'
31
+ end
32
+
33
+ def user_should_be_signed_out
34
+ page.should have_content('Sign in')
35
+ end
36
+
37
+ def user_with_reset_password
38
+ user = create(:user)
39
+ reset_password_for user.email
40
+ user.reload
41
+ end
42
+
43
+ def reset_password_for(email)
44
+ visit new_password_path
45
+ fill_in 'Email address', :with => email
46
+ click_button 'Reset password'
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,15 @@
1
+ Description:
2
+ Override the default clearance views. This generator will copy all off the
3
+ base clearance views into your project.
4
+
5
+ Examples:
6
+ rails generate clearance:views
7
+
8
+ View: app/views/clearance_mailer/change_password.html.erb
9
+ View: app/views/passwords/create.html.erb
10
+ View: app/views/passwords/edit.html.erb
11
+ View: app/views/passwords/new.html.erb
12
+ View: app/views/sessions/_form.html.erb
13
+ View: app/views/sessions/new.html.erb
14
+ View: app/views/users/_form.html.erb
15
+ View: app/views/users/new.html.erb
@@ -1,8 +1,29 @@
1
- require 'diesel/generators/views_base'
1
+ require 'rails/generators/base'
2
2
 
3
3
  module Clearance
4
4
  module Generators
5
- class ViewsGenerator < Diesel::Generators::ViewsBase
5
+ class ViewsGenerator < Rails::Generators::Base
6
+ source_root Clearance.root
7
+
8
+ def create_views
9
+ views.each do |view|
10
+ copy_file view
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def views
17
+ files_within_root('.', 'app/views/**/*.*')
18
+ end
19
+
20
+ def files_within_root(prefix, glob)
21
+ root = "#{self.class.source_root}/#{prefix}"
22
+
23
+ Dir["#{root}/#{glob}"].sort.map do |full_path|
24
+ full_path.sub(root, '.').gsub('/./', '/')
25
+ end
26
+ end
6
27
  end
7
28
  end
8
29
  end
@@ -53,8 +53,7 @@ describe Clearance::PasswordsController do
53
53
  ActionMailer::Base.deliveries.should be_empty
54
54
  end
55
55
 
56
- it { should set_the_flash.to(/unknown email/i).now }
57
- it { should render_template(:new) }
56
+ it { should render_template(:create) }
58
57
  end
59
58
  end
60
59
  end
@@ -8,15 +8,17 @@ require 'rails/test_help'
8
8
 
9
9
  Bundler.require
10
10
 
11
- require 'diesel/testing'
11
+ require 'clearance/testing/application'
12
12
  require 'rspec/rails'
13
13
  require 'bourne'
14
- require 'timecop'
15
14
  require 'factory_girl_rails'
16
15
  require 'shoulda-matchers'
17
16
  require 'clearance/testing'
17
+ require 'timecop'
18
+
19
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
18
20
 
19
- Dir[Rails.root.join('spec/support/**/*.rb')].each {|f| require f}
21
+ Clearance::Testing::Application.initialize!
20
22
 
21
23
  RSpec.configure do |config|
22
24
  config.include FactoryGirl::Syntax::Methods
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2012-09-20 00:00:00.000000000 Z
21
+ date: 2012-10-30 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: bcrypt-ruby
@@ -36,22 +36,6 @@ dependencies:
36
36
  - - ! '>='
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
- - !ruby/object:Gem::Dependency
40
- name: diesel
41
- requirement: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - '='
45
- - !ruby/object:Gem::Version
46
- version: 0.1.5
47
- type: :runtime
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 0.1.5
55
39
  - !ruby/object:Gem::Dependency
56
40
  name: rails
57
41
  requirement: !ruby/object:Gem::Requirement
@@ -297,16 +281,12 @@ files:
297
281
  - cucumber.yml
298
282
  - db/migrate/20110111224543_create_clearance_users.rb
299
283
  - db/schema.rb
300
- - features/engine/visitor_resets_password.feature
301
- - features/engine/visitor_signs_in.feature
302
- - features/engine/visitor_signs_out.feature
303
- - features/engine/visitor_signs_up.feature
304
- - features/integration.feature
284
+ - features/add_migrations_to_project.feature
285
+ - features/integration_with_rspec.feature
305
286
  - features/integration_with_test_unit.feature
306
287
  - features/step_definitions/configuration_steps.rb
307
- - features/step_definitions/engine/clearance_steps.rb
288
+ - features/step_definitions/gem_file_steps.rb
308
289
  - features/support/aruba.rb
309
- - features/support/clearance.rb
310
290
  - features/support/env.rb
311
291
  - gemfiles/3.0.17.gemfile
312
292
  - gemfiles/3.0.17.gemfile.lock
@@ -330,17 +310,36 @@ files:
330
310
  - lib/clearance/rack_session.rb
331
311
  - lib/clearance/session.rb
332
312
  - lib/clearance/testing.rb
313
+ - lib/clearance/testing/app/controllers/application_controller.rb
314
+ - lib/clearance/testing/application.rb
333
315
  - lib/clearance/testing/assertion_error.rb
316
+ - lib/clearance/testing/config/database.yml
317
+ - lib/clearance/testing/config/routes.rb
334
318
  - lib/clearance/testing/deny_access_matcher.rb
335
319
  - lib/clearance/testing/helpers.rb
336
320
  - lib/clearance/user.rb
337
321
  - lib/clearance/version.rb
338
- - lib/generators/clearance/features/features_generator.rb
339
322
  - lib/generators/clearance/install/install_generator.rb
340
323
  - lib/generators/clearance/install/templates/README
341
324
  - lib/generators/clearance/install/templates/clearance.rb
342
- - lib/generators/clearance/install/templates/db/migrate/upgrade_clearance_to_diesel.rb
325
+ - lib/generators/clearance/install/templates/db/migrate/add_clearance_to_users.rb
326
+ - lib/generators/clearance/install/templates/db/migrate/create_users.rb
343
327
  - lib/generators/clearance/install/templates/user.rb
328
+ - lib/generators/clearance/specs/USAGE
329
+ - lib/generators/clearance/specs/specs_generator.rb
330
+ - lib/generators/clearance/specs/templates/factories/clearance.rb
331
+ - lib/generators/clearance/specs/templates/integration/clearance/user_signs_out_spec.rb
332
+ - lib/generators/clearance/specs/templates/integration/clearance/visitor_resets_password_spec.rb
333
+ - lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_in_spec.rb
334
+ - lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_up_spec.rb
335
+ - lib/generators/clearance/specs/templates/integration/clearance/visitor_updates_password_spec.rb
336
+ - lib/generators/clearance/specs/templates/support/action_mailer.rb
337
+ - lib/generators/clearance/specs/templates/support/clearance.rb
338
+ - lib/generators/clearance/specs/templates/support/factory_girl.rb
339
+ - lib/generators/clearance/specs/templates/support/integration.rb
340
+ - lib/generators/clearance/specs/templates/support/integration/action_mailer_helpers.rb
341
+ - lib/generators/clearance/specs/templates/support/integration/clearance_helpers.rb
342
+ - lib/generators/clearance/views/USAGE
344
343
  - lib/generators/clearance/views/views_generator.rb
345
344
  - spec/clearance/constraints/signed_in_spec.rb
346
345
  - spec/clearance/constraints/signed_out_spec.rb
@@ -386,21 +385,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
386
385
  version: 1.3.1
387
386
  requirements: []
388
387
  rubyforge_project:
389
- rubygems_version: 1.8.24
388
+ rubygems_version: 1.8.23
390
389
  signing_key:
391
390
  specification_version: 3
392
391
  summary: Rails authentication & authorization with email & password.
393
392
  test_files:
394
- - features/engine/visitor_resets_password.feature
395
- - features/engine/visitor_signs_in.feature
396
- - features/engine/visitor_signs_out.feature
397
- - features/engine/visitor_signs_up.feature
398
- - features/integration.feature
393
+ - features/add_migrations_to_project.feature
394
+ - features/integration_with_rspec.feature
399
395
  - features/integration_with_test_unit.feature
400
396
  - features/step_definitions/configuration_steps.rb
401
- - features/step_definitions/engine/clearance_steps.rb
397
+ - features/step_definitions/gem_file_steps.rb
402
398
  - features/support/aruba.rb
403
- - features/support/clearance.rb
404
399
  - features/support/env.rb
405
400
  - spec/clearance/constraints/signed_in_spec.rb
406
401
  - spec/clearance/constraints/signed_out_spec.rb
@@ -1,34 +0,0 @@
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
- When I reset the password for "unknown.email@example.com"
9
- Then I am told email is unknown
10
-
11
- Scenario: User is signed up and requests password reset
12
- Given I signed up with "email@example.com"
13
- When I reset the password for "email@example.com"
14
- Then instructions for changing my password are emailed to "email@example.com"
15
-
16
- Scenario: User tries to reset his password with a blank password
17
- Given I signed up with "email@example.com"
18
- When I reset the password for "email@example.com"
19
- And I follow the password reset link sent to "email@example.com"
20
- And I update my password with ""
21
- Then I am told to enter a password
22
- And I should be signed out
23
-
24
- Scenario: User is signed up and updates his password
25
- Given I signed up with "email@example.com"
26
- When I reset the password for "email@example.com"
27
- And I follow the password reset link sent to "email@example.com"
28
- And I update my password with "newpassword"
29
- Then I should be signed in
30
- When I sign out
31
- Then I should be signed out
32
- When I sign in with "email@example.com" and "newpassword"
33
- Then I should be signed in
34
-
@@ -1,33 +0,0 @@
1
- Feature: Sign in
2
-
3
- In order to get access to protected sections of the site
4
- As a visitor
5
- I want to sign in
6
-
7
- Scenario: Visitor is not signed up
8
- When I sign in as "unknown.email@example.com"
9
- Then I am told email or password is bad
10
- And I should be signed out
11
-
12
- Scenario: Visitor enters wrong password
13
- Given I am signed up as "email@example.com"
14
- When I sign in as "email@example.com" and "badpassword"
15
- Then I am told email or password is bad
16
- And I should be signed out
17
-
18
- Scenario: Visitor signs in successfully
19
- Given I am signed up as "email@example.com"
20
- When I sign in as "email@example.com"
21
- Then I should be signed in
22
-
23
- Scenario: Visitor signs in successfully with uppercase email
24
- Given I am signed up as "email@example.com"
25
- When I sign in as "Email@example.com"
26
- Then I should be signed in
27
-
28
- Scenario: Visitor enters wrong password and goes to sign up
29
- Given I am signed up as "email@example.com"
30
- When I sign in as "email@example.com" and "badpassword"
31
- Then I am told email or password is bad
32
- When I follow the sign up link in the flash
33
- Then I should be on the sign up page
@@ -1,12 +0,0 @@
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@example.com"
9
- When I sign in as "email@example.com"
10
- Then I should be signed in
11
- When I sign out
12
- Then I should be signed out
@@ -1,17 +0,0 @@
1
- Feature: Sign up
2
-
3
- In order to access protected sections of the site
4
- As a visitor
5
- I want to sign up
6
-
7
- Scenario: Visitor signs up with invalid email
8
- When I sign up with "invalidemail" and "password"
9
- Then I should be signed out
10
-
11
- Scenario: Visitor signs up with blank password
12
- When I sign up with "email@example.com" and ""
13
- Then I should be signed out
14
-
15
- Scenario: Visitor signs up with valid data
16
- When I sign up with "email@example.com" and "password"
17
- Then I should be signed in
@@ -1,50 +0,0 @@
1
- Feature: integrate with application
2
-
3
- Background:
4
- When I successfully run `bundle exec rails new testapp`
5
- And I cd to "testapp"
6
- And I remove the file "public/index.html"
7
- And I remove the file "app/views/layouts/application.html.erb"
8
- And I configure ActionMailer to use "localhost" as a host
9
- And I configure a root route
10
- And I add the "cucumber-rails" gem
11
- And I add the "capybara" gem
12
- And I add the "rspec-rails" gem
13
- And I add the "factory_girl_rails" gem
14
- And I add the "database_cleaner" gem
15
- And I add the "clearance" gem from this project
16
- And I run `bundle install --local`
17
- And I successfully run `bundle exec rails generate cucumber:install`
18
- And I successfully run `bundle exec rails generate clearance:features`
19
-
20
- Scenario: generate a Rails app, run the generators, and run the tests
21
- When I successfully run `bundle exec rails generate clearance:install`
22
- Then the output should contain "Next steps"
23
- When I successfully run `bundle exec rake db:migrate --trace`
24
- And I successfully run `bundle exec rake --trace`
25
- Then the output should contain "passed"
26
- And the output should not contain "failed"
27
- And the output should not contain "Could not find generator"
28
-
29
- Scenario: Developer already has a users table in their database
30
- When I write to "db/migrate/001_create_users.rb" with:
31
- """
32
- class CreateUsers < ActiveRecord::Migration
33
- def self.up
34
- create_table(:users) do |t|
35
- t.string :email
36
- t.string :name
37
- end
38
- end
39
- def self.down
40
- end
41
- end
42
- """
43
- And I successfully run `bundle exec rake db:migrate --trace`
44
- And I successfully run `bundle exec rails generate clearance:install`
45
- And I successfully run `bundle exec rake db:migrate --trace`
46
- And I successfully run `bundle exec rake --trace`
47
- Then the output should contain "passed"
48
- And the output should not contain "failed"
49
- And the output should not contain "Could not find generator"
50
-
@@ -1,124 +0,0 @@
1
- # Existing users
2
-
3
- require 'factory_girl_rails'
4
-
5
- Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)"$/ do |email|
6
- FactoryGirl.create :user, :email => email
7
- end
8
-
9
- # Sign up
10
-
11
- When /^I sign up (?:with|as) "(.*)" and "(.*)"$/ do |email, password|
12
- visit sign_up_path
13
- page.should have_css("input[type='email']")
14
- fill_in 'Email', :with => email
15
- fill_in 'Password', :with => password
16
- click_button 'Sign up'
17
- end
18
-
19
- # Sign in
20
-
21
- Given /^I sign in$/ do
22
- email = FactoryGirl.generate(:email)
23
- steps %{
24
- Given I have signed up with "#{email}"
25
- And I sign in with "#{email}"
26
- }
27
- end
28
-
29
- When /^I sign in (?:with|as) "([^"]*)"$/ do |email|
30
- step %{I sign in with "#{email}" and "password"}
31
- end
32
-
33
- When /^I sign in (?:with|as) "([^"]*)" and "([^"]*)"$/ do |email, password|
34
- visit sign_in_path
35
- page.should have_css("input[type='email']")
36
- fill_in 'Email', :with => email
37
- fill_in 'Password', :with => password
38
- click_button 'Sign in'
39
- end
40
-
41
- # Sign out
42
-
43
- When 'I sign out' do
44
- visit '/'
45
- click_link 'Sign out'
46
- end
47
-
48
- # Reset password
49
-
50
- When /^I reset the password for "(.*)"$/ do |email|
51
- visit new_password_path
52
- page.should have_css("input[type='email']")
53
- fill_in 'Email address', :with => email
54
- click_button 'Reset password'
55
- end
56
-
57
- Then /^instructions for changing my password are emailed to "(.*)"$/ do |email|
58
- page.should have_content('instructions for changing your password')
59
- user = User.find_by_email!(email)
60
- assert !user.confirmation_token.blank?
61
- assert !ActionMailer::Base.deliveries.empty?
62
-
63
- result = ActionMailer::Base.deliveries.any? do |email|
64
- email.to == [user.email] &&
65
- email.subject =~ /password/i &&
66
- email.body =~ /#{user.confirmation_token}/
67
- end
68
-
69
- assert result
70
- end
71
-
72
- When /^I follow the password reset link sent to "(.*)"$/ do |email|
73
- user = User.find_by_email!(email)
74
- visit edit_user_password_path(:user_id => user,
75
- :token => user.confirmation_token)
76
- end
77
-
78
- When /^I change the password of "(.*)" without token$/ do |email|
79
- user = User.find_by_email!(email)
80
- visit edit_user_password_path(:user_id => user)
81
- end
82
-
83
- When /^I update my password with "(.*)"$/ do |password|
84
- fill_in 'Choose password', :with => password
85
- click_button 'Save this password'
86
- end
87
-
88
- # Navigation
89
-
90
- Then /^I should be on the sign up page$/ do
91
- page.current_path.should == sign_up_path
92
- end
93
-
94
- # Flashes
95
-
96
- Then /^I am told email or password is bad$/ do
97
- page.should have_content('Bad email or password. Are you trying to register a new account? Sign up.')
98
- end
99
-
100
- When /^I follow the sign up link in the flash$/ do
101
- within '#flash' do
102
- click_link 'Sign up'
103
- end
104
- end
105
-
106
- Then /^I am told email is unknown$/ do
107
- page.should have_content('Unknown email')
108
- end
109
-
110
- Then /^I am told to enter a password$/ do
111
- page.should have_content("Password can't be blank")
112
- end
113
-
114
- # Verification
115
-
116
- Then /^I should be signed in$/ do
117
- visit '/'
118
- page.should have_content 'Sign out'
119
- end
120
-
121
- Then /^I should be signed out$/ do
122
- visit '/'
123
- page.should have_content 'Sign in'
124
- end