mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-16 06:31:12 +00:00
Fix featured tags for remote accounts not being kept up to date (#33372)
This commit is contained in:
parent
8a80b30537
commit
34073b4d56
|
@ -83,6 +83,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
ApplicationRecord.transaction do
|
ApplicationRecord.transaction do
|
||||||
@status = Status.create!(@params)
|
@status = Status.create!(@params)
|
||||||
attach_tags(@status)
|
attach_tags(@status)
|
||||||
|
attach_mentions(@status)
|
||||||
end
|
end
|
||||||
|
|
||||||
resolve_thread(@status)
|
resolve_thread(@status)
|
||||||
|
@ -188,6 +189,15 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
# not a big deal
|
# not a big deal
|
||||||
Trends.tags.register(status)
|
Trends.tags.register(status)
|
||||||
|
|
||||||
|
# Update featured tags
|
||||||
|
return if @tags.empty? || !status.distributable?
|
||||||
|
|
||||||
|
@account.featured_tags.where(tag_id: @tags.pluck(:id)).find_each do |featured_tag|
|
||||||
|
featured_tag.increment(status.created_at)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def attach_mentions(status)
|
||||||
@mentions.each do |mention|
|
@mentions.each do |mention|
|
||||||
mention.status = status
|
mention.status = status
|
||||||
mention.save
|
mention.save
|
||||||
|
|
|
@ -188,7 +188,26 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_tags!
|
def update_tags!
|
||||||
@status.tags = Tag.find_or_create_by_names(@raw_tags)
|
previous_tags = @status.tags.to_a
|
||||||
|
current_tags = @status.tags = Tag.find_or_create_by_names(@raw_tags)
|
||||||
|
|
||||||
|
return unless @status.distributable?
|
||||||
|
|
||||||
|
added_tags = current_tags - previous_tags
|
||||||
|
|
||||||
|
unless added_tags.empty?
|
||||||
|
@account.featured_tags.where(tag_id: added_tags.pluck(:id)).find_each do |featured_tag|
|
||||||
|
featured_tag.increment(@status.created_at)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
removed_tags = previous_tags - current_tags
|
||||||
|
|
||||||
|
return if removed_tags.empty?
|
||||||
|
|
||||||
|
@account.featured_tags.where(tag_id: removed_tags.pluck(:id)).find_each do |featured_tag|
|
||||||
|
featured_tag.decrement(@status)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_mentions!
|
def update_mentions!
|
||||||
|
|
|
@ -25,10 +25,6 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
context 'when fetching' do
|
context 'when fetching' do
|
||||||
subject { described_class.new(json, sender) }
|
subject { described_class.new(json, sender) }
|
||||||
|
|
||||||
before do
|
|
||||||
subject.perform
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when object publication date is below ISO8601 range' do
|
context 'when object publication date is below ISO8601 range' do
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
|
@ -40,6 +36,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status with a valid creation date', :aggregate_failures do
|
it 'creates status with a valid creation date', :aggregate_failures do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -60,6 +58,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status with a valid creation date', :aggregate_failures do
|
it 'creates status with a valid creation date', :aggregate_failures do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -81,6 +81,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status with appropriate creation and edition dates', :aggregate_failures do
|
it 'creates status with appropriate creation and edition dates', :aggregate_failures do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -104,18 +106,14 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status and does not mark it as edited' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.text).to eq 'Lorem ipsum'
|
expect(status.text).to eq 'Lorem ipsum'
|
||||||
end
|
expect(status.edited?).to be false
|
||||||
|
|
||||||
it 'does not mark status as edited' do
|
|
||||||
status = sender.statuses.first
|
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
|
||||||
expect(status.edited?).to eq false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +127,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not create a status' do
|
it 'does not create a status' do
|
||||||
expect(sender.statuses.count).to be_zero
|
expect { subject.perform }.to_not change(sender.statuses, :count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -143,6 +141,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -150,6 +150,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'missing to/cc defaults to direct privacy' do
|
it 'missing to/cc defaults to direct privacy' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -168,6 +170,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -186,6 +190,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -204,6 +210,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -222,6 +230,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -240,6 +250,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -258,6 +270,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -276,6 +290,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -298,6 +314,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -317,15 +335,13 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status with a silent mention' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.visibility).to eq 'limited'
|
expect(status.visibility).to eq 'limited'
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates silent mention' do
|
|
||||||
status = sender.statuses.first
|
|
||||||
expect(status.mentions.first).to be_silent
|
expect(status.mentions.first).to be_silent
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -347,6 +363,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -367,6 +385,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -395,6 +415,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -417,6 +439,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -439,6 +463,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -465,6 +491,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -490,6 +518,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -515,6 +545,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -538,6 +570,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -560,6 +594,42 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status.tags.map(&:name)).to include('test')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with featured hashtags' do
|
||||||
|
let(:object_json) do
|
||||||
|
{
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||||
|
type: 'Note',
|
||||||
|
content: 'Lorem ipsum',
|
||||||
|
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
tag: [
|
||||||
|
{
|
||||||
|
type: 'Hashtag',
|
||||||
|
href: 'http://example.com/blah',
|
||||||
|
name: '#test',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
sender.featured_tags.create!(name: 'test')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates status and updates featured tag' do
|
||||||
|
expect { subject.perform }
|
||||||
|
.to change(sender.statuses, :count).by(1)
|
||||||
|
.and change { sender.featured_tags.first.reload.statuses_count }.by(1)
|
||||||
|
.and change { sender.featured_tags.first.reload.last_status_at }.from(nil).to(be_within(0.1).of(Time.now.utc))
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -583,6 +653,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -605,6 +677,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -629,6 +703,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -655,6 +731,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
|
@ -680,6 +758,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -701,6 +781,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
end
|
end
|
||||||
|
@ -731,13 +813,13 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status with a poll' do
|
||||||
|
expect { subject.perform }.to change(sender.statuses, :count).by(1)
|
||||||
|
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.poll).to_not be_nil
|
expect(status.poll).to_not be_nil
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a poll' do
|
|
||||||
poll = sender.polls.first
|
poll = sender.polls.first
|
||||||
expect(poll).to_not be_nil
|
expect(poll).to_not be_nil
|
||||||
expect(poll.status).to_not be_nil
|
expect(poll.status).to_not be_nil
|
||||||
|
@ -760,6 +842,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'adds a vote to the poll with correct uri' do
|
it 'adds a vote to the poll with correct uri' do
|
||||||
|
expect { subject.perform }.to change(poll.votes, :count).by(1)
|
||||||
|
|
||||||
vote = poll.votes.first
|
vote = poll.votes.first
|
||||||
expect(vote).to_not be_nil
|
expect(vote).to_not be_nil
|
||||||
expect(vote.uri).to eq object_json[:id]
|
expect(vote.uri).to eq object_json[:id]
|
||||||
|
@ -785,6 +869,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not add a vote to the poll' do
|
it 'does not add a vote to the poll' do
|
||||||
|
expect { subject.perform }.to_not change(poll.votes, :count)
|
||||||
|
|
||||||
expect(poll.votes.first).to be_nil
|
expect(poll.votes.first).to be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -294,16 +294,22 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService, type: :service do
|
||||||
updated: '2021-09-08T22:39:25Z',
|
updated: '2021-09-08T22:39:25Z',
|
||||||
tag: [
|
tag: [
|
||||||
{ type: 'Hashtag', name: 'foo' },
|
{ type: 'Hashtag', name: 'foo' },
|
||||||
|
{ type: 'Hashtag', name: 'bar' },
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.call(status, json, json)
|
status.account.featured_tags.create!(name: 'bar')
|
||||||
|
status.account.featured_tags.create!(name: 'test')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates tags' do
|
it 'updates tags and featured tags' do
|
||||||
expect(status.tags.reload.map(&:name)).to eq %w(foo)
|
expect { subject.call(status, json, json) }
|
||||||
|
.to change { status.tags.reload.pluck(:name) }.from(%w(test foo)).to(%w(foo bar))
|
||||||
|
.and change { status.account.featured_tags.find_by(name: 'test').statuses_count }.by(-1)
|
||||||
|
.and change { status.account.featured_tags.find_by(name: 'bar').statuses_count }.by(1)
|
||||||
|
.and change { status.account.featured_tags.find_by(name: 'bar').last_status_at }.from(nil).to(be_within(0.1).of(Time.now.utc))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user