diff --git a/spec/requests/admin/accounts/avatar_spec.rb b/spec/requests/admin/accounts/avatar_spec.rb new file mode 100644 index 00000000000..95292fdd04e --- /dev/null +++ b/spec/requests/admin/accounts/avatar_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Admin Accounts Avatar' do + before { sign_in user } + + describe 'DELETE #destroy' do + let(:user) { Fabricate(:user, role: role) } + let(:account) { Fabricate(:account, avatar: fixture_file_upload('avatar.gif', 'image/gif')) } + + context 'when user is not admin' do + let(:role) { UserRole.everyone } + + it 'fails to remove avatar' do + delete "/admin/accounts/#{account.id}/avatar" + + expect(response) + .to have_http_status 403 + end + end + end +end diff --git a/spec/requests/admin/accounts/avatars_spec.rb b/spec/requests/admin/accounts/avatars_spec.rb deleted file mode 100644 index b3c9eb28b1e..00000000000 --- a/spec/requests/admin/accounts/avatars_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'Admin Accounts Avatars' do - before { sign_in current_user } - - describe 'DELETE #destroy' do - subject { delete "/admin/accounts/#{account.id}/avatar" } - - let(:current_user) { Fabricate(:user, role: role) } - let(:account) { Fabricate(:account, avatar: fixture_file_upload('avatar.gif', 'image/gif')) } - - context 'when user is admin' do - let(:role) { UserRole.find_by(name: 'Admin') } - - it 'succeeds in removing avatar' do - expect { subject } - .to change { account.reload.avatar_file_name }.to(be_blank) - .and change(Admin::ActionLog, :count).by(1) - expect(response) - .to redirect_to admin_account_path(account.id) - end - end - - context 'when user is not admin' do - let(:role) { UserRole.everyone } - - it 'fails to remove avatar' do - subject - - expect(response) - .to have_http_status 403 - end - end - end -end diff --git a/spec/requests/admin/accounts/header_spec.rb b/spec/requests/admin/accounts/header_spec.rb new file mode 100644 index 00000000000..5582e8c28dd --- /dev/null +++ b/spec/requests/admin/accounts/header_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Admin Accounts Header' do + before { sign_in user } + + describe 'DELETE #destroy' do + let(:user) { Fabricate(:user, role: role) } + let(:account) { Fabricate(:account, header: fixture_file_upload('attachment.jpg', 'image/jpeg')) } + + context 'when user is not admin' do + let(:role) { UserRole.everyone } + + it 'fails to remove header' do + delete "/admin/accounts/#{account.id}/header" + + expect(response) + .to have_http_status 403 + end + end + end +end diff --git a/spec/requests/admin/accounts/headers_spec.rb b/spec/requests/admin/accounts/headers_spec.rb deleted file mode 100644 index 4fec01e98a3..00000000000 --- a/spec/requests/admin/accounts/headers_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'Admin Accounts Headers' do - before { sign_in current_user } - - describe 'DELETE #destroy' do - subject { delete "/admin/accounts/#{account.id}/header" } - - let(:current_user) { Fabricate(:user, role: role) } - let(:account) { Fabricate(:account, header: fixture_file_upload('attachment.jpg', 'image/jpeg')) } - - context 'when user is admin' do - let(:role) { UserRole.find_by(name: 'Admin') } - - it 'succeeds in removing header' do - expect { subject } - .to change { account.reload.header_file_name }.to(be_blank) - .and change(Admin::ActionLog, :count).by(1) - expect(response) - .to redirect_to admin_account_path(account.id) - end - end - - context 'when user is not admin' do - let(:role) { UserRole.everyone } - - it 'fails to remove header' do - subject - - expect(response) - .to have_http_status 403 - end - end - end -end diff --git a/spec/system/admin/accounts/avatar_spec.rb b/spec/system/admin/accounts/avatar_spec.rb new file mode 100644 index 00000000000..933dbc6b71a --- /dev/null +++ b/spec/system/admin/accounts/avatar_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Admin Accounts Avatar' do + before { sign_in user } + + let(:user) { Fabricate(:admin_user) } + + describe 'Deleting an account avatar' do + let(:account) { Fabricate(:account, avatar: fixture_file_upload('avatar.gif', 'image/gif')) } + + it 'succeeds in removing avatar' do + visit admin_account_path(account.id) + + expect { submit_delete } + .to change { account.reload.avatar_file_name }.to(be_blank) + .and change(Admin::ActionLog, :count).by(1) + expect(page) + .to have_content I18n.t('admin.accounts.removed_avatar_msg', username: account.acct) + end + + def submit_delete + click_on I18n.t('admin.accounts.remove_avatar') + end + end +end diff --git a/spec/system/admin/accounts/header_spec.rb b/spec/system/admin/accounts/header_spec.rb new file mode 100644 index 00000000000..cc9d4d4c068 --- /dev/null +++ b/spec/system/admin/accounts/header_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe 'Admin Accounts Header' do + before { sign_in user } + + let(:user) { Fabricate(:admin_user) } + + describe 'Deleting an account header' do + let(:account) { Fabricate(:account, header: fixture_file_upload('attachment.jpg', 'image/jpeg')) } + + it 'succeeds in removing header' do + visit admin_account_path(account.id) + + expect { submit_delete } + .to change { account.reload.header_file_name }.to(be_blank) + .and change(Admin::ActionLog, :count).by(1) + expect(page) + .to have_content I18n.t('admin.accounts.removed_header_msg', username: account.acct) + end + + def submit_delete + click_on I18n.t('admin.accounts.remove_header') + end + end +end