Skip to content

Commit

Permalink
Move HOST_DISPLAY config into rubygems.yml
Browse files Browse the repository at this point in the history
Remove unused env in rubygems.yml
  • Loading branch information
martinemde authored and simi committed Dec 4, 2024
1 parent 9a7a35c commit e92d5ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def self.config
DEFAULT_PAGINATION = 20
EMAIL_TOKEN_EXPIRES_AFTER = 3.hours
HOST = config["host"].freeze
HOST_DISPLAY = Rails.env.production? || Rails.env.development? || Rails.env.test? ? "RubyGems.org" : "RubyGems.org #{Rails.env}"
HOST_DISPLAY = Gemcutter.config[:host_display].freeze
NEWS_DAYS_LIMIT = 7.days
NEWS_MAX_PAGES = 10
NEWS_PER_PAGE = 10
Expand Down
14 changes: 4 additions & 10 deletions config/rubygems.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
development:
protocol: http
host: localhost
host_display: RubyGems.org
s3_bucket: s3bucket
s3_contents_bucket: contents
s3_compact_index_bucket: compact-index
Expand All @@ -11,6 +12,7 @@ development:
test:
protocol: http
host: localhost
host_display: RubyGems.org
s3_bucket: test.s3.rubygems.org
s3_contents_bucket: contents.test.s3.rubygems.org
s3_compact_index_bucket: compact-index.test.s3.rubygems.org
Expand All @@ -21,6 +23,7 @@ test:
staging:
protocol: https
host: staging.rubygems.org
host_display: RubyGems.org Staging
s3_bucket: oregon.staging.s3.rubygems.org
s3_region: us-west-2
s3_endpoint: s3-us-west-2.amazonaws.com
Expand All @@ -31,20 +34,11 @@ staging:
production:
protocol: https
host: rubygems.org
host_display: RubyGems.org
s3_bucket: oregon.production.s3.rubygems.org
s3_region: us-west-2
s3_endpoint: s3-us-west-2.amazonaws.com
s3_contents_bucket: contents.oregon.production.s3.rubygems.org
s3_compact_index_bucket: compact-index.oregon.production.s3.rubygems.org
versions_file_location: "./config/versions.list"
separate_admin_host: rubygems.team

oidc-api-token:
protocol: https
host: oidc-api-token.rubygems.org
s3_bucket: oregon.oidc-api-token.s3.rubygems.org
s3_region: us-west-2
s3_endpoint: s3-us-west-2.amazonaws.com
s3_contents_bucket: contents.oregon.oidc-api-token.s3.rubygems.org
s3_compact_index_bucket: compact-index.oregon.oidc-api-token.s3.rubygems.org
versions_file_location: "./config/versions.list"
28 changes: 28 additions & 0 deletions test/config/gemcutter_config_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require "test_helper"

# These tests just spot check to make sure config is loaded correctly and the file is not broken or missing
class GemcutterConfigTest < ActiveSupport::TestCase
context "Gemcutter.config[:host_display]" do
should "be set for test environment" do
assert_equal "RubyGems.org", Gemcutter.config[:host_display]
end

should "have a setting for each regularly used environment" do
assert_equal "RubyGems.org", Gemcutter::Application.config_for(:rubygems, env: "development").fetch(:host_display)
assert_equal "RubyGems.org", Gemcutter::Application.config_for(:rubygems, env: "production").fetch(:host_display)
assert_equal "RubyGems.org Staging", Gemcutter::Application.config_for(:rubygems, env: "staging").fetch(:host_display)
end
end

context "Gemcutter.config[:host]" do
should "be set for test environment" do
assert_equal "localhost", Gemcutter.config[:host]
end

should "have a setting for each regularly used environment" do
assert_equal "localhost", Gemcutter::Application.config_for(:rubygems, env: "development").fetch(:host)
assert_equal "rubygems.org", Gemcutter::Application.config_for(:rubygems, env: "production").fetch(:host)
assert_equal "staging.rubygems.org", Gemcutter::Application.config_for(:rubygems, env: "staging").fetch(:host)
end
end
end

0 comments on commit e92d5ed

Please sign in to comment.