diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-27 22:00:06 +0900 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-27 22:15:48 +0900 |
commit | 35259a4f48e19a19437be10c02eb8398c108d507 (patch) | |
tree | 99dab3d70660bc6e82ccca757843fa43e93b9032 /app/models/wiki_page.rb | |
parent | 5c51db0bce6d0f1b94aaf14d1ac9c8d70f7f9468 (diff) | |
download | gitlab-ce-35259a4f48e19a19437be10c02eb8398c108d507.tar.gz |
Encapsulate the commit.sha logic
Diffstat (limited to 'app/models/wiki_page.rb')
-rw-r--r-- | app/models/wiki_page.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 12f12674e56..148998bc9be 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -138,6 +138,10 @@ class WikiPage versions.first end + def last_commit_sha + commit&.sha + end + # Returns the Date that this latest version was # created on. def created_at @@ -196,7 +200,7 @@ class WikiPage @attributes[:content] = new_content @attributes[:format] = format - if last_commit_sha && last_commit_sha != commit.sha + if last_commit_sha && last_commit_sha != self.last_commit_sha raise PageChangedError.new("You are attempting to update a page that has changed since you started editing it.") end |