about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-01-10 19:12:10 +0100
committerThibaut Girka <thib@sitedethib.com>2019-01-10 21:00:30 +0100
commita2a64ecd3e3551707412c47f0d16e484dea25632 (patch)
treebc4e0b8e0ca2a2735f527bff8bd73421c0ff72dd /spec/services
parentfb0c906c717f2b21bb63610742a357850142b522 (diff)
parent70801b850c78d7879182eeba4eae509af42fafeb (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- .eslintrc.yml
  Removed, as upstream removed it.
- app/controllers/admin/statuses_controller.rb
  Minor code cleanup when porting one of our features.
- app/models/account.rb
  Note length validation has changed upstream.
  We now use upstream's validation (dropped legacy glitch-soc
  account metadata stuff) but with configurable limit.
- app/services/post_status_service.rb
  Upstream has added support for scheduled toots, refactoring
  the code a bit. Adapted our changes to this refactoring.
- app/views/stream_entries/_detailed_status.html.haml
  Not a real conflict, changes too close.
- app/views/stream_entries/_simple_status.html.haml
  Not a real conflict, changes too close.
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/batched_remove_status_service_spec.rb4
-rw-r--r--spec/services/post_status_service_spec.rb44
-rw-r--r--spec/services/remove_status_service_spec.rb2
-rw-r--r--spec/services/resolve_account_service_spec.rb2
4 files changed, 29 insertions, 23 deletions
diff --git a/spec/services/batched_remove_status_service_spec.rb b/spec/services/batched_remove_status_service_spec.rb
index c66214555..e53623449 100644
--- a/spec/services/batched_remove_status_service_spec.rb
+++ b/spec/services/batched_remove_status_service_spec.rb
@@ -8,8 +8,8 @@ RSpec.describe BatchedRemoveStatusService, type: :service do
   let!(:jeff)   { Fabricate(:user).account }
   let!(:hank)   { Fabricate(:account, username: 'hank', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox') }
 
-  let(:status1) { PostStatusService.new.call(alice, 'Hello @bob@example.com') }
-  let(:status2) { PostStatusService.new.call(alice, 'Another status') }
+  let(:status1) { PostStatusService.new.call(alice, text: 'Hello @bob@example.com') }
+  let(:status2) { PostStatusService.new.call(alice, text: 'Another status') }
 
   before do
     allow(Redis.current).to receive_messages(publish: nil)
diff --git a/spec/services/post_status_service_spec.rb b/spec/services/post_status_service_spec.rb
index 8f3552224..3774fed6f 100644
--- a/spec/services/post_status_service_spec.rb
+++ b/spec/services/post_status_service_spec.rb
@@ -7,7 +7,7 @@ RSpec.describe PostStatusService, type: :service do
     account = Fabricate(:account)
     text = "test status update"
 
-    status = subject.call(account, text)
+    status = subject.call(account, text: text)
 
     expect(status).to be_persisted
     expect(status.text).to eq text
@@ -18,20 +18,31 @@ RSpec.describe PostStatusService, type: :service do
     account = Fabricate(:account)
     text = "test status update"
 
-    status = subject.call(account, text, in_reply_to_status)
+    status = subject.call(account, text: text, thread: in_reply_to_status)
 
     expect(status).to be_persisted
     expect(status.text).to eq text
     expect(status.thread).to eq in_reply_to_status
   end
 
+  it 'schedules a status' do
+    account = Fabricate(:account)
+    future  = Time.now.utc + 2.hours
+
+    status = subject.call(account, text: 'Hi future!', scheduled_at: future)
+
+    expect(status).to be_a ScheduledStatus
+    expect(status.scheduled_at).to eq future
+    expect(status.params['text']).to eq 'Hi future!'
+  end
+
   it 'creates response to the original status of boost' do
     boosted_status = Fabricate(:status)
     in_reply_to_status = Fabricate(:status, reblog: boosted_status)
     account = Fabricate(:account)
     text = "test status update"
 
-    status = subject.call(account, text, in_reply_to_status)
+    status = subject.call(account, text: text, thread: in_reply_to_status)
 
     expect(status).to be_persisted
     expect(status.text).to eq text
@@ -69,7 +80,7 @@ RSpec.describe PostStatusService, type: :service do
   end
 
   it 'creates a status with limited visibility for silenced users' do
-    status = subject.call(Fabricate(:account, silenced: true), 'test', nil, visibility: :public)
+    status = subject.call(Fabricate(:account, silenced: true), text: 'test', visibility: :public)
 
     expect(status).to be_persisted
     expect(status.visibility).to eq "unlisted"
@@ -88,7 +99,7 @@ RSpec.describe PostStatusService, type: :service do
     account = Fabricate(:account)
     text = 'This is an English text.'
 
-    status = subject.call(account, text)
+    status = subject.call(account, text: text)
 
     expect(status.language).to eq 'en'
   end
@@ -99,7 +110,7 @@ RSpec.describe PostStatusService, type: :service do
     allow(ProcessMentionsService).to receive(:new).and_return(mention_service)
     account = Fabricate(:account)
 
-    status = subject.call(account, "test status update")
+    status = subject.call(account, text: "test status update")
 
     expect(ProcessMentionsService).to have_received(:new)
     expect(mention_service).to have_received(:call).with(status)
@@ -111,7 +122,7 @@ RSpec.describe PostStatusService, type: :service do
     allow(ProcessHashtagsService).to receive(:new).and_return(hashtags_service)
     account = Fabricate(:account)
 
-    status = subject.call(account, "test status update")
+    status = subject.call(account, text: "test status update")
 
     expect(ProcessHashtagsService).to have_received(:new)
     expect(hashtags_service).to have_received(:call).with(status)
@@ -124,7 +135,7 @@ RSpec.describe PostStatusService, type: :service do
 
     account = Fabricate(:account)
 
-    status = subject.call(account, "test status update")
+    status = subject.call(account, text: "test status update")
 
     expect(DistributionWorker).to have_received(:perform_async).with(status.id)
     expect(Pubsubhubbub::DistributionWorker).to have_received(:perform_async).with(status.stream_entry.id)
@@ -135,7 +146,7 @@ RSpec.describe PostStatusService, type: :service do
     allow(LinkCrawlWorker).to receive(:perform_async)
     account = Fabricate(:account)
 
-    status = subject.call(account, "test status update")
+    status = subject.call(account, text: "test status update")
 
     expect(LinkCrawlWorker).to have_received(:perform_async).with(status.id)
   end
@@ -146,8 +157,7 @@ RSpec.describe PostStatusService, type: :service do
 
     status = subject.call(
       account,
-      "test status update",
-      nil,
+      text: "test status update",
       media_ids: [media.id],
     )
 
@@ -160,8 +170,7 @@ RSpec.describe PostStatusService, type: :service do
     expect do
       subject.call(
         account,
-        "test status update",
-        nil,
+        text: "test status update",
         media_ids: [
           Fabricate(:media_attachment, account: account),
           Fabricate(:media_attachment, account: account),
@@ -182,8 +191,7 @@ RSpec.describe PostStatusService, type: :service do
     expect do
       subject.call(
         account,
-        "test status update",
-        nil,
+        text: "test status update",
         media_ids: [
           Fabricate(:media_attachment, type: :video, account: account),
           Fabricate(:media_attachment, type: :image, account: account),
@@ -197,12 +205,12 @@ RSpec.describe PostStatusService, type: :service do
 
   it 'returns existing status when used twice with idempotency key' do
     account = Fabricate(:account)
-    status1 = subject.call(account, 'test', nil, idempotency: 'meepmeep')
-    status2 = subject.call(account, 'test', nil, idempotency: 'meepmeep')
+    status1 = subject.call(account, text: 'test', idempotency: 'meepmeep')
+    status2 = subject.call(account, text: 'test', idempotency: 'meepmeep')
     expect(status2.id).to eq status1.id
   end
 
   def create_status_with_options(**options)
-    subject.call(Fabricate(:account), 'test', nil, options)
+    subject.call(Fabricate(:account), options.merge(text: 'test'))
   end
 end
diff --git a/spec/services/remove_status_service_spec.rb b/spec/services/remove_status_service_spec.rb
index 2134f51fd..7bba83a60 100644
--- a/spec/services/remove_status_service_spec.rb
+++ b/spec/services/remove_status_service_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe RemoveStatusService, type: :service do
     jeff.follow!(alice)
     hank.follow!(alice)
 
-    @status = PostStatusService.new.call(alice, 'Hello @bob@example.com')
+    @status = PostStatusService.new.call(alice, text: 'Hello @bob@example.com')
     Fabricate(:status, account: bill, reblog: @status, uri: 'hoge')
     subject.call(@status)
   end
diff --git a/spec/services/resolve_account_service_spec.rb b/spec/services/resolve_account_service_spec.rb
index dd7561587..27a85af7c 100644
--- a/spec/services/resolve_account_service_spec.rb
+++ b/spec/services/resolve_account_service_spec.rb
@@ -119,8 +119,6 @@ RSpec.describe ResolveAccountService, type: :service do
         expect(account.actor_type).to eq 'Person'
       end
     end
-
-    pending
   end
 
   it 'processes one remote account at a time using locks' do