mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
commit
610d566973
8 changed files with 1098 additions and 0 deletions
2
.hound.yml
Normal file
2
.hound.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
ruby:
|
||||
config/styles/ruby.yml
|
|
@ -16,6 +16,7 @@ class Api::V1::UsersController < Api::V1::BaseController
|
|||
time_zone: @user.time_zone,
|
||||
avatar: @user.profile.avatar.url,
|
||||
admin: @user.admin?,
|
||||
moderator: @user.gather_moderator?,
|
||||
steam: @user.steamid.nil? ? nil : {
|
||||
id: @user.steamid,
|
||||
url: @steam.nil? ? nil : @steam.base_url,
|
||||
|
|
|
@ -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
|
||||
|
|
1065
config/styles/ruby.yml
Executable file
1065
config/styles/ruby.yml
Executable file
File diff suppressed because it is too large
Load diff
|
@ -19,6 +19,7 @@ describe Api::V1::UsersController do
|
|||
expect(json["country"]).to eq(@user.country)
|
||||
expect(json["time_zone"]).to eq(@user.time_zone)
|
||||
expect(json["admin"]).to eq(@user.admin?)
|
||||
expect(json["moderator"]).to eq(@user.gather_moderator?)
|
||||
expect(json).to have_key("steam")
|
||||
expect(json["steam"]).to have_key("id")
|
||||
expect(json["steam"]).to have_key("url")
|
||||
|
@ -39,6 +40,13 @@ describe Api::V1::UsersController do
|
|||
expect(json["steam"]).to be_nil
|
||||
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
|
||||
expect {
|
||||
get :show, id: -1
|
||||
|
|
|
@ -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