Commit f094d0b5a76273ec9a5d2970f3c45c4157c556bd
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'fix_members_listing' into stable
Showing
4 changed files
with
20 additions
and
1 deletions
Show diff stats
app/models/user.rb
lib/user_activation_job.rb
test/unit/user_activation_job_test.rb
... | ... | @@ -29,6 +29,17 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
29 | 29 | end |
30 | 30 | end |
31 | 31 | |
32 | + should 'not destroy user if not activated but is template' do | |
33 | + user = new_user :login => 'test3' | |
34 | + user.person.is_template = true | |
35 | + user.person.save | |
36 | + job = UserActivationJob.new(user.id) | |
37 | + assert_no_difference 'User.count' do | |
38 | + job.perform | |
39 | + process_delayed_job_queue | |
40 | + end | |
41 | + end | |
42 | + | |
32 | 43 | protected |
33 | 44 | def new_user(options = {}) |
34 | 45 | user = User.new({ :login => 'quire', :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) | ... | ... |
test/unit/user_test.rb
... | ... | @@ -525,6 +525,13 @@ class UserTest < ActiveSupport::TestCase |
525 | 525 | assert_match /UserActivationJob/, Delayed::Job.last.handler |
526 | 526 | end |
527 | 527 | |
528 | + should 'not create job to check activation to template users' do | |
529 | + Person.any_instance.stubs(:is_template?).returns(true) | |
530 | + | |
531 | + user = new_user | |
532 | + assert_equal 0, Delayed::Job.by_handler("--- !ruby/struct:UserActivationJob\nuser_id: #{user.id}\n").count | |
533 | + end | |
534 | + | |
528 | 535 | should 'deactivate an user' do |
529 | 536 | user = new_user |
530 | 537 | user.activate | ... | ... |