Commit 9d1bd7a8d4170623632ea272cde3150822aaadfd
Exists in
master
and in
29 other branches
Merge branch 'custom_activation_check_time' into 'master'
New configuration to define when user activation check will perform See merge request !455
Showing
4 changed files
with
15 additions
and
4 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -363,6 +363,6 @@ class User < ActiveRecord::Base |
363 | 363 | |
364 | 364 | def delay_activation_check |
365 | 365 | return if person.is_template? |
366 | - Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => 72.hours.from_now}) | |
366 | + Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => (NOOSFERO_CONF['hours_until_user_activation_check'] || 72).hours.from_now}) | |
367 | 367 | end |
368 | 368 | end | ... | ... |
config/noosfero.yml.dist
test/unit/user_activation_job_test.rb
test/unit/user_test.rb
... | ... | @@ -526,9 +526,19 @@ class UserTest < ActiveSupport::TestCase |
526 | 526 | assert user.activated? |
527 | 527 | end |
528 | 528 | |
529 | - should 'delay activation check' do | |
529 | + should 'delay activation check with default time' do | |
530 | 530 | user = new_user |
531 | - assert_match /UserActivationJob/, Delayed::Job.last.handler | |
531 | + job = Delayed::Job.last | |
532 | + assert_match /UserActivationJob/, job.handler | |
533 | + assert_equal 72, ((job.run_at - user.created_at)/1.hour).round | |
534 | + end | |
535 | + | |
536 | + should 'delay activation check with custom time' do | |
537 | + NOOSFERO_CONF.stubs(:[]).with('hours_until_user_activation_check').returns(240) | |
538 | + user = new_user | |
539 | + job = Delayed::Job.last | |
540 | + assert_match /UserActivationJob/, job.handler | |
541 | + assert_equal 240, ((job.run_at - user.created_at)/1.hour).round | |
532 | 542 | end |
533 | 543 | |
534 | 544 | should 'not create job to check activation to template users' do | ... | ... |