Improve admin UI for accounts (#7360)
* Improve design of account statuses admin UI (consistent with reports) * Make account moderation notes look consistent with report notes * i18n-tasks remove-unused * Fix code style issues * Fix tests
This commit is contained in:
		@@ -22,7 +22,7 @@ describe Admin::ReportedStatusesController do
 | 
			
		||||
    let(:sensitive) { true }
 | 
			
		||||
    let!(:media_attachment) { Fabricate(:media_attachment, status: status) }
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to true' do
 | 
			
		||||
    context 'when action is nsfw_on' do
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          status.reload.sensitive
 | 
			
		||||
@@ -30,7 +30,7 @@ describe Admin::ReportedStatusesController do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to false' do
 | 
			
		||||
    context 'when action is nsfw_off' do
 | 
			
		||||
      let(:action) { 'nsfw_off' }
 | 
			
		||||
      let(:sensitive) { false }
 | 
			
		||||
 | 
			
		||||
@@ -41,35 +41,13 @@ describe Admin::ReportedStatusesController do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'redirects to report page' do
 | 
			
		||||
      subject.call
 | 
			
		||||
      expect(response).to redirect_to(admin_report_path(report))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
    context 'when action is delete' do
 | 
			
		||||
      let(:action) { 'delete' }
 | 
			
		||||
 | 
			
		||||
  describe 'PATCH #update' do
 | 
			
		||||
    subject do
 | 
			
		||||
      -> { patch :update, params: { report_id: report, id: status, status: { sensitive: sensitive } } }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let(:status) { Fabricate(:status, sensitive: !sensitive) }
 | 
			
		||||
    let(:sensitive) { true }
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to true' do
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          status.reload.sensitive
 | 
			
		||||
        }.from(false).to(true)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to false' do
 | 
			
		||||
      let(:sensitive) { false }
 | 
			
		||||
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          status.reload.sensitive
 | 
			
		||||
        }.from(true).to(false)
 | 
			
		||||
      it 'removes a status' do
 | 
			
		||||
        allow(RemovalWorker).to receive(:perform_async)
 | 
			
		||||
        subject.call
 | 
			
		||||
        expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -78,15 +56,4 @@ describe Admin::ReportedStatusesController do
 | 
			
		||||
      expect(response).to redirect_to(admin_report_path(report))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'DELETE #destroy' do
 | 
			
		||||
    it 'removes a status' do
 | 
			
		||||
      allow(RemovalWorker).to receive(:perform_async)
 | 
			
		||||
 | 
			
		||||
      delete :destroy, params: { report_id: report, id: status }
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
      expect(RemovalWorker).
 | 
			
		||||
        to have_received(:perform_async).with(status.id)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -34,13 +34,13 @@ describe Admin::StatusesController do
 | 
			
		||||
 | 
			
		||||
  describe 'POST #create' do
 | 
			
		||||
    subject do
 | 
			
		||||
      -> { post :create, params: { account_id: account.id, form_status_batch: { action: action, status_ids: status_ids } } }
 | 
			
		||||
      -> { post :create, params: { :account_id => account.id, action => '', :form_status_batch => { status_ids: status_ids } } }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    let(:action) { 'nsfw_on' }
 | 
			
		||||
    let(:status_ids) { [media_attached_status.id] }
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to true' do
 | 
			
		||||
    context 'when action is nsfw_on' do
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          media_attached_status.reload.sensitive
 | 
			
		||||
@@ -48,7 +48,7 @@ describe Admin::StatusesController do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to false' do
 | 
			
		||||
    context 'when action is nsfw_off' do
 | 
			
		||||
      let(:action) { 'nsfw_off' }
 | 
			
		||||
      let(:sensitive) { false }
 | 
			
		||||
 | 
			
		||||
@@ -59,32 +59,13 @@ describe Admin::StatusesController do
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'redirects to account statuses page' do
 | 
			
		||||
      subject.call
 | 
			
		||||
      expect(response).to redirect_to(admin_account_statuses_path(account.id))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
    context 'when action is delete' do
 | 
			
		||||
      let(:action) { 'delete' }
 | 
			
		||||
 | 
			
		||||
  describe 'PATCH #update' do
 | 
			
		||||
    subject do
 | 
			
		||||
      -> { patch :update, params: { account_id: account.id, id: media_attached_status, status: { sensitive: sensitive } } }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to true' do
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          media_attached_status.reload.sensitive
 | 
			
		||||
        }.from(false).to(true)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'updates sensitive column to false' do
 | 
			
		||||
      let(:sensitive) { false }
 | 
			
		||||
 | 
			
		||||
      it 'updates sensitive column' do
 | 
			
		||||
        is_expected.to change {
 | 
			
		||||
          media_attached_status.reload.sensitive
 | 
			
		||||
        }.from(true).to(false)
 | 
			
		||||
      it 'removes a status' do
 | 
			
		||||
        allow(RemovalWorker).to receive(:perform_async)
 | 
			
		||||
        subject.call
 | 
			
		||||
        expect(RemovalWorker).to have_received(:perform_async).with(status_ids.first)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@@ -93,15 +74,4 @@ describe Admin::StatusesController do
 | 
			
		||||
      expect(response).to redirect_to(admin_account_statuses_path(account.id))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'DELETE #destroy' do
 | 
			
		||||
    it 'removes a status' do
 | 
			
		||||
      allow(RemovalWorker).to receive(:perform_async)
 | 
			
		||||
 | 
			
		||||
      delete :destroy, params: { account_id: account.id, id: status }
 | 
			
		||||
      expect(response).to have_http_status(200)
 | 
			
		||||
      expect(RemovalWorker).
 | 
			
		||||
        to have_received(:perform_async).with(status.id)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user