about summary refs log tree commit diff
path: root/spec/controllers/statuses_controller_spec.rb
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-05-03 17:23:44 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-05-03 17:23:44 -0500
commitc816701550d7cdb593371dc47d0b9430c78308b0 (patch)
treecc4417d14de20e69fd5f9a58d66f84af4a623329 /spec/controllers/statuses_controller_spec.rb
parent3a47842223ff93d8c057f804809f1b111dfd6f76 (diff)
parenta7e71bbd08e089938fbf20ddef5768c2f3ee0702 (diff)
Merge remote-tracking branch 'origin/master' into gs-master
  Conflicts:
 	.travis.yml
 	Gemfile.lock
 	README.md
 	app/controllers/settings/follower_domains_controller.rb
 	app/controllers/statuses_controller.rb
 	app/javascript/mastodon/locales/ja.json
 	app/lib/feed_manager.rb
 	app/models/media_attachment.rb
 	app/models/mute.rb
 	app/models/status.rb
 	app/services/mute_service.rb
 	app/views/home/index.html.haml
 	app/views/stream_entries/_simple_status.html.haml
 	config/locales/ca.yml
 	config/locales/en.yml
 	config/locales/es.yml
 	config/locales/fr.yml
 	config/locales/nl.yml
 	config/locales/pl.yml
 	config/locales/pt-BR.yml
 	config/themes.yml
Diffstat (limited to 'spec/controllers/statuses_controller_spec.rb')
-rw-r--r--spec/controllers/statuses_controller_spec.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb
index 95fb4d594..b4f3c5a08 100644
--- a/spec/controllers/statuses_controller_spec.rb
+++ b/spec/controllers/statuses_controller_spec.rb
@@ -82,10 +82,53 @@ describe StatusesController do
         expect(assigns(:ancestors)).to eq []
       end
 
+      it 'assigns @descendant_threads for a thread with several statuses' do
+        status = Fabricate(:status)
+        child = Fabricate(:status, in_reply_to_id: status.id)
+        grandchild = Fabricate(:status, in_reply_to_id: child.id)
+
+        get :show, params: { account_username: status.account.username, id: status.id }
+
+        expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).to eq [child.id, grandchild.id]
+      end
+
+      it 'assigns @descendant_threads for several threads sharing the same descendant' do
+        status = Fabricate(:status)
+        child = Fabricate(:status, in_reply_to_id: status.id)
+        grandchildren = 2.times.map { Fabricate(:status, in_reply_to_id: child.id) }
+
+        get :show, params: { account_username: status.account.username, id: status.id }
+
+        expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).to eq [child.id, grandchildren[0].id]
+        expect(assigns(:descendant_threads)[1][:statuses].pluck(:id)).to eq [grandchildren[1].id]
+      end
+
+      it 'assigns @max_descendant_thread_id for the last thread if it is hitting the status limit' do
+        stub_const 'StatusesController::DESCENDANTS_LIMIT', 1
+        status = Fabricate(:status)
+        child = Fabricate(:status, in_reply_to_id: status.id)
+
+        get :show, params: { account_username: status.account.username, id: status.id }
+
+        expect(assigns(:descendant_threads)).to eq []
+        expect(assigns(:max_descendant_thread_id)).to eq child.id
+      end
+
+      it 'assigns @descendant_threads for threads with :next_status key if they are hitting the depth limit' do
+        stub_const 'StatusesController::DESCENDANTS_DEPTH_LIMIT', 1
+        status = Fabricate(:status)
+        child = Fabricate(:status, in_reply_to_id: status.id)
+
+        get :show, params: { account_username: status.account.username, id: status.id }
+
+        expect(assigns(:descendant_threads)[0][:statuses].pluck(:id)).not_to include child.id
+        expect(assigns(:descendant_threads)[0][:next_status].id).to eq child.id
+      end
+
       it 'returns a success' do
         status = Fabricate(:status)
         get :show, params: { account_username: status.account.username, id: status.id }
-        expect(response).to have_http_status(:success)
+        expect(response).to have_http_status(200)
       end
 
       it 'renders stream_entries/show' do