Commit 9ba92dccb042b167ec08c8da51cb0d6c94887d3d
1 parent
320bcfbb
Exists in
master
and in
27 other branches
New config to define when user activation check will perform
Showing
3 changed files
with
14 additions
and
3 deletions
Show diff stats
app/models/user.rb
@@ -359,6 +359,6 @@ class User < ActiveRecord::Base | @@ -359,6 +359,6 @@ class User < ActiveRecord::Base | ||
359 | 359 | ||
360 | def delay_activation_check | 360 | def delay_activation_check |
361 | return if person.is_template? | 361 | return if person.is_template? |
362 | - Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => 72.hours.from_now}) | 362 | + Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => (NOOSFERO_CONF['hours_until_user_activation_check'] || 72).hours.from_now}) |
363 | end | 363 | end |
364 | end | 364 | end |
config/noosfero.yml.dist
@@ -9,6 +9,7 @@ development: | @@ -9,6 +9,7 @@ development: | ||
9 | googlemaps_initial_zoom: 4 | 9 | googlemaps_initial_zoom: 4 |
10 | exception_recipients: [admin@example.com] | 10 | exception_recipients: [admin@example.com] |
11 | max_upload_size: 5MB | 11 | max_upload_size: 5MB |
12 | + hours_until_user_activation_check: 72 | ||
12 | 13 | ||
13 | test: | 14 | test: |
14 | 15 |
test/unit/user_test.rb
@@ -526,9 +526,19 @@ class UserTest < ActiveSupport::TestCase | @@ -526,9 +526,19 @@ class UserTest < ActiveSupport::TestCase | ||
526 | assert user.activated? | 526 | assert user.activated? |
527 | end | 527 | end |
528 | 528 | ||
529 | - should 'delay activation check' do | 529 | + should 'delay activation check with default time' do |
530 | user = new_user | 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 | end | 542 | end |
533 | 543 | ||
534 | should 'not create job to check activation to template users' do | 544 | should 'not create job to check activation to template users' do |