DEV: Allow new_features URL to be configurable (#24306)

This is so the new features plugin can be tested
easier locally.
This commit is contained in:
Martin Brennan 2023-11-09 13:50:21 +10:00 committed by GitHub
parent e5e7dd78c2
commit e772bb9fce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -218,6 +218,11 @@ module DiscourseUpdates
)
end
def new_features_endpoint
return "https://meta.discourse.org/new-features.json" if Rails.env.production?
ENV["DISCOURSE_NEW_FEATURES_ENDPOINT"] || "http://localhost:4200/new-features.json"
end
private
def last_installed_version_key
@ -248,10 +253,6 @@ module DiscourseUpdates
"missing_version"
end
def new_features_endpoint
"https://meta.discourse.org/new-features.json"
end
def new_features_key
"new_features"
end

View File

@ -15,8 +15,8 @@ RSpec.describe Jobs::CheckNewFeatures do
}
end
def stub_meta_new_features_endpoint(*features)
stub_request(:get, "https://meta.discourse.org/new-features.json").to_return(
def stub_new_features_endpoint(*features)
stub_request(:get, DiscourseUpdates.new_features_endpoint).to_return(
status: 200,
body: JSON.dump(features),
headers: {
@ -43,7 +43,7 @@ RSpec.describe Jobs::CheckNewFeatures do
before do
DiscourseUpdates.stubs(:current_version).returns("2.8.1.beta13")
freeze_time
stub_meta_new_features_endpoint(feature1, feature2, pending_feature)
stub_new_features_endpoint(feature1, feature2, pending_feature)
end
after { DiscourseUpdates.clean_state }