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 def new
@page = current_site.pages.build @page = current_site.pages.build
@page.parts << PagePart.build_body_part # @page.parts << PagePart.build_body_part
end end
def sort def sort

View File

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

View File

@ -44,7 +44,10 @@ module Models
end end
def hacked_descendants 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 self.class.all_in(path_field => [self._id]).order_by tree_order
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -18,16 +18,16 @@ Scenario: Creating a valid page
And I fill in "Title" with "Test" And I fill in "Title" with "Test"
And I fill in "Slug" with "test" And I fill in "Slug" with "test"
And I select "Home page" from "Parent" 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" And I press "Create"
Then I should see "Page was successfully created." 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 Scenario: Updating a valid page
When I go to pages When I go to pages
And I follow "Home page" And I follow "Home page"
And I fill in "Title" with "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" And I press "Update"
Then I should see "Page was successfully updated." 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 end
# checks to see if a string is in the slug # 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 page = @site.pages.where(:slug => page_slug).first
raise "Could not find page: #{page_slug}" unless page raise "Could not find page: #{page_slug}" unless page
part = page.parts.where(:slug => part_slug).first page.layout_template.should == content
raise "Could not find part: #{part_slug} within page: #{page_slug}" unless part
part.value.should == content
end end
# checks if the rendered body matches a string # 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; font-size: 0.7em !important;
} }
form.formtastic fieldset ol li.code label { display: none; }
form.formtastic fieldset ol li.code p.inline-errors { form.formtastic fieldset ol li.code p.inline-errors {
display: block; display: block;
float: right; float: right;