Merge remote-tracking branch 'parent/main' into upstream-20241026
This commit is contained in:
commit
0c99b8fbb0
79 changed files with 2403 additions and 2056 deletions
|
@ -231,28 +231,6 @@ RSpec.describe ApplicationHelper do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'visibility_icon' do
|
||||
it 'returns a globe icon for a public visible status' do
|
||||
result = helper.visibility_icon Status.new(visibility: 'public')
|
||||
expect(result).to match(/globe/)
|
||||
end
|
||||
|
||||
it 'returns an unlock icon for a unlisted visible status' do
|
||||
result = helper.visibility_icon Status.new(visibility: 'unlisted')
|
||||
expect(result).to match(/lock_open/)
|
||||
end
|
||||
|
||||
it 'returns a lock icon for a private visible status' do
|
||||
result = helper.visibility_icon Status.new(visibility: 'private')
|
||||
expect(result).to match(/lock/)
|
||||
end
|
||||
|
||||
it 'returns an at icon for a direct visible status' do
|
||||
result = helper.visibility_icon Status.new(visibility: 'direct')
|
||||
expect(result).to match(/alternate_email/)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'title' do
|
||||
it 'returns site title on production environment' do
|
||||
Setting.site_title = 'site title'
|
||||
|
|
61
spec/helpers/database_helper_spec.rb
Normal file
61
spec/helpers/database_helper_spec.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DatabaseHelper do
|
||||
context 'when a replica is enabled' do
|
||||
around do |example|
|
||||
ClimateControl.modify REPLICA_DB_NAME: 'prod-relay-quantum-tunnel-mirror' do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
before { allow(ApplicationRecord).to receive(:connected_to) }
|
||||
|
||||
describe '#with_read_replica' do
|
||||
it 'uses the replica for connections' do
|
||||
helper.with_read_replica { _x = 1 }
|
||||
|
||||
expect(ApplicationRecord)
|
||||
.to have_received(:connected_to).with(role: :reading, prevent_writes: true)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#with_primary' do
|
||||
it 'uses the primary for connections' do
|
||||
helper.with_primary { _x = 1 }
|
||||
|
||||
expect(ApplicationRecord)
|
||||
.to have_received(:connected_to).with(role: :writing)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a replica is not enabled' do
|
||||
around do |example|
|
||||
ClimateControl.modify REPLICA_DB_NAME: nil do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
before { allow(ApplicationRecord).to receive(:connected_to) }
|
||||
|
||||
describe '#with_read_replica' do
|
||||
it 'does not use the replica for connections' do
|
||||
helper.with_read_replica { _x = 1 }
|
||||
|
||||
expect(ApplicationRecord)
|
||||
.to_not have_received(:connected_to).with(role: :reading, prevent_writes: true)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#with_primary' do
|
||||
it 'does not use the primary for connections' do
|
||||
helper.with_primary { _x = 1 }
|
||||
|
||||
expect(ApplicationRecord)
|
||||
.to_not have_received(:connected_to).with(role: :writing)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -47,6 +47,26 @@ RSpec.describe StatusesHelper do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with a status that is public_unlisted' do
|
||||
let(:status) { Status.new(visibility: 'public_unlisted') }
|
||||
|
||||
it 'returns the correct fa icon' do
|
||||
result = helper.visibility_icon(status)
|
||||
|
||||
expect(result).to match('cloud')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a status that is login' do
|
||||
let(:status) { Status.new(visibility: 'login') }
|
||||
|
||||
it 'returns the correct fa icon' do
|
||||
result = helper.visibility_icon(status)
|
||||
|
||||
expect(result).to match('key')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a status that is unlisted' do
|
||||
let(:status) { Status.new(visibility: 'unlisted') }
|
||||
|
||||
|
@ -76,6 +96,16 @@ RSpec.describe StatusesHelper do
|
|||
expect(result).to match('alternate_email')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a status that is limited' do
|
||||
let(:status) { Status.new(visibility: 'limited') }
|
||||
|
||||
it 'returns the correct fa icon' do
|
||||
result = helper.visibility_icon(status)
|
||||
|
||||
expect(result).to match('shield')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#stream_link_target' do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue