Merge remote-tracking branch 'parent/main' into upstream-20241119
This commit is contained in:
commit
055045981f
221 changed files with 2006 additions and 1127 deletions
|
@ -3,16 +3,6 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe AccountsHelper do
|
||||
def set_not_embedded_view
|
||||
params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}"
|
||||
params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}"
|
||||
end
|
||||
|
||||
def set_embedded_view
|
||||
params[:controller] = StatusesHelper::EMBEDDED_CONTROLLER
|
||||
params[:action] = StatusesHelper::EMBEDDED_ACTION
|
||||
end
|
||||
|
||||
describe '#display_name' do
|
||||
it 'uses the display name when it exists' do
|
||||
account = Account.new(display_name: 'Display', username: 'Username')
|
||||
|
@ -28,9 +18,8 @@ RSpec.describe AccountsHelper do
|
|||
end
|
||||
|
||||
describe '#acct' do
|
||||
it 'is fully qualified for embedded local accounts' do
|
||||
it 'is fully qualified for local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
@ -38,32 +27,12 @@ RSpec.describe AccountsHelper do
|
|||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
|
||||
it 'is fully qualified for embedded foreign accounts' do
|
||||
set_embedded_view
|
||||
it 'is fully qualified for remote accounts' do
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded foreign accounts' do
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: 'foreign_server.com', username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@foreign_server.com'
|
||||
end
|
||||
|
||||
it 'is fully qualified for non embedded local accounts' do
|
||||
allow(Rails.configuration.x).to receive(:local_domain).and_return('local_domain')
|
||||
set_not_embedded_view
|
||||
account = Account.new(domain: nil, username: 'user')
|
||||
|
||||
acct = helper.acct(account)
|
||||
|
||||
expect(acct).to eq '@user@local_domain'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -261,11 +261,11 @@ RSpec.describe ApplicationHelper do
|
|||
expect(helper.html_title).to be_html_safe
|
||||
end
|
||||
|
||||
it 'removes extra new lines' do
|
||||
it 'does not escape twice' do
|
||||
Setting.site_title = 'Site Title'
|
||||
helper.content_for(:page_title, "Test Value\n")
|
||||
helper.content_for(:page_title, '"Test Value"'.html_safe)
|
||||
|
||||
expect(helper.html_title).to eq 'Test Value - Site Title'
|
||||
expect(helper.html_title).to eq '"Test Value" - Site Title'
|
||||
expect(helper.html_title).to be_html_safe
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,19 +3,20 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SelfDestructHelper do
|
||||
describe 'self_destruct?' do
|
||||
describe '#self_destruct?' do
|
||||
before { Rails.configuration.x.mastodon.self_destruct_value = destruct_value }
|
||||
after { Rails.configuration.x.mastodon.self_destruct_value = nil }
|
||||
|
||||
context 'when SELF_DESTRUCT is unset' do
|
||||
let(:destruct_value) { nil }
|
||||
|
||||
it 'returns false' do
|
||||
expect(helper.self_destruct?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when SELF_DESTRUCT is set to an invalid value' do
|
||||
around do |example|
|
||||
ClimateControl.modify SELF_DESTRUCT: 'true' do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
let(:destruct_value) { 'true' }
|
||||
|
||||
it 'returns false' do
|
||||
expect(helper.self_destruct?).to be false
|
||||
|
@ -23,9 +24,10 @@ RSpec.describe SelfDestructHelper do
|
|||
end
|
||||
|
||||
context 'when SELF_DESTRUCT is set to value signed for the wrong purpose' do
|
||||
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier('foo').generate('example.com') }
|
||||
|
||||
around do |example|
|
||||
ClimateControl.modify(
|
||||
SELF_DESTRUCT: Rails.application.message_verifier('foo').generate('example.com'),
|
||||
LOCAL_DOMAIN: 'example.com'
|
||||
) do
|
||||
example.run
|
||||
|
@ -38,9 +40,10 @@ RSpec.describe SelfDestructHelper do
|
|||
end
|
||||
|
||||
context 'when SELF_DESTRUCT is set to value signed for the wrong domain' do
|
||||
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier(described_class::VERIFY_PURPOSE).generate('foo.com') }
|
||||
|
||||
around do |example|
|
||||
ClimateControl.modify(
|
||||
SELF_DESTRUCT: Rails.application.message_verifier('self-destruct').generate('foo.com'),
|
||||
LOCAL_DOMAIN: 'example.com'
|
||||
) do
|
||||
example.run
|
||||
|
@ -53,9 +56,10 @@ RSpec.describe SelfDestructHelper do
|
|||
end
|
||||
|
||||
context 'when SELF_DESTRUCT is set to a correctly-signed value' do
|
||||
let(:destruct_value) { Rails.configuration.x.mastodon.self_destruct_value = Rails.application.message_verifier(described_class::VERIFY_PURPOSE).generate('example.com') }
|
||||
|
||||
around do |example|
|
||||
ClimateControl.modify(
|
||||
SELF_DESTRUCT: Rails.application.message_verifier('self-destruct').generate('example.com'),
|
||||
LOCAL_DOMAIN: 'example.com'
|
||||
) do
|
||||
example.run
|
||||
|
|
|
@ -107,28 +107,4 @@ RSpec.describe StatusesHelper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#stream_link_target' do
|
||||
it 'returns nil if it is not an embedded view' do
|
||||
set_not_embedded_view
|
||||
|
||||
expect(helper.stream_link_target).to be_nil
|
||||
end
|
||||
|
||||
it 'returns _blank if it is an embedded view' do
|
||||
set_embedded_view
|
||||
|
||||
expect(helper.stream_link_target).to eq '_blank'
|
||||
end
|
||||
end
|
||||
|
||||
def set_not_embedded_view
|
||||
params[:controller] = "not_#{StatusesHelper::EMBEDDED_CONTROLLER}"
|
||||
params[:action] = "not_#{StatusesHelper::EMBEDDED_ACTION}"
|
||||
end
|
||||
|
||||
def set_embedded_view
|
||||
params[:controller] = StatusesHelper::EMBEDDED_CONTROLLER
|
||||
params[:action] = StatusesHelper::EMBEDDED_ACTION
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue