Commit f0214e00 authored by Michel Felipe de Oliveira Ferreira's avatar Michel Felipe de Oliveira Ferreira
Browse files

Changed exception class name and message to a better legibility

parent 0623ae19
......@@ -48,7 +48,7 @@ class AccountController < ApplicationController
begin
self.current_user ||= User.authenticate(params[:user][:login], params[:user][:password], environment) if params[:user]
rescue NoosferoExceptions::UserInactive => e
rescue NoosferoExceptions::UserNotActivated => e
session[:notice] = e.message
return
end
......
......@@ -245,8 +245,8 @@ class User < ActiveRecord::Base
def authenticated?(password)
unless self.activated?
message = _('The user "%{login}" is not active!') % {login: self.login}
raise NoosferoExceptions::UserInactive.new(message, self)
message = _('The user "%{login}" is not activated! Please check your email to activate your user') % {login: self.login}
raise NoosferoExceptions::UserNotActivated.new(message, self)
end
result = (crypted_password == encrypt(password))
......@@ -293,7 +293,7 @@ class User < ActiveRecord::Base
self.errors.add(:current_password, _('does not match.'))
raise IncorrectPassword
end
rescue NoosferoExceptions::UserInactive => e
rescue NoosferoExceptions::UserNotActivated => e
self.errors.add(:current_password, e.message)
raise IncorrectPassword
end
......@@ -413,7 +413,7 @@ class User < ActiveRecord::Base
end
module NoosferoExceptions
class UserInactive < ActiveRecord::ActiveRecordError
class UserNotActivated < ActiveRecord::ActiveRecordError
attr_reader :user
def initialize(message, user = nil)
......
......@@ -44,7 +44,7 @@ class AccountControllerTest < ActionController::TestCase
user = User.create!(login: 'testuser', email: 'test@email.com', password:'test', password_confirmation:'test', activation_code: nil)
post :login, :user => { :login => 'testuser', :password => 'test' }
assert_match 'not active', session[:notice]
assert_match 'not activated', session[:notice]
assert_nil session[:user]
end
......@@ -759,7 +759,7 @@ class AccountControllerTest < ActionController::TestCase
assert_nil assigns(:message)
post :login, :user => {:login => 'testuser', :password => 'test123'}
assert_match 'not active', session[:notice]
assert_match 'not activated', session[:notice]
assert_nil session[:user]
end
......@@ -770,7 +770,7 @@ class AccountControllerTest < ActionController::TestCase
assert_nil assigns(:message)
post :login, :user => {:login => 'testuser', :password => 'test123'}
assert_match 'not active', session[:notice]
assert_match 'not activated', session[:notice]
assert_nil session[:user]
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment