mirror of
https://github.com/mastodon/mastodon.git
synced 2025-03-12 17:05:25 +00:00
Move feature flag test setup into config (#34124)
This commit is contained in:
parent
dc43699b77
commit
bedf808e02
|
@ -10,3 +10,5 @@ shared:
|
||||||
version:
|
version:
|
||||||
metadata: <%= ENV.fetch('MASTODON_VERSION_METADATA', nil) %>
|
metadata: <%= ENV.fetch('MASTODON_VERSION_METADATA', nil) %>
|
||||||
prerelease: <%= ENV.fetch('MASTODON_VERSION_PRERELEASE', nil) %>
|
prerelease: <%= ENV.fetch('MASTODON_VERSION_PRERELEASE', nil) %>
|
||||||
|
test:
|
||||||
|
experimental_features: <%= [ENV.fetch('EXPERIMENTAL_FEATURES', nil), 'testing_only'].compact.join(',') %>
|
||||||
|
|
|
@ -19,8 +19,8 @@ module Mastodon::Feature
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
def respond_to_missing?(name)
|
def respond_to_missing?(name, include_all = false)
|
||||||
name.to_s.end_with?('_enabled?')
|
name.to_s.end_with?('_enabled?') || super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,28 +3,23 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Mastodon::Feature do
|
RSpec.describe Mastodon::Feature do
|
||||||
around do |example|
|
describe '::testing_only_enabled?' do
|
||||||
original_value = Rails.configuration.x.mastodon.experimental_features
|
subject { described_class.testing_only_enabled? }
|
||||||
Rails.configuration.x.mastodon.experimental_features = 'fasp,fetch_all_replies'
|
|
||||||
example.run
|
|
||||||
Rails.configuration.x.mastodon.experimental_features = original_value
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::fasp_enabled?' do
|
|
||||||
subject { described_class.fasp_enabled? }
|
|
||||||
|
|
||||||
it { is_expected.to be true }
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '::fetch_all_replies_enabled?' do
|
|
||||||
subject { described_class.fetch_all_replies_enabled? }
|
|
||||||
|
|
||||||
it { is_expected.to be true }
|
it { is_expected.to be true }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '::unspecified_feature_enabled?' do
|
describe '::unspecified_feature_enabled?' do
|
||||||
|
context 'when example is not tagged with a feature' do
|
||||||
subject { described_class.unspecified_feature_enabled? }
|
subject { described_class.unspecified_feature_enabled? }
|
||||||
|
|
||||||
it { is_expected.to be false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when example is tagged with a feature', feature: 'unspecified_feature' do
|
||||||
|
subject { described_class.unspecified_feature_enabled? }
|
||||||
|
|
||||||
|
it { is_expected.to be true }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
8
spec/support/feature_flags.rb
Normal file
8
spec/support/feature_flags.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
RSpec.configure do |config|
|
||||||
|
config.before(:example, :feature) do |example|
|
||||||
|
feature = example.metadata[:feature]
|
||||||
|
allow(Mastodon::Feature).to receive(:"#{feature}_enabled?").and_return(true)
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user