about summary refs log tree commit diff
path: root/spec/models/status_spec.rb
diff options
context:
space:
mode:
authorpluralcafe-docker <docker@plural.cafe>2018-08-20 02:29:25 +0000
committerpluralcafe-docker <docker@plural.cafe>2018-08-20 02:29:25 +0000
commitc339d49d82b3fd2873831029d9c92b3fbf1236e3 (patch)
tree5a8528475f089f1e592dfbedd37ee91e6f748ffc /spec/models/status_spec.rb
parentb6e9537de469a178ce195b75fe8eaf03735e785a (diff)
parentf4d28ccfa3f9fd38a6d219fcde2d1a8bfcf6b306 (diff)
Merge branch 'glitch'
Diffstat (limited to 'spec/models/status_spec.rb')
-rw-r--r--spec/models/status_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 0e2bb0675..3467342ee 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -182,6 +182,27 @@ RSpec.describe Status, type: :model do
       reblog.destroy
       expect(subject.reblogs_count).to eq 0
     end
+
+    it 'does not fail when original is deleted before reblog' do
+      reblog = Fabricate(:status, account: bob, reblog: subject)
+      expect(subject.reblogs_count).to eq 1
+      expect { subject.destroy }.to_not raise_error
+      expect(Status.find_by(id: reblog.id)).to be_nil
+    end
+  end
+
+  describe '#replies_count' do
+    it 'is the number of replies' do
+      reply = Fabricate(:status, account: bob, thread: subject)
+      expect(subject.replies_count).to eq 1
+    end
+
+    it 'is decremented when reply is removed' do
+      reply = Fabricate(:status, account: bob, thread: subject)
+      expect(subject.replies_count).to eq 1
+      reply.destroy
+      expect(subject.replies_count).to eq 0
+    end
   end
 
   describe '#favourites_count' do