diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index f04c161aec..2c9360d0ac 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -76,7 +76,7 @@ class WikiPage < ActiveRecord::Base after_destroy :delete_wiki_menu_item after_destroy do |wiki_page| - wiki_page.wiki.project.disable_module(:wiki) if is_only_wiki_page? + wiki_page.wiki.project.disable_module(:wiki) and wiki_page.wiki.destroy if is_only_wiki_page? end def check_and_mark_as_protected diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 70905b4667..985c23fdeb 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -63,6 +63,10 @@ describe WikiPage do it 'deactivates the wiki module' do project.module_enabled?(:wiki).should be_false end + + it 'destroys the project wiki' do + project.wiki.should be_nil + end end context 'when one of two wiki pages is destroyed' do @@ -75,6 +79,10 @@ describe WikiPage do it 'does not deactivate the wiki module' do project.module_enabled?(:wiki).should be_true end + + it 'does not destroy the project wiki' do + project.wiki.should be_present + end end end end