2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-05 08:59:27 +08:00

refactor User and TrustLevel a bit

* rename `User#password_required` to `User#password_required!`
* emails with "i" @ something are a special case as well
* get rid of `self.` and returns where possible
* prefer "unless a" instead of "if !a"
* `unread_notifications` without manually iterating
* introduce `User#moderator?`
* introduce `TrustLevel#valid_key?`, `TrustLevel#compare`, and
  `TrustLevel#level_key`
This commit is contained in:
Gosha Arinich 2013-02-28 16:08:56 +03:00
parent 46a02ae5b1
commit d2f3c829db
6 changed files with 109 additions and 117 deletions

View file

@ -87,7 +87,7 @@ describe User do
end
describe '.approve!' do
describe '.approve' do
let(:user) { Fabricate(:user) }
let(:admin) { Fabricate(:admin) }
@ -231,7 +231,7 @@ describe User do
User.new.trust_level.should == TrustLevel.Levels[:advanced]
end
describe 'has_trust_level' do
describe 'has_trust_level?' do
it "raises an error with an invalid level" do
lambda { user.has_trust_level?(:wat) }.should raise_error