adds official? method to User
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user