File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,6 +245,12 @@ def load_rels
245245 def update
246246 replace_entry 'word/document.xml' , doc . serialize ( save_with : 0 )
247247 replace_entry 'word/styles.xml' , styles_configuration . serialize ( save_with : 0 )
248+ headers . each do |name , content |
249+ replace_entry "word/#{ name } .xml" , content . serialize ( save_with : 0 )
250+ end
251+ footers . each do |name , content |
252+ replace_entry "word/#{ name } .xml" , content . serialize ( save_with : 0 )
253+ end
248254 end
249255
250256 # generate Elements::Containers::Paragraph from paragraph XML node
Original file line number Diff line number Diff line change 8484 end
8585 end
8686
87+ describe 'updating headers and footers' do
88+ before do
89+ @doc = Docx ::Document . open ( @fixtures_path + '/multi_doc.docx' )
90+ @new_doc_path = @fixtures_path + '/multi_doc_saved.docx'
91+ end
92+
93+ after do
94+ File . delete ( @new_doc_path ) if File . exist? ( @new_doc_path )
95+ end
96+
97+ it 'persists changes to headers and footers after save' do
98+ @doc . headers [ 'header1' ] . at_xpath ( '//w:t' ) . content = 'Edited header.'
99+ @doc . footers [ 'footer1' ] . at_xpath ( '//w:t' ) . content = 'Edited footer.'
100+ @doc . save ( @new_doc_path )
101+
102+ reopened = Docx ::Document . open ( @new_doc_path )
103+ expect ( reopened . headers [ 'header1' ] . text ) . to eq 'Edited header.'
104+ expect ( reopened . footers [ 'footer1' ] . text ) . to eq 'Edited footer.'
105+ end
106+ end
107+
87108 describe 'read tables' do
88109 before do
89110 @doc = Docx ::Document . open ( @fixtures_path + '/tables.docx' )
You can’t perform that action at this time.
0 commit comments