Skip to content

Commit f4b5be8

Browse files
committed
Use CompactIndexV2API in CompactIndexCooldownBadCreatedAt
1 parent 7e0132a commit f4b5be8

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

spec/install/cooldown_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,31 +217,31 @@ def gemrc_cooldown(days)
217217
it "applies it when bundler configures none of its own" do
218218
gemrc_cooldown 7
219219

220-
bundle "install", artifice: "compact_index_cooldown"
220+
bundle "install", artifice: "compact_index_v2"
221221

222222
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
223223
end
224224

225225
it "takes the longer of the two settings" do
226226
gemrc_cooldown 7
227227

228-
bundle "install", env: { "BUNDLE_COOLDOWN" => "1" }, artifice: "compact_index_cooldown"
228+
bundle "install", env: { "BUNDLE_COOLDOWN" => "1" }, artifice: "compact_index_v2"
229229

230230
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
231231
end
232232

233233
it "counts a bundler-side 0 as a value rather than as unset" do
234234
gemrc_cooldown 7
235235

236-
bundle "install", env: { "BUNDLE_COOLDOWN" => "0" }, artifice: "compact_index_cooldown"
236+
bundle "install", env: { "BUNDLE_COOLDOWN" => "0" }, artifice: "compact_index_v2"
237237

238238
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
239239
end
240240

241241
it "counts a gemrc 0 as a value rather than as unset" do
242242
gemrc_cooldown 0
243243

244-
bundle "install", env: { "BUNDLE_COOLDOWN" => "7" }, artifice: "compact_index_cooldown"
244+
bundle "install", env: { "BUNDLE_COOLDOWN" => "7" }, artifice: "compact_index_v2"
245245

246246
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
247247
end
@@ -254,23 +254,23 @@ def gemrc_cooldown(days)
254254
gem "ripe_gem"
255255
G
256256

257-
bundle "install", artifice: "compact_index_cooldown"
257+
bundle "install", artifice: "compact_index_v2"
258258

259259
expect(the_bundle).to include_gems("ripe_gem 1.0.0")
260260
end
261261

262262
it "lets --cooldown 0 bypass it" do
263263
gemrc_cooldown 7
264264

265-
bundle "install --cooldown 0", artifice: "compact_index_cooldown"
265+
bundle "install --cooldown 0", artifice: "compact_index_v2"
266266

267267
expect(the_bundle).to include_gems("ripe_gem 2.0.0")
268268
end
269269

270270
it "warns and ignores it when it is not a number" do
271271
gemrc_cooldown "seven"
272272

273-
bundle "install", artifice: "compact_index_cooldown"
273+
bundle "install", artifice: "compact_index_v2"
274274

275275
expect(err).to include('Invalid cooldown value "seven" in the gemrc file, so it is ignored.')
276276
expect(the_bundle).to include_gems("ripe_gem 2.0.0")

spec/support/artifice/compact_index_cooldown_bad_created_at.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# frozen_string_literal: true
22

3-
require_relative "helpers/compact_index_cooldown"
3+
require_relative "helpers/compact_index_v2"
44

55
# Serves every version with a created_at year that Time.iso8601 accepts but
66
# whose distance from now overflows Float.
7-
class CompactIndexCooldownBadCreatedAt < CompactIndexCooldownAPI
7+
class CompactIndexCooldownBadCreatedAt < CompactIndexV2API
88
helpers do
99
def build_gem_version(spec, deps, checksum)
10-
CompactIndex::GemVersionV2.new(spec.version.version, spec.platform.to_s, checksum, nil,
11-
deps, spec.required_ruby_version.to_s, spec.required_rubygems_version.to_s, "#{"9" * 400}-01-01T00:00:00Z")
10+
# The system-RubyGems jobs run this artifice against a Gem::Specification
11+
# that predates the content-addressable accessors.
12+
ruby_abi = spec.ruby_abi if spec.respond_to?(:ruby_abi)
13+
content_address = spec.content_address if spec.respond_to?(:content_address)
14+
VendoredCompactIndex::GemVersionV2.new(spec.version.version, spec.platform.to_s, checksum, nil,
15+
deps, spec.required_ruby_version.to_s, spec.required_rubygems_version.to_s, "#{"9" * 400}-01-01T00:00:00Z",
16+
ruby_abi, content_address)
1217
end
1318
end
1419
end

0 commit comments

Comments
 (0)