ensl.org/spec/models/user_spec.rb

69 lines
1.7 KiB
Ruby
Raw Normal View History

# == Schema Information
#
# Table name: users
#
2020-04-02 00:08:19 +00:00
# id :integer not null, primary key
# birthdate :date
# country :string(255)
# email :string(255)
# firstname :string(255)
# lastip :string(255)
# lastname :string(255)
# lastvisit :datetime
# password :string(255)
# password_hash :integer default(0)
# public_email :boolean default(FALSE), not null
# steamid :string(255)
# time_zone :string(255)
# username :string(255)
# version :integer
# created_at :datetime
# updated_at :datetime
# team_id :integer
#
# Indexes
#
# index_users_on_lastvisit (lastvisit)
# index_users_on_team_id (team_id)
#
2019-10-17 18:29:15 +00:00
require 'rails_helper'
describe User do
let!(:user) { create :user }
describe "#banned?" do
it "returns false if user is not banned" do
expect(user.banned?).to be_falsey
end
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)
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)
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
end