diff --git a/app/models/locomotive/page.rb b/app/models/locomotive/page.rb index 7126e454..cbd01c16 100644 --- a/app/models/locomotive/page.rb +++ b/app/models/locomotive/page.rb @@ -51,7 +51,7 @@ module Locomotive scope :published, :where => { :published => true } scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } } scope :handle, lambda { |handle| { :where => { :handle => handle } } } - scope :minimal_attributes, lambda { |attrs=[]| {:only => attrs + %w(title slug fullpath position depth published templatized redirect listed parent_id created_at updated_at) } } + scope :minimal_attributes, lambda { |attrs = []| { :only => (attrs || []) + %w(title slug fullpath position depth published templatized redirect listed parent_id site_id created_at updated_at) } } ## methods ## diff --git a/spec/models/locomotive/editable_file_spec.rb b/spec/models/locomotive/editable_file_spec.rb index b5bced3c..b16d1d15 100644 --- a/spec/models/locomotive/editable_file_spec.rb +++ b/spec/models/locomotive/editable_file_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Locomotive::EditableElement do +describe Locomotive::EditableFile do before(:each) do @site = FactoryGirl.create(:site) @@ -22,4 +22,23 @@ describe Locomotive::EditableElement do (fields.include?('source') && fields.include?(:source)).should be_false end + context 'with an attached file' do + + before(:each) do + @editable_file = @home.editable_elements.first + @editable_file.source = FixturedAsset.open('5k.png') + @home.save + end + + it 'has a valid source' do + @editable_file.source?.should be_true + end + + it 'returns the right path even if the page has been retrieved with the minimum_attributes scope' do + @home = @site.pages.minimal_attributes(%w(editable_elements)).root.first + @home.editable_elements.first.source?.should be_true + end + + end + end