blob: 01802dcc8ef9ba4ca81e7c5c134d78814afcf052 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# frozen_string_literal: true
class User
alias_method :share_with_original, :share_with
def share_with(*args)
disable_send_workers
inlined_jobs do
share_with_original(*args)
end
end
def add_contact_to_aspect(contact, aspect)
return if AspectMembership.exists?(contact_id: contact.id, aspect_id: aspect.id)
contact.aspect_memberships.create!(aspect: aspect)
end
def post(class_name, opts = {})
disable_send_workers
inlined_jobs do
aspects = self.aspects_from_ids(opts[:to])
p = build_post(class_name, opts)
p.aspects = aspects
if p.save!
self.aspects.reload
dispatch_post(p, url: Rails.application.routes.url_helpers.post_url(p, host: AppConfig.pod_uri.to_s))
end
unless opts[:created_at]
p.created_at = Time.now - 1
p.save
end
p
end
end
def build_comment(options={})
Comment::Generator.new(self, options.delete(:post), options.delete(:text)).build(options)
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
|