Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b94f734
Update clearance dependency to version 0.12.0
sferik Sep 9, 2011
4ea8467
Remove confirmed_password
sferik Sep 9, 2011
a08ed4d
Replace Factory(:email_confirmed_user) with Factory(:user)
sferik Sep 9, 2011
d3fd3cf
Generate new clearance features
sferik Sep 9, 2011
6553ccf
Remove confirmations controller
sferik Sep 9, 2011
7193927
Make unit tests pass with new clearance version
sferik Sep 9, 2011
ab3ad4d
Require clearance/testing instead of clearance/shoulda_macros.
cmeiklejohn Sep 13, 2011
1129386
There is no more email confirmed.
cmeiklejohn Sep 13, 2011
2e62da8
No longer test for confirmed users.
cmeiklejohn Sep 13, 2011
1e98ca7
No longer confirm email.
cmeiklejohn Sep 13, 2011
b25c3c9
No longer email_confirmed?
cmeiklejohn Sep 13, 2011
78a66f6
Update features with new clearance syntax.
cmeiklejohn Sep 13, 2011
fcf5c15
Update clearance syntax.
cmeiklejohn Sep 13, 2011
0958000
Update clearance step to assign current user to @me.
cmeiklejohn Sep 13, 2011
a2e7d63
Fix missed syntax change.
cmeiklejohn Sep 13, 2011
6dccb16
There is no longer a flash success after create in clearance.
cmeiklejohn Sep 13, 2011
5b0ae60
No longer a flash message on successful sign-in.
cmeiklejohn Sep 13, 2011
74562f4
We no longer have email confirmed users.
cmeiklejohn Sep 13, 2011
df2125a
One error message on too-long, but well-formed email; no confirmation…
cmeiklejohn Sep 13, 2011
51d254d
Don't require that the sign in and sign out links be in title case.
cmeiklejohn Sep 16, 2011
5d066d9
Only one error message here.
cmeiklejohn Sep 16, 2011
09f07f8
Fix some more testing against case insensitive links.
cmeiklejohn Sep 16, 2011
5b697a8
Fix form localization.
cmeiklejohn Sep 16, 2011
0799fd9
DOn't require that the sign in check be on a particular page.
cmeiklejohn Sep 16, 2011
39c3b05
Add guard.
cmeiklejohn Sep 16, 2011
e3f1257
Add guard-bundler.
cmeiklejohn Sep 16, 2011
64badb7
The app has a capybara dependency for testing through the clearance f…
cmeiklejohn Sep 16, 2011
9eb4d08
Hard code the steps of singing in with a new password, since we only …
cmeiklejohn Sep 16, 2011
4d34d82
Remove session is cleared code.
cmeiklejohn Sep 16, 2011
e4fc25c
Fix selector syntax issue in the clearance steps.
cmeiklejohn Sep 16, 2011
9941fb5
Downcase the email in the override, as stock clearance would.
cmeiklejohn Sep 16, 2011
42ed451
Update stock clearance matcher for email field to match our email or …
cmeiklejohn Sep 16, 2011
6c4301f
Add home page path.
cmeiklejohn Sep 16, 2011
beab67e
Update input fields to be of email type.
cmeiklejohn Sep 16, 2011
82e0e6f
Kill double coverage scenario since we've already got it in handle/si…
cmeiklejohn Sep 17, 2011
2c2657b
Update form fields to use the email_field type instead of text_field.
cmeiklejohn Sep 17, 2011
50e40b7
Rename the reset to change since there is no longer a confirmation. …
cmeiklejohn Sep 17, 2011
874cd81
Update form to have an email-type field instead of a plain text field.
cmeiklejohn Sep 17, 2011
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem 'psych', :platforms => :ruby_19

gem 'rails', '~> 3.0.10'

gem 'clearance', '~> 0.9.1'
gem 'clearance'
gem 'fog'
gem 'gchartrb', :require => 'google_chart'
gem 'gravtastic'
Expand All @@ -32,6 +32,9 @@ end

group :development, :test do
gem 'silent-postgres'
gem 'guard'
gem 'guard-cucumber'
gem 'guard-bundler'
end

# These gems suck and do stupid things when in maintenance mode
Expand All @@ -41,6 +44,7 @@ group :development, :test, :staging, :production do
end

group :test do
gem 'capybara', '~> 1.1'
gem 'cucumber-rails'
gem 'database_cleaner'
gem 'factory_girl_rails'
Expand Down
21 changes: 18 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ GEM
xpath (~> 0.1.4)
childprocess (0.2.2)
ffi (~> 1.0.6)
clearance (0.9.1)
rails (~> 3.0.0)
clearance (0.12.0)
diesel (~> 0.1.4)
rails (>= 3.0)
coderay (0.9.8)
crack (0.1.8)
cucumber (1.0.6)
Expand All @@ -59,6 +60,8 @@ GEM
delayed_job (2.1.4)
activesupport (~> 3.0)
daemons
diesel (0.1.5)
railties
diff-lcs (1.1.3)
erubis (2.6.6)
abstract (>= 1.0.0)
Expand All @@ -83,6 +86,14 @@ GEM
gherkin (2.4.18)
json (>= 1.4.6)
gravtastic (3.2.6)
guard (0.7.0)
thor (~> 0.14.6)
guard-bundler (0.1.3)
bundler (>= 1.0.0)
guard (>= 0.2.2)
guard-cucumber (0.6.3)
cucumber (>= 0.10)
guard (>= 0.4.0)
high_voltage (1.0.1)
hoptoad_notifier (2.4.11)
activesupport
Expand Down Expand Up @@ -189,14 +200,18 @@ PLATFORMS
ruby

DEPENDENCIES
clearance (~> 0.9.1)
capybara (~> 1.1)
clearance
cucumber-rails
database_cleaner
delayed_job
factory_girl_rails
fog
gchartrb
gravtastic
guard
guard-bundler
guard-cucumber
high_voltage
hoptoad_notifier
jruby-openssl
Expand Down
14 changes: 14 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'cucumber' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end

guard 'bundler' do
watch('Gemfile')
# Uncomment next line if Gemfile contain `gemspec' command
# watch(/^.+\.gemspec/)
end
2 changes: 1 addition & 1 deletion app/controllers/api/v1/api_keys_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Api::V1::ApiKeysController < Api::BaseController
def show
authenticate_or_request_with_http_basic do |username, password|
@_current_user = User.authenticate(username, password)
if current_user && current_user.email_confirmed
if current_user
respond_to do |format|
format.any(:all) { render :text => current_user.api_key }
format.json { render :json => {:rubygems_api_key => current_user.api_key} }
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def authenticate_with_api_key
def verify_authenticated_user
if current_user.nil?
render :text => t(:please_sign_up), :status => 401
elsif !current_user.email_confirmed
render :text => t(:please_confirm), :status => 403
end
end

Expand Down
14 changes: 0 additions & 14 deletions app/controllers/confirmations_controller.rb

This file was deleted.

15 changes: 2 additions & 13 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,8 @@ def create
flash_failure_after_create
render :template => 'sessions/new', :status => :unauthorized
else
if @user.email_confirmed? && !@user.email_reset
sign_in(@user)
flash_success_after_create
redirect_back_or(url_after_create)
else
if @user.email_reset
Mailer.email_reset(@user).deliver
else
ClearanceMailer.confirmation(@user).deliver
end
flash_notice_after_create
redirect_to(new_session_url)
end
sign_in(@user)
redirect_back_or(url_after_create)
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/models/rubyforger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def transferable?(password)
def self.transfer(email, password)
if rubyforger = Rubyforger.find_by_email(email)
if user = rubyforger.transferable?(password)
user.update_password(password, password)
user.confirm_email!
user.update_password(password)
rubyforger.destroy
user
end
Expand Down
17 changes: 2 additions & 15 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ class User < ActiveRecord::Base
include Gravtastic
is_gravtastic :default => "retro"

attr_accessible :bio, :email, :handle, :location, :password,
:password_confirmation, :website
attr_accessible :bio, :email, :handle, :location, :password, :website

has_many :rubygems, :through => :ownerships,
:conditions => { 'ownerships.approved' => true }
Expand All @@ -18,14 +17,13 @@ class User < ActiveRecord::Base

before_validation :regenerate_token, :if => :email_changed?, :on => :update
before_create :generate_api_key
after_update :deliver_email_reset, :if => :email_reset

validates_uniqueness_of :handle, :allow_nil => true
validates_format_of :handle, :with => /\A[A-Za-z][A-Za-z_\-0-9]*\z/, :allow_nil => true
validates_length_of :handle, :within => 3..15, :allow_nil => true

def self.authenticate(who, password)
if user = Rubyforger.transfer(who, password) || find_by_email(who) || find_by_handle(who)
if user = Rubyforger.transfer(who, password) || find_by_email(who.downcase) || find_by_handle(who)
user if user.authenticated?(password)
end
end
Expand Down Expand Up @@ -74,24 +72,13 @@ def to_yaml(*args)
end

def regenerate_token
self.email_reset = true
generate_confirmation_token
end

def deliver_email_reset
Mailer.email_reset(self).deliver
end

def generate_api_key
self.api_key = ActiveSupport::SecureRandom.hex(16)
end

def confirm_email!
self.email_confirmed = true
self.confirmation_token = self.email_reset = nil
save(:validate => false)
end

def total_downloads_count
rubygems.to_a.sum(&:downloads)
end
Expand Down
8 changes: 0 additions & 8 deletions app/views/clearance_mailer/confirmation.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
Welcome to RubyGems.org, the Ruby community's gem hosting service!

To confirm your account, please follow this link:

<%= new_user_confirmation_url(
:user_id => @user,
:token => @user.confirmation_token,
:encode => false) %>

If you're having trouble getting set up, let us know at:

