Display "asciicast:<id>" as a title for title-less asciicasts

openid
Marcin Kulik 11 years ago
parent e9a8f1f645
commit 6009250a36

@ -23,13 +23,7 @@ class AsciicastDecorator < ApplicationDecorator
end
def title
if model.title.present?
model.title
elsif command.present?
"$ #{command}"
else
"##{id}"
end
model.title.presence || model.command.presence || "asciicast:#{id}"
end
def thumbnail(width = THUMBNAIL_WIDTH, height = THUMBNAIL_HEIGHT)

@ -133,7 +133,7 @@ describe AsciicastDecorator do
asciicast.command = 'cmd'
end
it { should == '$ cmd' }
it { should == 'cmd' }
end
context 'when no title nor command is present' do
@ -144,7 +144,7 @@ describe AsciicastDecorator do
end
it 'should be in the form of "#<id>"' do
should == "##{asciicast.id}"
should == "asciicast:#{asciicast.id}"
end
end
end

Loading…
Cancel
Save