fix bugs with acts_as_tree + fix cucumber tests

This commit is contained in:
dinedine 2010-08-20 18:24:59 +02:00
parent e25ded881b
commit dbc542c4d7
11 changed files with 23 additions and 21 deletions

View File

@ -11,7 +11,7 @@ module Admin
def new
@page = current_site.pages.build
@page.parts << PagePart.build_body_part
# @page.parts << PagePart.build_body_part
end
def sort

View File

@ -3,9 +3,9 @@ class ApplicationController < ActionController::Base
protected
rescue_from Exception, :with => :render_error
def render_error
render :template => "/admin/errors/500", :layout => 'admin/box', :status => 500
end
# rescue_from Exception, :with => :render_error
#
# def render_error
# render :template => "/admin/errors/500", :layout => 'admin/box', :status => 500
# end
end

View File

@ -44,7 +44,10 @@ module Models
end
def hacked_descendants
return [] if new_record?
# workorund for mongoid unexpected behavior
_new_record_var = self.instance_variable_get(:@new_record)
_new_record = _new_record_var != false
return [] if _new_record
self.class.all_in(path_field => [self._id]).order_by tree_order
end

View File

@ -17,9 +17,6 @@ class Page
field :layout_template # FIXME: added for liquid inheritance
# allows newly pages to have a default body
attr_accessor :body
## associations ##
referenced_in :site

View File

@ -83,7 +83,7 @@ class Site
self.pages.create({
:slug => slug,
:title => I18n.t("attributes.defaults.pages.#{slug}.title"),
:body => I18n.t("attributes.defaults.pages.#{slug}.body"),
:layout_template => I18n.t("attributes.defaults.pages.#{slug}.body"),
:published => true
})
end

View File

@ -21,8 +21,9 @@
= f.input :cache_strategy, :as => :select, :collection => options_for_page_cache_strategy, :include_blank => false
= f.foldable_inputs :name => :code do
= f.foldable_inputs :name => :layout_template do
= f.custom_input :value, :css => 'code full', :with_label => false do
= f.label :layout_template
%code{ :class => 'html' }
= f.text_area :layout_template
/ .more

View File

@ -245,6 +245,7 @@ en:
information: General information
meta: SEO Metadata
code: Code
layout_template: Layout
credentials: Credentials
language: Language
sites: Sites

View File

@ -244,6 +244,7 @@ fr:
information: Informations générales
meta: SEO Metadata
code: Code
layout_template: Gabarit
credentials: Informations de connexion
language: Langue
sites: Sites

View File

@ -18,16 +18,16 @@ Scenario: Creating a valid page
And I fill in "Title" with "Test"
And I fill in "Slug" with "test"
And I select "Home page" from "Parent"
And I fill in "Layout Template" with "Lorem ipsum...."
And I fill in "Layout template" with "Lorem ipsum...."
And I press "Create"
Then I should see "Page was successfully created."
And I should have "Lorem ipsum...." in the test page layout
And I should have "Lorem ipsum...." in the test page
Scenario: Updating a valid page
When I go to pages
And I follow "Home page"
And I fill in "Title" with "Home page !"
And I fill in "Layout Template" with "My new content is here"
And I fill in "Layout template" with "My new content is here"
And I press "Update"
Then I should see "Page was successfully updated."
And I should have "My new content is here" in the index page layout
And I should have "My new content is here" in the index page

View File

@ -42,14 +42,11 @@ When /^I view the rendered page at "([^"]*)"$/ do |path|
end
# checks to see if a string is in the slug
Then /^I should have "(.*)" in the (.*) page (.*)$/ do |content, page_slug, part_slug|
Then /^I should have "(.*)" in the (.*) page$/ do |content, page_slug|
page = @site.pages.where(:slug => page_slug).first
raise "Could not find page: #{page_slug}" unless page
part = page.parts.where(:slug => part_slug).first
raise "Could not find part: #{part_slug} within page: #{page_slug}" unless part
part.value.should == content
page.layout_template.should == content
end
# checks if the rendered body matches a string

View File

@ -137,6 +137,8 @@ form.formtastic fieldset ol li p.inline-errors {
font-size: 0.7em !important;
}
form.formtastic fieldset ol li.code label { display: none; }
form.formtastic fieldset ol li.code p.inline-errors {
display: block;
float: right;