about summary refs log tree commit diff
diff options
context:
space:
mode:
authorShuhei Kitagawa <shuheiktgw@users.noreply.github.com>2018-05-09 15:41:46 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-05-09 08:41:46 +0200
commitce35d81db73367a016ad019aadefba0a5ecb0d2d (patch)
treedd691c28764e37130393c5248acf4f1794617166
parent35eff337d5482ac251e2f75031c5be2ab583e265 (diff)
Add tests for admin/roles_controller (#7421)
-rw-r--r--spec/controllers/admin/roles_controller_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/controllers/admin/roles_controller_spec.rb b/spec/controllers/admin/roles_controller_spec.rb
new file mode 100644
index 000000000..8e0de73cb
--- /dev/null
+++ b/spec/controllers/admin/roles_controller_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+describe Admin::RolesController do
+  render_views
+
+  let(:admin) { Fabricate(:user, admin: true) }
+
+  before do
+    sign_in admin, scope: :user
+  end
+
+  describe 'POST #promote' do
+    subject { post :promote, params: { account_id: user.account_id } }
+
+    let(:user) { Fabricate(:user, moderator: false, admin: false) }
+
+    it 'promotes user' do
+      expect(subject).to redirect_to admin_account_path(user.account_id)
+      expect(user.reload).to be_moderator
+    end
+  end
+
+  describe 'POST #demote' do
+    subject { post :demote, params: { account_id: user.account_id } }
+
+    let(:user) { Fabricate(:user, moderator: true, admin: false) }
+
+    it 'demotes user' do
+      expect(subject).to redirect_to admin_account_path(user.account_id)
+      expect(user.reload).not_to be_moderator
+    end
+  end
+end