This commit is contained in:
Didier Lafforgue 2012-05-07 00:31:59 +02:00
parent f42fb1afe1
commit e225ad2278
2 changed files with 8 additions and 1 deletions

View File

@ -27,7 +27,7 @@ module Locomotive
def set_label_field
if @new_label_field_name.present?
self.label_field_id = self.entries_custom_fields.detect { |f| f.name == @new_label_field_name.underscore }._id
self.label_field_id = self.entries_custom_fields.detect { |f| f.name == @new_label_field_name.underscore }.try(:_id)
end
# unknown label_field_name, get the first one instead

View File

@ -284,6 +284,13 @@ describe Locomotive::ContentType do
lambda { asset.active_at }.should raise_error
end
it 'removes the field used as the label when setting the original label_field_name value before' do
@content_type.label_field_name = 'name'
@content_type.entries_custom_fields.destroy_all :conditions => { :name => @content_type.label_field_name }
@content_type.save
@content_type.label_field_name.should == 'description'
end
it 'renames field label' do
@content_type.entries_custom_fields[1].label = 'Simple description'
@content_type.entries_custom_fields[1].name = nil