|
|
|
@ -99,73 +99,87 @@ RSpec.describe Notification do
|
|
|
|
|
]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads target status' do
|
|
|
|
|
# mention
|
|
|
|
|
expect(subject[0].type).to eq :mention
|
|
|
|
|
expect(subject[0].association(:mention)).to be_loaded
|
|
|
|
|
expect(subject[0].mention.association(:status)).to be_loaded
|
|
|
|
|
|
|
|
|
|
# status
|
|
|
|
|
expect(subject[1].type).to eq :status
|
|
|
|
|
expect(subject[1].association(:status)).to be_loaded
|
|
|
|
|
|
|
|
|
|
# reblog
|
|
|
|
|
expect(subject[2].type).to eq :reblog
|
|
|
|
|
expect(subject[2].association(:status)).to be_loaded
|
|
|
|
|
expect(subject[2].status.association(:reblog)).to be_loaded
|
|
|
|
|
|
|
|
|
|
# follow: nothing
|
|
|
|
|
expect(subject[3].type).to eq :follow
|
|
|
|
|
expect(subject[3].target_status).to be_nil
|
|
|
|
|
|
|
|
|
|
# follow_request: nothing
|
|
|
|
|
expect(subject[4].type).to eq :follow_request
|
|
|
|
|
expect(subject[4].target_status).to be_nil
|
|
|
|
|
|
|
|
|
|
# favourite
|
|
|
|
|
expect(subject[5].type).to eq :favourite
|
|
|
|
|
expect(subject[5].association(:favourite)).to be_loaded
|
|
|
|
|
expect(subject[5].favourite.association(:status)).to be_loaded
|
|
|
|
|
|
|
|
|
|
# poll
|
|
|
|
|
expect(subject[6].type).to eq :poll
|
|
|
|
|
expect(subject[6].association(:poll)).to be_loaded
|
|
|
|
|
expect(subject[6].poll.association(:status)).to be_loaded
|
|
|
|
|
context 'with a preloaded target status' do
|
|
|
|
|
it 'preloads mention' do
|
|
|
|
|
expect(subject[0].type).to eq :mention
|
|
|
|
|
expect(subject[0].association(:mention)).to be_loaded
|
|
|
|
|
expect(subject[0].mention.association(:status)).to be_loaded
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads status' do
|
|
|
|
|
expect(subject[1].type).to eq :status
|
|
|
|
|
expect(subject[1].association(:status)).to be_loaded
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads reblog' do
|
|
|
|
|
expect(subject[2].type).to eq :reblog
|
|
|
|
|
expect(subject[2].association(:status)).to be_loaded
|
|
|
|
|
expect(subject[2].status.association(:reblog)).to be_loaded
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads follow as nil' do
|
|
|
|
|
expect(subject[3].type).to eq :follow
|
|
|
|
|
expect(subject[3].target_status).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads follow_request as nill' do
|
|
|
|
|
expect(subject[4].type).to eq :follow_request
|
|
|
|
|
expect(subject[4].target_status).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads favourite' do
|
|
|
|
|
expect(subject[5].type).to eq :favourite
|
|
|
|
|
expect(subject[5].association(:favourite)).to be_loaded
|
|
|
|
|
expect(subject[5].favourite.association(:status)).to be_loaded
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'preloads poll' do
|
|
|
|
|
expect(subject[6].type).to eq :poll
|
|
|
|
|
expect(subject[6].association(:poll)).to be_loaded
|
|
|
|
|
expect(subject[6].poll.association(:status)).to be_loaded
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces to cached status' do
|
|
|
|
|
# mention
|
|
|
|
|
expect(subject[0].type).to eq :mention
|
|
|
|
|
expect(subject[0].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[0].target_status).to eq mention.status
|
|
|
|
|
|
|
|
|
|
# status
|
|
|
|
|
expect(subject[1].type).to eq :status
|
|
|
|
|
expect(subject[1].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[1].target_status).to eq status
|
|
|
|
|
|
|
|
|
|
# reblog
|
|
|
|
|
expect(subject[2].type).to eq :reblog
|
|
|
|
|
expect(subject[2].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[2].target_status).to eq reblog.reblog
|
|
|
|
|
|
|
|
|
|
# follow: nothing
|
|
|
|
|
expect(subject[3].type).to eq :follow
|
|
|
|
|
expect(subject[3].target_status).to be_nil
|
|
|
|
|
|
|
|
|
|
# follow_request: nothing
|
|
|
|
|
expect(subject[4].type).to eq :follow_request
|
|
|
|
|
expect(subject[4].target_status).to be_nil
|
|
|
|
|
|
|
|
|
|
# favourite
|
|
|
|
|
expect(subject[5].type).to eq :favourite
|
|
|
|
|
expect(subject[5].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[5].target_status).to eq favourite.status
|
|
|
|
|
|
|
|
|
|
# poll
|
|
|
|
|
expect(subject[6].type).to eq :poll
|
|
|
|
|
expect(subject[6].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[6].target_status).to eq poll.status
|
|
|
|
|
context 'with a cached status' do
|
|
|
|
|
it 'replaces mention' do
|
|
|
|
|
expect(subject[0].type).to eq :mention
|
|
|
|
|
expect(subject[0].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[0].target_status).to eq mention.status
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces status' do
|
|
|
|
|
expect(subject[1].type).to eq :status
|
|
|
|
|
expect(subject[1].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[1].target_status).to eq status
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces reblog' do
|
|
|
|
|
expect(subject[2].type).to eq :reblog
|
|
|
|
|
expect(subject[2].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[2].target_status).to eq reblog.reblog
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces follow' do
|
|
|
|
|
expect(subject[3].type).to eq :follow
|
|
|
|
|
expect(subject[3].target_status).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces follow_request' do
|
|
|
|
|
expect(subject[4].type).to eq :follow_request
|
|
|
|
|
expect(subject[4].target_status).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces favourite' do
|
|
|
|
|
expect(subject[5].type).to eq :favourite
|
|
|
|
|
expect(subject[5].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[5].target_status).to eq favourite.status
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'replaces poll' do
|
|
|
|
|
expect(subject[6].type).to eq :poll
|
|
|
|
|
expect(subject[6].target_status.association(:account)).to be_loaded
|
|
|
|
|
expect(subject[6].target_status).to eq poll.status
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|