* Fix #16937 * Add test for statuses order
This commit is contained in:
parent
3f382e337d
commit
1c826471e7
2 changed files with 8 additions and 3 deletions
|
@ -14,7 +14,7 @@ module Admin
|
||||||
@statuses = @account.statuses.where(visibility: [:public, :unlisted])
|
@statuses = @account.statuses.where(visibility: [:public, :unlisted])
|
||||||
|
|
||||||
if params[:media]
|
if params[:media]
|
||||||
@statuses.merge!(Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id)).reorder('statuses.id desc')
|
@statuses = @statuses.merge(Status.joins(:media_attachments).merge(@account.media_attachments.reorder(nil)).group(:id)).reorder('statuses.id desc')
|
||||||
end
|
end
|
||||||
|
|
||||||
@statuses = @statuses.preload(:media_attachments, :mentions).page(params[:page]).per(PER_PAGE)
|
@statuses = @statuses.preload(:media_attachments, :mentions).page(params[:page]).per(PER_PAGE)
|
||||||
|
|
|
@ -8,6 +8,9 @@ describe Admin::StatusesController do
|
||||||
let!(:status) { Fabricate(:status, account: account) }
|
let!(:status) { Fabricate(:status, account: account) }
|
||||||
let(:media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
|
let(:media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
|
||||||
let!(:media_attachment) { Fabricate(:media_attachment, account: account, status: media_attached_status) }
|
let!(:media_attachment) { Fabricate(:media_attachment, account: account, status: media_attached_status) }
|
||||||
|
let(:last_media_attached_status) { Fabricate(:status, account: account, sensitive: !sensitive) }
|
||||||
|
let!(:last_media_attachment) { Fabricate(:media_attachment, account: account, status: last_media_attached_status) }
|
||||||
|
let!(:last_status) { Fabricate(:status, account: account) }
|
||||||
let(:sensitive) { true }
|
let(:sensitive) { true }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -19,7 +22,8 @@ describe Admin::StatusesController do
|
||||||
get :index, params: { account_id: account.id }
|
get :index, params: { account_id: account.id }
|
||||||
|
|
||||||
statuses = assigns(:statuses).to_a
|
statuses = assigns(:statuses).to_a
|
||||||
expect(statuses.size).to eq 2
|
expect(statuses.size).to eq 4
|
||||||
|
expect(statuses.first.id).to eq last_status.id
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +31,8 @@ describe Admin::StatusesController do
|
||||||
get :index, params: { account_id: account.id, media: true }
|
get :index, params: { account_id: account.id, media: true }
|
||||||
|
|
||||||
statuses = assigns(:statuses).to_a
|
statuses = assigns(:statuses).to_a
|
||||||
expect(statuses.size).to eq 1
|
expect(statuses.size).to eq 2
|
||||||
|
expect(statuses.first.id).to eq last_media_attached_status.id
|
||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue