fix #289. This fix is different from the one in the master branch. It only the filename (without the whole path and the extension)
This commit is contained in:
parent
1da5617b80
commit
f77bdd9826
@ -39,11 +39,13 @@ module Locomotive
|
||||
alias :_permalink= :_slug=
|
||||
|
||||
def _label(type = nil)
|
||||
if self._label_field_name
|
||||
value = if self._label_field_name
|
||||
self.send(self._label_field_name.to_sym)
|
||||
else
|
||||
self.send((type || self.content_type).label_field_name.to_sym)
|
||||
end
|
||||
|
||||
value.respond_to?(:to_label) ? value.to_label : value
|
||||
end
|
||||
|
||||
def next
|
||||
|
@ -2,6 +2,10 @@ module CarrierWave
|
||||
module Uploader
|
||||
class Base
|
||||
|
||||
def to_label
|
||||
File.basename(self.to_s, File.extname(self.to_s))
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
Locomotive::Liquid::Drops::Uploader.new(self)
|
||||
end
|
||||
|
@ -10,6 +10,7 @@ describe Locomotive::ContentEntry do
|
||||
@content_type.entries_custom_fields.build :label => 'Title', :type => 'string'
|
||||
@content_type.entries_custom_fields.build :label => 'Description', :type => 'text'
|
||||
@content_type.entries_custom_fields.build :label => 'Visible ?', :type => 'boolean', :name => 'visible'
|
||||
@content_type.entries_custom_fields.build :label => 'File', :type => 'file'
|
||||
@content_type.valid?
|
||||
@content_type.send(:set_default_values)
|
||||
end
|
||||
@ -127,6 +128,12 @@ describe Locomotive::ContentEntry do
|
||||
@content_entry._permalink.should == 'my-test'
|
||||
end
|
||||
|
||||
it 'also accepts a file field as the highlighted field' do
|
||||
@content_entry.stubs(:_label_field_name).returns('file')
|
||||
@content_entry.file = FixturedAsset.open('5k.png'); @content_entry.send(:set_slug)
|
||||
@content_entry._permalink.should == '5k'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#visibility' do
|
||||
|
Loading…
Reference in New Issue
Block a user