Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-13 00:59:30 +0300
committerRobert Speicher <rspeicher@gmail.com>2015-05-26 22:48:31 +0300
commit91eb346de6abd56fae469417a224bc2b2e7c7364 (patch)
treece088c4f8d4ff7849098c0d9e711f6e22bc3c83a /spec/support
parent136ab73803850c10588b369862b1e5524849d31c (diff)
Add invalidate_reference to ReferenceFilterSpecHelper
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/reference_filter_spec_helper.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/reference_filter_spec_helper.rb b/spec/support/reference_filter_spec_helper.rb
index 06c39e1ada5..d2766615ccb 100644
--- a/spec/support/reference_filter_spec_helper.rb
+++ b/spec/support/reference_filter_spec_helper.rb
@@ -10,6 +10,25 @@ module ReferenceFilterSpecHelper
Rails.application.routes.url_helpers
end
+ # Modify a reference to make it invalid
+ #
+ # Commit SHAs get reversed, IDs get incremented by 1
+ #
+ # reference - String reference to modify
+ #
+ # Returns a String
+ def invalidate_reference(reference)
+ if reference =~ /\A(.+)?.\d+\z/
+ # Integer-based reference with optional project prefix
+ reference.gsub(/\d+\z/) { |i| i.to_i + 1 }
+ elsif reference =~ /\A(.+@)?(\h{6,40}\z)/
+ # SHA-based reference with optional prefix
+ reference.gsub(/\h{6,40}\z/) { |v| v.reverse }
+ else
+ reference
+ end
+ end
+
# Perform `call` on the described class
#
# Automatically passes the current `project` value to the context if none is