2015-05-05 21:43:54 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: users
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# username :string(255)
|
|
|
|
# password :string(255)
|
|
|
|
# firstname :string(255)
|
|
|
|
# lastname :string(255)
|
|
|
|
# email :string(255)
|
|
|
|
# steamid :string(255)
|
|
|
|
# team_id :integer
|
|
|
|
# lastvisit :datetime
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# lastip :string(255)
|
|
|
|
# country :string(255)
|
|
|
|
# birthdate :date
|
|
|
|
# time_zone :string(255)
|
|
|
|
# version :integer
|
|
|
|
# public_email :boolean default(FALSE), not null
|
2015-08-20 14:58:10 +00:00
|
|
|
# salt :string(255)
|
2015-05-05 21:43:54 +00:00
|
|
|
#
|
|
|
|
|
2015-11-07 06:21:31 +00:00
|
|
|
require "spec_helper"
|
2015-05-05 21:43:54 +00:00
|
|
|
|
|
|
|
describe User do
|
2015-08-15 11:50:28 +00:00
|
|
|
let!(:user) { create :user }
|
2015-05-05 21:43:54 +00:00
|
|
|
|
2015-08-15 11:50:28 +00:00
|
|
|
describe "#banned?" do
|
|
|
|
it "returns false if user is not banned" do
|
|
|
|
expect(user.banned?).to be_falsey
|
|
|
|
end
|
2015-05-05 21:43:54 +00:00
|
|
|
|
2015-08-15 11:50:28 +00:00
|
|
|
it "returns true if user is banned" do
|
2015-08-15 18:23:42 +00:00
|
|
|
Ban.create!(ban_type: Ban::TYPE_SITE,
|
2015-11-07 06:21:31 +00:00
|
|
|
expiry: Time.now.utc + 10.days,
|
2015-08-15 18:23:42 +00:00
|
|
|
user_name: user.username)
|
|
|
|
|
2015-08-15 11:50:28 +00:00
|
|
|
expect(user.banned?).to be_truthy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns true for specific bans" do
|
2015-08-15 18:23:42 +00:00
|
|
|
Ban.create!(ban_type: Ban::TYPE_MUTE,
|
2015-11-07 06:21:31 +00:00
|
|
|
expiry: Time.now.utc + 10.days,
|
2015-08-15 18:23:42 +00:00
|
|
|
user_name: user.username)
|
|
|
|
|
2015-08-15 11:50:28 +00:00
|
|
|
expect(user.banned? Ban::TYPE_MUTE).to be_truthy
|
|
|
|
end
|
|
|
|
end
|
2015-10-20 17:04:50 +00:00
|
|
|
|
|
|
|
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
|
2015-08-15 11:50:28 +00:00
|
|
|
end
|