clean up first day user definition and object model

This commit is contained in:
Sam
2015-03-26 16:48:36 +11:00
parent 9834d11503
commit 5aa1272f05
4 changed files with 16 additions and 18 deletions

View File

@ -722,21 +722,17 @@ describe User do
end
describe "#added_a_day_ago?" do
context "when user is more than a day old" do
subject(:user) { Fabricate(:user, created_at: Date.today - 2.days) }
describe "#first_day_user?" do
it "returns false" do
expect(user).to_not be_added_a_day_ago
end
def test_user?(opts={})
Fabricate.build(:user, {created_at: Time.now}.merge(opts)).first_day_user?
end
context "is less than a day old" do
subject(:user) { Fabricate(:user) }
it "returns true" do
expect(user).to be_added_a_day_ago
end
it "works" do
expect(test_user?).to eq(true)
expect(test_user?(moderator: true)).to eq(false)
expect(test_user?(trust_level: TrustLevel[2])).to eq(false)
expect(test_user?(created_at: 2.days.ago)).to eq(false)
end
end