Improve admin page (#4121)
* Improve admin page * Fix test * Add spec * Improve select style
This commit is contained in:
		
					parent
					
						
							
								8387b3928e
							
						
					
				
			
			
				commit
				
					
						4d42a38954
					
				
			
		
					 15 changed files with 508 additions and 19 deletions
				
			
		
							
								
								
									
										52
									
								
								spec/models/form/status_batch_spec.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								spec/models/form/status_batch_spec.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,52 @@
 | 
			
		|||
require 'rails_helper'
 | 
			
		||||
 | 
			
		||||
describe Form::StatusBatch do
 | 
			
		||||
  let(:form) { Form::StatusBatch.new(action: action, status_ids: status_ids) }
 | 
			
		||||
  let(:status) { Fabricate(:status) }
 | 
			
		||||
 | 
			
		||||
  describe 'with nsfw action' do
 | 
			
		||||
    let(:status_ids) { [status.id, nonsensitive_status.id, sensitive_status.id] }
 | 
			
		||||
    let(:nonsensitive_status) { Fabricate(:status, sensitive: false) }
 | 
			
		||||
    let(:sensitive_status) { Fabricate(:status, sensitive: true) }
 | 
			
		||||
    let!(:shown_media_attachment) { Fabricate(:media_attachment, status: nonsensitive_status) }
 | 
			
		||||
    let!(:hidden_media_attachment) { Fabricate(:media_attachment, status: sensitive_status) }
 | 
			
		||||
 | 
			
		||||
    context 'nsfw_on' do
 | 
			
		||||
      let(:action) { 'nsfw_on' }
 | 
			
		||||
 | 
			
		||||
      it { expect(form.save).to be true }
 | 
			
		||||
      it { expect { form.save }.to change { nonsensitive_status.reload.sensitive }.from(false).to(true) }
 | 
			
		||||
      it { expect { form.save }.not_to change { sensitive_status.reload.sensitive } }
 | 
			
		||||
      it { expect { form.save }.not_to change { status.reload.sensitive } }
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'nsfw_off' do
 | 
			
		||||
      let(:action) { 'nsfw_off' }
 | 
			
		||||
 | 
			
		||||
      it { expect(form.save).to be true }
 | 
			
		||||
      it { expect { form.save }.to change { sensitive_status.reload.sensitive }.from(true).to(false) }
 | 
			
		||||
      it { expect { form.save }.not_to change { nonsensitive_status.reload.sensitive } }
 | 
			
		||||
      it { expect { form.save }.not_to change { status.reload.sensitive } }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe 'with delete action' do
 | 
			
		||||
    let(:status_ids) { [status.id] }
 | 
			
		||||
    let(:action) { 'delete' }
 | 
			
		||||
    let!(:another_status) { Fabricate(:status) }
 | 
			
		||||
 | 
			
		||||
    before do
 | 
			
		||||
      allow(RemovalWorker).to receive(:perform_async)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'call RemovalWorker' do
 | 
			
		||||
      form.save
 | 
			
		||||
      expect(RemovalWorker).to have_received(:perform_async).with(status.id)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    it 'do not call RemovalWorker' do
 | 
			
		||||
      form.save
 | 
			
		||||
      expect(RemovalWorker).not_to have_received(:perform_async).with(another_status.id)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue