diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-23 21:26:02 +0900 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-23 21:26:02 +0900 |
commit | 9b25bbc45d4e6602452e230506601ff0ed8ba84a (patch) | |
tree | 95f7326e4162a325a5e7c7304c33f18194b52cbe /app/models/wiki_page.rb | |
parent | 839018d2d4e3e899b1fa06a43d093a0fdceced42 (diff) | |
parent | b92d5135d8522e1370636799d74b51f9a37d0b2f (diff) | |
download | gitlab-ce-9b25bbc45d4e6602452e230506601ff0ed8ba84a.tar.gz |
Merge branch 'master' into 1827-prevent-concurrent-editing-wiki
Conflicts:
app/controllers/projects/wikis_controller.rb
app/views/projects/wikis/edit.html.haml
spec/features/projects/wiki/user_updates_wiki_page_spec.rb
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 4c5df6937f2..fa70b69f02f 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -24,16 +24,16 @@ class WikiPage def self.group_by_directory(pages) return [] if pages.blank? - pages.sort_by { |page| [page.directory, page.slug] }. - group_by(&:directory). - map do |dir, pages| + pages.sort_by { |page| [page.directory, page.slug] } + .group_by(&:directory) + .map do |dir, pages| if dir.present? WikiDirectory.new(dir, pages) else pages end - end. - flatten + end + .flatten end def self.unhyphenize(name) @@ -151,7 +151,13 @@ class WikiPage end # Returns boolean True or False if this instance - # has been fully saved to disk or not. + # is the latest commit version of the page. + def latest? + !historical? + end + + # Returns boolean True or False if this instance + # has been fully created on disk or not. def persisted? @persisted == true end @@ -227,6 +233,8 @@ class WikiPage end def save(method, *args) + saved = false + project_wiki = wiki if valid? && project_wiki.send(method, *args) @@ -244,10 +252,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 |