requireFile.dirname(__FILE__) + '/../test_helper'defdefault_options(options = {})
{:user_id => 3829,
:featured_by=> 2,
:corkd_take => "Rules",
:start_date => Date.today + 14,
:end_date => Date.today + 21
}.merge(options)
end
context "A generic Featured User object"do
specify "should return the correct user for today"do
FeaturedUser.current.should.not.be.nilend
specify "should return the correct user for another day"do
FeaturedUser.featured_on(Date.today + 1).should.not.be.nilend
specify "should return nil for a blank range"do
FeaturedUser.featured_on(Date.today + 14).should.be.nilend
specify "should get a list of days / users for a given month"do
days_users = FeaturedUser.featured_for_month(Time.now.month, Time.now.year)
# days_users.should.include? "simplebits"
# days_users.index("simplebits").should.be Today.now.day
endend
context "A featured user creation attempt should fail"do
setup do
@featured_user = FeaturedUser.new(default_options)
end
specify "without a user_id"do
@featured_user.user_id = nil@featured_user.should.not.validateend
specify "without a featuring person"do
@featured_user.featured_by = nil@featured_user.should.not.validateend
specify "without a cork'd take"do
@featured_user.corkd_take = nil@featured_user.should.not.validateend
specify "without a start date"do
@featured_user.start_date = nil@featured_user.should.not.validateend
specify "without an end date"do
@featured_user.end_date = nil@featured_user.should.not.validateend
specify "with conflicting dates"do
@featured_user.start_date = Time.now - 1.week
@featured_user.should.not.validateend
specify "with dates that are within another ranges dates"do
@featured_user.start_date = Time.now - 1.week + 300@featured_user.end_date = Time.now + 1.week - 300@featured_user.should.not.validateend
specify "with reversed dates"do
@featured_user.start_date = Time.now + 2.weeks
@featured_user.end_date = Time.now + 1.week
@featured_user.should.not.validateendend
context "A featured user creation attempt should succede"do
setup do
@featured_user = FeaturedUser.new(default_options)
end
specify "with everything as it should be"do
@featured_user.should.validateendend