fix a bug with the url of file field
did
committed Oct 11, 2015
commit c48744339c4a3194614699da3df775d0a388ce20
Showing 3
changed files with
4 additions
and 3 deletions
locomotive/steam/entities/content_entry.rb b/lib/locomotive/steam/entities/content_entry.rb
+1
-1
| @@ | @@ -127,7 +127,7 @@ module Locomotive::Steam |
| def _cast_file(field) | |
| _cast_convertor(field.name) do |value| | |
| - | value.respond_to?(:url) ? value : FileField.new(value, self[:base_url], self.updated_at) |
| + | value.respond_to?(:url) ? value : FileField.new(value, self.base_url, self.updated_at) |
| end | |
| end | |
spec/unit/entities/content_entry_spec.rb
+2
-1
| @@ | @@ -58,13 +58,14 @@ describe Locomotive::Steam::ContentEntry do |
| describe '#to_hash' do | |
| let(:fields) { [instance_double('TitleField', name: :title, type: :string), instance_double('PictureField', name: :picture, type: :file, localized: true)] } | |
| - | let(:attributes) { { id: 42, title: 'Hello world', _slug: 'hello-world', picture: Locomotive::Steam::Models::I18nField.new(:picture, fr: 'foo.png', en: 'bar.png'), base_url: '/assets', custom_fields_recipe: ['hello', 'world'], _type: 'Entry' } } |
| + | let(:attributes) { { id: 42, title: 'Hello world', _slug: 'hello-world', picture: Locomotive::Steam::Models::I18nField.new(:picture, fr: 'foo.png', en: 'bar.png'), custom_fields_recipe: ['hello', 'world'], _type: 'Entry' } } |
| subject { content_entry.to_hash } | |
| before do | |
| allow(type).to receive(:fields_by_name).and_return({ title: fields.first, picture: fields.last }) | |
| allow(type).to receive(:persisted_field_names).and_return([:title, :picture]) | |
| + | allow(content_entry).to receive(:base_url).and_return('/assets') |
| end | |
| it { expect(Set.new(subject.keys)).to eq(Set.new(['_id', '_position', '_visible', '_label', '_slug', 'content_type_slug', 'title', 'picture', 'created_at', 'updated_at'])) } | |
spec/unit/services/translator_service_spec.rb
+1
-1
| @@ | @@ -33,7 +33,7 @@ describe Locomotive::Steam::TranslatorService do |
| context "specifying a locale that doesn't exist" do | |
| - | let(:locale) { puts 'NL'; 'nl' } |
| + | let(:locale) { 'nl' } |
| it 'reverts to default locale' do | |
| is_expected.to eq 'example_test' | |