Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

rubygems.org's db uses platform from index and not from spec

* add a way to clear the gem cache for tests
* we still want to insert/update the records for yanked gems if they're
being added
  • Loading branch information...
commit 2aff17024fe1b60854e06f9ef6dc99fcd6cd5ea8 1 parent 4e82c60
@hone hone authored
Showing with 15 additions and 5 deletions.
  1. +8 −2 lib/bundler_api/update/job.rb
  2. +7 −3 spec/update/job_spec.rb
View
10 lib/bundler_api/update/job.rb
@@ -23,6 +23,10 @@ def run
end
end
+ def self.clear_cache
+ @@gem_cache.clear
+ end
+
private
def gem_exists?
key = @payload.full_name
@@ -39,6 +43,7 @@ def gem_exists?
AND rubygems.name = ?
AND versions.number = ?
AND versions.platform = ?
+ AND versions.indexed = true
SQL
result = dataset.count > 0
@@ -58,7 +63,7 @@ def insert_spec(spec)
timer = Metriks.timer('job.insert_spec').time
@db.transaction do
version = spec.version.version
- platform = spec.platform.to_s
+ platform = @payload.platform
rubygem = @db[:rubygems].filter(name: spec.name.to_s).select(:id).first
rubygem_id = nil
if rubygem
@@ -90,7 +95,8 @@ def insert_spec(spec)
rubygem_id: rubygem_id,
updated_at: Time.now,
summary: spec.summary,
- platform: spec.platform.to_s,
+ # rubygems.org actually uses the platform from the index and not from the spec
+ platform: platform,
created_at: Time.now,
indexed: true,
prerelease: @payload.prerelease,
View
10 spec/update/job_spec.rb
@@ -14,6 +14,10 @@
db.transaction(:rollback => :always) { example.run }
end
+ before do
+ BundlerApi::Job.clear_cache
+ end
+
describe "#run" do
before do
Artifice.activate_with(GemspecGenerator)
@@ -75,7 +79,7 @@ def gem_exists?(db, name, version = '1.0', platform = 'ruby')
jobs.first.run
expect { jobs[1].run }.not_to raise_error(Sequel::DatabaseError)
- gem_exists?(db, 'foo', '1.0', 'java')
+ gem_exists?(db, 'foo', '1.0', 'jruby')
end
it "sets the indexed attribute to true" do
@@ -84,7 +88,7 @@ def gem_exists?(db, name, version = '1.0', platform = 'ruby')
BundlerApi::Job.new(db, payload, mutex, counter)
end
jobs.first.run
- version_id = db[<<-SQL, 'foo', '1.0', 'java'].first[:id]
+ version_id = db[<<-SQL, 'foo', '1.0', 'jruby'].first[:id]
SELECT versions.id
FROM rubygems, versions
WHERE rubygems.id = versions.rubygem_id
@@ -95,7 +99,7 @@ def gem_exists?(db, name, version = '1.0', platform = 'ruby')
db[:versions].where(id: version_id).update(indexed: false)
jobs[1].run
- gem_exists?(db, 'foo', '1.0', 'java')
+ gem_exists?(db, 'foo', '1.0', 'jruby')
expect(db[:versions].filter(id: version_id).select(:indexed).first[:indexed]).to be_true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.