about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-28 21:22:56 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-28 21:22:56 +0100
commit11ff92c9d7b27c2c9ed86f649aef8d956cc8b989 (patch)
treea6294bad9352e6f2e181388a33a4b45dcda53319 /spec
parent47d50b0e3967f1d396bdbe8ea3e8909ce2be599f (diff)
Adding a test for ReblogService, fixing mentions for remote statuses
Diffstat (limited to 'spec')
-rw-r--r--spec/rails_helper.rb2
-rw-r--r--spec/services/reblog_service_spec.rb27
2 files changed, 28 insertions, 1 deletions
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 0a04d560c..cb8088061 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -5,8 +5,10 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ
 
 require 'spec_helper'
 require 'rspec/rails'
+require 'webmock/rspec'
 
 ActiveRecord::Migration.maintain_test_schema!
+WebMock.disable_net_connect!
 
 RSpec.configure do |config|
   config.fixture_path = "#{::Rails.root}/spec/fixtures"
diff --git a/spec/services/reblog_service_spec.rb b/spec/services/reblog_service_spec.rb
index 4e94d5a70..f12fdb837 100644
--- a/spec/services/reblog_service_spec.rb
+++ b/spec/services/reblog_service_spec.rb
@@ -1,5 +1,30 @@
 require 'rails_helper'
 
 RSpec.describe ReblogService do
-  pending
+  let(:alice)  { Fabricate(:account, username: 'alice') }
+  let(:bob)    { Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://salmon.example.com') }
+  let(:status) { Fabricate(:status, account: bob, uri: 'tag:example.com;something:something') }
+
+  subject { ReblogService.new }
+
+  before do
+    stub_const('HUB_URL', 'http://hub.example.com')
+
+    stub_request(:post, 'http://hub.example.com')
+    stub_request(:post, 'http://salmon.example.com')
+
+    subject.(alice, status)
+  end
+
+  it 'creates a reblog' do
+    expect(status.reblogs.count).to eq 1
+  end
+
+  it 'pings PubSubHubbub hubs' do
+    expect(a_request(:post, 'http://hub.example.com')).to have_been_made
+  end
+
+  it 'sends a Salmon slap for a remote reblog' do
+    expect(a_request(:post, 'http://salmon.example.com')).to have_been_made
+  end
 end