1
0
Fork 0
forked from gitea/nas

Merge commit '45ba9ada34' into kb_migration_development

This commit is contained in:
KMY 2023-05-17 20:06:53 +09:00
commit 922c936ef1
26 changed files with 336 additions and 18 deletions

View file

@ -63,4 +63,72 @@ RSpec.describe Api::V1::Emails::ConfirmationsController do
end
end
end
describe '#check' do
let(:scopes) { 'read' }
context 'with an oauth token' do
before do
allow(controller).to receive(:doorkeeper_token) { token }
end
context 'when the account is not confirmed' do
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns false' do
get :check
expect(body_as_json).to be false
end
end
context 'when the account is confirmed' do
let(:confirmed_at) { Time.now.utc }
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns true' do
get :check
expect(body_as_json).to be true
end
end
end
context 'with an authentication cookie' do
before do
sign_in user, scope: :user
end
context 'when the account is not confirmed' do
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns false' do
get :check
expect(body_as_json).to be false
end
end
context 'when the account is confirmed' do
let(:confirmed_at) { Time.now.utc }
it 'returns http success' do
get :check
expect(response).to have_http_status(200)
end
it 'returns true' do
get :check
expect(body_as_json).to be true
end
end
end
end
end

View file

@ -0,0 +1,63 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Form::AccountBatch do
let(:account_batch) { described_class.new }
describe '#save' do
subject { account_batch.save }
let(:account) { Fabricate(:user, role: UserRole.find_by(name: 'Admin')).account }
let(:account_ids) { [] }
let(:query) { Account.none }
before do
account_batch.assign_attributes(
action: action,
current_account: account,
account_ids: account_ids,
query: query,
select_all_matching: select_all_matching
)
end
context 'when action is "suspend"' do
let(:action) { 'suspend' }
let(:target_account) { Fabricate(:account) }
let(:target_account2) { Fabricate(:account) }
before do
Fabricate(:report, target_account: target_account)
Fabricate(:report, target_account: target_account2)
end
context 'when accounts are passed as account_ids' do
let(:select_all_matching) { '0' }
let(:account_ids) { [target_account.id, target_account2.id] }
it 'suspends the expected users' do
expect { subject }.to change { [target_account.reload.suspended?, target_account2.reload.suspended?] }.from([false, false]).to([true, true])
end
it 'closes open reports targeting the suspended users' do
expect { subject }.to change { Report.unresolved.where(target_account: [target_account, target_account2]).count }.from(2).to(0)
end
end
context 'when accounts are passed as a query' do
let(:select_all_matching) { '1' }
let(:query) { Account.where(id: [target_account.id, target_account2.id]) }
it 'suspends the expected users' do
expect { subject }.to change { [target_account.reload.suspended?, target_account2.reload.suspended?] }.from([false, false]).to([true, true])
end
it 'closes open reports targeting the suspended users' do
expect { subject }.to change { Report.unresolved.where(target_account: [target_account, target_account2]).count }.from(2).to(0)
end
end
end
end
end