Commit f0214e00bcb5c95e7b45ded76bd52c5987aab4bf
1 parent
0623ae19
Exists in
master
and in
6 other branches
Changed exception class name and message to a better legibility
Showing
3 changed files
with
8 additions
and
8 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -48,7 +48,7 @@ class AccountController < ApplicationController |
48 | 48 | |
49 | 49 | begin |
50 | 50 | self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user] |
51 | - rescue NoosferoExceptions::UserInactive => e | |
51 | + rescue NoosferoExceptions::UserNotActivated => e | |
52 | 52 | session[:notice] = e.message |
53 | 53 | return |
54 | 54 | end | ... | ... |
app/models/user.rb
... | ... | @@ -245,8 +245,8 @@ class User < ActiveRecord::Base |
245 | 245 | def authenticated?(password) |
246 | 246 | |
247 | 247 | unless self.activated? |
248 | - message = _('The user "%{login}" is not active!') % {login: self.login} | |
249 | - raise NoosferoExceptions::UserInactive.new(message, self) | |
248 | + message = _('The user "%{login}" is not activated! Please check your email to activate your user') % {login: self.login} | |
249 | + raise NoosferoExceptions::UserNotActivated.new(message, self) | |
250 | 250 | end |
251 | 251 | |
252 | 252 | result = (crypted_password == encrypt(password)) |
... | ... | @@ -293,7 +293,7 @@ class User < ActiveRecord::Base |
293 | 293 | self.errors.add(:current_password, _('does not match.')) |
294 | 294 | raise IncorrectPassword |
295 | 295 | end |
296 | - rescue NoosferoExceptions::UserInactive => e | |
296 | + rescue NoosferoExceptions::UserNotActivated => e | |
297 | 297 | self.errors.add(:current_password, e.message) |
298 | 298 | raise IncorrectPassword |
299 | 299 | end |
... | ... | @@ -413,7 +413,7 @@ class User < ActiveRecord::Base |
413 | 413 | end |
414 | 414 | |
415 | 415 | module NoosferoExceptions |
416 | - class UserInactive < ActiveRecord::ActiveRecordError | |
416 | + class UserNotActivated < ActiveRecord::ActiveRecordError | |
417 | 417 | attr_reader :user |
418 | 418 | |
419 | 419 | def initialize(message, user = nil) | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -44,7 +44,7 @@ class AccountControllerTest < ActionController::TestCase |
44 | 44 | user = User.create!(login: 'testuser', email: 'test@email.com', password:'test', password_confirmation:'test', activation_code: nil) |
45 | 45 | post :login, :user => { :login => 'testuser', :password => 'test' } |
46 | 46 | |
47 | - assert_match 'not active', session[:notice] | |
47 | + assert_match 'not activated', session[:notice] | |
48 | 48 | assert_nil session[:user] |
49 | 49 | end |
50 | 50 | |
... | ... | @@ -759,7 +759,7 @@ class AccountControllerTest < ActionController::TestCase |
759 | 759 | assert_nil assigns(:message) |
760 | 760 | post :login, :user => {:login => 'testuser', :password => 'test123'} |
761 | 761 | |
762 | - assert_match 'not active', session[:notice] | |
762 | + assert_match 'not activated', session[:notice] | |
763 | 763 | assert_nil session[:user] |
764 | 764 | end |
765 | 765 | |
... | ... | @@ -770,7 +770,7 @@ class AccountControllerTest < ActionController::TestCase |
770 | 770 | assert_nil assigns(:message) |
771 | 771 | post :login, :user => {:login => 'testuser', :password => 'test123'} |
772 | 772 | |
773 | - assert_match 'not active', session[:notice] | |
773 | + assert_match 'not activated', session[:notice] | |
774 | 774 | assert_nil session[:user] |
775 | 775 | end |
776 | 776 | ... | ... |