|
|
@ -7,7 +7,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
account = Fabricate(:account)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
text = "test status update"
|
|
|
|
text = "test status update"
|
|
|
|
|
|
|
|
|
|
|
|
status = subject.call(account, text)
|
|
|
|
status = subject.call(account, text: text)
|
|
|
|
|
|
|
|
|
|
|
|
expect(status).to be_persisted
|
|
|
|
expect(status).to be_persisted
|
|
|
|
expect(status.text).to eq text
|
|
|
|
expect(status.text).to eq text
|
|
|
@ -18,20 +18,31 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
account = Fabricate(:account)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
text = "test status update"
|
|
|
|
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).to be_persisted
|
|
|
|
expect(status.text).to eq text
|
|
|
|
expect(status.text).to eq text
|
|
|
|
expect(status.thread).to eq in_reply_to_status
|
|
|
|
expect(status.thread).to eq in_reply_to_status
|
|
|
|
end
|
|
|
|
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
|
|
|
|
it 'creates response to the original status of boost' do
|
|
|
|
boosted_status = Fabricate(:status)
|
|
|
|
boosted_status = Fabricate(:status)
|
|
|
|
in_reply_to_status = Fabricate(:status, reblog: boosted_status)
|
|
|
|
in_reply_to_status = Fabricate(:status, reblog: boosted_status)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
text = "test status update"
|
|
|
|
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).to be_persisted
|
|
|
|
expect(status.text).to eq text
|
|
|
|
expect(status.text).to eq text
|
|
|
@ -69,7 +80,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'creates a status with limited visibility for silenced users' do
|
|
|
|
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).to be_persisted
|
|
|
|
expect(status.visibility).to eq "unlisted"
|
|
|
|
expect(status.visibility).to eq "unlisted"
|
|
|
@ -88,7 +99,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
account = Fabricate(:account)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
text = 'This is an English text.'
|
|
|
|
text = 'This is an English text.'
|
|
|
|
|
|
|
|
|
|
|
|
status = subject.call(account, text)
|
|
|
|
status = subject.call(account, text: text)
|
|
|
|
|
|
|
|
|
|
|
|
expect(status.language).to eq 'en'
|
|
|
|
expect(status.language).to eq 'en'
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -99,7 +110,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
allow(ProcessMentionsService).to receive(:new).and_return(mention_service)
|
|
|
|
allow(ProcessMentionsService).to receive(:new).and_return(mention_service)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
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(ProcessMentionsService).to have_received(:new)
|
|
|
|
expect(mention_service).to have_received(:call).with(status)
|
|
|
|
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)
|
|
|
|
allow(ProcessHashtagsService).to receive(:new).and_return(hashtags_service)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
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(ProcessHashtagsService).to have_received(:new)
|
|
|
|
expect(hashtags_service).to have_received(:call).with(status)
|
|
|
|
expect(hashtags_service).to have_received(:call).with(status)
|
|
|
@ -124,7 +135,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
|
|
|
|
|
|
|
|
account = Fabricate(:account)
|
|
|
|
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(DistributionWorker).to have_received(:perform_async).with(status.id)
|
|
|
|
expect(Pubsubhubbub::DistributionWorker).to have_received(:perform_async).with(status.stream_entry.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)
|
|
|
|
allow(LinkCrawlWorker).to receive(:perform_async)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
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)
|
|
|
|
expect(LinkCrawlWorker).to have_received(:perform_async).with(status.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -146,8 +157,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
|
|
|
|
|
|
|
|
status = subject.call(
|
|
|
|
status = subject.call(
|
|
|
|
account,
|
|
|
|
account,
|
|
|
|
"test status update",
|
|
|
|
text: "test status update",
|
|
|
|
nil,
|
|
|
|
|
|
|
|
media_ids: [media.id],
|
|
|
|
media_ids: [media.id],
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -160,8 +170,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
expect do
|
|
|
|
expect do
|
|
|
|
subject.call(
|
|
|
|
subject.call(
|
|
|
|
account,
|
|
|
|
account,
|
|
|
|
"test status update",
|
|
|
|
text: "test status update",
|
|
|
|
nil,
|
|
|
|
|
|
|
|
media_ids: [
|
|
|
|
media_ids: [
|
|
|
|
Fabricate(:media_attachment, account: account),
|
|
|
|
Fabricate(:media_attachment, account: account),
|
|
|
|
Fabricate(:media_attachment, account: account),
|
|
|
|
Fabricate(:media_attachment, account: account),
|
|
|
@ -182,8 +191,7 @@ RSpec.describe PostStatusService, type: :service do
|
|
|
|
expect do
|
|
|
|
expect do
|
|
|
|
subject.call(
|
|
|
|
subject.call(
|
|
|
|
account,
|
|
|
|
account,
|
|
|
|
"test status update",
|
|
|
|
text: "test status update",
|
|
|
|
nil,
|
|
|
|
|
|
|
|
media_ids: [
|
|
|
|
media_ids: [
|
|
|
|
Fabricate(:media_attachment, type: :video, account: account),
|
|
|
|
Fabricate(:media_attachment, type: :video, account: account),
|
|
|
|
Fabricate(:media_attachment, type: :image, 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
|
|
|
|
it 'returns existing status when used twice with idempotency key' do
|
|
|
|
account = Fabricate(:account)
|
|
|
|
account = Fabricate(:account)
|
|
|
|
status1 = subject.call(account, 'test', nil, idempotency: 'meepmeep')
|
|
|
|
status1 = subject.call(account, text: 'test', idempotency: 'meepmeep')
|
|
|
|
status2 = subject.call(account, 'test', nil, idempotency: 'meepmeep')
|
|
|
|
status2 = subject.call(account, text: 'test', idempotency: 'meepmeep')
|
|
|
|
expect(status2.id).to eq status1.id
|
|
|
|
expect(status2.id).to eq status1.id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def create_status_with_options(**options)
|
|
|
|
def create_status_with_options(**options)
|
|
|
|
subject.call(Fabricate(:account), 'test', nil, options)
|
|
|
|
subject.call(Fabricate(:account), options.merge(text: 'test'))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|