mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Merge pull request #60 from cblanc/report_gather_moderators
Report gather moderators
This commit is contained in:
commit
84d878e6cd
6 changed files with 31 additions and 0 deletions
|
@ -16,6 +16,7 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||||
time_zone: @user.time_zone,
|
time_zone: @user.time_zone,
|
||||||
avatar: @user.profile.avatar.url,
|
avatar: @user.profile.avatar.url,
|
||||||
admin: @user.admin?,
|
admin: @user.admin?,
|
||||||
|
moderator: @user.gather_moderator?,
|
||||||
steam: @user.steamid.nil? ? nil : {
|
steam: @user.steamid.nil? ? nil : {
|
||||||
id: @user.steamid,
|
id: @user.steamid,
|
||||||
url: @steam.nil? ? nil : @steam.base_url,
|
url: @steam.nil? ? nil : @steam.base_url,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -19,6 +19,7 @@ describe Api::V1::UsersController do
|
||||||
expect(json["country"]).to eq(@user.country)
|
expect(json["country"]).to eq(@user.country)
|
||||||
expect(json["time_zone"]).to eq(@user.time_zone)
|
expect(json["time_zone"]).to eq(@user.time_zone)
|
||||||
expect(json["admin"]).to eq(@user.admin?)
|
expect(json["admin"]).to eq(@user.admin?)
|
||||||
|
expect(json["moderator"]).to eq(@user.gather_moderator?)
|
||||||
expect(json).to have_key("steam")
|
expect(json).to have_key("steam")
|
||||||
expect(json["steam"]).to have_key("id")
|
expect(json["steam"]).to have_key("id")
|
||||||
expect(json["steam"]).to have_key("url")
|
expect(json["steam"]).to have_key("url")
|
||||||
|
@ -39,6 +40,13 @@ describe Api::V1::UsersController do
|
||||||
expect(json["steam"]).to be_nil
|
expect(json["steam"]).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns gather moderator status" do
|
||||||
|
group = create :group, :gather_moderator
|
||||||
|
create :grouper, user: @user, group: group
|
||||||
|
get :show, id: @user.id
|
||||||
|
expect(json["moderator"]).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns 404 if user does not exist" do
|
it "returns 404 if user does not exist" do
|
||||||
expect {
|
expect {
|
||||||
get :show, id: -1
|
get :show, id: -1
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue