DEV: Add test for job ensuring consistency

DEV: Add test for job ensuring consistency

Follow-up to ed8b3dd2d29473a63c7b2c2424cc9268d36d9275.

diff --git a/spec/jobs/encrypt_consistency_spec.rb b/spec/jobs/encrypt_consistency_spec.rb
new file mode 100644
index 0000000..9489c24
--- /dev/null
+++ b/spec/jobs/encrypt_consistency_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+describe Jobs::EncryptConsistency do
+  let(:topic) { Fabricate(:encrypt_topic) }
+
+  let(:user_without_invite) { Fabricate(:user) }
+  let(:user_without_key) { Fabricate(:user) }
+
+  before do
+    DiscourseEncrypt::set_key(topic.id, user_without_invite.id, 'topic key')
+    TopicAllowedUser.create(topic_id: topic.id, user_id: user_without_key.id)
+  end
+
+  it 'ensures invites and topic keys are consistent' do
+    expect { subject.execute({}) }
+      .to change { TopicAllowedUser.exists?(topic: topic, user: user_without_invite) }.from(false).to(true)
+      .and change { TopicAllowedUser.exists?(topic: topic, user: user_without_key) }.from(true).to(false)
+  end
+end

GitHub sha: dd4479cf