mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 12:30:48 +00:00
Added moderator group
This commit is contained in:
parent
205e515d2c
commit
3056437308
4 changed files with 22 additions and 0 deletions
|
@ -21,6 +21,7 @@ class Group < ActiveRecord::Base
|
|||
CHAMPIONS = 7
|
||||
PREDICTORS = 8
|
||||
STAFF = 10
|
||||
GATHER_MODERATORS = 14
|
||||
|
||||
attr_protected :id, :updated_at, :created_at, :founder_id
|
||||
validates_length_of :name, :maximum => 20
|
||||
|
|
|
@ -205,6 +205,10 @@ class User < ActiveRecord::Base
|
|||
groups.exists? :id => Group::CASTERS
|
||||
end
|
||||
|
||||
def gather_moderator?
|
||||
groups.exists? id: Group::GATHER_MODERATORS
|
||||
end
|
||||
|
||||
def verified?
|
||||
# created_at < DateTime.now.ago(VERIFICATION_TIME)
|
||||
true
|
||||
|
|
|
@ -19,4 +19,9 @@ FactoryGirl.define do
|
|||
name "Donors"
|
||||
id Group::DONORS
|
||||
end
|
||||
|
||||
trait :gather_moderator do
|
||||
name "Gather Moderator"
|
||||
id Group::GATHER_MODERATORS
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,4 +48,16 @@ describe User do
|
|||
expect(user.banned? Ban::TYPE_MUTE).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
describe "#gather_moderator?" do
|
||||
let!(:group) { create :group, :gather_moderator }
|
||||
|
||||
it "returns true if gather moderator" do
|
||||
create :grouper, group: group, user: user
|
||||
expect(user.gather_moderator?).to eq(true)
|
||||
end
|
||||
it "returns false if not gather moderator" do
|
||||
expect(user.gather_moderator?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue