# Delete a project's wiki
def destroy
if request.post? && params[:confirm] && @project.wiki
- if @project.wiki.destroy
- Wiki.create_default(@project) unless @wiki
- end
+ @project.wiki.destroy
redirect_to project_path(@project)
end
end
when 'wiki'
# Create a wiki with a default start page
if project && project.wiki.nil?
- Wiki.create_default(project)
+ Wiki.create(:project => project, :start_page => 'Wiki')
end
end
end
end
end
- def self.create_default(project)
- create(:project => project, :start_page => 'Wiki')
- end
-
# turn a string into a valid page title
def self.titleize(title)
# replace spaces with _ and remove unwanted caracters
end
end
- def test_post_destroy_should_reinitialize_empty_wiki
+ def test_post_destroy_should_delete_wiki
set_tmp_attachments_directory
@request.session[:user_id] = 1
- wiki = Project.find(1).wiki
post :destroy, :params => {:id => 1, :confirm => 1}
assert_redirected_to :controller => 'projects',
:action => 'show', :id => 'ecookbook'
-
- new_wiki = Project.find(1).wiki
- assert_not_equal wiki, new_wiki
- assert_equal "Wiki", new_wiki.start_page
+ assert_nil Project.find(1).wiki
end
def test_not_found
assert wiki.save
end
- def test_create_default
- wiki = Wiki.create_default(Project.find(1))
- assert wiki.save
- assert_equal "Wiki", wiki.start_page
- end
-
def test_update
@wiki = Wiki.find(1)
@wiki.start_page = "Another start page"