diff --git a/app/models/user.rb b/app/models/user.rb index 8c6531b..bd18bc9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -359,6 +359,6 @@ class User < ActiveRecord::Base def delay_activation_check return if person.is_template? - Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => 72.hours.from_now}) + Delayed::Job.enqueue(UserActivationJob.new(self.id), {:priority => 0, :run_at => (NOOSFERO_CONF['hours_until_user_activation_check'] || 72).hours.from_now}) end end diff --git a/config/noosfero.yml.dist b/config/noosfero.yml.dist index 86aafd2..e4df627 100644 --- a/config/noosfero.yml.dist +++ b/config/noosfero.yml.dist @@ -9,6 +9,7 @@ development: googlemaps_initial_zoom: 4 exception_recipients: [admin@example.com] max_upload_size: 5MB + hours_until_user_activation_check: 72 test: diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 22aceac..9f508d4 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -526,9 +526,19 @@ class UserTest < ActiveSupport::TestCase assert user.activated? end - should 'delay activation check' do + should 'delay activation check with default time' do user = new_user - assert_match /UserActivationJob/, Delayed::Job.last.handler + job = Delayed::Job.last + assert_match /UserActivationJob/, job.handler + assert_equal 72, ((job.run_at - user.created_at)/1.hour).round + end + + should 'delay activation check with custom time' do + NOOSFERO_CONF.stubs(:[]).with('hours_until_user_activation_check').returns(240) + user = new_user + job = Delayed::Job.last + assert_match /UserActivationJob/, job.handler + assert_equal 240, ((job.run_at - user.created_at)/1.hour).round end should 'not create job to check activation to template users' do -- libgit2 0.21.2