adds official? method to User

This commit is contained in:
Juanjo Bazán
2015-08-14 09:58:54 +02:00
parent f827e860e4
commit d80fd8e468
2 changed files with 17 additions and 0 deletions

View File

@@ -25,4 +25,8 @@ class User < ActiveRecord::Base
def moderator? def moderator?
@is_moderator ||= Moderator.where(user_id: id).exists? @is_moderator ||= Moderator.where(user_id: id).exists?
end end
def official?
official_level && official_level > 0
end
end end

View File

@@ -107,4 +107,17 @@ describe User do
end end
end end
describe "official?" do
it "is false when the user is not an official" do
expect(subject.official_level).to eq(0)
expect(subject.official?).to be false
end
it "is true when the user is an official" do
subject.official_level = 3
subject.save
expect(subject.official?).to be true
end
end
end end