summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-03-02 10:51:43 +0000
committerDouwe Maan <douwe@gitlab.com>2016-03-02 10:51:43 +0000
commitca8a44be82628c436b438527d06d8e3bf495db38 (patch)
treead4134c900b70e435b38a376fba679d3c42ddfce /spec
parent8eadb373ec9e92e0b84a7c37a5866c2ef96b28b1 (diff)
parentd9e01915924836722b4ed67e26535076efba1be4 (diff)
downloadgitlab-ce-ca8a44be82628c436b438527d06d8e3bf495db38.tar.gz
Merge branch 'issue_13716' into 'master'
Check for conflicts before creating new revert branch Fixes #13716 See merge request !2953
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb35
1 files changed, 31 insertions, 4 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 51ae2c04ed0..1c7d66398cb 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -457,11 +457,38 @@ describe Repository, models: true do
end
end
- describe '#revert_merge' do
- it 'should revert the changes' do
- repository.revert(user, merge_commit, 'master')
+ describe '#revert' do
+ let(:new_image_commit) { repository.commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9') }
+ let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).not_to be_present
+ context 'when there is a conflict' do
+ it 'should abort the operation' do
+ expect(repository.revert(user, new_image_commit, 'master')).to eq(false)
+ end
+ end
+
+ context 'when commit was already reverted' do
+ it 'should abort the operation' do
+ repository.revert(user, update_image_commit, 'master')
+
+ expect(repository.revert(user, update_image_commit, 'master')).to eq(false)
+ end
+ end
+
+ context 'when commit can be reverted' do
+ it 'should revert the changes' do
+ expect(repository.revert(user, update_image_commit, 'master')).to be_truthy
+ end
+ end
+
+ context 'reverting a merge commit' do
+ it 'should revert the changes' do
+ merge_commit
+ expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).to be_present
+
+ repository.revert(user, merge_commit, 'master')
+ expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).not_to be_present
+ end
end
end