diff options
author | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-27 16:00:06 +0300 |
---|---|---|
committer | Hiroyuki Sato <sathiroyuki@gmail.com> | 2017-07-27 16:15:48 +0300 |
commit | 35259a4f48e19a19437be10c02eb8398c108d507 (patch) | |
tree | 99dab3d70660bc6e82ccca757843fa43e93b9032 /spec | |
parent | 5c51db0bce6d0f1b94aaf14d1ac9c8d70f7f9468 (diff) |
Encapsulate the commit.sha logic
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/wiki_page_spec.rb | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index 732a32684e8..e2cdff5fa22 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -211,15 +211,13 @@ describe WikiPage, models: true do context 'with same last commit sha' do it 'returns true' do - last_commit_sha = @page.commit.sha - expect(@page.update('more content', last_commit_sha: last_commit_sha)).to be_truthy + expect(@page.update('more content', last_commit_sha: @page.last_commit_sha)).to be_truthy end end context 'with different last commit sha' do it 'raises exception' do - last_commit_sha = 'xxx' - expect { @page.update('more content', last_commit_sha: last_commit_sha) }.to raise_error(WikiPage::PageChangedError) + expect { @page.update('more content', last_commit_sha: 'xxx') }.to raise_error(WikiPage::PageChangedError) end end end @@ -345,6 +343,30 @@ describe WikiPage, models: true do end end + describe '#last_commit_sha' do + before do + create_page("Update", "content") + @page = wiki.find_page("Update") + end + + after do + destroy_page("Update") + end + + it 'returns commit sha' do + expect(@page.last_commit_sha).to eq @page.commit.sha + end + + it 'is changed after page updated' do + last_commit_sha_before_update = @page.last_commit_sha + + @page.update("new content") + @page = wiki.find_page("Update") + + expect(@page.last_commit_sha).not_to eq last_commit_sha_before_update + end + end + private def remove_temp_repo(path) |