Added moderator group

This commit is contained in:
Chris Blanchard 2015-10-20 18:04:50 +01:00
parent 205e515d2c
commit 3056437308
4 changed files with 22 additions and 0 deletions

View file

@ -21,6 +21,7 @@ class Group < ActiveRecord::Base
CHAMPIONS = 7 CHAMPIONS = 7
PREDICTORS = 8 PREDICTORS = 8
STAFF = 10 STAFF = 10
GATHER_MODERATORS = 14
attr_protected :id, :updated_at, :created_at, :founder_id attr_protected :id, :updated_at, :created_at, :founder_id
validates_length_of :name, :maximum => 20 validates_length_of :name, :maximum => 20

View file

@ -205,6 +205,10 @@ class User < ActiveRecord::Base
groups.exists? :id => Group::CASTERS groups.exists? :id => Group::CASTERS
end end
def gather_moderator?
groups.exists? id: Group::GATHER_MODERATORS
end
def verified? def verified?
# created_at < DateTime.now.ago(VERIFICATION_TIME) # created_at < DateTime.now.ago(VERIFICATION_TIME)
true true

View file

@ -19,4 +19,9 @@ FactoryGirl.define do
name "Donors" name "Donors"
id Group::DONORS id Group::DONORS
end end
trait :gather_moderator do
name "Gather Moderator"
id Group::GATHER_MODERATORS
end
end end

View file

@ -48,4 +48,16 @@ describe User do
expect(user.banned? Ban::TYPE_MUTE).to be_truthy expect(user.banned? Ban::TYPE_MUTE).to be_truthy
end end
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 end