diff --git a/Gemfile b/Gemfile index fa0cfdf09bb..146362f3c9c 100644 --- a/Gemfile +++ b/Gemfile @@ -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' @@ -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 @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 597f4b0a545..d8d67311976 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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 @@ -189,7 +200,8 @@ PLATFORMS ruby DEPENDENCIES - clearance (~> 0.9.1) + capybara (~> 1.1) + clearance cucumber-rails database_cleaner delayed_job @@ -197,6 +209,9 @@ DEPENDENCIES fog gchartrb gravtastic + guard + guard-bundler + guard-cucumber high_voltage hoptoad_notifier jruby-openssl diff --git a/Guardfile b/Guardfile new file mode 100644 index 00000000000..2d0994b1d61 --- /dev/null +++ b/Guardfile @@ -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 diff --git a/app/controllers/api/v1/api_keys_controller.rb b/app/controllers/api/v1/api_keys_controller.rb index fbe1fa2d319..df94d8ca7cd 100644 --- a/app/controllers/api/v1/api_keys_controller.rb +++ b/app/controllers/api/v1/api_keys_controller.rb @@ -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} } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d2028ffbb5f..05a68dada25 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb deleted file mode 100644 index 7e667c06dfb..00000000000 --- a/app/controllers/confirmations_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class ConfirmationsController < Clearance::ConfirmationsController - - ssl_required - - private - - def redirect_signed_out_confirmed_user - user = User.find(params[:user_id]) - if user && user.email_confirmed? && !user.email_reset && signed_out? - flash_already_confirmed - redirect_to(url_already_confirmed) - end - end -end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index d49d6c0a135..eeaf766416f 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -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 diff --git a/app/models/rubyforger.rb b/app/models/rubyforger.rb index 9889840a7e6..28732283095 100644 --- a/app/models/rubyforger.rb +++ b/app/models/rubyforger.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 6f09d794c47..d5dc98debb5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 } @@ -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 @@ -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 diff --git a/app/views/clearance_mailer/confirmation.html.erb b/app/views/clearance_mailer/confirmation.html.erb index 729868910dd..339ee8ce7bc 100644 --- a/app/views/clearance_mailer/confirmation.html.erb +++ b/app/views/clearance_mailer/confirmation.html.erb @@ -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! diff --git a/app/views/mailer/email_reset.erb b/app/views/mailer/email_reset.erb index 7fd4b8805b9..e69de29bb2d 100644 --- a/app/views/mailer/email_reset.erb +++ b/app/views/mailer/email_reset.erb @@ -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 %> diff --git a/app/views/passwords/edit.html.erb b/app/views/passwords/edit.html.erb index de962f303cb..bd1aa2747af 100644 --- a/app/views/passwords/edit.html.erb +++ b/app/views/passwords/edit.html.erb @@ -8,10 +8,6 @@ <%= form.label :password %> <%= form.password_field :password, :size => 25 %> -
- <%= form.label :password_confirmation %> - <%= form.password_field :password_confirmation, :size => 25 %> -
<%= form.submit t('.submit'), :disable_with => t('form_disable_with') %>
diff --git a/app/views/passwords/new.html.erb b/app/views/passwords/new.html.erb index 0caac72e76a..ec8e41d5b5c 100644 --- a/app/views/passwords/new.html.erb +++ b/app/views/passwords/new.html.erb @@ -5,7 +5,7 @@ <%= form_for :password, :url => passwords_path do |form| %>
<%= form.label :email, t('activerecord.attributes.user.email') %> - <%= form.text_field :email, :size => '25' %> + <%= form.email_field :email, :size => '25' %>
<%= form.submit t('.submit'), :disable_with => t('form_disable_with') %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb index 0f1098ed3d2..88211268a7b 100644 --- a/app/views/profiles/edit.html.erb +++ b/app/views/profiles/edit.html.erb @@ -16,7 +16,7 @@
<%= form.label :email %> - <%= form.text_field :email, :size => 25 %> + <%= form.email_field :email, :size => 25 %>
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 759efaff8f3..95e62768b41 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -8,7 +8,7 @@ <%= form_for :session, :url => session_path do |form| %>
<%= form.label :who, t('activerecord.attributes.session.who') %> - <%= form.text_field :who, :size => 25 %> + <%= form.email_field :who, :size => 25 %>
<%= form.label :password, t('activerecord.attributes.session.password') %> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 29cd4e5606b..16628f92785 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,7 +1,7 @@ <%= form.error_messages %>
<%= form.label :email %> - <%= form.text_field :email, :size => 25 %> + <%= form.email_field :email, :size => 25 %>
<%= form.label :handle %> @@ -11,7 +11,3 @@ <%= form.label :password %> <%= form.password_field :password, :size => 25 %>
-
- <%= form.label :password_confirmation %> - <%= form.password_field :password_confirmation, :size => 25 %> -
diff --git a/config/locales/en.yml b/config/locales/en.yml index cccd88d7156..d9b09792ba0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -191,7 +191,6 @@ en: avatar: Avatar email: Email address handle: Handle - password_confirmation: Confirm password password: Password linkset: bugs: Bug Tracker URL diff --git a/config/routes.rb b/config/routes.rb index e3497d0668e..18e7ad74b16 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 ################################################################################ diff --git a/features/api_key_reset.feature b/features/api_key_reset.feature index ce5bfc938c9..ea4529ce76c 100644 --- a/features/api_key_reset.feature +++ b/features/api_key_reset.feature @@ -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" diff --git a/features/clearance/visitor_resets_password.feature b/features/clearance/visitor_resets_password.feature new file mode 100644 index 00000000000..999b2ee605e --- /dev/null +++ b/features/clearance/visitor_resets_password.feature @@ -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 + diff --git a/features/clearance/visitor_signs_in.feature b/features/clearance/visitor_signs_in.feature new file mode 100644 index 00000000000..dc995cc1e31 --- /dev/null +++ b/features/clearance/visitor_signs_in.feature @@ -0,0 +1,34 @@ +Feature: Sign in + + In order to get access to protected sections of the site + As a visitor + I want to sign in + + Scenario: Visitor is not signed up + Given no user exists with an email of "email@example.com" + When I go to the sign in page + And I sign in as "email@example.com" + Then I should see "Bad email or password" + And I should be signed out + + Scenario: Visitor enters wrong password + Given I am signed up as "email@example.com" + When I go to the sign in page + And I fill in "Email" with "email@example.com" + And I fill in "Password" with "badpassword" + And I press "Sign in" + Then I should see "Bad email or password" + And I should be signed out + + Scenario: Visitor signs in successfully + Given I am signed up as "email@example.com" + When I go to the sign in page + Then I should see an email field + And I sign in as "email@example.com" + Then I should be signed in + + Scenario: Visitor signs in successfully with uppercase email + Given I am signed up as "email@example.com" + When I go to the sign in page + And I sign in as "Email@example.com" + Then I should be signed in diff --git a/features/clearance/visitor_signs_out.feature b/features/clearance/visitor_signs_out.feature new file mode 100644 index 00000000000..c74ac5863d1 --- /dev/null +++ b/features/clearance/visitor_signs_out.feature @@ -0,0 +1,12 @@ +Feature: Sign out + + In order to protect my account from unauthorized access + As a signed in user + I want to sign out + + Scenario: User signs out + Given I am signed up as "email@example.com" + When I sign in as "email@example.com" + Then I should be signed in + And I sign out + Then I should be signed out diff --git a/features/clearance/visitor_signs_up.feature b/features/clearance/visitor_signs_up.feature new file mode 100644 index 00000000000..46739f7f4a9 --- /dev/null +++ b/features/clearance/visitor_signs_up.feature @@ -0,0 +1,21 @@ +Feature: Sign up + + In order to access protected sections of the site + As a visitor + I want to sign up + + Background: + When I go to the sign up page + Then I should see an email field + + Scenario: Visitor signs up with invalid email + When I fill in "Email" with "invalidemail" + And I fill in "Password" with "password" + And I press "Sign up" + Then I should see "Must be a valid email address" + + Scenario: Visitor signs up with blank password + When I fill in "Email" with "email@example.com" + And I fill in "Password" with "" + And I press "Sign up" + Then I should see "Password can't be blank" diff --git a/features/dashboard.feature b/features/dashboard.feature index 1e834e44a15..cf1d6c68d4f 100644 --- a/features/dashboard.feature +++ b/features/dashboard.feature @@ -4,7 +4,7 @@ Feature: Dashboard Should be able to see a list of updates in their feed Background: - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" Scenario: User goes to their dashboard Given the following rubygems exist: @@ -27,7 +27,7 @@ Feature: Dashboard | email: email@person.com | name: fireworm | And I download the rubygem "fireworm" version "1.0.0" 1001 times And I download the rubygem "sandworm" version "2.0.0" 1008 times - When I sign in as "email@person.com/password" + When I sign in as "email@person.com" And I go to the dashboard And I should see "ffi" And I should see "java" diff --git a/features/download.feature b/features/download.feature index 7710ffe49f4..e25c54f1294 100644 --- a/features/download.feature +++ b/features/download.feature @@ -4,7 +4,7 @@ Feature: Download Gems Should be able to download some gems Scenario: Download a gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have a gem "sandworm" with version "1.0.0" And I have a gem "sandworm" with version "2.0.0" And I have an API key for "email@person.com/password" @@ -37,7 +37,7 @@ Feature: Download Gems And I should see "1,003 for this version" Scenario: Download a platform gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have a gem "crysknife" with version "1.0.0" And I have a gem "crysknife" with version "1.0.0" and platform "java" And I have an API key for "email@person.com/password" @@ -61,7 +61,7 @@ Feature: Download Gems And I should see "2 for this version" Scenario: Download a .gem file for a platform gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have a gem "andhapp" with version "1.1.1" And I have a gem "andhapp" with version "1.1.0" And I have an API key for "email@person.com/password" diff --git a/features/edit_profile.feature b/features/edit_profile.feature index b7f5521a061..ac29f36c536 100644 --- a/features/edit_profile.feature +++ b/features/edit_profile.feature @@ -4,7 +4,7 @@ Feature: Edit Profile Should be able to edit their profile Scenario: Edit Handle - Given I have signed in with "john@example.com/password" + Given I have signed in with "john@example.com" And my handle is "johndoe" And I am on my edit profile page When I fill in "Handle" with "john_doe" @@ -16,7 +16,7 @@ Feature: Edit Profile Given the following user exists: | email | handle | | janedoe@example.com | some_doe | - And I have signed in with "johndoe@example.com/password" + And I have signed in with "johndoe@example.com" And I am on my edit profile page When I fill in "Handle" with "some_doe" And I press "Update" diff --git a/features/email_change.feature b/features/email_change.feature new file mode 100644 index 00000000000..85d2ffc6138 --- /dev/null +++ b/features/email_change.feature @@ -0,0 +1,19 @@ +Feature: Email change + In order to still use my account after I've changed my email address + A user + Should be able to change the email address associated with my account + + Background: + Given I have signed in with "email@person.com" + + Scenario: User changes their email to a new address + When I have changed my email address to "email@newperson.com" + And I sign out + When I sign in as "email@newperson.com" + Then I should not see "sign in" + + Scenario: User tries to change their email to an invalid email address + When I am on my edit profile page + And I fill in "Email address" with "this is an invalid email address" + And I press "Update" + Then I should see an error message diff --git a/features/email_reset.feature b/features/email_reset.feature deleted file mode 100644 index 76de4a47a77..00000000000 --- a/features/email_reset.feature +++ /dev/null @@ -1,39 +0,0 @@ -Feature: Email reset - In order to still use my account after I've changed my email address - A user - Should be able to reset the email address associated with my account - - Background: - Given I have signed in with "email@person.com/password" - - Scenario: User resets email address - Given I am on my edit profile page - When I fill in "Email address" with "email@newperson.com" - And I press "Update" - Then an email entitled "Email address confirmation" should be sent to "email@newperson.com" - And I should see "You will receive an email within the next few minutes." - And I should be signed out - - Scenario: User tries to reset email with an invalid email address - When I am on my edit profile page - And I fill in "Email address" with "this is an invalid email address" - And I press "Update" - Then I should see error messages - - Scenario: User confirms new email address - When I have reset my email address to "email@newperson.com" - And I follow the confirmation link sent to "email@newperson.com" - Then I should see "Confirmed email and signed in" - And I should be signed in - - Scenario: User tries to sign in in after resetting email address without confirmation - When I have reset my email address to "email@newperson.com" - And I sign in as "email@newperson.com/password" - Then I should see "Confirmation email will be resent." - And an email entitled "Email address confirmation" should be sent to "email@newperson.com" - - Scenario: User signs in after resetting and confirming email address - When I have reset my email address to "email@newperson.com" - And I follow the confirmation link sent to "email@newperson.com" - And I sign in as "email@newperson.com/password" - Then I should not see "sign in" diff --git a/features/gems_api.feature b/features/gems_api.feature index 01f309fa131..8cd4fd4b335 100644 --- a/features/gems_api.feature +++ b/features/gems_api.feature @@ -4,7 +4,7 @@ Feature: List gems API Should be able to list their gems Scenario: Gem owner user lists their gems - Given I am signed up and confirmed as "original@owner.org/password" + Given I am signed up as "original@owner.org" And I have an API key for "original@owner.org/password" And the following version exists: | rubygem | number | diff --git a/features/gravatar.feature b/features/gravatar.feature index 79b6e037e07..4955279887c 100644 --- a/features/gravatar.feature +++ b/features/gravatar.feature @@ -8,6 +8,6 @@ Feature: Gravatar Then I should not see my gravatar Scenario: User is signed in - Given I have signed in with "email@person.com/password" + Given I have signed in with "email@person.com" When I go to the homepage Then I should see my gravatar diff --git a/features/handle/password_reset.feature b/features/handle/password_reset.feature new file mode 100644 index 00000000000..a1fc9acbe7b --- /dev/null +++ b/features/handle/password_reset.feature @@ -0,0 +1,22 @@ +Feature: Password reset with handle + In order to sign in even if user forgot their password + A user + Should be able to reset it with handle + + Scenario: User is signed up and updates his password without having a handle + Given I signed up with "email@person.com" + And my handle is nil + When I go to the password reset request page + And I fill in "Email address" with "email@person.com" + And I press "Reset password" + Then a password reset message should be sent to "email@person.com" + When I follow the password reset link sent to "email@person.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@person.com" + And I fill in "Password" with "newpassword" + And I press "Sign in" + Then I should be signed in diff --git a/features/handle/sign_in.feature b/features/handle/sign_in.feature new file mode 100644 index 00000000000..a8e2ff82593 --- /dev/null +++ b/features/handle/sign_in.feature @@ -0,0 +1,11 @@ +Feature: Sign in with handle + In order to get access to protected sections of the site + A user + Should be able to sign in with handle + + Scenario: User signs in successfully with handle + Given I am signed up as "email@person.com" + And my handle is "signinnow" + When I go to the sign in page + And I sign in as "signinnow" + Then I should be signed in diff --git a/features/handle/sign_up.feature b/features/handle/sign_up.feature new file mode 100644 index 00000000000..5467da450a7 --- /dev/null +++ b/features/handle/sign_up.feature @@ -0,0 +1,27 @@ +Feature: Sign up with handle + In order to get access to protected sections of the site + A user + Should be able to sign up with handle + + Scenario: User signs up with no handle + When I go to the sign up page + And I fill in "Email" with "email@person.com" + And I fill in "Password" with "password" + And I press "Sign up" + Then I should see error messages + + Scenario: User signs up with invalid handle + When I go to the sign up page + And I fill in "Email" with "email@person.com" + And I fill in "Handle" with "thisusernameiswaytoolongseriouslywaytoolong" + And I fill in "Password" with "password" + And I press "Sign up" + Then I should see an error message + + Scenario: User signs up with valid data + When I go to the sign up page + And I fill in "Email" with "email@person.com" + And I fill in "Handle" with "validhandledude" + And I fill in "Password" with "password" + And I press "Sign up" + Then I should be signed in diff --git a/features/homepage.feature b/features/homepage.feature index cc75e2e6126..47ab73e6411 100644 --- a/features/homepage.feature +++ b/features/homepage.feature @@ -1,7 +1,7 @@ Feature: Homepage Scenario: Most downloaded gems for today - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a gem "sandworm" with version "1.0.0" And I have a gem "sandworm" with version "2.0.0" diff --git a/features/owner.feature b/features/owner.feature index 9cf3259147f..189dd82e253 100644 --- a/features/owner.feature +++ b/features/owner.feature @@ -4,7 +4,7 @@ Feature: Manage owners Should be able to add and remove gem owners Background: - Given the following email confirmed users exist: + Given the following users exist: | email | | original@owner.org | | new@owner.org | @@ -16,7 +16,7 @@ Feature: Manage owners | email: original@owner.org | name: OGem | Scenario Outline: Gem owner user lists gem owners - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" When I list the owners of gem "OGem" as "" with my API key Then I should see "original@owner.org" @@ -28,7 +28,7 @@ Feature: Manage owners | yaml | Scenario: Gem owner adds another owner - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" When I add the owner "new@owner.org" to the rubygem "OGem" with my API key And I list the owners of gem "OGem" with my API key @@ -36,13 +36,13 @@ Feature: Manage owners And I should see "new@owner.org" Scenario: Gem owner attempts to add another owner that does not exist - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" When I add the owner "other@owner.org" to the rubygem "OGem" with my API key Then the response should contain "Owner could not be found." Scenario: Gem owner removes an owner - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" And the following ownership exists: | user | rubygem | @@ -53,13 +53,13 @@ Feature: Manage owners And I should not see "new@owner.org" Scenario: Gem owner attempts to remove ownership from a user that is not an owner - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" When I remove the owner "new@owner.org" from the rubygem "OGem" with my API key Then the response should contain "Owner could not be found." Scenario: Gem owner removes himself when he is not the last owner - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" And the following ownership exists: | user | rubygem | @@ -68,13 +68,13 @@ Feature: Manage owners Then the response should contain "Owner removed successfully." Scenario: Gem owner removes himself when he is the last owner - Given I sign in as "original@owner.org/password" + Given I sign in as "original@owner.org" And I have an API key for "original@owner.org/password" When I remove the owner "original@owner.org" from the rubygem "OGem" with my API key Then the response should contain "Unable to remove owner." Scenario Outline: Attempt to manage a gem without the right permission - Given I am signed up and confirmed as "non@owner.org/password" + Given I am signed up as "non@owner.org" And I have an API key for "non@owner.org/password" When I with my API key Then the response should contain "You do not have permission to manage this gem." diff --git a/features/password_reset.feature b/features/password_reset.feature deleted file mode 100644 index 9f3f3674830..00000000000 --- a/features/password_reset.feature +++ /dev/null @@ -1,46 +0,0 @@ -Feature: Password reset - In order to sign in even if user forgot their password - A user - Should be able to reset it - - Scenario: User is not signed up - When I request password reset link to be sent to "email@person.com" - Then I should see "Unknown email" - - Scenario: User is signed up and requests password reset - Given I signed up with "email@person.com/password" - When I request password reset link to be sent to "email@person.com" - Then I should see "instructions for changing your password" - And a password reset message should be sent to "email@person.com" - - Scenario: User is signed up updated his password and types wrong confirmation - Given I signed up with "email@person.com/password" - When I follow the password reset link sent to "email@person.com" - And I update my password with "newpassword/wrongconfirmation" - Then I should see error messages - And I should be signed out - - Scenario: User is signed up and updates his password - Given I signed up with "email@person.com/password" - When I follow the password reset link sent to "email@person.com" - And I update my password with "newpassword/newpassword" - Then I should be signed in - When I sign out - Then I should be signed out - And I sign in as "email@person.com/newpassword" - Then I should be signed in - - Scenario: User is signed up and updates his password without having a handle - Given I signed up with "email@person.com/password" - And my handle is nil - When I go to the password reset request page - And I fill in "Email address" with "email@person.com" - And I press "Reset password" - Then a password reset message should be sent to "email@person.com" - When I follow the password reset link sent to "email@person.com" - And I update my password with "newpassword/newpassword" - Then I should be signed in - When I sign out - Then I should be signed out - And I sign in as "email@person.com/newpassword" - Then I should be signed in diff --git a/features/profile.feature b/features/profile.feature index 728a9d6c5c5..c9c8716e78b 100644 --- a/features/profile.feature +++ b/features/profile.feature @@ -4,7 +4,7 @@ Feature: Profile Feature I want to see a page with all of my gems Background: - Given I have signed in with "jon@example.com/password" + Given I have signed in with "jon@example.com" And the following version exists: | rubygem | number | | name: sandworm | 2.0.0 | @@ -24,7 +24,7 @@ Feature: Profile Feature And I should see "3 today" Scenario: View another user's profile - Given I have signed in with "bob@example.com/password" + Given I have signed in with "bob@example.com" When I go to "jon@example.com" profile page Then I should see "sandworm" diff --git a/features/push.feature b/features/push.feature index 2006875dc3a..758409acfff 100644 --- a/features/push.feature +++ b/features/push.feature @@ -4,7 +4,7 @@ Feature: Push Gems Should be able to push gems up to Gemcutter Scenario: User pushes new gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have a gem "RGem" with version "1.2.3" And I have an API key for "email@person.com/password" When I push the gem "RGem-1.2.3.gem" with my API key @@ -13,7 +13,7 @@ Feature: Push Gems And I should see "1.2.3" Scenario: User pushes existing version of existing gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have a gem "PGem" with version "1.0.0" and summary "First try" And I have an API key for "email@person.com/password" When I push the gem "PGem-1.0.0.gem" with my API key @@ -32,7 +32,7 @@ Feature: Push Gems And I should see "First try" Scenario: User pushes new version of existing gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a gem "BGem" with version "2.0.0" And I push the gem "BGem-2.0.0.gem" with my API key @@ -44,28 +44,28 @@ Feature: Push Gems And I should see "3.0.0" Scenario: User pushes gem with bad url - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a gem "badurl" with version "1.0.0" and homepage "badurl.com" When I push the gem "badurl-1.0.0.gem" with my API key Then I should see "Home does not appear to be a valid URL" Scenario: User pushes gem with bad name - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a bad gem "true" with version "1.0.0" When I push the gem "true-1.0.0.gem" with my API key Then I should see "Name must be a String" Scenario: User pushes gem with bad authors - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a gem "badauthors" with version "1.0.0" and authors "[3]" When I push the gem "badauthors-1.0.0.gem" with my API key Then I should see "Authors must be an Array of Strings" Scenario: User pushes gem with bad runtime dependency - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And I have a gem "baddeps" with version "1.0.0" and runtime dependency "unknown" When I push the gem "baddeps-1.0.0.gem" with my API key @@ -76,7 +76,7 @@ Feature: Push Gems Scenario: User pushes gem with missing :rubygems_version, :specification_version, :name, :version, :date, :summary, :require_paths Scenario: User pushes file that is not a gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" When I push an invalid .gem file Then I should see "RubyGems.org cannot process this gem." diff --git a/features/rf_sign_in.feature b/features/rf_sign_in.feature index 5a8b1d0087f..ad1ef0343c0 100644 --- a/features/rf_sign_in.feature +++ b/features/rf_sign_in.feature @@ -5,17 +5,16 @@ Feature: RubyForge legacy sign in And automatically be given an account Scenario: RubyForge user has never logged on to GemCutter - Given I signed up with "email@person.com/randompw" + Given I signed up with "email@person.com" And I have a RubyForge account with "email@person.com/rfpassword" - And I sign in as "email@person.com/rfpassword" - Then I should see "Signed in" - And I should be signed in + And I sign in as "email@person.com" + Then I should be signed in And my GemCutter password should be "rfpassword" And no RubyForge user exists with an email of "email@person.com" Scenario: RubyForge user logs on with wrong password Given I have a RubyForge account with "email@person.com/rfpassword" When I go to the sign in page - And I sign in as "email@person.com/badpassword" + And I sign in as "email@person.com" Then I should see "Bad email or password" And I should be signed out diff --git a/features/sign_in.feature b/features/sign_in.feature deleted file mode 100644 index 9b5a15192d6..00000000000 --- a/features/sign_in.feature +++ /dev/null @@ -1,43 +0,0 @@ -Feature: Sign in - In order to get access to protected sections of the site - A user - Should be able to sign in - - Scenario: User is not signed up - When I go to the sign in page - And I sign in as "email@person.com/password" - Then I should see "Bad email or password" - And I should be signed out - - Scenario: User is not confirmed - Given I signed up with "email@person.com/password" - When I go to the sign in page - And I sign in as "email@person.com/password" - Then I should see "User has not confirmed email" - And I should be signed out - - Scenario: User enters wrong password - Given I am signed up and confirmed as "email@person.com/password" - When I go to the sign in page - And I sign in as "email@person.com/wrongpassword" - Then I should see "Bad email or password" - And I should be signed out - - Scenario: User signs in successfully with email - Given I am signed up and confirmed as "email@person.com/password" - When I go to the sign in page - And I sign in as "email@person.com/password" - Then I should see "Signed in" - And I should be signed in - When I return next time - Then I should be signed in - - Scenario: User signs in successfully with handle - Given I am signed up and confirmed as "email@person.com/password" - And my handle is "signinnow" - When I go to the sign in page - And I sign in as "signinnow/password" - Then I should see "Signed in" - And I should be signed in - When I return next time - Then I should be signed in diff --git a/features/sign_out.feature b/features/sign_out.feature deleted file mode 100644 index 870f973a2a8..00000000000 --- a/features/sign_out.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Sign out - To protect my account from unauthorized access - A signed in user - Should be able to sign out - - Scenario: User signs out - Given I am signed up and confirmed as "email@person.com/password" - When I sign in as "email@person.com/password" - Then I should be signed in - And I sign out - Then I should see "Signed out" - And I should be signed out - When I return next time - Then I should be signed out diff --git a/features/sign_up.feature b/features/sign_up.feature deleted file mode 100644 index fa88344c6c9..00000000000 --- a/features/sign_up.feature +++ /dev/null @@ -1,63 +0,0 @@ -Feature: Sign up - In order to get access to protected sections of the site - A user - Should be able to sign up - - Scenario: User signs up with invalid email - When I go to the sign up page - And I fill in "Email" with "invalidemail" - And I fill in "Password" with "password" - And I fill in "Confirm password" with "" - And I press "Sign up" - Then I should see error messages - - Scenario: User signs up with no handle - When I go to the sign up page - And I fill in "Email" with "email@person.com" - And I fill in "Password" with "password" - And I fill in "Confirm password" with "" - And I press "Sign up" - Then I should see error messages - - Scenario: User signs up with invalid handle - When I go to the sign up page - And I fill in "Email" with "email@person.com" - And I fill in "Handle" with "thisusernameiswaytoolongseriouslywaytoolong" - And I fill in "Password" with "password" - And I fill in "Confirm password" with "" - And I press "Sign up" - Then I should see error messages - - Scenario: User signs up with valid data - When I go to the sign up page - And I fill in "Email" with "email@person.com" - And I fill in "Handle" with "validhandledude" - And I fill in "Password" with "password" - And I fill in "Confirm password" with "password" - And I press "Sign up" - Then I should see "instructions for confirming" - And a confirmation message should be sent to "email@person.com" - - Scenario: User confirms his account - Given I signed up with "email@person.com/password" - When I follow the confirmation link sent to "email@person.com" - Then I should see "Confirmed email and signed in" - And I should be signed in - - Scenario: Signed in user clicks confirmation link again - Given I signed up with "email@person.com/password" - When I follow the confirmation link sent to "email@person.com" - Then I should be signed in - When I follow the confirmation link sent to "email@person.com" - Then I should see "Confirmed email and signed in" - And I should be signed in - - Scenario: Signed out user clicks confirmation link again - Given I signed up with "email@person.com/password" - When I follow the confirmation link sent to "email@person.com" - Then I should be signed in - When I sign out - And I follow the confirmation link sent to "email@person.com" - Then I should see "Already confirmed email. Please sign in." - And I should be signed out - diff --git a/features/step_definitions/clearance/clearance_steps.rb b/features/step_definitions/clearance/clearance_steps.rb new file mode 100644 index 00000000000..2844998cc56 --- /dev/null +++ b/features/step_definitions/clearance/clearance_steps.rb @@ -0,0 +1,104 @@ +# General + +Then /^I should see error messages$/ do + Then %{I should see "errors prohibited"} +end + +Then /^I should see an error message$/ do + Then %{I should see "error prohibited"} +end + +Then /^I should see an email field$/ do + if page.respond_to?(:should) + page.should have_css?("input[type='email']") + else + assert page.has_css?("input[type='email']") + end +end + +# Database + +Given /^no user exists with an email of "(.*)"$/ do |email| + assert_nil User.find_by_email(email) +end + +Given /^(?:I am|I have|I) signed up (?:as|with) "(.*)"$/ do |email| + @me = Factory(:user, :email => email) +end + +Given /^a user "([^"]*)" exists without a salt, remember token, or password$/ do |email| + @me = user = Factory(:user, :email => email) + sql = "update users set salt = NULL, encrypted_password = NULL, remember_token = NULL where id = #{user.id}" + ActiveRecord::Base.connection.update(sql) +end + +# Session + +Then /^I should be signed in$/ do + Then %{I should see "sign out"} +end + +Then /^I should be signed out$/ do + Then %{I should see "sign in"} +end + +Given /^(?:I am|I have|I) signed in (?:with|as) "(.*)"$/ do |email| + Given %{I am signed up as "#{email}"} + And %{I sign in as "#{email}"} +end + +Given /^I sign in$/ do + email = Factory.next(:email) + Given %{I have signed in with "#{email}"} +end + +# Emails + +Then /^a password reset message should be sent to "(.*)"$/ do |email| + user = User.find_by_email(email) + assert !user.confirmation_token.blank? + assert !ActionMailer::Base.deliveries.empty? + result = ActionMailer::Base.deliveries.any? do |email| + email.to == [user.email] && + email.subject =~ /password/i && + email.body =~ /#{user.confirmation_token}/ + end + assert result +end + +When /^I follow the password reset link sent to "(.*)"$/ do |email| + user = User.find_by_email(email) + visit edit_user_password_path(:user_id => user, + :token => user.confirmation_token) +end + +When /^I try to change the password of "(.*)" without token$/ do |email| + user = User.find_by_email(email) + visit edit_user_password_path(:user_id => user) +end + +# Actions +When /^I sign in (?:with|as) "(.*)"$/ do |email| + When %{I go to the sign in page} + And %{I fill in "Email" with "#{email}"} + And %{I fill in "Password" with "password"} + And %{I press "Sign in"} +end + +When "I sign out" do + steps %{ + When I go to the homepage + And I follow "sign out" + } +end + +When /^I request password reset link to be sent to "(.*)"$/ do |email| + When %{I go to the password reset request page} + And %{I fill in "Email address" with "#{email}"} + And %{I press "Reset password"} +end + +When /^I update my password with "(.*)"$/ do |password| + And %{I fill in "Password" with "#{password}"} + And %{I press "Save this password"} +end diff --git a/features/step_definitions/clearance_steps.rb b/features/step_definitions/clearance_steps.rb deleted file mode 100644 index bacb47c9846..00000000000 --- a/features/step_definitions/clearance_steps.rb +++ /dev/null @@ -1,115 +0,0 @@ -# General - -Then /^I should see error messages$/ do - assert_match /error(s)? prohibited/m, page.body -end - -# Database - -Given /^I signed up with "(.*)\/(.*)"$/ do |email, password| - @me = user = Factory(:user, - :email => email, - :password => password, - :password_confirmation => password) -end - -Given /^I am signed up and confirmed as "(.*)\/(.*)"$/ do |email, password| - @me = user = Factory(:email_confirmed_user, - :email => email, - :password => password, - :password_confirmation => password) -end - -Given /^my handle is "([^\"]*)"$/ do |handle| - @me.update_attribute :handle, handle -end - -Given /^my handle is nil$/ do - @me.update_attribute :handle, nil -end - -# Session - -Then /^I should be signed in$/ do - Then %{I should see "sign out"} -end - -Then /^I should be signed out$/ do - Then %{I should see "sign in"} -end - -Given /^I have signed in with "(.*)\/(.*)"$/ do |email, password| - Given %{I am signed up and confirmed as "#{email}/#{password}"} - And %{I sign in as "#{email}/#{password}"} -end - -# Emails - -Then /^a confirmation message should be sent to "(.*)"$/ do |email| - user = User.find_by_email(email) - sent = ActionMailer::Base.deliveries.last - assert_equal [user.email], sent.to - assert_match /confirm/i, sent.subject - assert !user.confirmation_token.blank? - assert_match /#{user.confirmation_token}/, sent.body.to_s -end - -When /^I follow the confirmation link sent to "(.*)"$/ do |email| - user = User.find_by_email(email) - visit new_user_confirmation_path(:user_id => user, - :token => user.confirmation_token) -end - -Then /^a password reset message should be sent to "(.*)"$/ do |email| - user = User.find_by_email(email) - sent = ActionMailer::Base.deliveries.last - assert_equal [user.email], sent.to - assert_match /password/i, sent.subject - assert !user.confirmation_token.blank? - assert_match /#{user.confirmation_token}/, sent.body.to_s -end - -When /^I follow the password reset link sent to "(.*)"$/ do |email| - user = User.find_by_email(email) - visit edit_user_password_path(:user_id => user, - :token => user.confirmation_token) -end - -When /^I try to change the password of "(.*)" without token$/ do |email| - user = User.find_by_email(email) - visit edit_user_password_path(:user_id => user) -end - -Then /^I should be forbidden$/ do - assert_response :forbidden -end - -# Actions - -When /^I sign in as "(.*)\/(.*)"$/ do |email, password| - When %{I go to the sign in page} - And %{I fill in "Email" with "#{email}"} - And %{I fill in "Password" with "#{password}"} - And %{I press "Sign in"} -end - -When /^I sign out$/ do - When %{I follow "sign out"} -end - -When /^I request password reset link to be sent to "(.*)"$/ do |email| - When %{I go to the password reset request page} - And %{I fill in "Email address" with "#{email}"} - And %{I press "Reset password"} -end - -When /^I update my password with "(.*)\/(.*)"$/ do |password, confirmation| - And %{I fill in "Password" with "#{password}"} - And %{I fill in "Confirm password" with "#{confirmation}"} - And %{I press "Save this password"} -end - -When /^I return next time$/ do - reset! - And %{I go to the homepage} -end diff --git a/features/step_definitions/email_change_steps.rb b/features/step_definitions/email_change_steps.rb new file mode 100644 index 00000000000..a36251e3e57 --- /dev/null +++ b/features/step_definitions/email_change_steps.rb @@ -0,0 +1,5 @@ +Given /^I have changed my email address to "([^\"]*)"$/ do |email| + Given %{I am on my edit profile page} + When %{I fill in "Email address" with "#{email}"} + And %{I press "Update"} +end diff --git a/features/step_definitions/email_reset_steps.rb b/features/step_definitions/email_reset_steps.rb deleted file mode 100644 index edda56395d5..00000000000 --- a/features/step_definitions/email_reset_steps.rb +++ /dev/null @@ -1,11 +0,0 @@ -Then /^an email entitled "([^\"]*)" should be sent to "([^\"]*)"$/ do |subject, email| - sent = ActionMailer::Base.deliveries.last - assert_equal [email], sent.to - assert_match subject, sent.subject -end - -Given /^I have reset my email address to "([^\"]*)"$/ do |email| - Given %{I am on my edit profile page} - When %{I fill in "Email address" with "#{email}"} - And %{I press "Update"} -end diff --git a/features/step_definitions/handle_steps.rb b/features/step_definitions/handle_steps.rb new file mode 100644 index 00000000000..f40d9bee708 --- /dev/null +++ b/features/step_definitions/handle_steps.rb @@ -0,0 +1,14 @@ +Given /^my handle is "([^\"]*)"$/ do |handle| + @me.update_attribute :handle, handle +end + +Given /^my handle is nil$/ do + @me.update_attribute :handle, nil +end + +When /^I sign in (?:with|as) "(.*)" with "(.*)"$/ do |email, password| + When %{I go to the sign in page} + And %{I fill in "Email" with "#{email}"} + And %{I fill in "Password" with "#{password}"} + And %{I press "Sign in"} +end diff --git a/features/support/paths.rb b/features/support/paths.rb index 2338d97e454..d0cbc6f3072 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -9,6 +9,8 @@ def path_to(page_name) case page_name when /the homepage/ root_path + when /the home page/ + root_path when /the sign up page/ new_user_path when /the sign in page/ @@ -23,6 +25,12 @@ def path_to(page_name) profile_path(User.find_by_email!($1)) # Add more mappings here. + when /the sign up page/i + sign_up_path + when /the sign in page/i + sign_in_path + when /the password reset request page/i + new_password_path # Here is an example that pulls values out of the Regexp: # # when /^(.*)'s profile page$/i diff --git a/features/webhooks.feature b/features/webhooks.feature index df3896f281d..cc63d04cd0d 100644 --- a/features/webhooks.feature +++ b/features/webhooks.feature @@ -4,7 +4,7 @@ Feature: Web Hooks Should be able to configure web hooks to be hit when a gem is pushed Background: - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" Scenario: User pushes new gem with webhook Given I have a gem "fiddler" with version "1.0.0" diff --git a/features/yank.feature b/features/yank.feature index 16355909e82..76fd7b8857d 100644 --- a/features/yank.feature +++ b/features/yank.feature @@ -4,7 +4,7 @@ Feature: Delete Gems I want to delete gems from Gemcutter Scenario: User yanks a gem - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And the following ownership exists: | rubygem | user | @@ -22,7 +22,7 @@ Feature: Delete Gems Then I should see the version "1.2.2" featured Scenario: User yanks the last version of a gem and a new gem is pushed on that namespace - Given I am signed up and confirmed as "email@person.com/password" + Given I am signed up as "email@person.com" And I have an API key for "email@person.com/password" And the following ownership exists: | rubygem | user | @@ -35,7 +35,7 @@ Feature: Delete Gems And I follow "RGem" Then I should see "This gem has been yanked" - Given I am signed up and confirmed as "new@owner.com/password" + Given I am signed up as "new@owner.com" And I have a gem "RGem" with version "0.1.0" And I have an API key for "new@owner.com/password" When I push the gem "RGem-0.1.0.gem" with my API key @@ -47,7 +47,7 @@ Feature: Delete Gems And I should not see "old@owner.com" Scenario: User who is not owner attempts to yank a gem - Given I am signed up and confirmed as "non@owner.org/password" + Given I am signed up as "non@owner.org" And I have an API key for "non@owner.org/password" And the following version exists: | rubygem | number | indexed | @@ -59,7 +59,7 @@ Feature: Delete Gems Then I should see "You do not have permission to yank this gem." Scenario: User attempts to yank a nonexistent version of a gem - Given I am signed up and confirmed as "the@owner.com/password" + Given I am signed up as "the@owner.com" And I have an API key for "the@owner.com/password" And the following ownership exists: | rubygem | user | @@ -71,7 +71,7 @@ Feature: Delete Gems Then I should see "The version 1.2.4 does not exist." Scenario: User attempts to yank a gem that has already been yanked - Given I am signed up and confirmed as "the@owner.com/password" + Given I am signed up as "the@owner.com" And I have an API key for "the@owner.com/password" And the following ownership exists: | rubygem | user | @@ -83,7 +83,7 @@ Feature: Delete Gems Then I should see "The version 1.2.3 has already been yanked" Scenario: User unyanks a gem - Given I am signed up and confirmed as "the@owner.com/password" + Given I am signed up as "the@owner.com" And I have an API key for "the@owner.com/password" And the following ownership exists: | rubygem | user | diff --git a/test/factories/clearance.rb b/test/factories/clearance.rb index 763ce09fd29..b59f302b8ad 100644 --- a/test/factories/clearance.rb +++ b/test/factories/clearance.rb @@ -10,11 +10,6 @@ factory :user do email handle - password "password" - password_confirmation "password" - end - - factory :email_confirmed_user, :parent => :user do - email_confirmed true + password "password" end end diff --git a/test/functional/api/v1/api_keys_controller_test.rb b/test/functional/api/v1/api_keys_controller_test.rb index cb564c8bf4f..68660684450 100644 --- a/test/functional/api/v1/api_keys_controller_test.rb +++ b/test/functional/api/v1/api_keys_controller_test.rb @@ -26,18 +26,6 @@ def authorize_with(str) @request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64(str) end - context "on GET to show with unconfirmed user" do - setup do - @user = Factory(:user) - authorize_with("#{@user.email}:#{@user.password}") - get :show - end - should "deny access" do - assert_response 401 - assert_match "HTTP Basic: Access denied.", @response.body - end - end - context "on GET to show with bad credentials" do setup do @user = Factory(:user) @@ -53,7 +41,7 @@ def authorize_with(str) # this endpoint is used by rubygems context "on GET to show with TEXT and with confirmed user" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) authorize_with("#{@user.email}:#{@user.password}") get :show, :format => 'text' end @@ -66,7 +54,7 @@ def authorize_with(str) def self.should_respond_to(format, to_meth = :to_s) context "with #{format.to_s.upcase} and with confirmed user" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) authorize_with("#{@user.email}:#{@user.password}") get :show, :format => format end @@ -96,7 +84,7 @@ def self.should_respond_to(format, to_meth = :to_s) context "on PUT to reset with signed in user" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end should "reset the user's api key" do diff --git a/test/functional/api/v1/owners_controller_test.rb b/test/functional/api/v1/owners_controller_test.rb index a4909dfad3a..4cb57f6ca56 100644 --- a/test/functional/api/v1/owners_controller_test.rb +++ b/test/functional/api/v1/owners_controller_test.rb @@ -13,7 +13,7 @@ def self.should_respond_to(format) context "on GET to show with #{format.to_s.upcase}" do setup do @rubygem = Factory(:rubygem) - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @rubygem.ownerships.create(:user => @user, :approved => true) @request.env["HTTP_AUTHORIZATION"] = @user.api_key diff --git a/test/functional/api/v1/rubygems_controller_test.rb b/test/functional/api/v1/rubygems_controller_test.rb index 158d712ee28..93f1c8e9c53 100644 --- a/test/functional/api/v1/rubygems_controller_test.rb +++ b/test/functional/api/v1/rubygems_controller_test.rb @@ -53,7 +53,7 @@ def self.should_respond_to(format, &block) context "When logged in" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end @@ -108,7 +108,7 @@ def self.should_respond_to(format) Factory(:ownership, :user => @user, :rubygem => rubygem, :approved => true) end - @other_user = Factory(:email_confirmed_user) + @other_user = Factory(:user) @not_my_rubygem = Factory(:rubygem, :name => "NotMyGem") Factory(:version, :rubygem => @not_my_rubygem) Factory(:ownership, :user => @other_user, :rubygem => @not_my_rubygem, :approved => true) @@ -130,7 +130,7 @@ def self.should_respond_to(format) context "with a confirmed user authenticated" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @request.env["HTTP_AUTHORIZATION"] = @user.api_key end @@ -231,7 +231,7 @@ def self.should_respond_to(format) context "On POST to create for someone else's gem" do setup do - @other_user = Factory(:email_confirmed_user) + @other_user = Factory(:user) create_gem(@other_user, :name => "test") @rubygem.reload @@ -319,7 +319,7 @@ def self.should_respond_to(format) context "ON DELETE to yank for someone else's gem" do setup do - @other_user = Factory(:email_confirmed_user) + @other_user = Factory(:user) @request.env["HTTP_AUTHORIZATION"] = @other_user.api_key delete :yank, :gem_name => @rubygem.to_param, :version => '0.1.0' end diff --git a/test/functional/api/v1/web_hooks_controller_test.rb b/test/functional/api/v1/web_hooks_controller_test.rb index 206cc7b81b8..0622ca07329 100644 --- a/test/functional/api/v1/web_hooks_controller_test.rb +++ b/test/functional/api/v1/web_hooks_controller_test.rb @@ -51,7 +51,7 @@ def self.should_respond_to(format) context "When logged in" do setup do @url = "http://example.org" - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @request.env["Authorization"] = @user.api_key end @@ -183,7 +183,7 @@ def self.should_respond_to(format) context "with some unowned hooks" do setup do - @other_user = Factory(:email_confirmed_user) + @other_user = Factory(:user) @rubygem_hook = Factory(:web_hook, :user => @other_user, :rubygem => @rubygem) diff --git a/test/functional/dashboards_controller_test.rb b/test/functional/dashboards_controller_test.rb index 8fb95f8fa19..5efe9c7ced8 100644 --- a/test/functional/dashboards_controller_test.rb +++ b/test/functional/dashboards_controller_test.rb @@ -3,7 +3,7 @@ class DashboardsControllerTest < ActionController::TestCase context "When logged in" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end diff --git a/test/functional/profiles_controller_test.rb b/test/functional/profiles_controller_test.rb index 43bae1fd29a..db3366d7f5d 100644 --- a/test/functional/profiles_controller_test.rb +++ b/test/functional/profiles_controller_test.rb @@ -12,7 +12,7 @@ class ProfilesControllerTest < ActionController::TestCase context "when logged in" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end @@ -67,7 +67,7 @@ class ProfilesControllerTest < ActionController::TestCase context "updating handle" do setup do @handle = "john_m_doe" - @user = Factory(:email_confirmed_user, :handle => "johndoe") + @user = Factory(:user, :handle => "johndoe") sign_in_as(@user) put :update, :user => {:handle => @handle} end diff --git a/test/functional/rubygems_controller_test.rb b/test/functional/rubygems_controller_test.rb index 380ad5f91f9..05eb4a84622 100644 --- a/test/functional/rubygems_controller_test.rb +++ b/test/functional/rubygems_controller_test.rb @@ -3,13 +3,13 @@ class RubygemsControllerTest < ActionController::TestCase context "When logged in" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end context "On GET to show for any gem" do setup do - @owners = [@user, Factory(:email_confirmed_user)] + @owners = [@user, Factory(:user)] create_gem(*@owners) get :show, :id => @rubygem.to_param end @@ -26,7 +26,7 @@ class RubygemsControllerTest < ActionController::TestCase context "On GET to show for any gem without a linkset" do setup do - @owners = [@user, Factory(:email_confirmed_user)] + @owners = [@user, Factory(:user)] create_gem(*@owners) @rubygem.linkset = nil get :show, :id => @rubygem.to_param @@ -123,7 +123,7 @@ class RubygemsControllerTest < ActionController::TestCase context "On GET to edit for another user's gem" do setup do - @other_user = Factory(:email_confirmed_user) + @other_user = Factory(:user) create_gem(@other_user) get :edit, :id => @rubygem.to_param end diff --git a/test/functional/subscriptions_controller_test.rb b/test/functional/subscriptions_controller_test.rb index 58053fb3938..130a245dc4a 100644 --- a/test/functional/subscriptions_controller_test.rb +++ b/test/functional/subscriptions_controller_test.rb @@ -3,7 +3,7 @@ class SubscriptionsControllerTest < ActionController::TestCase context "When logged in" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) sign_in_as(@user) end end diff --git a/test/test_helper.rb b/test/test_helper.rb index e051a682718..8e2ec4150ef 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,7 @@ ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' -require 'clearance/shoulda_macros' +require 'clearance/testing' require 'capybara/rails' class ActiveSupport::TestCase diff --git a/test/unit/helpers/rubygems_helper_test.rb b/test/unit/helpers/rubygems_helper_test.rb index 96259af191d..24add59ed73 100644 --- a/test/unit/helpers/rubygems_helper_test.rb +++ b/test/unit/helpers/rubygems_helper_test.rb @@ -85,7 +85,7 @@ class RubygemsHelperTest < ActionView::TestCase end should "create links to owners gem overviews" do - users = Array.new(2) { Factory(:email_confirmed_user) } + users = Array.new(2) { Factory(:user) } create_gem(*users) expected_links = users.sort_by(&:id).map { |u| link_to gravatar(48, "gravatar-#{u.id}", u), profile_path(u.display_id), :alt => u.display_handle, diff --git a/test/unit/pusher_test.rb b/test/unit/pusher_test.rb index aa09c3f9e8b..5acd00a0c57 100644 --- a/test/unit/pusher_test.rb +++ b/test/unit/pusher_test.rb @@ -17,7 +17,7 @@ class PusherTest < ActiveSupport::TestCase context "creating a new gemcutter" do setup do - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @gem = gem_file @cutter = Pusher.new(@user, @gem) end diff --git a/test/unit/rubyforger_test.rb b/test/unit/rubyforger_test.rb index f6c77440ce7..93549f35e7d 100644 --- a/test/unit/rubyforger_test.rb +++ b/test/unit/rubyforger_test.rb @@ -31,7 +31,7 @@ class RubyforgerTest < ActiveSupport::TestCase end should "fail transfer when password is wrong" do - Factory(:email_confirmed_user, :email => @email) + Factory(:user, :email => @email) assert_nil Rubyforger.transfer(@email, "trogdor") assert Rubyforger.exists?(@rubyforger.id) diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 81f3cce8416..4bf95e306d7 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -140,26 +140,6 @@ class UserTest < ActiveSupport::TestCase assert_equal [my_rubygem], @user.rubygems end - context "with a confirmed email address" do - setup do - @user = Factory(:email_confirmed_user, :confirmation_token => nil) - @user.email = "changed@example.com" - @user.save - end - - should "generate a new confirmation token when the email gets changed" do - assert @user.reload.email_reset - end - - should "reset token, confirmation, and reset when confirming email" do - @user.confirm_email! - - assert @user.reload.email_confirmed - assert_nil @user.reload.confirmation_token - assert_nil @user.reload.email_reset - end - end - context "with subscribed gems" do setup do @subscribed_gem = Factory(:rubygem) diff --git a/test/unit/web_hook_test.rb b/test/unit/web_hook_test.rb index 0290e07c88d..f94f8cde031 100644 --- a/test/unit/web_hook_test.rb +++ b/test/unit/web_hook_test.rb @@ -34,7 +34,7 @@ class WebHookTest < ActiveSupport::TestCase context "with a global webhook for a gem" do setup do @url = "http://example.org" - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @webhook = Factory(:global_web_hook, :user => @user, :url => @url) end @@ -62,7 +62,7 @@ class WebHookTest < ActiveSupport::TestCase context "with a webhook for a gem" do setup do @url = "http://example.org" - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @rubygem = Factory(:rubygem) @webhook = Factory(:web_hook, :user => @user, :rubygem => @rubygem, @@ -195,7 +195,7 @@ class WebHookTest < ActiveSupport::TestCase context "with invalid URL" do setup do @url = 'http://someinvaliddomain.com' - @user = Factory(:email_confirmed_user) + @user = Factory(:user) @rubygem = Factory(:rubygem) @version = Factory(:version, :rubygem => @rubygem) @hook = Factory(:global_web_hook, :url => @url, diff --git a/vendor/cache/clearance-0.12.0.gem b/vendor/cache/clearance-0.12.0.gem new file mode 100644 index 00000000000..5202909ba7b Binary files /dev/null and b/vendor/cache/clearance-0.12.0.gem differ diff --git a/vendor/cache/clearance-0.9.1.gem b/vendor/cache/clearance-0.9.1.gem deleted file mode 100644 index 9f6024cf7a1..00000000000 Binary files a/vendor/cache/clearance-0.9.1.gem and /dev/null differ diff --git a/vendor/cache/diesel-0.1.5.gem b/vendor/cache/diesel-0.1.5.gem new file mode 100644 index 00000000000..97ccfbb6d15 Binary files /dev/null and b/vendor/cache/diesel-0.1.5.gem differ diff --git a/vendor/cache/guard-0.7.0.gem b/vendor/cache/guard-0.7.0.gem new file mode 100644 index 00000000000..d079d07ec8c Binary files /dev/null and b/vendor/cache/guard-0.7.0.gem differ diff --git a/vendor/cache/guard-bundler-0.1.3.gem b/vendor/cache/guard-bundler-0.1.3.gem new file mode 100644 index 00000000000..cd7357f8914 Binary files /dev/null and b/vendor/cache/guard-bundler-0.1.3.gem differ diff --git a/vendor/cache/guard-cucumber-0.6.3.gem b/vendor/cache/guard-cucumber-0.6.3.gem new file mode 100644 index 00000000000..0948dd42520 Binary files /dev/null and b/vendor/cache/guard-cucumber-0.6.3.gem differ