public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
fix site_admin? error

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2489 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Nov 22 07:54:10 -0800 2006
commit  074a752d003e8b6cf3282b2a4186f7a913d358f4
tree    e6425938bd771bec2dbb51d5b7e5aee178530df4
parent  1e21424dd8c10a3f3fccda6134bc3166463d5acd
...
77
78
79
 
 
 
 
 
80
81
82
...
77
78
79
80
81
82
83
84
85
86
87
0
@@ -77,6 +77,11 @@ class User < ActiveRecord::Base
0
     token_expires_at && Time.now.utc < token_expires_at
0
   end
0
 
0
+ # The site admin property is brought in from memberships.admin, when joined with the sites table.
0
+ def site_admin?
0
+ ActiveRecord::ConnectionAdapters::Column.value_to_boolean read_attribute(:site_admin)
0
+ end
0
+
0
   def reset_token!
0
     returning self.token = rand_key do |t|
0
       self.token_expires_at = 2.weeks.from_now.utc
...
112
113
114
 
 
 
 
 
 
 
 
 
 
 
 
 
115
116
117
...
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
0
@@ -112,6 +112,19 @@ class UserTest < Test::Unit::TestCase
0
     assert_models_equal [users(:quentin)], User.find_admins(:all)
0
   end
0
 
0
+ def test_should_interpret_site_admin
0
+ @user = User.new
0
+ [1, '1', 't', true].each do |value|
0
+ @user.instance_variable_get(:@attributes)['site_admin'] = value
0
+ assert @user.site_admin?, "#{value.inspect} was false"
0
+ end
0
+
0
+ [0, '0', 'f', false, nil].each do |value|
0
+ @user.instance_variable_get(:@attributes)['site_admin'] = value
0
+ assert !@user.site_admin?, "#{value.inspect} was true"
0
+ end
0
+ end
0
+
0
   protected
0
     def create_user(options = {})
0
       User.create({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options))

Comments

    No one has commented yet.