Commit 5de97f16
Changed files (4)
app
controllers
models
config
locales
spec
features
app/controllers/passwords_controller.rb
@@ -9,7 +9,7 @@ class PasswordsController < ApplicationController
user = current_user
if user.change_password(params[:user][:password], params[:user][:password_confirmation])
sign_in(user, :bypass => true) unless Rails.env.test?
- flash[:notice] = "Your password has been updated successfully!"
+ flash[:notice] = t('passwords.updated')
render :index
else
flash[:error] = t(:passwords_do_not_match)
app/models/user.rb
@@ -15,7 +15,7 @@ class User < ActiveRecord::Base
has_many :favorites, :dependent => :destroy
has_many :tutorials, :dependent => :destroy
#has_and_belongs_to_many :interests, :join_table => 'users_interests', uniq: true, :autosave => true
- has_and_belongs_to_many :interests, -> { where unique: true }, :join_table => 'users_interests', :autosave => true
+ has_and_belongs_to_many :interests, :join_table => 'users_interests', :autosave => true
has_one :avatar
acts_as_tagger
before_save :ensure_authentication_token
config/locales/en.yml
@@ -24,3 +24,5 @@ en:
share_something: "You have not uploaded anything!"
passwords_do_not_match: 'The passwords should match and should be a minimum of 6 characters.'
tutorial_saved: 'Your tutorial was added.'
+ passwords:
+ updated: 'Your password was updated.'
spec/features/change_password_spec.rb
@@ -0,0 +1,28 @@
+require "spec_helper"
+
+describe "changing my password", :js => true do
+ context "when changing my password" do
+ let(:user) { create(:user, :password => "password") }
+
+ before :each do
+ visit user_session_path
+ within('.form-inline') do
+ fill_in('user_email', :with => user.email)
+ fill_in('user_password', :with => "password")
+ end
+ click_button("Sign In")
+ click_link(user.name)
+ click_link("Settings")
+ click_link("Password")
+ within(".form-horizontal") do
+ fill_in('user_password', :with => "mopass")
+ fill_in('user_password_confirmation', :with => "mopass")
+ end
+ click_button "Change password"
+ end
+
+ it "should display a confirmation message" do
+ page.should have_content(I18n.translate('passwords.updated'))
+ end
+ end
+end