From 109e8ef4485fb45f0a50690e732ee2b9c6e910b0 Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Fri, 30 Dec 2016 13:26:30 +0000 Subject: [PATCH] Make WikiPage comparable according to StaticModel interface * Add WikiPage#id method returning associated SHA for wiki page commit --- app/models/wiki_page.rb | 4 ++++ spec/models/wiki_page_spec.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 6347b274341..2caebb496db 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -207,6 +207,10 @@ class WikiPage 'projects/wikis/wiki_page' end + def id + page.version.to_s + end + private def set_attributes diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 579ebac7afb..753dc938c52 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -318,6 +318,19 @@ describe WikiPage, models: true do end end + describe '#==' do + let(:original_wiki_page) { create(:wiki_page) } + + it 'returns true for identical wiki page' do + expect(original_wiki_page).to eq(original_wiki_page) + end + + it 'returns false for updated wiki page' do + updated_wiki_page = original_wiki_page.update("Updated content") + expect(original_wiki_page).not_to eq(updated_wiki_page) + end + end + private def remove_temp_repo(path)