http://help.rubygems.org

Happy gem push'ing!
3 changes: 0 additions & 3 deletions app/views/mailer/email_reset.erb
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
You changed your email address on Gemcutter. Please visit this url to re-activate your account:

<%= new_user_confirmation_url :user_id => @user, :token => @user.confirmation_token, :encode => false %>
4 changes: 0 additions & 4 deletions app/views/passwords/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<%= form.label :password %>
<%= form.password_field :password, :size => 25 %>
</div>
<div class="password_field">
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, :size => 25 %>
</div>
<div class="form_bottom">
<%= form.submit t('.submit'), :disable_with => t('form_disable_with') %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/passwords/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= form_for :password, :url => passwords_path do |form| %>
<div class="text_field">
<%= form.label :email, t('activerecord.attributes.user.email') %>
<%= form.text_field :email, :size => '25' %>
<%= form.email_field :email, :size => '25' %>
</div>
<div class="submit_field">
<%= form.submit t('.submit'), :disable_with => t('form_disable_with') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/profiles/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<div class="text_field">
<%= form.label :email %>
<%= form.text_field :email, :size => 25 %>
<%= form.email_field :email, :size => 25 %>
</div>

<div class="submit_field">
Expand Down
2 changes: 1 addition & 1 deletion app/views/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= form_for :session, :url => session_path do |form| %>
<div class="text_field">
<%= form.label :who, t('activerecord.attributes.session.who') %>
<%= form.text_field :who, :size => 25 %>
<%= form.email_field :who, :size => 25 %>
</div>
<div class="password_field">
<%= form.label :password, t('activerecord.attributes.session.password') %>
Expand Down
6 changes: 1 addition & 5 deletions app/views/users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%= form.error_messages %>
<div class="text_field">
<%= form.label :email %>
<%= form.text_field :email, :size => 25 %>
<%= form.email_field :email, :size => 25 %>
</div>
<div class="text_field">
<%= form.label :handle %>
Expand All @@ -11,7 +11,3 @@
<%= form.label :password %>
<%= form.password_field :password, :size => 25 %>
</div>
<div class="password_field">
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, :size => 25 %>
</div>
1 change: 0 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ en:
avatar: Avatar
email: Email address
handle: Handle
password_confirmation: Confirm password
password: Password
linkset:
bugs: Bug Tracker URL
Expand Down
4 changes: 0 additions & 4 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,11 @@
# Clearance Overrides

resource :session, :only => [:new, :create]
scope :path => 'users/:user_id' do
resource :confirmation, :only => [:new, :create], :as => :user_confirmation
end

resources :passwords, :only => [:new, :create]

resources :users do
resource :password, :only => [:create, :edit, :update]
resource :confirmation, :only => [:new, :create]
end

################################################################################
Expand Down
4 changes: 2 additions & 2 deletions features/api_key_reset.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Feature: API key reset
Should be able to reset it

Scenario: User sees existing key on their profile page
Given I have signed in with "email@person.com/password"
Given I have signed in with "email@person.com"
And I am on my edit profile page
Then I should see my "API key"

Scenario: User resets API key
Given I have signed in with "email@person.com/password"
Given I have signed in with "email@person.com"
And I am on my edit profile page
When I press "Reset my API key"
Then I should see my new "API key"
53 changes: 53 additions & 0 deletions features/clearance/visitor_resets_password.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Feature: Password reset

In order to sign in even if I forgot my password
As a user
I want to reset my password

Scenario: User is not signed up
Given no user exists with an email of "email@example.com"
When I request password reset link to be sent to "email@example.com"
Then I should see "Unknown email"

Scenario: User is signed up and requests password reset
Given I signed up with "email@example.com"
When I request password reset link to be sent to "email@example.com"
Then I should see "instructions for changing your password"
And a password reset message should be sent to "email@example.com"

Scenario: User tries to reset his password with a blank password
Given I signed up with "email@example.com"
And I go to the password reset request page
Then I should see an email field
And I fill in "Email address" with "email@example.com"
And I press "Reset password"
When I follow the password reset link sent to "email@example.com"
And I update my password with ""
Then I should see "Password can't be blank."
And I should be signed out

Scenario: User is signed up and updates his password
Given I signed up with "email@example.com"
And I go to the password reset request page
And I fill in "Email address" with "email@example.com"
And I press "Reset password"
When I follow the password reset link sent to "email@example.com"
And I update my password with "newpassword"
Then I should be signed in
When I sign out
Then I should be signed out
When I go to the sign in page
And I fill in "Email" with "email@example.com"
And I fill in "Password" with "newpassword"
And I press "Sign in"
Then I should be signed in

Scenario: User who was created before Clearance was installed creates password for first time
Given a user "email@example.com" exists without a salt, remember token, or password
When I go to the password reset request page
And I fill in "Email address" with "email@example.com"
And I press "Reset password"
When I follow the password reset link sent to "email@example.com"
And I update my password with "newpassword"
Then I should be signed in

Loading