Commit 55ed4cb56e07bdfcb6bc23fcb953e3510aff57a6
1 parent
6548e2f2
Exists in
master
and in
28 other branches
ActionItem980: making it easier to find users
In the console, specially
Showing
2 changed files
with
8 additions
and
0 deletions
Show diff stats
app/models/user.rb
@@ -8,6 +8,10 @@ class User < ActiveRecord::Base | @@ -8,6 +8,10 @@ class User < ActiveRecord::Base | ||
8 | N_('Password confirmation') | 8 | N_('Password confirmation') |
9 | N_('Terms accepted') | 9 | N_('Terms accepted') |
10 | 10 | ||
11 | + def self.[](login) | ||
12 | + self.find_by_login(login) | ||
13 | + end | ||
14 | + | ||
11 | # FIXME ugly workaround | 15 | # FIXME ugly workaround |
12 | def self.human_attribute_name(attrib) | 16 | def self.human_attribute_name(attrib) |
13 | case attrib.to_sym | 17 | case attrib.to_sym |
test/unit/user_test.rb
@@ -283,6 +283,10 @@ class UserTest < Test::Unit::TestCase | @@ -283,6 +283,10 @@ class UserTest < Test::Unit::TestCase | ||
283 | assert !user.email_activation_pending? | 283 | assert !user.email_activation_pending? |
284 | end | 284 | end |
285 | 285 | ||
286 | + should 'be able to use [] operator to find users by login' do | ||
287 | + assert_equal users(:ze), User['ze'] | ||
288 | + end | ||
289 | + | ||
286 | protected | 290 | protected |
287 | def new_user(options = {}) | 291 | def new_user(options = {}) |
288 | user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) | 292 | user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) |