about summary refs log tree commit diff
path: root/spec/services/post_status_service_spec.rb
diff options
context:
space:
mode:
authorreverite <samantha@chalker.io>2019-01-29 21:13:22 -0800
committerreverite <samantha@chalker.io>2019-01-29 21:13:22 -0800
commit3510128c51f615634350a93dfb19053519d65454 (patch)
tree85bac2a16c9c2371679d43311d9d6b069c988e94 /spec/services/post_status_service_spec.rb
parentc5b97d18762dce34a95ca42e9335e672c66953c0 (diff)
parentc2ccdad102cae9bc3dc94d1d6c6f306ca0366370 (diff)
Merge branch 'master' into production
Diffstat (limited to 'spec/services/post_status_service_spec.rb')
-rw-r--r--spec/services/post_status_service_spec.rb29
1 files changed, 28 insertions, 1 deletions
diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb
index 3774fed6f..facbe977f 100644
--- a/spec/services/post_status_service_spec.rb
+++ b/spec/services/post_status_service_spec.rb
@@ -36,6 +36,20 @@ RSpec.describe PostStatusService, type: :service do
     expect(status.params['text']).to eq 'Hi future!'
   end
 
+  it 'does not immediately create a status when scheduling a status' do
+    account = Fabricate(:account)
+    media = Fabricate(:media_attachment)
+    future  = Time.now.utc + 2.hours
+
+    status = subject.call(account, text: 'Hi future!', media_ids: [media.id], scheduled_at: future)
+
+    expect(status).to be_a ScheduledStatus
+    expect(status.scheduled_at).to eq future
+    expect(status.params['text']).to eq 'Hi future!'
+    expect(media.reload.status).to be_nil
+    expect(Status.where(text: 'Hi future!').exists?).to be_falsey
+  end
+
   it 'creates response to the original status of boost' do
     boosted_status = Fabricate(:status)
     in_reply_to_status = Fabricate(:status, reblog: boosted_status)
@@ -153,7 +167,7 @@ RSpec.describe PostStatusService, type: :service do
 
   it 'attaches the given media to the created status' do
     account = Fabricate(:account)
-    media = Fabricate(:media_attachment)
+    media = Fabricate(:media_attachment, account: account)
 
     status = subject.call(
       account,
@@ -164,6 +178,19 @@ RSpec.describe PostStatusService, type: :service do
     expect(media.reload.status).to eq status
   end
 
+  it 'does not attach media from another account to the created status' do
+    account = Fabricate(:account)
+    media = Fabricate(:media_attachment, account: Fabricate(:account))
+
+    status = subject.call(
+      account,
+      text: "test status update",
+      media_ids: [media.id],
+    )
+
+    expect(media.reload.status).to eq nil
+  end
+
   it 'does not allow attaching more than 4 files' do
     account = Fabricate(:account)