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,6 +363,6 @@ class User < ActiveRecord::Base | ||
363 | 363 | ||
364 | def delay_activation_check | 364 | def delay_activation_check |
365 | return if person.is_template? | 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 | end | 367 | end |
368 | end | 368 | 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_activation_job_test.rb
1 | require_relative "../test_helper" | 1 | require_relative "../test_helper" |
2 | 2 | ||
3 | -class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase | 3 | +class UserActivationJobTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | should 'create job on user creation' do | 5 | should 'create job on user creation' do |
6 | user = new_user :login => 'test1' | 6 | user = new_user :login => 'test1' |
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 |