about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
committerThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
commitab5ff638f2968e3f434e504c7caab370bf71c9c0 (patch)
tree172f2c2fc8192688b960dd2bd42ea126ad9245fb /spec/services
parent66ab1f83b0d342341181e0c88da83c966391fc0c (diff)
parent902c6bed5aab12c2e97af3452f122247777226af (diff)
Merge branch 'master' into glitch-soc/master
Conflicts:
- `config/locales/en.yml`
  No real conflict, upstream added a translatable string “too close” to
  one specific to glitch-soc
- `lib/mastodon/statuses_cli.rb`
  Fixes made upstream, while changed in glitch-soc to keep bookmarked statuses
- `package.json`
  No real conflict, additional dependency in glitch-soc
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/activitypub/fetch_remote_status_service_spec.rb20
-rw-r--r--spec/services/fetch_remote_account_service_spec.rb50
-rw-r--r--spec/services/fetch_remote_status_service_spec.rb7
-rw-r--r--spec/services/fetch_resource_service_spec.rb8
4 files changed, 27 insertions, 58 deletions
diff --git a/spec/services/activitypub/fetch_remote_status_service_spec.rb b/spec/services/activitypub/fetch_remote_status_service_spec.rb
index 78dd59e3b..1ecc46952 100644
--- a/spec/services/activitypub/fetch_remote_status_service_spec.rb
+++ b/spec/services/activitypub/fetch_remote_status_service_spec.rb
@@ -104,6 +104,26 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
       end
     end
 
+    context 'with Event object' do
+      let(:object) do
+        {
+          '@context': 'https://www.w3.org/ns/activitystreams',
+          id: "https://#{valid_domain}/@foo/1234",
+          type: 'Event',
+          name: "Let's change the world",
+          attributedTo: ActivityPub::TagManager.instance.uri_for(sender)
+        }
+      end
+
+      it 'creates status' do
+        status = sender.statuses.first
+
+        expect(status).to_not be_nil
+        expect(status.url).to eq "https://#{valid_domain}/@foo/1234"
+        expect(strip_tags(status.text)).to eq "Let's change the world https://#{valid_domain}/@foo/1234"
+      end
+    end
+
     context 'with wrong id' do
       let(:note) do
         {
diff --git a/spec/services/fetch_remote_account_service_spec.rb b/spec/services/fetch_remote_account_service_spec.rb
deleted file mode 100644
index ee7325be2..000000000
--- a/spec/services/fetch_remote_account_service_spec.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-require 'rails_helper'
-
-RSpec.describe FetchRemoteAccountService, type: :service do
-  let(:url) { 'https://example.com/alice' }
-  let(:prefetched_body) { nil }
-  let(:protocol) { :ostatus }
-
-  subject { FetchRemoteAccountService.new.call(url, prefetched_body, protocol) }
-
-  let(:actor) do
-    {
-      '@context': 'https://www.w3.org/ns/activitystreams',
-      id: 'https://example.com/alice',
-      type: 'Person',
-      preferredUsername: 'alice',
-      name: 'Alice',
-      summary: 'Foo bar',
-      inbox: 'http://example.com/alice/inbox',
-    }
-  end
-
-  let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice' }] } }
-  let(:xml) { File.read(Rails.root.join('spec', 'fixtures', 'xml', 'mastodon.atom')) }
-
-  shared_examples 'return Account' do
-    it { is_expected.to be_an Account }
-  end
-
-  context 'protocol is :activitypub' do
-    let(:prefetched_body) { Oj.dump(actor) }
-    let(:protocol) { :activitypub }
-
-    before do
-      stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
-    end
-
-    include_examples 'return Account'
-  end
-
-  context 'when prefetched_body is nil' do
-    context 'protocol is :activitypub' do
-      before do
-        stub_request(:get, url).to_return(status: 200, body: Oj.dump(actor), headers: { 'Content-Type' => 'application/activity+json' })
-        stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: Oj.dump(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
-      end
-
-      include_examples 'return Account'
-    end
-  end
-end
diff --git a/spec/services/fetch_remote_status_service_spec.rb b/spec/services/fetch_remote_status_service_spec.rb
index f9db024b9..1c4b4fee2 100644
--- a/spec/services/fetch_remote_status_service_spec.rb
+++ b/spec/services/fetch_remote_status_service_spec.rb
@@ -16,9 +16,8 @@ RSpec.describe FetchRemoteStatusService, type: :service do
   end
 
   context 'protocol is :activitypub' do
-    subject { described_class.new.call(note[:id], prefetched_body, protocol) }
+    subject { described_class.new.call(note[:id], prefetched_body) }
     let(:prefetched_body) { Oj.dump(note) }
-    let(:protocol) { :activitypub }
 
     before do
       account.update(uri: ActivityPub::TagManager.instance.uri_for(account))
@@ -59,7 +58,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do
         </entry>
       XML
 
-      expect(subject.call('https://fake.domain/foo', status_body, :ostatus)).to be_nil
+      expect(subject.call('https://fake.domain/foo', status_body)).to be_nil
     end
 
     it 'does not create status with wrong id when id uses http format' do
@@ -81,7 +80,7 @@ RSpec.describe FetchRemoteStatusService, type: :service do
         </entry>
       XML
 
-      expect(subject.call('https://real.domain/statuses/456', status_body, :ostatus)).to be_nil
+      expect(subject.call('https://real.domain/statuses/456', status_body)).to be_nil
     end
   end
 end
diff --git a/spec/services/fetch_resource_service_spec.rb b/spec/services/fetch_resource_service_spec.rb
index f836147d3..3af6a0689 100644
--- a/spec/services/fetch_resource_service_spec.rb
+++ b/spec/services/fetch_resource_service_spec.rb
@@ -71,14 +71,14 @@ RSpec.describe FetchResourceService, type: :service do
         let(:content_type) { 'application/activity+json; charset=utf-8' }
         let(:body) { json }
 
-        it { is_expected.to eq [1, { prefetched_body: body, id: true }, :activitypub] }
+        it { is_expected.to eq [1, { prefetched_body: body, id: true }] }
       end
 
       context 'when content type is ld+json with profile' do
         let(:content_type) { 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }
         let(:body) { json }
 
-        it { is_expected.to eq [1, { prefetched_body: body, id: true }, :activitypub] }
+        it { is_expected.to eq [1, { prefetched_body: body, id: true }] }
       end
 
       before do
@@ -89,14 +89,14 @@ RSpec.describe FetchResourceService, type: :service do
       context 'when link header is present' do
         let(:headers) { { 'Link' => '<http://example.com/foo>; rel="alternate"; type="application/activity+json"', } }
 
-        it { is_expected.to eq [1, { prefetched_body: json, id: true }, :activitypub] }
+        it { is_expected.to eq [1, { prefetched_body: json, id: true }] }
       end
 
       context 'when content type is text/html' do
         let(:content_type) { 'text/html' }
         let(:body) { '<html><head><link rel="alternate" href="http://example.com/foo" type="application/activity+json"/></head></html>' }
 
-        it { is_expected.to eq [1, { prefetched_body: json, id: true }, :activitypub] }
+        it { is_expected.to eq [1, { prefetched_body: json, id: true }] }
       end
     end
   end