Add tests to indicate inclusion of self replies in statuses endpoint (#23266)
This commit is contained in:
parent
f553b064e0
commit
45e2936c89
1 changed files with 28 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe Api::V1::Accounts::StatusesController do
|
describe Api::V1::Accounts::StatusesController do
|
||||||
|
@ -15,7 +16,12 @@ describe Api::V1::Accounts::StatusesController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: user.account.id, limit: 1 }
|
get :index, params: { account_id: user.account.id, limit: 1 }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns expected headers' do
|
||||||
|
get :index, params: { account_id: user.account.id, limit: 1 }
|
||||||
|
|
||||||
expect(response.headers['Link'].links.size).to eq(2)
|
expect(response.headers['Link'].links.size).to eq(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,19 +29,29 @@ describe Api::V1::Accounts::StatusesController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: user.account.id, only_media: true }
|
get :index, params: { account_id: user.account.id, only_media: true }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with exclude replies' do
|
context 'with exclude replies' do
|
||||||
|
let!(:older_statuses) { user.account.statuses.destroy_all }
|
||||||
|
let!(:status) { Fabricate(:status, account: user.account) }
|
||||||
|
let!(:status_self_reply) { Fabricate(:status, account: user.account, thread: status) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:status, account: user.account, thread: Fabricate(:status))
|
Fabricate(:status, account: user.account, thread: Fabricate(:status)) # Reply to another user
|
||||||
|
get :index, params: { account_id: user.account.id, exclude_replies: true }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: user.account.id, exclude_replies: true }
|
expect(response).to have_http_status(:ok)
|
||||||
|
end
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
it 'returns posts along with self replies' do
|
||||||
|
json = body_as_json
|
||||||
|
post_ids = json.map { |item| item[:id].to_i }.sort
|
||||||
|
|
||||||
|
expect(post_ids).to eq [status.id, status_self_reply.id]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +63,7 @@ describe Api::V1::Accounts::StatusesController do
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: user.account.id, pinned: true }
|
get :index, params: { account_id: user.account.id, pinned: true }
|
||||||
|
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,12 +71,15 @@ describe Api::V1::Accounts::StatusesController do
|
||||||
let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
let(:account) { Fabricate(:account, username: 'bob', domain: 'example.com') }
|
||||||
let(:status) { Fabricate(:status, account: account) }
|
let(:status) { Fabricate(:status, account: account) }
|
||||||
let(:private_status) { Fabricate(:status, account: account, visibility: :private) }
|
let(:private_status) { Fabricate(:status, account: account, visibility: :private) }
|
||||||
let!(:pin) { Fabricate(:status_pin, account: account, status: status) }
|
|
||||||
let!(:private_pin) { Fabricate(:status_pin, account: account, status: private_status) }
|
before do
|
||||||
|
Fabricate(:status_pin, account: account, status: status)
|
||||||
|
Fabricate(:status_pin, account: account, status: private_status)
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns http success' do
|
it 'returns http success' do
|
||||||
get :index, params: { account_id: account.id, pinned: true }
|
get :index, params: { account_id: account.id, pinned: true }
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(:ok)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user does not follow account' do
|
context 'when user does not follow account' do
|
||||||
|
|
Loading…
Reference in a new issue