Skip to content

Commit

Permalink
[api] Cleanup in User.states
Browse files Browse the repository at this point in the history
- default_states were unused (replaced by states)
- default_states were conflicting with states (5, 6)
  • Loading branch information
kobliha authored and coolo committed Nov 1, 2012
1 parent 21f5fae commit c85ae65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
40 changes: 11 additions & 29 deletions src/api/app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ class User < ActiveRecord::Base
# git commit 107d7a612. Thus we have to explicitly list the allowed attributes:
attr_accessible :login, :email, :realname, :password, :password_confirmation, :state

# This method returns a hash with the the available user states.
# By default it returns the private class constant DEFAULT_STATES.
def self.states
default_states
end

# This method returns an array with the names of all available
# password hash types supported by this User class.
def self.password_hash_types
Expand Down Expand Up @@ -888,16 +882,18 @@ def state_transition_allowed?(from, to)
false
end
end


STATES = {
'unconfirmed' => 1,
'confirmed' => 2,
'locked' => 3,
'deleted' => 4,
'ichainrequest' => 5,
'retrieved_password' => 6,
}

def self.states
{
'unconfirmed' => 1,
'confirmed' => 2,
'locked' => 3,
'deleted' => 4,
'ichainrequest' => 5,
'retrieved_password' => 6
}
STATES
end

# updates users email address and real name using data transmitted by authentification proxy
Expand Down Expand Up @@ -1298,20 +1294,6 @@ def self.execute_without_timestamps
end

private
# This method returns a hash which contains a mapping of user states
# valid by default and their description.
def self.default_states
{
'unconfirmed' => 1,
'confirmed' => 2,
'locked' => 3,
'deleted' => 4,
# The user has just retrieved his password and he must now
# it. The user cannot anything in this state but change his
# password after having logged in and retrieve another one.
'retrieved_password' => 5
}
end

# This method returns an array which contains all valid hash types.
def self.default_password_hash_types
Expand Down
5 changes: 4 additions & 1 deletion src/api/test/unit/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@ def test_ldap

CONFIG['ldap_mode'], CONFIG['ldap_group_support'] = ldm, lgs
end
end

def test_states
assert_not_nil User.states
end
end

0 comments on commit c85ae65

Please sign in to comment.