fix a bug about the editable_file not correctly displayed in a snippet given as an argument of the new nav tag

This commit is contained in:
Didier Lafforgue 2012-03-09 13:05:44 +01:00
parent 7ab8110e41
commit 1c902a5448
2 changed files with 21 additions and 2 deletions

View File

@ -51,7 +51,7 @@ module Locomotive
scope :published, :where => { :published => true } scope :published, :where => { :published => true }
scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } } scope :fullpath, lambda { |fullpath| { :where => { :fullpath => fullpath } } }
scope :handle, lambda { |handle| { :where => { :handle => handle } } } 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 ## ## methods ##

View File

@ -1,6 +1,6 @@
require 'spec_helper' require 'spec_helper'
describe Locomotive::EditableElement do describe Locomotive::EditableFile do
before(:each) do before(:each) do
@site = FactoryGirl.create(:site) @site = FactoryGirl.create(:site)
@ -22,4 +22,23 @@ describe Locomotive::EditableElement do
(fields.include?('source') && fields.include?(:source)).should be_false (fields.include?('source') && fields.include?(:source)).should be_false
end 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 end