v3: make create request specs use new sidekiq abstraction, so it does not mess with Sidekiq internals
This commit is contained in:
parent
b7466074ca
commit
b30aa0e8c5
|
@ -33,12 +33,6 @@ module Travis::API::V3
|
||||||
|
|
||||||
def perform_async(identifier, *args)
|
def perform_async(identifier, *args)
|
||||||
Sidekiqs[identifier].perform_async(*args)
|
Sidekiqs[identifier].perform_async(*args)
|
||||||
# class_name, queue = @@sidekiq_cache[identifier] ||= [
|
|
||||||
# "Travis::Sidekiq::#{identifier.to_s.camelcase}".freeze,
|
|
||||||
# identifier.to_s.pluralize.freeze
|
|
||||||
# ]
|
|
||||||
#
|
|
||||||
# ::Sidekiq::Client.push('queue'.freeze => queue, 'class'.freeze => class_name, 'args'.freeze => args)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def includes?(key)
|
def includes?(key)
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Sidekiq
|
class Sidekiq
|
||||||
def self.client(value = nil)
|
def self.client
|
||||||
@client = value if value
|
@client ||= ::Sidekiq::Client
|
||||||
@client ||= defined?(super) ? super : ::Sidekiq::Client.default
|
end
|
||||||
|
|
||||||
|
def self.client=(value)
|
||||||
|
@client = value
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :class_name, :queue, :identifier
|
attr_accessor :class_name, :queue, :identifier
|
||||||
|
|
|
@ -2,20 +2,16 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe Travis::API::V3::Services::Requests::Create do
|
describe Travis::API::V3::Services::Requests::Create do
|
||||||
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
|
let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first }
|
||||||
let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last[:payload]).deep_symbolize_keys }
|
let(:sidekiq_requests) { [] }
|
||||||
before { repo.requests.each(&:delete) }
|
before { repo.requests.each(&:delete) }
|
||||||
|
|
||||||
before do
|
let(:sidekiq_payload) do
|
||||||
Travis::Features.stubs(:owner_active?).returns(true)
|
expect(sidekiq_requests).not_to be_empty, 'expected at least one sidekiq request to be sent, none sent'
|
||||||
@original_sidekiq = Sidekiq::Client
|
JSON.load(sidekiq_requests.last['args'].last[:payload]).deep_symbolize_keys
|
||||||
Sidekiq.send(:remove_const, :Client) # to avoid a warning
|
|
||||||
Sidekiq::Client = []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
before { Travis::API::V3::Sidekiq.client = sidekiq_requests }
|
||||||
Sidekiq.send(:remove_const, :Client) # to avoid a warning
|
after { Travis::API::V3::Sidekiq.client = nil }
|
||||||
Sidekiq::Client = @original_sidekiq
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "not authenticated" do
|
describe "not authenticated" do
|
||||||
before { post("/v3/repo/#{repo.id}/requests") }
|
before { post("/v3/repo/#{repo.id}/requests") }
|
||||||
|
@ -104,8 +100,8 @@ describe Travis::API::V3::Services::Requests::Create do
|
||||||
config: {}
|
config: {}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
example { expect(Sidekiq::Client.last['queue']).to be == 'build_requests' }
|
example { expect(sidekiq_requests.last['queue']).to be == 'build_requests' }
|
||||||
example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildRequest' }
|
example { expect(sidekiq_requests.last['class']).to be == 'Travis::Sidekiq::BuildRequest' }
|
||||||
|
|
||||||
describe "setting id has no effect" do
|
describe "setting id has no effect" do
|
||||||
let(:params) {{ id: 42 }}
|
let(:params) {{ id: 42 }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user