From 30564373087a4c78d4133d3a1ffdf262507c10de Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Tue, 20 Oct 2015 18:04:50 +0100 Subject: [PATCH] Added moderator group --- app/models/group.rb | 1 + app/models/user.rb | 4 ++++ spec/factories/group.rb | 5 +++++ spec/models/user_spec.rb | 12 ++++++++++++ 4 files changed, 22 insertions(+) diff --git a/app/models/group.rb b/app/models/group.rb index 734ea38..367185d 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 13d0407..1d28615 100755 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/spec/factories/group.rb b/spec/factories/group.rb index bf72ae2..68cec21 100644 --- a/spec/factories/group.rb +++ b/spec/factories/group.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 49f261c..0258344 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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