diff --git a/spec/controllers/admin/accounts/avatars_controller_spec.rb b/spec/controllers/admin/accounts/avatars_controller_spec.rb index 9559c9945c0..2eb1dedaf7e 100644 --- a/spec/controllers/admin/accounts/avatars_controller_spec.rb +++ b/spec/controllers/admin/accounts/avatars_controller_spec.rb @@ -11,13 +11,17 @@ RSpec.describe Admin::Accounts::AvatarsController do subject { delete :destroy, params: { account_id: account.id } } let(:current_user) { Fabricate(:user, role: role) } - let(:account) { Fabricate(:account) } + 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 redirect_to admin_account_path(account.id) + 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 @@ -25,7 +29,10 @@ RSpec.describe Admin::Accounts::AvatarsController do let(:role) { UserRole.everyone } it 'fails to remove avatar' do - expect(subject).to have_http_status 403 + subject + + expect(response) + .to have_http_status 403 end end end diff --git a/spec/controllers/admin/accounts/headers_controller_spec.rb b/spec/controllers/admin/accounts/headers_controller_spec.rb index f4c2e8c461f..161b138d7e4 100644 --- a/spec/controllers/admin/accounts/headers_controller_spec.rb +++ b/spec/controllers/admin/accounts/headers_controller_spec.rb @@ -11,13 +11,17 @@ RSpec.describe Admin::Accounts::HeadersController do subject { delete :destroy, params: { account_id: account.id } } let(:current_user) { Fabricate(:user, role: role) } - let(:account) { Fabricate(:account) } + 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 redirect_to admin_account_path(account.id) + 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 @@ -25,7 +29,10 @@ RSpec.describe Admin::Accounts::HeadersController do let(:role) { UserRole.everyone } it 'fails to remove header' do - expect(subject).to have_http_status 403 + subject + + expect(response) + .to have_http_status 403 end end end