Merge remote-tracking branch 'parent/main' into upstream-20240216
This commit is contained in:
commit
d000e56393
50 changed files with 250 additions and 131 deletions
|
@ -19,12 +19,10 @@ describe 'email confirmation flow when captcha is enabled' do
|
|||
# It presents the user with a captcha form
|
||||
expect(page).to have_title(I18n.t('auth.captcha_confirmation.title'))
|
||||
|
||||
# It does not confirm the user just yet
|
||||
expect(user.reload.confirmed?).to be false
|
||||
|
||||
# It redirects to app and confirms user
|
||||
click_on I18n.t('challenge.confirm')
|
||||
expect(user.reload.confirmed?).to be true
|
||||
expect { click_on I18n.t('challenge.confirm') }
|
||||
.to change { user.reload.confirmed? }.from(false).to(true)
|
||||
|
||||
expect(page).to have_current_path(/\A#{client_app.confirmation_redirect_uri}/, url: true)
|
||||
|
||||
# Browsers will generally reload the original page upon redirection
|
||||
|
@ -32,8 +30,9 @@ describe 'email confirmation flow when captcha is enabled' do
|
|||
visit "/auth/confirmation?confirmation_token=#{user.confirmation_token}&redirect_to_app=true"
|
||||
|
||||
# It presents a page with a link to the app callback
|
||||
expect(page).to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
|
||||
expect(page).to have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
||||
expect(page)
|
||||
.to have_content(I18n.t('auth.confirmations.registration_complete', domain: 'cb6e6126.ngrok.io'))
|
||||
.and have_link(I18n.t('auth.confirmations.clicking_this_link'), href: client_app.confirmation_redirect_uri)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2145,12 +2145,15 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
it 'creates an encrypted message' do
|
||||
encrypted_message = target_device.encrypted_messages.reload.first
|
||||
|
||||
expect(encrypted_message).to_not be_nil
|
||||
expect(encrypted_message.from_device_id).to eq '1234'
|
||||
expect(encrypted_message.from_account).to eq sender
|
||||
expect(encrypted_message.type).to eq 1
|
||||
expect(encrypted_message.body).to eq 'Foo'
|
||||
expect(encrypted_message.digest).to eq 'Foo123'
|
||||
expect(encrypted_message)
|
||||
.to be_present
|
||||
.and have_attributes(
|
||||
from_device_id: eq('1234'),
|
||||
from_account: eq(sender),
|
||||
type: eq(1),
|
||||
body: eq('Foo'),
|
||||
digest: eq('Foo123')
|
||||
)
|
||||
end
|
||||
|
||||
it 'creates a message franking' do
|
||||
|
|
|
@ -224,7 +224,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
|||
end
|
||||
|
||||
it 'does not update the text, spoiler_text or edited_at' do
|
||||
expect { subject.call(status, json, json) }.to_not(change { s = status.reload; [s.text, s.spoiler_text, s.edited_at] })
|
||||
expect { subject.call(status, json, json) }
|
||||
.to_not(change { status.reload.attributes.slice('text', 'spoiler_text', 'edited_at').values })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -32,27 +32,27 @@ RSpec.describe PostStatusService, type: :service do
|
|||
let!(:future) { Time.now.utc + 2.hours }
|
||||
let!(:previous_status) { Fabricate(:status, account: account) }
|
||||
|
||||
it 'schedules a status' do
|
||||
status = subject.call(account, text: 'Hi future!', scheduled_at: future)
|
||||
expect(status).to be_a ScheduledStatus
|
||||
expect(status.scheduled_at).to eq future
|
||||
expect(status.params['text']).to eq 'Hi future!'
|
||||
end
|
||||
|
||||
it 'does not immediately create a status' do
|
||||
it 'schedules a status for future creation and does not create one immediately' do
|
||||
media = Fabricate(:media_attachment, account: account)
|
||||
status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future)
|
||||
|
||||
expect(status).to be_a ScheduledStatus
|
||||
expect(status.scheduled_at).to eq future
|
||||
expect(status.params['text']).to eq 'Hi future!'
|
||||
expect(status.params['media_ids']).to eq [media.id]
|
||||
expect(status)
|
||||
.to be_a(ScheduledStatus)
|
||||
.and have_attributes(
|
||||
scheduled_at: eq(future),
|
||||
params: include(
|
||||
'text' => eq('Hi future!'),
|
||||
'media_ids' => contain_exactly(media.id)
|
||||
)
|
||||
)
|
||||
expect(media.reload.status).to be_nil
|
||||
expect(Status.where(text: 'Hi future!')).to_not exist
|
||||
end
|
||||
|
||||
it 'does not change statuses count' do
|
||||
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }.to_not(change { [account.statuses_count, previous_status.replies_count] })
|
||||
it 'does not change statuses_count of account or replies_count of thread previous status' do
|
||||
expect { subject.call(account, text: 'Hi future!', scheduled_at: future, thread: previous_status) }
|
||||
.to not_change { account.statuses_count }
|
||||
.and(not_change { previous_status.replies_count })
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'rails_helper'
|
|||
|
||||
RSpec.describe BlacklistedEmailValidator do
|
||||
describe '#validate' do
|
||||
subject { described_class.new.validate(user); errors }
|
||||
subject { described_class.new.validate(user) }
|
||||
|
||||
let(:user) { instance_double(User, email: 'info@mail.com', sign_up_ip: '1.2.3.4', errors: errors) }
|
||||
let(:errors) { instance_double(ActiveModel::Errors, add: nil) }
|
||||
|
@ -18,7 +18,8 @@ RSpec.describe BlacklistedEmailValidator do
|
|||
let(:blocked_email) { true }
|
||||
|
||||
it 'adds error' do
|
||||
described_class.new.validate(user)
|
||||
subject
|
||||
|
||||
expect(errors).to have_received(:add).with(:email, :blocked).once
|
||||
end
|
||||
end
|
||||
|
@ -27,7 +28,8 @@ RSpec.describe BlacklistedEmailValidator do
|
|||
let(:blocked_email) { false }
|
||||
|
||||
it 'does not add errors' do
|
||||
described_class.new.validate(user)
|
||||
subject
|
||||
|
||||
expect(errors).to_not have_received(:add)
|
||||
end
|
||||
|
||||
|
@ -39,7 +41,8 @@ RSpec.describe BlacklistedEmailValidator do
|
|||
end
|
||||
|
||||
it 'adds error' do
|
||||
described_class.new.validate(user)
|
||||
subject
|
||||
|
||||
expect(errors).to have_received(:add).with(:email, :taken).once
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue