test/unit/text_document_test.rb in zena-1.0.0.beta3 vs test/unit/text_document_test.rb in zena-1.0.0.rc1

- old
+ new

@@ -24,11 +24,11 @@ should 'parse css assets' do css =<<-END_CSS body { font-size:10px; } #header { background:url('bird.jpg') } #pv { background:url('bird_pv.jpg') } - #footer { background:url('/projects/wiki/flower.jpg') } + #footer { background:url('/projects list/a wiki with Zena/flower.jpg') } #no_stamp { background:url('/en/image30_pv.jpg?100001001345') } END_CSS assert subject.update_attributes(:text => css) @@ -46,42 +46,42 @@ node = secure(Node) { nodes(:style_css) } assert_equal parsed_css, node.text end end # in a folder with an image end # on a css text_document - + context 'creating a text document' do context 'with a content_type' do subject do secure!(TextDocument) { TextDocument.create( - :node_name => "yoba", + :title => "yoba", :parent_id => nodes_id(:wiki), :text => "#header { color:red; }\n#footer { color:blue; }", - :content_type => 'text/css') + :content_type => 'text/css') } end - + should 'create a new TextDocument' do assert_difference('TextDocument.count', 1) do subject end end - + should 'set extension from content_type' do assert_equal 'css', subject.ext end end # with a content_type end # creating a text document end # A visitor with write access def test_create_simplest login(:tiger) - doc = secure!(Document) { Document.create(:parent_id=>nodes_id(:cleanWater), :node_name => 'skiny')} + doc = secure!(Document) { Document.create(:parent_id=>nodes_id(:cleanWater), :title => 'skiny')} assert_equal TextDocument, doc.class assert !doc.new_record?, "Not a new record" assert_equal 0, doc.size - doc = secure!(Document) { Document.create(:parent_id=>nodes_id(:cleanWater), :node_name => 'medium', :text=>"12345678901234567890")} + doc = secure!(Document) { Document.create(:parent_id=>nodes_id(:cleanWater), :title => 'medium', :text=>"12345678901234567890")} assert_equal TextDocument, doc.class assert !doc.new_record?, "Not a new record" assert_equal 20, doc.size end @@ -89,10 +89,11 @@ login(:tiger) next_id = Version.find(:first, :order=>"id DESC")[:id] + 1 file = uploaded_text('some.txt') doc = secure!(Document) { Document.create( :parent_id => nodes_id(:cleanWater), :file => file ) } + assert_equal TextDocument, doc.class # reload doc = secure!(Document) { Document.find(doc[:id])} assert_nil doc.filepath assert_equal 'txt', doc.ext @@ -125,12 +126,12 @@ Zena::Db.set_attribute(bird, :updated_at, b_at) start =<<-END_CSS body { font-size:10px; behavior:url("/stylesheets/csshover2.htc"); } #header { background:url('bird.jpg') } #pv { background:url('bird_pv.jpg') } - #footer { background:url('/projects/wiki/flower.jpg') } - #back { background:url('../../projects/wiki/flower.jpg') } + #footer { background:url('/projects list/a wiki with Zena/flower.jpg') } + #back { background:url('../../projects list/a wiki with Zena/flower.jpg') } #no_stamp { background:url('/en/image30_pv.jpg') } END_CSS node.text = start.dup # dummy controller helper = ApplicationController.new @@ -152,12 +153,12 @@ text = node.unparse_assets(text, helper, 'text') unparsed =<<-END_CSS body { font-size:10px; behavior:url("/stylesheets/csshover2.htc"); } #header { background:url('bird.jpg') } #pv { background:url('bird_pv.jpg') } - #footer { background:url('/projects/wiki/flower.jpg') } - #back { background:url('/projects/wiki/flower.jpg') } + #footer { background:url('/projects list/a wiki with Zena/flower.jpg') } + #back { background:url('/projects list/a wiki with Zena/flower.jpg') } #no_stamp { background:url('bird_pv.jpg') } END_CSS assert_equal unparsed, text text = node.unparse_assets(text, helper, 'text') assert_equal unparsed, text @@ -167,16 +168,16 @@ login(:lion) node = secure!(Node) { nodes(:style_css) } bird = secure!(Node) { nodes(:bird_jpg)} b_at = bird.updated_at # We need to publish so that the title is used for fullpath - assert bird.update_attributes(:parent_id => node[:parent_id], :title => "greenBird", :v_status => Zena::Status[:pub]) + assert bird.update_attributes(:parent_id => node[:parent_id], :title => "green_bird", :v_status => Zena::Status[:pub]) Zena::Db.set_attribute(bird, :updated_at, b_at) start =<<-END_CSS body { font-size:10px; } #header { background:url('green_bird.jpg') } #tiny { background:url('green_bird_tiny.jpg') } - #footer { background:url('/projects/wiki/flower.jpg') } + #footer { background:url('/projects list/a wiki with Zena/flower.jpg') } END_CSS node.text = start.dup # dummy controller helper = ApplicationController.new helper.instance_variable_set(:@visitor, visitor)