From e6f53532459ae6b9760c9a4efe67033c68730ebe Mon Sep 17 00:00:00 2001 From: did Date: Sun, 27 Feb 2011 11:33:49 +0100 Subject: [PATCH] add more tests --- doc/TODO | 5 ++- spec/models/editable_element_spec.rb | 55 ++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 spec/models/editable_element_spec.rb diff --git a/doc/TODO b/doc/TODO index da86681c..427c15eb 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,9 +1,12 @@ BOARD: +x pull requests #31 et #32 - duostack version - bugs - editable_elements slug becomes nil -- pull requests #31 et #32 + - uploading videos http://groups.google.com/group/carrierwave/browse_thread/thread/6e211d98f1ff4bc0/51717c2167695ca2?lnk=gst&q=version#51717c2167695ca2 + - editable_elements not updated (doesn't use index anymore) + - custom_fields not deleted (doesn't use index anymore) - editable_elements: inheritable: false (Mattias) - 2 different sites on the same main domain (one in www, the other one in something else) (Raphael Costa) diff --git a/spec/models/editable_element_spec.rb b/spec/models/editable_element_spec.rb new file mode 100644 index 00000000..429cd8bf --- /dev/null +++ b/spec/models/editable_element_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe EditableElement do + + before(:each) do + @site = Factory(:site) + @home = @site.pages.root.first + @home.update_attributes :raw_template => "{% block body %}{% editable_short_text 'body' %}Lorem ipsum{% endeditable_short_text %}{% endblock %}" + + @sub_page_1 = Factory(:page, :slug => 'sub_page_1', :parent => @home, :raw_template => "{% extends 'parent' %}") + @sub_page_2 = Factory(:page, :slug => 'sub_page_2', :parent => @home, :raw_template => "{% extends 'parent' %}") + + @sub_page_1_1 = Factory(:page, :slug => 'sub_page_1_1', :parent => @sub_page_1, :raw_template => "{% extends 'parent' %}") + end + + context 'in sub pages level #1' do + + before(:each) do + @sub_page_1.reload + @sub_page_2.reload + end + + it 'exists' do + @sub_page_1.editable_elements.size.should == 1 + @sub_page_2.editable_elements.size.should == 1 + end + + it 'has a non-nil slug' do + @sub_page_1.editable_elements.first.slug.should == 'body' + end + + end + + context 'in sub pages level #2' do + + before(:each) do + @sub_page_1_1.reload + end + + it 'exists' do + @sub_page_1_1.editable_elements.size.should == 1 + end + + it 'has a non-nil slug' do + @sub_page_1_1.editable_elements.first.slug.should == 'body' + end + + it 'removes editable elements' do + @sub_page_1_1.editable_elements.destroy_all + @sub_page_1_1.reload + @sub_page_1_1.editable_elements.size.should == 0 + end + + end +end \ No newline at end of file