mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-11-15 01:11:23 +00:00
Added test to find out how banning works
This commit is contained in:
parent
7044bb0758
commit
54f5bba669
1 changed files with 44 additions and 0 deletions
44
spec/models/user_spec.rb
Normal file
44
spec/models/user_spec.rb
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# == 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
|
||||||
|
#
|
||||||
|
|
||||||
|
require 'spec_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_false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true if user is banned" do
|
||||||
|
ban = Ban.create! ban_type: Ban::TYPE_SITE, expiry: Time.now + 10.days, user_name: user.username
|
||||||
|
expect(user.banned?).to be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true for specific bans" do
|
||||||
|
ban = Ban.create! ban_type: Ban::TYPE_MUTE, expiry: Time.now + 10.days, user_name: user.username
|
||||||
|
expect(user.banned? Ban::TYPE_MUTE).to be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue