Stop disabling Send workers for each example

This commit is contained in:
cmrd Senya 2017-08-13 04:08:46 +03:00
parent b447eb6e95
commit 8f46073809
No known key found for this signature in database
GPG key ID: 5FCC5BA680E67BFE
3 changed files with 15 additions and 7 deletions

View file

@ -5,6 +5,7 @@
describe StreamsController, :type => :controller do describe StreamsController, :type => :controller do
describe '#multi' do describe '#multi' do
before do before do
allow(Workers::SendPublic).to receive(:perform_async)
sign_in alice, scope: :user sign_in alice, scope: :user
end end

View file

@ -106,8 +106,6 @@ RSpec.configure do |config|
I18n.locale = :en I18n.locale = :en
stub_request(:post, "https://pubsubhubbub.appspot.com/") stub_request(:post, "https://pubsubhubbub.appspot.com/")
$process_queue = false $process_queue = false
allow(Workers::SendPublic).to receive(:perform_async)
allow(Workers::SendPrivate).to receive(:perform_async)
end end
config.expect_with :rspec do |expect_config| config.expect_with :rspec do |expect_config|

View file

@ -2,6 +2,8 @@ class User
alias_method :share_with_original, :share_with alias_method :share_with_original, :share_with
def share_with(*args) def share_with(*args)
disable_send_workers
inlined_jobs do inlined_jobs do
share_with_original(*args) share_with_original(*args)
end end
@ -13,6 +15,8 @@ class User
end end
def post(class_name, opts = {}) def post(class_name, opts = {})
disable_send_workers
inlined_jobs do inlined_jobs do
aspects = self.aspects_from_ids(opts[:to]) aspects = self.aspects_from_ids(opts[:to])
@ -22,11 +26,9 @@ class User
self.aspects.reload self.aspects.reload
dispatch_opts = { dispatch_opts = {
url: Rails.application.routes.url_helpers.post_url( url: Rails.application.routes.url_helpers.post_url(p, host: AppConfig.pod_uri.to_s),
p, to: opts[:to]
host: AppConfig.pod_uri.to_s }
),
to: opts[:to]}
dispatch_post(p, dispatch_opts) dispatch_post(p, dispatch_opts)
end end
unless opts[:created_at] unless opts[:created_at]
@ -40,4 +42,11 @@ class User
def build_comment(options={}) def build_comment(options={})
Comment::Generator.new(self, options.delete(:post), options.delete(:text)).build(options) Comment::Generator.new(self, options.delete(:post), options.delete(:text)).build(options)
end end
def disable_send_workers
RSpec.current_example&.example_group_instance&.instance_eval do
allow(Workers::SendPrivate).to receive(:perform_async)
allow(Workers::SendPublic).to receive(:perform_async)
end
end
end end