diff options
author | ThibG <thib@sitedethib.com> | 2018-12-16 15:26:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-16 15:26:50 +0100 |
commit | 396c5dea87f259255f3676bb7b30f5cfdfec9d4e (patch) | |
tree | 33c64f250983b0d8c07bad2a0ec970539e78b1d6 /spec/controllers/admin | |
parent | f0505a5b2e727da73c8aa651b804508a8187a3c4 (diff) | |
parent | 7238e4ea5f4f619396f73009032844d95bdf809c (diff) |
Merge pull request #856 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r-- | spec/controllers/admin/action_logs_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/admin/dashboard_controller_spec.rb | 14 | ||||
-rw-r--r-- | spec/controllers/admin/invites_controller_spec.rb | 16 | ||||
-rw-r--r-- | spec/controllers/admin/suspensions_controller_spec.rb | 7 | ||||
-rw-r--r-- | spec/controllers/admin/tags_controller_spec.rb | 71 |
5 files changed, 122 insertions, 0 deletions
diff --git a/spec/controllers/admin/action_logs_controller_spec.rb b/spec/controllers/admin/action_logs_controller_spec.rb new file mode 100644 index 000000000..4720ed2e2 --- /dev/null +++ b/spec/controllers/admin/action_logs_controller_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Admin::ActionLogsController, type: :controller do + describe 'GET #index' do + it 'returns 200' do + sign_in Fabricate(:user, admin: true) + get :index, params: { page: 1 } + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb new file mode 100644 index 000000000..73b50e721 --- /dev/null +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Admin::DashboardController, type: :controller do + describe 'GET #index' do + it 'returns 200' do + sign_in Fabricate(:user, admin: true) + get :index + + expect(response).to have_http_status(200) + end + end +end diff --git a/spec/controllers/admin/invites_controller_spec.rb b/spec/controllers/admin/invites_controller_spec.rb index 34b51a6aa..449a699e4 100644 --- a/spec/controllers/admin/invites_controller_spec.rb +++ b/spec/controllers/admin/invites_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe Admin::InvitesController do @@ -40,4 +42,18 @@ describe Admin::InvitesController do expect(invite.reload).to be_expired end end + + describe 'POST #deactivate_all' do + it 'expires all invites, then redirects to admin_invites_path' do + invites = Fabricate.times(2, :invite, expires_at: nil) + + post :deactivate_all + + invites.each do |invite| + expect(invite.reload).to be_expired + end + + expect(response).to redirect_to admin_invites_path + end + end end diff --git a/spec/controllers/admin/suspensions_controller_spec.rb b/spec/controllers/admin/suspensions_controller_spec.rb index babb1ed96..1bc33e490 100644 --- a/spec/controllers/admin/suspensions_controller_spec.rb +++ b/spec/controllers/admin/suspensions_controller_spec.rb @@ -7,6 +7,13 @@ describe Admin::SuspensionsController do sign_in Fabricate(:user, admin: true), scope: :user end + describe 'GET #new' do + it 'returns 200' do + get :new, params: { account_id: Fabricate(:account).id, report_id: Fabricate(:report).id } + expect(response).to have_http_status(200) + end + end + describe 'POST #create' do it 'redirects to admin accounts page' do account = Fabricate(:account, suspended: false) diff --git a/spec/controllers/admin/tags_controller_spec.rb b/spec/controllers/admin/tags_controller_spec.rb new file mode 100644 index 000000000..3af994071 --- /dev/null +++ b/spec/controllers/admin/tags_controller_spec.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Admin::TagsController, type: :controller do + render_views + + before do + sign_in Fabricate(:user, admin: true) + end + + describe 'GET #index' do + before do + account_tag_stat = Fabricate(:tag).account_tag_stat + account_tag_stat.update(hidden: hidden, accounts_count: 1) + get :index, params: { hidden: hidden } + end + + context 'with hidden tags' do + let(:hidden) { true } + + it 'returns status 200' do + expect(response).to have_http_status(200) + end + end + + context 'without hidden tags' do + let(:hidden) { false } + + it 'returns status 200' do + expect(response).to have_http_status(200) + end + end + end + + describe 'POST #hide' do + let(:tag) { Fabricate(:tag) } + + before do + tag.account_tag_stat.update(hidden: false) + post :hide, params: { id: tag.id } + end + + it 'hides tag' do + tag.reload + expect(tag).to be_hidden + end + + it 'redirects to admin_tags_path' do + expect(response).to redirect_to(admin_tags_path(controller.instance_variable_get(:@filter_params))) + end + end + + describe 'POST #unhide' do + let(:tag) { Fabricate(:tag) } + + before do + tag.account_tag_stat.update(hidden: true) + post :unhide, params: { id: tag.id } + end + + it 'unhides tag' do + tag.reload + expect(tag).not_to be_hidden + end + + it 'redirects to admin_tags_path' do + expect(response).to redirect_to(admin_tags_path(controller.instance_variable_get(:@filter_params))) + end + end +end |