Commit da464f010dbd05a41df4bd71a6fead897731309a
1 parent
108f6a21
Exists in
master
and in
29 other branches
Prevent templates from being destroyed
Check if is template before creating job to check activation
Showing
3 changed files
with
9 additions
and
1 deletions
Show diff stats
app/models/user.rb
test/unit/user_activation_job_test.rb
... | ... | @@ -34,7 +34,7 @@ class NotifyActivityToProfilesJobTest < ActiveSupport::TestCase |
34 | 34 | user.person.is_template = true |
35 | 35 | user.person.save |
36 | 36 | job = UserActivationJob.new(user.id) |
37 | - assert_no_difference User, :count do | |
37 | + assert_no_difference 'User.count' do | |
38 | 38 | job.perform |
39 | 39 | process_delayed_job_queue |
40 | 40 | end | ... | ... |
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 | ... | ... |