如何测试用户创建的14天时间



我正在尝试构建一个试用期检查器,并尝试测试用户是否在14天内创建。所以如果它在外面14天,那么我会得到一个假的。想法?

if @user.trial_period === true
trial_users = User.where(created_at:14.days.ago..Time.current.end_of_day)
@trial_check_user = trial_users.where('id = ?', current_user.id)
if @trial_check_user.first.present?
@user_in_trial = true
puts "!!!!!!!    USER STILL IN TRIAL WINDOW   !!!!!!!".red
else
@user_in_trial  = false
puts "!!!!!!!     NOT IN TRIAL NEED SUBCRIPTION   !!!!!!!".red
redirect_to new_subscription_path
end
if current_user.created_at > 14.days.ago
# Still in trial
@trial_check_users = User.where('created_at > ?', 14.days.ago).count
else
@trial_check = false
redirect_to new_subscription_path
end

最新更新