소스 검색

improve status title (#8596)

* improve shown status title, useful for atom/rss

* use single quotes to satisfy codeclimate

* fix tests, make message more pretty

* fix tests

* fix codestyle

* fix codestyle

* remove atom_serializer_spec

Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
pull/1263/head
Alexander Yamagishi Kazutoshi 1 년 전
부모
커밋
05756c9a14
2개의 변경된 파일13개의 추가작업 그리고 5개의 파일을 삭제
  1. +5
    -1
      app/models/status.rb
  2. +8
    -4
      spec/models/status_spec.rb

+ 5
- 1
app/models/status.rb 파일 보기

@@ -194,8 +194,12 @@ class Status < ApplicationRecord
def title
if destroyed?
"#{account.acct} deleted status"
elsif reblog?
preview = sensitive ? '<sensitive>' : text.slice(0, 10).split("\n")[0]
"#{account.acct} shared #{reblog.account.acct}'s: #{preview}"
else
reblog? ? "#{account.acct} shared a status by #{reblog.account.acct}" : "New status by #{account.acct}"
preview = sensitive ? '<sensitive>' : text.slice(0, 20).split("\n")[0]
"#{account.acct}: #{preview}"
end
end



+ 8
- 4
spec/models/status_spec.rb 파일 보기

@@ -96,16 +96,20 @@ RSpec.describe Status, type: :model do

context 'unless destroyed?' do
context 'if reblog?' do
it 'returns "#{account.acct} shared a status by #{reblog.account.acct}"' do
it 'returns "#{account.acct} shared #{reblog.account.acct}\'s: #{preview}"' do
reblog = subject.reblog = other
expect(subject.title).to eq "#{account.acct} shared a status by #{reblog.account.acct}"
preview = subject.text.slice(0, 10).split("\n")[0]
expect(subject.title).to(
eq "#{account.acct} shared #{reblog.account.acct}'s: #{preview}"
)
end
end

context 'unless reblog?' do
it 'returns "New status by #{account.acct}"' do
it 'returns "#{account.acct}: #{preview}"' do
subject.reblog = nil
expect(subject.title).to eq "New status by #{account.acct}"
preview = subject.text.slice(0, 20).split("\n")[0]
expect(subject.title).to eq "#{account.acct}: #{preview}"
end
end
end


불러오는 중...
취소
저장