about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/stream_entries_controller_spec.rb10
-rw-r--r--spec/models/status_pin_spec.rb31
-rw-r--r--spec/services/activitypub/process_account_service_spec.rb28
3 files changed, 61 insertions, 8 deletions
diff --git a/spec/controllers/stream_entries_controller_spec.rb b/spec/controllers/stream_entries_controller_spec.rb
index f81e2be7b..665c5b747 100644
--- a/spec/controllers/stream_entries_controller_spec.rb
+++ b/spec/controllers/stream_entries_controller_spec.rb
@@ -66,16 +66,12 @@ RSpec.describe StreamEntriesController, type: :controller do
   describe 'GET #show' do
     include_examples 'before_action', :show
 
-    it 'renders with HTML' do
-      ancestor = Fabricate(:status)
-      status = Fabricate(:status, in_reply_to_id: ancestor.id)
-      descendant = Fabricate(:status, in_reply_to_id: status.id)
+    it 'redirects to status page' do
+      status = Fabricate(:status)
 
       get :show, params: { account_username: status.account.username, id: status.stream_entry.id }
 
-      expect(assigns(:ancestors)).to eq [ancestor]
-      expect(assigns(:descendants)).to eq [descendant]
-      expect(response).to have_http_status(:success)
+      expect(response).to redirect_to(short_account_status_url(status.account, status))
     end
 
     it 'returns http success with Atom' do
diff --git a/spec/models/status_pin_spec.rb b/spec/models/status_pin_spec.rb
index 6f54f80f9..944baf639 100644
--- a/spec/models/status_pin_spec.rb
+++ b/spec/models/status_pin_spec.rb
@@ -37,5 +37,36 @@ RSpec.describe StatusPin, type: :model do
 
       expect(StatusPin.new(account: account, status: status).save).to be false
     end
+
+    max_pins = 5
+    it 'does not allow pins above the max' do
+      account = Fabricate(:account)
+      status = []
+
+      (max_pins + 1).times do |i|
+        status[i] = Fabricate(:status, account: account)
+      end
+
+      max_pins.times do |i|
+        expect(StatusPin.new(account: account, status: status[i]).save).to be true
+      end
+
+      expect(StatusPin.new(account: account, status: status[max_pins]).save).to be false
+    end
+
+    it 'allows pins above the max for remote accounts' do
+      account = Fabricate(:account, domain: 'remote', username: 'bob', url: 'https://remote/')
+      status = []
+
+      (max_pins + 1).times do |i|
+        status[i] = Fabricate(:status, account: account)
+      end
+
+      max_pins.times do |i|
+        expect(StatusPin.new(account: account, status: status[i]).save).to be true
+      end
+
+      expect(StatusPin.new(account: account, status: status[max_pins]).save).to be true
+    end
   end
 end
diff --git a/spec/services/activitypub/process_account_service_spec.rb b/spec/services/activitypub/process_account_service_spec.rb
index 84a74c231..15e1f4bb2 100644
--- a/spec/services/activitypub/process_account_service_spec.rb
+++ b/spec/services/activitypub/process_account_service_spec.rb
@@ -1,5 +1,31 @@
 require 'rails_helper'
 
 RSpec.describe ActivityPub::ProcessAccountService do
-  pending
+  subject { described_class.new }
+
+  context 'property values' do
+    let(:payload) do
+      {
+        id: 'https://foo',
+        type: 'Actor',
+        inbox: 'https://foo/inbox',
+        attachment: [
+          { type: 'PropertyValue', name: 'Pronouns', value: 'They/them' },
+          { type: 'PropertyValue', name: 'Occupation', value: 'Unit test' },
+        ],
+      }.with_indifferent_access
+    end
+
+    it 'parses out of attachment' do
+      account = subject.call('alice', 'example.com', payload)
+      expect(account.fields).to be_a Array
+      expect(account.fields.size).to eq 2
+      expect(account.fields[0]).to be_a Account::Field
+      expect(account.fields[0].name).to eq 'Pronouns'
+      expect(account.fields[0].value).to eq 'They/them'
+      expect(account.fields[1]).to be_a Account::Field
+      expect(account.fields[1].name).to eq 'Occupation'
+      expect(account.fields[1].value).to eq 'Unit test'
+    end
+  end
 end