mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Use system spec for button clicks
This commit is contained in:
parent
f1b6f2fc78
commit
030f22678f
23
spec/requests/admin/accounts/avatar_spec.rb
Normal file
23
spec/requests/admin/accounts/avatar_spec.rb
Normal file
|
@ -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
|
|
@ -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
|
23
spec/requests/admin/accounts/header_spec.rb
Normal file
23
spec/requests/admin/accounts/header_spec.rb
Normal file
|
@ -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
|
|
@ -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
|
27
spec/system/admin/accounts/avatar_spec.rb
Normal file
27
spec/system/admin/accounts/avatar_spec.rb
Normal file
|
@ -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
|
27
spec/system/admin/accounts/header_spec.rb
Normal file
27
spec/system/admin/accounts/header_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in New Issue
Block a user