about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-05-06 13:05:03 +0200
committerGitHub <noreply@github.com>2017-05-06 13:05:03 +0200
commitb8e166894b1d41ef417c89836a336590d93532f9 (patch)
tree5e95134e1a81518a02a5ae0e70833aa28c6adcaf /spec
parent1f15a15621860d97107c2be420af8925756970c5 (diff)
Fix Scheduler::SubscriptionsScheduler (#2834)
* Fix Scheduler::SubscriptionsScheduler, add worker test for it

* Change production log level of Sidekiq to "warn" instead of "info"
Diffstat (limited to 'spec')
-rw-r--r--spec/workers/scheduler/subscriptions_scheduler_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/workers/scheduler/subscriptions_scheduler_spec.rb b/spec/workers/scheduler/subscriptions_scheduler_spec.rb
new file mode 100644
index 000000000..a7d1046de
--- /dev/null
+++ b/spec/workers/scheduler/subscriptions_scheduler_spec.rb
@@ -0,0 +1,19 @@
+require 'rails_helper'
+
+describe Scheduler::SubscriptionsScheduler do
+  subject { Scheduler::SubscriptionsScheduler.new }
+
+  let!(:expiring_account1) { Fabricate(:account, subscription_expires_at: 20.minutes.from_now, domain: 'example.com', followers_count: 1, hub_url: 'http://hub.example.com') }
+  let!(:expiring_account2) { Fabricate(:account, subscription_expires_at: 4.hours.from_now, domain: 'example.org', followers_count: 1, hub_url: 'http://hub.example.org') }
+
+  before do
+    stub_request(:post, 'http://hub.example.com/').to_return(status: 202)
+    stub_request(:post, 'http://hub.example.org/').to_return(status: 202)
+  end
+
+  it 're-subscribes for all expiring accounts' do
+    subject.perform
+    expect(a_request(:post, 'http://hub.example.com/')).to have_been_made.once
+    expect(a_request(:post, 'http://hub.example.org/')).to have_been_made.once
+  end
+end