Defect #34634 » 0004-Disable-the-wiki-module-after-deletion-of-a-project-.patch
| app/models/wiki.rb | ||
|---|---|---|
| 30 | 30 |
validates_length_of :start_page, maximum: 255 |
| 31 | 31 | |
| 32 | 32 |
before_destroy :delete_redirects |
| 33 |
after_destroy :disable_wiki_module |
|
| 33 | 34 | |
| 34 | 35 |
safe_attributes 'start_page' |
| 35 | 36 | |
| ... | ... | |
| 78 | 79 |
WikiRedirect.where(:redirects_to_wiki_id => id).delete_all |
| 79 | 80 |
end |
| 80 | 81 | |
| 82 |
# Disables the wiki module after deletion of a project wiki |
|
| 83 |
def disable_wiki_module |
|
| 84 |
project.disable_module!(:wiki) |
|
| 85 |
end |
|
| 86 |
private :disable_wiki_module |
|
| 87 | ||
| 81 | 88 |
# Finds a page by title |
| 82 | 89 |
# The given string can be of one of the forms: "title" or "project:title" |
| 83 | 90 |
# Examples: |
| test/functional/wikis_controller_test.rb | ||
|---|---|---|
| 43 | 43 |
:action => 'show', :id => 'ecookbook' |
| 44 | 44 |
assert_nil Project.find(1).wiki |
| 45 | 45 |
end |
| 46 |
|
|
| 47 |
def test_post_destroy_should_disable_wiki_module |
|
| 48 |
set_tmp_attachments_directory |
|
| 49 |
@request.session[:user_id] = 1 |
|
| 50 |
assert Project.find(1).module_enabled?(:wiki) |
|
| 51 |
post :destroy, :params => {:id => 1, :confirm => 1}
|
|
| 52 |
assert_not Project.find(1).module_enabled?(:wiki) |
|
| 53 |
end |
|
| 46 | 54 | |
| 47 | 55 |
def test_not_found |
| 48 | 56 |
@request.session[:user_id] = 1 |