From eb151d440b54dbfe8fef108caa90f5287e967d10 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 29 Apr 2013 11:38:43 -0400 Subject: [PATCH] Don't call discourse hub during user destroy if hub integration is disabled --- lib/user_destroyer.rb | 2 +- spec/components/user_destroyer_spec.rb | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/user_destroyer.rb b/lib/user_destroyer.rb index 3b2230657a2..72bbb19bf6d 100644 --- a/lib/user_destroyer.rb +++ b/lib/user_destroyer.rb @@ -20,7 +20,7 @@ class UserDestroyer user.destroy.tap do |u| if u AdminLogger.new(@admin).log_user_deletion(user) - DiscourseHub.unregister_nickname(user.username) + DiscourseHub.unregister_nickname(user.username) if SiteSetting.call_discourse_hub? MessageBus.publish "/file-change", ["refresh"], user_ids: [user.id] end end diff --git a/spec/components/user_destroyer_spec.rb b/spec/components/user_destroyer_spec.rb index 6d9ef0bf2cd..0276e8e9fe8 100644 --- a/spec/components/user_destroyer_spec.rb +++ b/spec/components/user_destroyer_spec.rb @@ -86,10 +86,17 @@ describe UserDestroyer do destroy end - it 'should unregister the nickname as the discourse hub' do + it 'should unregister the nickname as the discourse hub if hub integration is enabled' do + SiteSetting.stubs(:call_discourse_hub?).returns(true) DiscourseHub.expects(:unregister_nickname).with(@user.username) destroy end + + it 'should not try to unregister the nickname as the discourse hub if hub integration is disabled' do + SiteSetting.stubs(:call_discourse_hub?).returns(false) + DiscourseHub.expects(:unregister_nickname).never + destroy + end end context 'and destroy fails' do