diff options
author | Rémy Coutable <remy@rymai.me> | 2017-03-20 16:53:24 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2017-03-20 16:53:24 +0300 |
commit | b075d38c9b98d4b39441bd29d2c36be4637b6f72 (patch) | |
tree | 2f87f6d4a2b120696c24a74a46551859e865bdf4 /app | |
parent | 915af2dc5ae903d0007f5c2c75518483e00ab610 (diff) | |
parent | 2dd9b8a38ad545c98355115589a9060b93de0b03 (diff) |
Merge branch '29405-fix-project-wiki-update' into 'master'
Fix Project Wiki update
Closes #29405
See merge request !9990
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 3 | ||||
-rw-r--r-- | app/helpers/nav_helper.rb | 1 | ||||
-rw-r--r-- | app/models/wiki_page.rb | 8 |
3 files changed, 8 insertions, 4 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 8b6c83d4fed..f210f7e61d2 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -45,8 +45,9 @@ class Projects::WikisController < Projects::ApplicationController return render('empty') unless can?(current_user, :create_wiki, @project) @page = @project_wiki.find_page(params[:id]) + @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) - if @page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page) + if @page.valid? redirect_to( namespace_project_wiki_path(@project.namespace, @project, @page), notice: 'Wiki was successfully updated.' diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index c1523b4dabf..a8f167cbff2 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -16,6 +16,7 @@ module NavHelper "page-gutter build-sidebar right-sidebar-expanded" elsif current_path?('wikis#show') || current_path?('wikis#edit') || + current_path?('wikis#update') || current_path?('wikis#history') || current_path?('wikis#git_access') "page-gutter wiki-sidebar right-sidebar-expanded" diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 465c4d903ac..c771c22f46a 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -155,7 +155,7 @@ class WikiPage end # Returns boolean True or False if this instance - # has been fully saved to disk or not. + # has been fully created on disk or not. def persisted? @persisted == true end @@ -226,6 +226,8 @@ class WikiPage end def save(method, *args) + saved = false + project_wiki = wiki if valid? && project_wiki.send(method, *args) @@ -243,10 +245,10 @@ class WikiPage set_attributes @persisted = true + saved = true else errors.add(:base, project_wiki.error_message) if project_wiki.error_message - @persisted = false end - @persisted + saved end end |