summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-07-27 19:29:25 +0000
committerRobert Speicher <robert@gitlab.com>2017-07-27 19:29:25 +0000
commit64131f04e192d64a560177d562f5e32f6a5694ab (patch)
tree878b472639334aaef236fa0b7458907b93f46b81 /spec/models
parentfba50b4afe4e81b7f11103ec131341fea670753b (diff)
parent35259a4f48e19a19437be10c02eb8398c108d507 (diff)
downloadgitlab-ce-64131f04e192d64a560177d562f5e32f6a5694ab.tar.gz
Merge branch '1827-prevent-concurrent-editing-wiki' into 'master'
Prevent concurrent editing wiki Closes #1827 See merge request !9707
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/wiki_page_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index 90ad3cdeb93..55d9c4ddd7b 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -208,6 +208,18 @@ describe WikiPage do
expect(@page.update("more content")).to be_truthy
end
end
+
+ context 'with same last commit sha' do
+ it 'returns true' do
+ 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
+ expect { @page.update('more content', last_commit_sha: 'xxx') }.to raise_error(WikiPage::PageChangedError)
+ end
+ end
end
describe "#destroy" do
@@ -331,6 +343,30 @@ describe WikiPage 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)