mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Merge commit 'f1a6f4333a75f5bc186334f7f43a26e969cd712d' into glitch-soc/merge-upstream
This commit is contained in:
@@ -43,7 +43,7 @@ RSpec.describe Oauth::AuthorizedApplicationsController do
|
||||
let!(:application) { Fabricate(:application) }
|
||||
let!(:access_token) { Fabricate(:accessible_access_token, application: application, resource_owner_id: user.id) }
|
||||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, user: user, access_token: access_token) }
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::Namespace, publish: nil) }
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::PipelinedConnection, publish: nil) }
|
||||
|
||||
before do
|
||||
sign_in user, scope: :user
|
||||
|
||||
8
spec/fabricators/rule_translation_fabricator.rb
Normal file
8
spec/fabricators/rule_translation_fabricator.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Fabricator(:rule_translation) do
|
||||
text 'MyText'
|
||||
hint 'MyText'
|
||||
language 'en'
|
||||
rule { Fabricate.build(:rule) }
|
||||
end
|
||||
@@ -26,20 +26,6 @@ RSpec.describe Mastodon::RedisConfiguration do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'setting a namespace' do
|
||||
context 'when setting the `REDIS_NAMESPACE` variable' do
|
||||
around do |example|
|
||||
ClimateControl.modify REDIS_NAMESPACE: 'testns' do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
it 'uses the value for the namespace' do
|
||||
expect(subject[:namespace]).to eq 'testns'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'secondary configuration' do |prefix|
|
||||
context "when no `#{prefix}_REDIS_` environment variables are present" do
|
||||
it 'uses the url from the base config' do
|
||||
@@ -208,7 +194,6 @@ RSpec.describe Mastodon::RedisConfiguration do
|
||||
end
|
||||
|
||||
it_behaves_like 'setting a different driver'
|
||||
it_behaves_like 'setting a namespace'
|
||||
it_behaves_like 'sentinel support'
|
||||
end
|
||||
|
||||
@@ -217,7 +202,6 @@ RSpec.describe Mastodon::RedisConfiguration do
|
||||
|
||||
it_behaves_like 'secondary configuration', 'SIDEKIQ'
|
||||
it_behaves_like 'setting a different driver'
|
||||
it_behaves_like 'setting a namespace'
|
||||
it_behaves_like 'sentinel support', 'SIDEKIQ'
|
||||
end
|
||||
|
||||
@@ -238,22 +222,8 @@ RSpec.describe Mastodon::RedisConfiguration do
|
||||
})
|
||||
end
|
||||
|
||||
context 'when `REDIS_NAMESPACE` is not set' do
|
||||
it 'uses the `cache` namespace' do
|
||||
expect(subject[:namespace]).to eq 'cache'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when setting the `REDIS_NAMESPACE` variable' do
|
||||
around do |example|
|
||||
ClimateControl.modify REDIS_NAMESPACE: 'testns' do
|
||||
example.run
|
||||
end
|
||||
end
|
||||
|
||||
it 'attaches the `_cache` postfix to the namespace' do
|
||||
expect(subject[:namespace]).to eq 'testns_cache'
|
||||
end
|
||||
it 'uses the `cache` namespace' do
|
||||
expect(subject[:namespace]).to eq 'cache'
|
||||
end
|
||||
|
||||
it_behaves_like 'secondary configuration', 'CACHE'
|
||||
|
||||
@@ -16,4 +16,24 @@ RSpec.describe Rule do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#move!' do
|
||||
let!(:first_rule) { Fabricate(:rule, text: 'foo') }
|
||||
let!(:second_rule) { Fabricate(:rule, text: 'bar') }
|
||||
let!(:third_rule) { Fabricate(:rule, text: 'baz') }
|
||||
|
||||
it 'moves the rules as expected' do
|
||||
expect { first_rule.move!(+1) }
|
||||
.to change { described_class.ordered.pluck(:text) }.from(%w(foo bar baz)).to(%w(bar foo baz))
|
||||
|
||||
expect { first_rule.move!(-1) }
|
||||
.to change { described_class.ordered.pluck(:text) }.from(%w(bar foo baz)).to(%w(foo bar baz))
|
||||
|
||||
expect { third_rule.move!(-1) }
|
||||
.to change { described_class.ordered.pluck(:text) }.from(%w(foo bar baz)).to(%w(foo baz bar))
|
||||
|
||||
expect { second_rule.move!(-1) }
|
||||
.to change { described_class.ordered.pluck(:text) }.from(%w(foo baz bar)).to(%w(foo bar baz))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,17 +11,6 @@ RSpec.describe User do
|
||||
|
||||
it_behaves_like 'two_factor_backupable'
|
||||
|
||||
describe 'legacy_otp_secret' do
|
||||
it 'is encrypted with OTP_SECRET environment variable' do
|
||||
user = Fabricate(:user,
|
||||
encrypted_otp_secret: "Fttsy7QAa0edaDfdfSz094rRLAxc8cJweDQ4BsWH/zozcdVA8o9GLqcKhn2b\nGi/V\n",
|
||||
encrypted_otp_secret_iv: 'rys3THICkr60BoWC',
|
||||
encrypted_otp_secret_salt: '_LMkAGvdg7a+sDIKjI3mR2Q==')
|
||||
|
||||
expect(user.send(:legacy_otp_secret)).to eq 'anotpsecretthatshouldbeencrypted'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'otp_secret' do
|
||||
it 'encrypts the saved value' do
|
||||
user = Fabricate(:user, otp_secret: '123123123')
|
||||
@@ -489,7 +478,7 @@ RSpec.describe User do
|
||||
let!(:access_token) { Fabricate(:access_token, resource_owner_id: user.id) }
|
||||
let!(:web_push_subscription) { Fabricate(:web_push_subscription, access_token: access_token) }
|
||||
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::Namespace, publish: nil) }
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::PipelinedConnection, publish: nil) }
|
||||
|
||||
before { stub_redis }
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ RSpec.describe REST::RuleSerializer do
|
||||
it 'returns expected values' do
|
||||
expect(subject)
|
||||
.to include(
|
||||
'id' => be_a(String).and(eq('123'))
|
||||
'id' => be_a(String).and(eq('123')),
|
||||
'translations' => be_a(Hash)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ class StreamingServerManager
|
||||
@running_thread = Thread.new do
|
||||
Open3.popen2e(
|
||||
{
|
||||
'REDIS_NAMESPACE' => REDIS_CONFIGURATION.base[:namespace],
|
||||
'REDIS_DB' => (ENV.fetch('TEST_ENV_NUMBER', 0).to_i + 1).to_s,
|
||||
'DB_NAME' => "#{ENV.fetch('DB_NAME', 'mastodon')}_test#{ENV.fetch('TEST_ENV_NUMBER', '')}",
|
||||
'RAILS_ENV' => ENV.fetch('RAILS_ENV', 'test'),
|
||||
'NODE_ENV' => ENV.fetch('STREAMING_NODE_ENV', 'development'),
|
||||
|
||||
@@ -48,6 +48,29 @@ RSpec.describe 'Admin Rules' do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Moving down an existing rule' do
|
||||
let!(:first_rule) { Fabricate(:rule, text: 'This is another rule') }
|
||||
let!(:second_rule) { Fabricate(:rule, text: 'This is a rule') }
|
||||
|
||||
it 'moves the rule down' do
|
||||
visit admin_rules_path
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.rules.title'))
|
||||
|
||||
expect(Rule.ordered.pluck(:text)).to eq ['This is another rule', 'This is a rule']
|
||||
|
||||
click_on(I18n.t('admin.rules.move_down'))
|
||||
|
||||
expect(page)
|
||||
.to have_content(I18n.t('admin.rules.title'))
|
||||
.and have_content(first_rule.text)
|
||||
.and have_content(second_rule.text)
|
||||
|
||||
expect(Rule.ordered.pluck(:text)).to eq ['This is a rule', 'This is another rule']
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Editing an existing rule' do
|
||||
let!(:rule) { Fabricate :rule, text: 'Rule text' }
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ RSpec.describe 'Settings applications page' do
|
||||
end
|
||||
|
||||
describe 'Destroying an application' do
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::Namespace, publish: nil) }
|
||||
let(:redis_pipeline_stub) { instance_double(Redis::PipelinedConnection, publish: nil) }
|
||||
let!(:access_token) { Fabricate(:accessible_access_token, application: application) }
|
||||
|
||||
before { stub_redis_pipeline }
|
||||
|
||||
Reference in New Issue
Block a user