about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/settings_helper_spec.rb4
-rw-r--r--spec/lib/activitypub/activity/update_spec.rb8
-rw-r--r--spec/lib/activitypub/tag_manager_spec.rb28
-rw-r--r--spec/models/report_spec.rb14
-rw-r--r--spec/services/activitypub/fetch_remote_account_service_spec.rb2
-rw-r--r--spec/services/unsubscribe_service_spec.rb2
6 files changed, 51 insertions, 7 deletions
diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb
index 5a51e0ef1..092c37583 100644
--- a/spec/helpers/settings_helper_spec.rb
+++ b/spec/helpers/settings_helper_spec.rb
@@ -4,10 +4,10 @@ require 'rails_helper'
 
 describe SettingsHelper do
   describe 'the HUMAN_LOCALES constant' do
-    it 'has the same number of keys as I18n locales exist' do
+    it 'includes all I18n locales' do
       options = I18n.available_locales
 
-      expect(described_class::HUMAN_LOCALES.keys).to eq(options)
+      expect(described_class::HUMAN_LOCALES.keys).to include(*options)
     end
   end
 
diff --git a/spec/lib/activitypub/activity/update_spec.rb b/spec/lib/activitypub/activity/update_spec.rb
index 0bd6d00d9..ea308e35c 100644
--- a/spec/lib/activitypub/activity/update_spec.rb
+++ b/spec/lib/activitypub/activity/update_spec.rb
@@ -2,12 +2,16 @@ require 'rails_helper'
 
 RSpec.describe ActivityPub::Activity::Update do
   let!(:sender) { Fabricate(:account) }
-  
+
   before do
+    stub_request(:get, actor_json[:outbox]).to_return(status: 404)
+    stub_request(:get, actor_json[:followers]).to_return(status: 404)
+    stub_request(:get, actor_json[:following]).to_return(status: 404)
+
     sender.update!(uri: ActivityPub::TagManager.instance.uri_for(sender))
   end
 
-  let(:modified_sender) do 
+  let(:modified_sender) do
     sender.dup.tap do |modified_sender|
       modified_sender.display_name = 'Totally modified now'
     end
diff --git a/spec/lib/activitypub/tag_manager_spec.rb b/spec/lib/activitypub/tag_manager_spec.rb
index 8f7662e24..dea8abc65 100644
--- a/spec/lib/activitypub/tag_manager_spec.rb
+++ b/spec/lib/activitypub/tag_manager_spec.rb
@@ -91,9 +91,35 @@ RSpec.describe ActivityPub::TagManager do
   end
 
   describe '#uri_to_resource' do
-    it 'returns the local resource' do
+    it 'returns the local account' do
       account = Fabricate(:account)
       expect(subject.uri_to_resource(subject.uri_for(account), Account)).to eq account
     end
+
+    it 'returns the remote account by matching URI without fragment part' do
+      account = Fabricate(:account, uri: 'https://example.com/123')
+      expect(subject.uri_to_resource('https://example.com/123#456', Account)).to eq account
+    end
+
+    it 'returns the local status for ActivityPub URI' do
+      status = Fabricate(:status)
+      expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status
+    end
+
+    it 'returns the local status for OStatus tag: URI' do
+      status = Fabricate(:status)
+      expect(subject.uri_to_resource(::TagManager.instance.uri_for(status), Status)).to eq status
+    end
+
+    it 'returns the local status for OStatus StreamEntry URL' do
+      status = Fabricate(:status)
+      stream_entry_url = account_stream_entry_url(status.account, status.stream_entry)
+      expect(subject.uri_to_resource(stream_entry_url, Status)).to eq status
+    end
+
+    it 'returns the remote status by matching URI without fragment part' do
+      status = Fabricate(:status, uri: 'https://example.com/123')
+      expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status
+    end
   end
 end
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb
index 6c2723845..d40ebf6dc 100644
--- a/spec/models/report_spec.rb
+++ b/spec/models/report_spec.rb
@@ -21,4 +21,18 @@ describe Report do
       expect(report.media_attachments).to eq [media_attachment]
     end
   end
+
+  describe 'validatiions' do
+    it 'has a valid fabricator' do
+      report = Fabricate(:report)
+      report.valid?
+      expect(report).to be_valid
+    end
+
+    it 'is invalid if comment is longer than 1000 characters' do
+      report = Fabricate.build(:report, comment: Faker::Lorem.characters(1001))
+      report.valid?
+      expect(report).to model_have_error_on_field(:comment)
+    end
+  end
 end
diff --git a/spec/services/activitypub/fetch_remote_account_service_spec.rb b/spec/services/activitypub/fetch_remote_account_service_spec.rb
index 391d051c1..ed7e9bba8 100644
--- a/spec/services/activitypub/fetch_remote_account_service_spec.rb
+++ b/spec/services/activitypub/fetch_remote_account_service_spec.rb
@@ -41,7 +41,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
 
       before do
         actor[:inbox] = nil
-        
+
         stub_request(:get, 'https://example.com/alice').to_return(body: Oj.dump(actor))
         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
diff --git a/spec/services/unsubscribe_service_spec.rb b/spec/services/unsubscribe_service_spec.rb
index c81772037..2a02f4c75 100644
--- a/spec/services/unsubscribe_service_spec.rb
+++ b/spec/services/unsubscribe_service_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe UnsubscribeService do
     stub_request(:post, 'http://hub.example.com/').to_raise(HTTP::Error)
     subject.call(account)
 
-    expect(logger).to have_received(:debug).with(/PuSH subscription request for bob@example.com could not be made due to HTTP or SSL error/)
+    expect(logger).to have_received(:debug).with(/unsubscribe for bob@example.com failed/)
   end
 
   def stub_logger