about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorJenkins <jenkins@jenkins.ninjawedding.org>2018-05-17 11:17:21 +0000
committerJenkins <jenkins@jenkins.ninjawedding.org>2018-05-17 11:17:21 +0000
commit2636a23092306bdb07250add02d2851476d58bc2 (patch)
treed1c396ac03b7356e95c8da165f601a431ab05553 /spec
parent4bf43e6f3e93643d989a2872763b41505fab2206 (diff)
parent7293b9fc6190acd6d2a481c158c718a7a8299c73 (diff)
Merge remote-tracking branch 'tootsuite/master' into glitchsoc/master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/admin/account_moderation_notes_controller_spec.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/controllers/admin/account_moderation_notes_controller_spec.rb b/spec/controllers/admin/account_moderation_notes_controller_spec.rb
index ca4e55c4d..410ce6543 100644
--- a/spec/controllers/admin/account_moderation_notes_controller_spec.rb
+++ b/spec/controllers/admin/account_moderation_notes_controller_spec.rb
@@ -1,4 +1,46 @@
 require 'rails_helper'
 
 RSpec.describe Admin::AccountModerationNotesController, type: :controller do
+  render_views
+
+  let(:user) { Fabricate(:user, admin: true) }
+  let(:target_account) { Fabricate(:account) }
+
+  before do
+    sign_in user, scope: :user
+  end
+
+  describe 'POST #create' do
+    subject { post :create, params: params }
+
+    context 'when parameters are valid' do
+      let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: 'test content' } } }
+
+      it 'successfully creates a note' do
+        expect { subject }.to change { AccountModerationNote.count }.by(1)
+        expect(subject).to redirect_to admin_account_path(target_account.id)
+      end
+    end
+
+    context 'when parameters are invalid' do
+      let(:params) { { account_moderation_note: { target_account_id: target_account.id, content: '' } } }
+
+      it 'falls to create a note' do
+        expect { subject }.not_to change { AccountModerationNote.count }
+        expect(subject).to render_template 'admin/accounts/show'
+      end
+    end
+  end
+
+  describe 'DELETE #destroy' do
+    subject { delete :destroy, params: { id: note.id } }
+
+    let!(:note) { Fabricate(:account_moderation_note, account: account, target_account: target_account) }
+    let(:account) { Fabricate(:account) }
+
+    it 'destroys note' do
+      expect { subject }.to change { AccountModerationNote.count }.by(-1)
+      expect(subject).to redirect_to admin_account_path(target_account.id)
+    end
+  end
 end