Commit 3dda245a authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-11-20

parents f382173e 21c4428d
...@@ -401,7 +401,7 @@ group :test do ...@@ -401,7 +401,7 @@ group :test do
gem 'rails-controller-testing' if rails5? # Rails5 only gem. gem 'rails-controller-testing' if rails5? # Rails5 only gem.
gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0. gem 'test_after_commit', '~> 1.1' unless rails5? # Remove this gem when migrated to rails 5.0. It's been integrated to rails 5.0.
gem 'sham_rack', '~> 1.3.6' gem 'sham_rack', '~> 1.3.6'
gem 'concurrent-ruby', '~> 1.0.5' gem 'concurrent-ruby', '~> 1.1'
gem 'test-prof', '~> 0.2.5' gem 'test-prof', '~> 0.2.5'
gem 'rspec_junit_formatter' gem 'rspec_junit_formatter'
end end
......
...@@ -136,9 +136,9 @@ GEM ...@@ -136,9 +136,9 @@ GEM
concord (0.1.5) concord (0.1.5)
adamantium (~> 0.2.0) adamantium (~> 0.2.0)
equalizer (~> 0.0.9) equalizer (~> 0.0.9)
concurrent-ruby (1.0.5) concurrent-ruby (1.1.3)
concurrent-ruby-ext (1.0.5) concurrent-ruby-ext (1.1.3)
concurrent-ruby (= 1.0.5) concurrent-ruby (= 1.1.3)
connection_pool (2.2.2) connection_pool (2.2.2)
crack (0.4.3) crack (0.4.3)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
...@@ -406,7 +406,7 @@ GEM ...@@ -406,7 +406,7 @@ GEM
json (~> 1.8) json (~> 1.8)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
httpclient (2.8.3) httpclient (2.8.3)
i18n (1.1.0) i18n (1.1.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
icalendar (2.4.1) icalendar (2.4.1)
ice_nine (0.11.2) ice_nine (0.11.2)
...@@ -472,7 +472,7 @@ GEM ...@@ -472,7 +472,7 @@ GEM
activesupport (>= 4) activesupport (>= 4)
railties (>= 4) railties (>= 4)
request_store (~> 1.0) request_store (~> 1.0)
loofah (2.2.2) loofah (2.2.3)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.0) mail (2.7.0)
...@@ -481,7 +481,7 @@ GEM ...@@ -481,7 +481,7 @@ GEM
memoist (0.16.0) memoist (0.16.0)
memoizable (0.4.2) memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1) thread_safe (~> 0.3, >= 0.3.1)
method_source (0.9.0) method_source (0.9.2)
mime-types (3.2.2) mime-types (3.2.2)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812) mime-types-data (3.2018.0812)
...@@ -504,7 +504,7 @@ GEM ...@@ -504,7 +504,7 @@ GEM
net-ssh (5.0.1) net-ssh (5.0.1)
netrc (0.11.0) netrc (0.11.0)
nio4r (2.3.1) nio4r (2.3.1)
nokogiri (1.8.4) nokogiri (1.8.5)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0) nokogumbo (1.5.0)
nokogiri nokogiri
...@@ -632,7 +632,7 @@ GEM ...@@ -632,7 +632,7 @@ GEM
get_process_mem (~> 0.2) get_process_mem (~> 0.2)
puma (>= 2.7, < 4) puma (>= 2.7, < 4)
pyu-ruby-sasl (0.0.3.3) pyu-ruby-sasl (0.0.3.3)
rack (2.0.5) rack (2.0.6)
rack-accept (0.4.5) rack-accept (0.4.5)
rack (>= 0.4) rack (>= 0.4)
rack-attack (4.4.1) rack-attack (4.4.1)
...@@ -796,8 +796,8 @@ GEM ...@@ -796,8 +796,8 @@ GEM
ruby-progressbar (1.9.0) ruby-progressbar (1.9.0)
ruby-saml (1.7.2) ruby-saml (1.7.2)
nokogiri (>= 1.5.10) nokogiri (>= 1.5.10)
ruby_parser (3.9.0) ruby_parser (3.11.0)
sexp_processor (~> 4.1) sexp_processor (~> 4.9)
rubyntlm (0.6.2) rubyntlm (0.6.2)
rubypants (0.2.0) rubypants (0.2.0)
rubyzip (1.2.2) rubyzip (1.2.2)
...@@ -837,7 +837,7 @@ GEM ...@@ -837,7 +837,7 @@ GEM
sentry-raven (2.7.2) sentry-raven (2.7.2)
faraday (>= 0.7.6, < 1.0) faraday (>= 0.7.6, < 1.0)
settingslogic (2.0.9) settingslogic (2.0.9)
sexp_processor (4.9.0) sexp_processor (4.11.0)
sham_rack (1.3.6) sham_rack (1.3.6)
rack rack
shoulda-matchers (3.1.2) shoulda-matchers (3.1.2)
...@@ -997,7 +997,7 @@ DEPENDENCIES ...@@ -997,7 +997,7 @@ DEPENDENCIES
chronic (~> 0.10.2) chronic (~> 0.10.2)
chronic_duration (~> 0.10.6) chronic_duration (~> 0.10.6)
commonmarker (~> 0.17) commonmarker (~> 0.17)
concurrent-ruby (~> 1.0.5) concurrent-ruby (~> 1.1)
connection_pool (~> 2.0) connection_pool (~> 2.0)
creole (~> 0.5.0) creole (~> 0.5.0)
database_cleaner (~> 1.5.0) database_cleaner (~> 1.5.0)
......
...@@ -133,9 +133,9 @@ GEM ...@@ -133,9 +133,9 @@ GEM
concord (0.1.5) concord (0.1.5)
adamantium (~> 0.2.0) adamantium (~> 0.2.0)
equalizer (~> 0.0.9) equalizer (~> 0.0.9)
concurrent-ruby (1.0.5) concurrent-ruby (1.1.3)
concurrent-ruby-ext (1.0.5) concurrent-ruby-ext (1.1.3)
concurrent-ruby (= 1.0.5) concurrent-ruby (= 1.1.3)
connection_pool (2.2.2) connection_pool (2.2.2)
crack (0.4.3) crack (0.4.3)
safe_yaml (~> 1.0.0) safe_yaml (~> 1.0.0)
...@@ -469,7 +469,7 @@ GEM ...@@ -469,7 +469,7 @@ GEM
activesupport (>= 4) activesupport (>= 4)
railties (>= 4) railties (>= 4)
request_store (~> 1.0) request_store (~> 1.0)
loofah (2.2.2) loofah (2.2.3)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.7.0) mail (2.7.0)
...@@ -500,7 +500,7 @@ GEM ...@@ -500,7 +500,7 @@ GEM
net-ntp (2.1.3) net-ntp (2.1.3)
net-ssh (5.0.1) net-ssh (5.0.1)
netrc (0.11.0) netrc (0.11.0)
nokogiri (1.8.4) nokogiri (1.8.5)
mini_portile2 (~> 2.3.0) mini_portile2 (~> 2.3.0)
nokogumbo (1.5.0) nokogumbo (1.5.0)
nokogiri nokogiri
...@@ -788,8 +788,8 @@ GEM ...@@ -788,8 +788,8 @@ GEM
ruby-progressbar (1.9.0) ruby-progressbar (1.9.0)
ruby-saml (1.7.2) ruby-saml (1.7.2)
nokogiri (>= 1.5.10) nokogiri (>= 1.5.10)
ruby_parser (3.9.0) ruby_parser (3.11.0)
sexp_processor (~> 4.1) sexp_processor (~> 4.9)
rubyntlm (0.6.2) rubyntlm (0.6.2)
rubypants (0.2.0) rubypants (0.2.0)
rubyzip (1.2.2) rubyzip (1.2.2)
...@@ -829,7 +829,7 @@ GEM ...@@ -829,7 +829,7 @@ GEM
sentry-raven (2.7.2) sentry-raven (2.7.2)
faraday (>= 0.7.6, < 1.0) faraday (>= 0.7.6, < 1.0)
settingslogic (2.0.9) settingslogic (2.0.9)
sexp_processor (4.9.0) sexp_processor (4.11.0)
sham_rack (1.3.6) sham_rack (1.3.6)
rack rack
shoulda-matchers (3.1.2) shoulda-matchers (3.1.2)
...@@ -988,7 +988,7 @@ DEPENDENCIES ...@@ -988,7 +988,7 @@ DEPENDENCIES
chronic (~> 0.10.2) chronic (~> 0.10.2)
chronic_duration (~> 0.10.6) chronic_duration (~> 0.10.6)
commonmarker (~> 0.17) commonmarker (~> 0.17)
concurrent-ruby (~> 1.0.5) concurrent-ruby (~> 1.1)
connection_pool (~> 2.0) connection_pool (~> 2.0)
creole (~> 0.5.0) creole (~> 0.5.0)
database_cleaner (~> 1.5.0) database_cleaner (~> 1.5.0)
......
...@@ -39,7 +39,7 @@ function blockTagText(text, textArea, blockTag, selected) { ...@@ -39,7 +39,7 @@ function blockTagText(text, textArea, blockTag, selected) {
} }
} }
function moveCursor({ textArea, tag, wrapped, removedLastNewLine, select }) { function moveCursor({ textArea, tag, positionBetweenTags, removedLastNewLine, select }) {
var pos; var pos;
if (!textArea.setSelectionRange) { if (!textArea.setSelectionRange) {
return; return;
...@@ -51,7 +51,7 @@ function moveCursor({ textArea, tag, wrapped, removedLastNewLine, select }) { ...@@ -51,7 +51,7 @@ function moveCursor({ textArea, tag, wrapped, removedLastNewLine, select }) {
return textArea.setSelectionRange(startPosition, endPosition); return textArea.setSelectionRange(startPosition, endPosition);
} }
if (textArea.selectionStart === textArea.selectionEnd) { if (textArea.selectionStart === textArea.selectionEnd) {
if (wrapped) { if (positionBetweenTags) {
pos = textArea.selectionStart - tag.length; pos = textArea.selectionStart - tag.length;
} else { } else {
pos = textArea.selectionStart; pos = textArea.selectionStart;
...@@ -67,7 +67,6 @@ function moveCursor({ textArea, tag, wrapped, removedLastNewLine, select }) { ...@@ -67,7 +67,6 @@ function moveCursor({ textArea, tag, wrapped, removedLastNewLine, select }) {
export function insertMarkdownText({ textArea, text, tag, blockTag, selected, wrap, select }) { export function insertMarkdownText({ textArea, text, tag, blockTag, selected, wrap, select }) {
var textToInsert, var textToInsert,
inserted,
selectedSplit, selectedSplit,
startChar, startChar,
removedLastNewLine, removedLastNewLine,
...@@ -155,7 +154,7 @@ export function insertMarkdownText({ textArea, text, tag, blockTag, selected, wr ...@@ -155,7 +154,7 @@ export function insertMarkdownText({ textArea, text, tag, blockTag, selected, wr
return moveCursor({ return moveCursor({
textArea, textArea,
tag: tag.replace(textPlaceholder, selected), tag: tag.replace(textPlaceholder, selected),
wrap, positionBetweenTags: wrap && selected.length === 0,
removedLastNewLine, removedLastNewLine,
select, select,
}); });
...@@ -171,10 +170,6 @@ function updateText({ textArea, tag, blockTag, wrap, select }) { ...@@ -171,10 +170,6 @@ function updateText({ textArea, tag, blockTag, wrap, select }) {
return insertMarkdownText({ textArea, text, tag, blockTag, selected, wrap, select }); return insertMarkdownText({ textArea, text, tag, blockTag, selected, wrap, select });
} }
function replaceRange(s, start, end, substitute) {
return s.substring(0, start) + substitute + s.substring(end);
}
export function addMarkdownListeners(form) { export function addMarkdownListeners(form) {
return $('.js-md', form) return $('.js-md', form)
.off('click') .off('click')
......
...@@ -58,7 +58,7 @@ class EventsFinder ...@@ -58,7 +58,7 @@ class EventsFinder
def by_target_type(events) def by_target_type(events)
return events unless Event::TARGET_TYPES[params[:target_type]] return events unless Event::TARGET_TYPES[params[:target_type]]
events.where(target_type: Event::TARGET_TYPES[params[:target_type]]) events.where(target_type: Event::TARGET_TYPES[params[:target_type]].name)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -100,7 +100,7 @@ module Ci ...@@ -100,7 +100,7 @@ module Ci
scope :matches_tag_ids, -> (tag_ids) do scope :matches_tag_ids, -> (tag_ids) do
matcher = ::ActsAsTaggableOn::Tagging matcher = ::ActsAsTaggableOn::Tagging
.where(taggable_type: CommitStatus) .where(taggable_type: CommitStatus.name)
.where(context: 'tags') .where(context: 'tags')
.where('taggable_id = ci_builds.id') .where('taggable_id = ci_builds.id')
.where.not(tag_id: tag_ids).select('1') .where.not(tag_id: tag_ids).select('1')
...@@ -110,7 +110,7 @@ module Ci ...@@ -110,7 +110,7 @@ module Ci
scope :with_any_tags, -> do scope :with_any_tags, -> do
matcher = ::ActsAsTaggableOn::Tagging matcher = ::ActsAsTaggableOn::Tagging
.where(taggable_type: CommitStatus) .where(taggable_type: CommitStatus.name)
.where(context: 'tags') .where(context: 'tags')
.where('taggable_id = ci_builds.id').select('1') .where('taggable_id = ci_builds.id').select('1')
......
...@@ -86,7 +86,7 @@ module Avatarable ...@@ -86,7 +86,7 @@ module Avatarable
params[:model].upload_paths(params[:identifier]) params[:model].upload_paths(params[:identifier])
end end
Upload.where(uploader: AvatarUploader, path: paths).find_each do |upload| Upload.where(uploader: AvatarUploader.name, path: paths).find_each do |upload|
model = model_class.instantiate('id' => upload.model_id) model = model_class.instantiate('id' => upload.model_id)
loader.call({ model: model, identifier: File.basename(upload.path) }, upload) loader.call({ model: model, identifier: File.basename(upload.path) }, upload)
......
...@@ -45,7 +45,7 @@ module Todos ...@@ -45,7 +45,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def remove_confidential_issue_todos def remove_confidential_issue_todos
Todo.where( Todo.where(
target_id: confidential_issues.select(:id), target_type: Issue, user_id: user.id target_id: confidential_issues.select(:id), target_type: Issue.name, user_id: user.id
).delete_all ).delete_all
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
...@@ -14,9 +14,9 @@ module Todos ...@@ -14,9 +14,9 @@ module Todos
def execute def execute
ProjectFeature.where(project_id: project_ids).each do |project_features| ProjectFeature.where(project_id: project_ids).each do |project_features|
target_types = [] target_types = []
target_types << Issue if private?(project_features.issues_access_level) target_types << Issue.name if private?(project_features.issues_access_level)
target_types << MergeRequest if private?(project_features.merge_requests_access_level) target_types << MergeRequest.name if private?(project_features.merge_requests_access_level)
target_types << Commit if private?(project_features.repository_access_level) target_types << Commit.name if private?(project_features.repository_access_level)
next if target_types.empty? next if target_types.empty?
......
- labels.each do |label|
%span.label-row.btn-group{ role: "group", aria: { label: label.name }, style: "color: #{text_color_for_bg(label.color)}" }
= link_to_label(label, subject: @project, css_class: 'btn btn-transparent')
%button.btn.btn-transparent.label-remove.js-label-filter-remove{ type: "button", style: "background-color: #{label.color};", data: { label: label.title } }
= icon("times")
---
title: Refine cursor positioning in Markdown Editor for wrap tags
merge_request: 23085
author: Johann Hubert Sonntagbauer
type: changed
---
title: Enable even more frozen string for lib/gitlab
merge_request:
author: gfyoung
type: performance
---
title: 'Rails5: Passing a class as a value in an Active Record query is deprecated'
merge_request: 23164
author: Jasper Maes
type: other
---
title: Bump nokogiri, loofah, and rack gems for security updates
merge_request: 23204
author:
type: security
---
title: Show what RPC is called in the performance bar
merge_request: 23140
author:
type: other
...@@ -1682,6 +1682,11 @@ include: ...@@ -1682,6 +1682,11 @@ include:
NOTE: **Note:** NOTE: **Note:**
The remote file must be publicly accessible through a simple GET request, as we don't support authentication schemas in the remote URL. The remote file must be publicly accessible through a simple GET request, as we don't support authentication schemas in the remote URL.
NOTE: **Note:**
In order to include files from another repository inside your local network,
you may need to enable the **Allow requests to the local network from hooks and services** checkbox
located in the **Settings > Network > Outbound requests** section within the **Admin area**.
--- ---
......
# frozen_string_literal: true # frozen_string_literal: true
# Gitaly note: JV: seems to be completely migrated (behind feature flags).
module Gitlab module Gitlab
module Git module Git
class Blob class Blob
......
...@@ -885,12 +885,6 @@ module Gitlab ...@@ -885,12 +885,6 @@ module Gitlab
Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid) Gitlab::GitalyClient::ConflictsService.new(self, our_commit_oid, their_commit_oid)
end end
def gitaly_migrate(method, status: Gitlab::GitalyClient::MigrationStatus::OPT_IN, &block)
wrapped_gitaly_errors do
Gitlab::GitalyClient.migrate(method, status: status, &block)
end
end
def clean_stale_repository_files def clean_stale_repository_files
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_repository_client.cleanup if exists? gitaly_repository_client.cleanup if exists?
......
...@@ -9,11 +9,6 @@ require 'grpc/health/v1/health_services_pb' ...@@ -9,11 +9,6 @@ require 'grpc/health/v1/health_services_pb'
module Gitlab module Gitlab
module GitalyClient module GitalyClient
include Gitlab::Metrics::Methods include Gitlab::Metrics::Methods
module MigrationStatus
DISABLED = 1
OPT_IN = 2
OPT_OUT = 3
end
class TooManyInvocationsError < StandardError class TooManyInvocationsError < StandardError
attr_reader :call_site, :invocation_count, :max_call_stack attr_reader :call_site, :invocation_count, :max_call_stack
...@@ -31,7 +26,7 @@ module Gitlab ...@@ -31,7 +26,7 @@ module Gitlab
end end
end end
SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'.freeze SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'
MAXIMUM_GITALY_CALLS = 35 MAXIMUM_GITALY_CALLS = 35
CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze
...@@ -43,11 +38,6 @@ module Gitlab ...@@ -43,11 +38,6 @@ module Gitlab
self.query_time = 0 self.query_time = 0
define_histogram :gitaly_migrate_call_duration_seconds do
docstring "Gitaly migration call execution timings"
base_labels gitaly_enabled: nil, feature: nil
end
define_histogram :gitaly_controller_action_duration_seconds do define_histogram :gitaly_controller_action_duration_seconds do
docstring "Gitaly endpoint histogram by controller and action combination" docstring "Gitaly endpoint histogram by controller and action combination"
base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil) base_labels Gitlab::Metrics::Transaction::BASE_LABELS.merge(gitaly_service: nil, rpc: nil)
...@@ -126,7 +116,6 @@ module Gitlab ...@@ -126,7 +116,6 @@ module Gitlab
def self.call(storage, service, rpc, request, remote_storage: nil, timeout: nil) def self.call(storage, service, rpc, request, remote_storage: nil, timeout: nil)
start = Gitlab::Metrics::System.monotonic_time start = Gitlab::Metrics::System.monotonic_time
request_hash = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : {} request_hash = request.is_a?(Google::Protobuf::MessageExts) ? request.to_h : {}
@current_call_id ||= SecureRandom.uuid
enforce_gitaly_request_limits(:call) enforce_gitaly_request_limits(:call)
...@@ -145,9 +134,7 @@ module Gitlab ...@@ -145,9 +134,7 @@ module Gitlab
current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s), current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s),
duration) duration)
add_call_details(id: @current_call_id, feature: service, duration: duration, request: request_hash) add_call_details(feature: "#{service}##{rpc}", duration: duration, request: request_hash, rpc: rpc)
@current_call_id = nil
end end
def self.handle_grpc_unavailable!(ex) def self.handle_grpc_unavailable!(ex)
...@@ -222,7 +209,7 @@ module Gitlab ...@@ -222,7 +209,7 @@ module Gitlab
result result
end end
SERVER_FEATURE_FLAGS = %w[gogit_findcommit].freeze SERVER_FEATURE_FLAGS = %w[].freeze
def self.server_feature_flags def self.server_feature_flags
SERVER_FEATURE_FLAGS.map do |f| SERVER_FEATURE_FLAGS.map do |f|
...@@ -237,82 +224,8 @@ module Gitlab ...@@ -237,82 +224,8 @@ module Gitlab
params['gitaly_token'].presence || Gitlab.config.gitaly['token'] params['gitaly_token'].presence || Gitlab.config.gitaly['token']
end end
# Evaluates whether a feature toggle is on or off def self.feature_enabled?(feature_name)
def self.feature_enabled?(feature_name, status: MigrationStatus::OPT_IN) Feature.enabled?("gitaly_#{feature_name}")
# Disabled features are always off!
return false if status == MigrationStatus::DISABLED
feature = Feature.get("gitaly_#{feature_name}")
# If the feature has been set, always evaluate
if Feature.persisted?(feature)
if feature.percentage_of_time_value > 0
# Probabilistically enable this feature
return Random.rand() * 100 < feature.percentage_of_time_value
end
return feature.enabled?
end
# If the feature has not been set, the default depends
# on it's status
case status
when MigrationStatus::OPT_OUT
true
when MigrationStatus::OPT_IN
opt_into_all_features? && !explicit_opt_in_required.include?(feature_name)
else
false
end
rescue => ex
# During application startup feature lookups in SQL can fail
Rails.logger.warn "exception while checking Gitaly feature status for #{feature_name}: #{ex}"
false
end
# We have a mechanism to let GitLab automatically opt in to all Gitaly
# features. We want to be able to exclude some features from automatic
# opt-in. This function has an override in EE.
def self.explicit_opt_in_required
[]
end
# opt_into_all_features? returns true when the current environment
# is one in which we opt into features automatically
def self.opt_into_all_features?
Rails.env.development? || ENV["GITALY_FEATURE_DEFAULT_ON"] == "1"
end
private_class_method :opt_into_all_features?
def self.migrate(feature, status: MigrationStatus::OPT_IN)
# Enforce limits at both the `migrate` and `call` sites to ensure that
# problems are not hidden by a feature being disabled
enforce_gitaly_request_limits(:migrate)
is_enabled = feature_enabled?(feature, status: status)
metric_name = feature.to_s
metric_name += "_gitaly" if is_enabled
Gitlab::Metrics.measure(metric_name) do
# Some migrate calls wrap other migrate calls
allow_n_plus_1_calls do
feature_stack = Thread.current[:gitaly_feature_stack] ||= []
feature_stack.unshift(feature)
begin
start = Gitlab::Metrics::System.monotonic_time
@current_call_id = SecureRandom.uuid
call_details = { id: @current_call_id }
yield is_enabled
ensure
total_time = Gitlab::Metrics::System.monotonic_time - start
gitaly_migrate_call_duration_seconds.observe({ gitaly_enabled: is_enabled, feature: feature }, total_time)
feature_stack.shift
Thread.current[:gitaly_feature_stack] = nil if feature_stack.empty?
add_call_details(call_details.merge(feature: feature, duration: total_time))
end
end
end
end end
# Ensures that Gitaly is not being abuse through n+1 misuse etc # Ensures that Gitaly is not being abuse through n+1 misuse etc
...@@ -368,38 +281,20 @@ module Gitlab ...@@ -368,38 +281,20 @@ module Gitlab
end end
private_class_method :decrement_call_count private_class_method :decrement_call_count
# Returns an estimate of the number of Gitaly calls made for this # Returns the of the number of Gitaly calls made for this request
# request
def self.get_request_count def self.get_request_count
return 0 unless Gitlab::SafeRequestStore.active? get_call_count("gitaly_call_actual")
gitaly_migrate_count = get_call_count("gitaly_migrate_actual")
gitaly_call_count = get_call_count("gitaly_call_actual")
# Using the maximum of migrate and call_count will provide an
# indicator of how many Gitaly calls will be made, even
# before a feature is enabled. This provides us with a single
# metric, but not an exact number, but this tradeoff is acceptable
if gitaly_migrate_count > gitaly_call_count
gitaly_migrate_count
else
gitaly_call_count
end
end end
def self.reset_counts def self.reset_counts
return unless Gitlab::SafeRequestStore.active? return unless Gitlab::SafeRequestStore.active?
%w[migrate call].each do |call_site| Gitlab::SafeRequestStore["gitaly_call_actual"] = 0
Gitlab::SafeRequestStore["gitaly_#{call_site}_actual"] = 0 Gitlab::SafeRequestStore["gitaly_call_permitted"] = 0
Gitlab::SafeRequestStore["gitaly_#{call_site}_permitted"] = 0
end
end end
def self.add_call_details(details) def self.add_call_details(details)
id = details.delete(:id) return unless Gitlab::SafeRequestStore[:peek_enabled]
return unless id && Gitlab::SafeRequestStore[:peek_enabled]
Gitlab::SafeRequestStore['gitaly_call_details'] ||= {} Gitlab::SafeRequestStore['gitaly_call_details'] ||= {}
Gitlab::SafeRequestStore['gitaly_call_details'][id] ||= {} Gitlab::SafeRequestStore['gitaly_call_details'][id] ||= {}
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class BaseBuilder class BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class IssuableBuilder < BaseBuilder class IssuableBuilder < BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class IssueBuilder < BaseBuilder class IssueBuilder < BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class MergeRequestBuilder < BaseBuilder class MergeRequestBuilder < BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class NoteBuilder < BaseBuilder class NoteBuilder < BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module HookData module HookData
class WikiPageBuilder < BaseBuilder class WikiPageBuilder < BaseBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module I18n module I18n
class MetadataEntry class MetadataEntry
......
# frozen_string_literal: true
module Gitlab module Gitlab
module I18n module I18n
class PoLinter class PoLinter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module I18n module I18n
class TranslationEntry class TranslationEntry
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Import module Import
class Logger < ::Gitlab::JsonLogger class Logger < ::Gitlab::JsonLogger
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
module AfterExportStrategies module AfterExportStrategies
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
module AfterExportStrategies module AfterExportStrategies
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
module AfterExportStrategies module AfterExportStrategies
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class AfterExportStrategyBuilder class AfterExportStrategyBuilder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class AttributeCleaner class AttributeCleaner
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class AttributesFinder class AttributesFinder
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class AvatarRestorer class AvatarRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class AvatarSaver class AvatarSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
module CommandLineUtil module CommandLineUtil
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
Error = Class.new(StandardError) Error = Class.new(StandardError)
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class FileImporter class FileImporter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
# Given a class, it finds or creates a new object # Given a class, it finds or creates a new object
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class HashUtil class HashUtil
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class Importer class Importer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
# Generates a hash that conforms with http://apidock.com/rails/Hash/to_json # Generates a hash that conforms with http://apidock.com/rails/Hash/to_json
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class LfsRestorer class LfsRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class LfsSaver class LfsSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class MembersMapper class MembersMapper
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class MergeRequestParser class MergeRequestParser
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class ProjectTreeRestorer class ProjectTreeRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class ProjectTreeSaver class ProjectTreeSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class Reader class Reader
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class RelationFactory class RelationFactory
...@@ -213,7 +215,7 @@ module Gitlab ...@@ -213,7 +215,7 @@ module Gitlab
def update_note_for_missing_author(author_name) def update_note_for_missing_author(author_name)
@relation_hash['note'] = '*Blank note*' if @relation_hash['note'].blank? @relation_hash['note'] = '*Blank note*' if @relation_hash['note'].blank?
@relation_hash['note'] += missing_author_note(@relation_hash['updated_at'], author_name) @relation_hash['note'] = "#{@relation_hash['note']}#{missing_author_note(@relation_hash['updated_at'], author_name)}"
end end
def admin_user? def admin_user?
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class RepoRestorer class RepoRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class RepoSaver class RepoSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class Saver class Saver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class Shared class Shared
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class StatisticsRestorer class StatisticsRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class UploadsManager class UploadsManager
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class UploadsRestorer < UploadsSaver class UploadsRestorer < UploadsSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class UploadsSaver class UploadsSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class VersionChecker class VersionChecker
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class VersionSaver class VersionSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class WikiRepoSaver < RepoSaver class WikiRepoSaver < RepoSaver
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ImportExport module ImportExport
class WikiRestorer < RepoRestorer class WikiRestorer < RepoRestorer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
class ConfigMap class ConfigMap
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Helm module Helm
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
class Namespace class Namespace
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Kubernetes module Kubernetes
module Pod module Pod
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class BaseFormatter class BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class BranchFormatter < BaseFormatter class BranchFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class Client class Client
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class CommentFormatter < BaseFormatter class CommentFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class Importer class Importer
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class IssuableFormatter < BaseFormatter class IssuableFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class IssueFormatter < IssuableFormatter class IssueFormatter < IssuableFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class LabelFormatter < BaseFormatter class LabelFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class MilestoneFormatter < BaseFormatter class MilestoneFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class ProjectCreator class ProjectCreator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class PullRequestFormatter < IssuableFormatter class PullRequestFormatter < IssuableFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class ReleaseFormatter < BaseFormatter class ReleaseFormatter < BaseFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class UserFormatter class UserFormatter
......
# frozen_string_literal: true
module Gitlab module Gitlab
module LegacyGithubImport module LegacyGithubImport
class WikiFormatter class WikiFormatter
......
# frozen_string_literal: true
# Class to parse manifest file and build a list of repositories for import # Class to parse manifest file and build a list of repositories for import
# #
# <manifest> # <manifest>
......
# frozen_string_literal: true
module Gitlab module Gitlab
module ManifestImport module ManifestImport
class ProjectCreator class ProjectCreator
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
class BackgroundTransaction < Transaction class BackgroundTransaction < Transaction
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Class for calculating the difference between two numeric values. # Class for calculating the difference between two numeric values.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module InfluxDb module InfluxDb
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Module for instrumenting methods. # Module for instrumenting methods.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Class for tracking timing information about method calls # Class for tracking timing information about method calls
......
# frozen_string_literal: true
# rubocop:disable Style/ClassVars # rubocop:disable Style/ClassVars
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Methods module Methods
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Class for storing details of a single metric (label, value, etc). # Class for storing details of a single metric (label, value, etc).
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Mocks ::Prometheus::Client::Metric and all derived metrics # Mocks ::Prometheus::Client::Metric and all derived metrics
......
# frozen_string_literal: true
require 'prometheus/client' require 'prometheus/client'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Rack middleware for tracking Rails and Grape requests. # Rack middleware for tracking Rails and Grape requests.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
class RequestsRackMiddleware class RequestsRackMiddleware
......
# frozen_string_literal: true
require 'logger' require 'logger'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Samplers module Samplers
......
# frozen_string_literal: true
require 'prometheus/client/support/unicorn' require 'prometheus/client/support/unicorn'
module Gitlab module Gitlab
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Samplers module Samplers
......
# frozen_string_literal: true
require 'webrick' require 'webrick'
require 'prometheus/client/rack/exporter' require 'prometheus/client/rack/exporter'
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Sidekiq middleware for tracking jobs. # Sidekiq middleware for tracking jobs.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Subscribers module Subscribers
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Subscribers module Subscribers
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
module Subscribers module Subscribers
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Module for gathering system/process statistics such as the memory usage. # Module for gathering system/process statistics such as the memory usage.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
# Class for storing metrics information of a single transaction. # Class for storing metrics information of a single transaction.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Metrics module Metrics
class WebTransaction < Transaction class WebTransaction < Transaction
...@@ -40,7 +42,7 @@ module Gitlab ...@@ -40,7 +42,7 @@ module Gitlab
# increasing the cardinality of our metrics, we limit the number of # increasing the cardinality of our metrics, we limit the number of
# possible suffixes. # possible suffixes.
if suffix && ALLOWED_SUFFIXES.include?(suffix) if suffix && ALLOWED_SUFFIXES.include?(suffix)
action += ".#{suffix}" action = "#{action}.#{suffix}"
end end
{ controller: controller.class.name, action: action } { controller: controller.class.name, action: action }
......
# frozen_string_literal: true
# A dumb middleware that returns a Go HTML document if the go-get=1 query string # A dumb middleware that returns a Go HTML document if the go-get=1 query string
# is used irrespective if the namespace/project exists # is used irrespective if the namespace/project exists
module Gitlab module Gitlab
......
# frozen_string_literal: true
# Gitlab::Middleware::Multipart - a Rack::Multipart replacement # Gitlab::Middleware::Multipart - a Rack::Multipart replacement
# #
# Rack::Multipart leaves behind tempfiles in /tmp and uses valuable Ruby # Rack::Multipart leaves behind tempfiles in /tmp and uses valuable Ruby
......
# frozen_string_literal: true
# This Rack middleware is intended to measure the latency between # This Rack middleware is intended to measure the latency between
# gitlab-workhorse forwarding a request to the Rails application and the # gitlab-workhorse forwarding a request to the Rails application and the
# time this middleware is reached. # time this middleware is reached.
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Middleware module Middleware
class ReadOnly class ReadOnly
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Middleware module Middleware
class ReadOnly class ReadOnly
......
module Gitlab # rubocop:disable Naming/FileName # rubocop:disable Naming/FileName
# frozen_string_literal: true
module Gitlab
module Middleware module Middleware
# Some of middleware would hold env for no good reason even after the # Some of middleware would hold env for no good reason even after the
# request had already been processed, and we could not garbage collect # request had already been processed, and we could not garbage collect
......
# frozen_string_literal: true
module Gitlab module Gitlab
module Middleware module Middleware
class Static < ActionDispatch::Static class Static < ActionDispatch::Static
......
require 'spec_helper' require 'spec_helper'
describe 'User updates wiki page' do describe 'User updates wiki page' do
shared_examples 'wiki page user update' do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
...@@ -16,7 +15,7 @@ describe 'User updates wiki page' do ...@@ -16,7 +15,7 @@ describe 'User updates wiki page' do
end end
context 'in a user namespace' do context 'in a user namespace' do
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) } let(:project) { create(:project, :wiki_repo) }
it 'redirects back to the home edit page' do it 'redirects back to the home edit page' do
page.within(:css, '.wiki-form .form-actions') do page.within(:css, '.wiki-form .form-actions') do
...@@ -72,7 +71,7 @@ describe 'User updates wiki page' do ...@@ -72,7 +71,7 @@ describe 'User updates wiki page' do
end end
context 'in a user namespace' do context 'in a user namespace' do
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) } let(:project) { create(:project, :wiki_repo) }
it 'updates a page' do it 'updates a page' do
# Commit message field should have correct value. # Commit message field should have correct value.
...@@ -151,7 +150,7 @@ describe 'User updates wiki page' do ...@@ -151,7 +150,7 @@ describe 'User updates wiki page' do
end end
context 'when the page is in a subdir' do context 'when the page is in a subdir' do
let!(:project) { create(:project, :wiki_repo, namespace: user.namespace) } let!(:project) { create(:project, :wiki_repo) }
let(:project_wiki) { create(:project_wiki, project: project, user: project.creator) } let(:project_wiki) { create(:project_wiki, project: project, user: project.creator) }
let(:page_name) { 'page_name' } let(:page_name) { 'page_name' }
let(:page_dir) { "foo/bar/#{page_name}" } let(:page_dir) { "foo/bar/#{page_name}" }
...@@ -161,7 +160,7 @@ describe 'User updates wiki page' do ...@@ -161,7 +160,7 @@ describe 'User updates wiki page' do
visit(project_wiki_edit_path(project, wiki_page)) visit(project_wiki_edit_path(project, wiki_page))
end end
it 'moves the page to the root folder', :skip_gitaly_mock do it 'moves the page to the root folder' do
fill_in(:wiki_title, with: "/#{page_name}") fill_in(:wiki_title, with: "/#{page_name}")
click_button('Save changes') click_button('Save changes')
...@@ -221,13 +220,4 @@ describe 'User updates wiki page' do ...@@ -221,13 +220,4 @@ describe 'User updates wiki page' do
it_behaves_like 'wiki file attachments' it_behaves_like 'wiki file attachments'
end end
end
context 'when Gitaly is enabled' do
it_behaves_like 'wiki page user update'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'wiki page user update'
end
end end
require 'spec_helper' require 'spec_helper'
describe 'User views a wiki page' do describe 'User views a wiki page' do
shared_examples 'wiki page user view' do
include WikiHelpers include WikiHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -162,13 +161,4 @@ describe 'User views a wiki page' do ...@@ -162,13 +161,4 @@ describe 'User views a wiki page' do
expect(page).to have_content('Home · Create Page') expect(page).to have_content('Home · Create Page')
end end
end
context 'when Gitaly is enabled' do
it_behaves_like 'wiki page user view'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'wiki page user view'
end
end end
...@@ -46,7 +46,7 @@ describe PendingTodosFinder do ...@@ -46,7 +46,7 @@ describe PendingTodosFinder do
create(:todo, :pending, user: user, target: note) create(:todo, :pending, user: user, target: note)
todos = described_class.new(user, target_type: issue.class).execute todos = described_class.new(user, target_type: issue.class.name).execute
expect(todos).to eq([todo]) expect(todos).to eq([todo])
end end
......
...@@ -86,6 +86,29 @@ describe('init markdown', () => { ...@@ -86,6 +86,29 @@ describe('init markdown', () => {
expect(textArea.value).toEqual(`${initialValue}* `); expect(textArea.value).toEqual(`${initialValue}* `);
}); });
it('places the cursor inside the tags', () => {
const start = 'lorem ';
const end = ' ipsum';
const tag = '*';
textArea.value = `${start}${end}`;
textArea.setSelectionRange(start.length, start.length);
insertMarkdownText({
textArea,
text: textArea.value,
tag,
blockTag: null,
selected: '',
wrap: true,
});
expect(textArea.value).toEqual(`${start}**${end}`);
// cursor placement should be between tags
expect(textArea.selectionStart).toBe(start.length + tag.length);
});
}); });
describe('with selection', () => { describe('with selection', () => {
...@@ -98,16 +121,22 @@ describe('init markdown', () => { ...@@ -98,16 +121,22 @@ describe('init markdown', () => {
}); });
it('applies the tag to the selected value', () => { it('applies the tag to the selected value', () => {
const selectedIndex = text.indexOf(selected);
const tag = '*';
insertMarkdownText({ insertMarkdownText({
textArea, textArea,
text: textArea.value, text: textArea.value,
tag: '*', tag,
blockTag: null, blockTag: null,
selected, selected,
wrap: true, wrap: true,
}); });
expect(textArea.value).toEqual(text.replace(selected, `*${selected}*`)); expect(textArea.value).toEqual(text.replace(selected, `*${selected}*`));
// cursor placement should be after selection + 2 tag lengths
expect(textArea.selectionStart).toBe(selectedIndex + selected.length + 2 * tag.length);
}); });
it('replaces the placeholder in the tag', () => { it('replaces the placeholder in the tag', () => {
......
...@@ -205,7 +205,6 @@ describe ExtractsPath do ...@@ -205,7 +205,6 @@ describe ExtractsPath do
end end
describe '#lfs_blob_ids' do describe '#lfs_blob_ids' do
shared_examples '#lfs_blob_ids' do
let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') } let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') }
let(:ref) { tag.target } let(:ref) { tag.target }
let(:params) { { ref: ref, path: 'README.md' } } let(:params) { { ref: ref, path: 'README.md' } }
...@@ -220,13 +219,4 @@ describe ExtractsPath do ...@@ -220,13 +219,4 @@ describe ExtractsPath do
expect(lfs_blob_ids).to eq([]) expect(lfs_blob_ids).to eq([])
end end
end end
context 'when gitaly is enabled' do
it_behaves_like '#lfs_blob_ids'
end
context 'when gitaly is disabled', :skip_gitaly_mock do
it_behaves_like '#lfs_blob_ids'
end
end
end end
...@@ -37,17 +37,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do ...@@ -37,17 +37,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
let(:stub_path) { '.gitignore' } let(:stub_path) { '.gitignore' }
end end
shared_examples 'initializes a DiffCollection' do
it 'returns a valid instance of a DiffCollection' do it 'returns a valid instance of a DiffCollection' do
expect(diff_files).to be_a(Gitlab::Git::DiffCollection) expect(diff_files).to be_a(Gitlab::Git::DiffCollection)
end end
end
context 'with Gitaly disabled', :disable_gitaly do
it_behaves_like 'initializes a DiffCollection'
end
context 'with Gitaly enabled' do
it_behaves_like 'initializes a DiffCollection'
end
end end
...@@ -128,7 +128,7 @@ describe Gitlab::Git::Blob, :seed_helper do ...@@ -128,7 +128,7 @@ describe Gitlab::Git::Blob, :seed_helper do
end end
end end
shared_examples 'finding blobs by ID' do describe '.raw' do
let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) }
let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) } let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) }
...@@ -166,16 +166,6 @@ describe Gitlab::Git::Blob, :seed_helper do ...@@ -166,16 +166,6 @@ describe Gitlab::Git::Blob, :seed_helper do
end end
end end
describe '.raw' do
context 'when the blob_raw Gitaly feature is enabled' do
it_behaves_like 'finding blobs by ID'
end
context 'when the blob_raw Gitaly feature is disabled', :skip_gitaly_mock do
it_behaves_like 'finding blobs by ID'
end
end
describe '.batch' do describe '.batch' do
let(:blob_references) do let(:blob_references) do
[ [
......
...@@ -183,7 +183,6 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -183,7 +183,6 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
shared_examples '.where' do
context 'path is empty string' do context 'path is empty string' do
subject do subject do
commits = described_class.where( commits = described_class.where(
...@@ -279,15 +278,6 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -279,15 +278,6 @@ describe Gitlab::Git::Commit, :seed_helper do
it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") } it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
it { is_expected.not_to include(SeedRepo::Commit::ID) } it { is_expected.not_to include(SeedRepo::Commit::ID) }
end end
end
describe '.where with gitaly' do
it_should_behave_like '.where'
end
describe '.where without gitaly', :skip_gitaly_mock do
it_should_behave_like '.where'
end
describe '.between' do describe '.between' do
subject do subject do
...@@ -508,7 +498,7 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -508,7 +498,7 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
shared_examples '#stats' do describe '#stats' do
subject { commit.stats } subject { commit.stats }
describe '#additions' do describe '#additions' do
...@@ -527,14 +517,6 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -527,14 +517,6 @@ describe Gitlab::Git::Commit, :seed_helper do
end end
end end
describe '#stats with gitaly on' do
it_should_behave_like '#stats'
end
describe '#stats with gitaly disabled', :skip_gitaly_mock do
it_should_behave_like '#stats'
end
describe '#has_zero_stats?' do describe '#has_zero_stats?' do
it { expect(commit.has_zero_stats?).to eq(false) } it { expect(commit.has_zero_stats?).to eq(false) }
end end
...@@ -577,28 +559,18 @@ describe Gitlab::Git::Commit, :seed_helper do ...@@ -577,28 +559,18 @@ describe Gitlab::Git::Commit, :seed_helper do
commit_ids.map { |id| described_class.get_message(repository, id) } commit_ids.map { |id| described_class.get_message(repository, id) }
end end
shared_examples 'getting commit messages' do
it 'gets commit messages' do it 'gets commit messages' do
expect(subject).to contain_exactly( expect(subject).to contain_exactly(
"Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n", "Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n",
"Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n" "Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"
) )
end end
end
context 'when Gitaly commit_messages feature is enabled' do
it_behaves_like 'getting commit messages'
it 'gets messages in one batch', :request_store do it 'gets messages in one batch', :request_store do
expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1) expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end end
end end
context 'when Gitaly commit_messages feature is disabled', :disable_gitaly do
it_behaves_like 'getting commit messages'
end
end
def sample_commit_hash def sample_commit_hash
{ {
author_email: "dmitriy.zaporozhets@gmail.com", author_email: "dmitriy.zaporozhets@gmail.com",
......
...@@ -3,7 +3,7 @@ require "spec_helper" ...@@ -3,7 +3,7 @@ require "spec_helper"
describe Gitlab::Git::Tag, :seed_helper do describe Gitlab::Git::Tag, :seed_helper do
let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '') }
shared_examples 'Gitlab::Git::Repository#tags' do describe '#tags' do
describe 'first tag' do describe 'first tag' do
let(:tag) { repository.tags.first } let(:tag) { repository.tags.first }
...@@ -25,14 +25,6 @@ describe Gitlab::Git::Tag, :seed_helper do ...@@ -25,14 +25,6 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) } it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) }
end end
context 'when Gitaly tags feature is enabled' do
it_behaves_like 'Gitlab::Git::Repository#tags'
end
context 'when Gitaly tags feature is disabled', :skip_gitaly_mock do
it_behaves_like 'Gitlab::Git::Repository#tags'
end
describe '.get_message' do describe '.get_message' do
let(:tag_ids) { %w[f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b] } let(:tag_ids) { %w[f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b] }
...@@ -40,26 +32,16 @@ describe Gitlab::Git::Tag, :seed_helper do ...@@ -40,26 +32,16 @@ describe Gitlab::Git::Tag, :seed_helper do
tag_ids.map { |id| described_class.get_message(repository, id) } tag_ids.map { |id| described_class.get_message(repository, id) }
end end
shared_examples 'getting tag messages' do
it 'gets tag messages' do it 'gets tag messages' do
expect(subject[0]).to eq("Release\n") expect(subject[0]).to eq("Release\n")
expect(subject[1]).to eq("Version 1.1.0\n") expect(subject[1]).to eq("Version 1.1.0\n")
end end
end
context 'when Gitaly tag_messages feature is enabled' do
it_behaves_like 'getting tag messages'
it 'gets messages in one batch', :request_store do it 'gets messages in one batch', :request_store do
expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1) expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end end
end end
context 'when Gitaly tag_messages feature is disabled', :disable_gitaly do
it_behaves_like 'getting tag messages'
end
end
describe 'tag into from Gitaly tag' do describe 'tag into from Gitaly tag' do
context 'message_size != message.size' do context 'message_size != message.size' do
let(:gitaly_tag) { build(:gitaly_tag, message: ''.b, message_size: message_size) } let(:gitaly_tag) { build(:gitaly_tag, message: ''.b, message_size: message_size) }
......
...@@ -80,18 +80,8 @@ describe Gitlab::Git::Tree, :seed_helper do ...@@ -80,18 +80,8 @@ describe Gitlab::Git::Tree, :seed_helper do
end end
describe '#where' do describe '#where' do
shared_examples '#where' do
it 'returns an empty array when called with an invalid ref' do it 'returns an empty array when called with an invalid ref' do
expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([]) expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([])
end end
end end
context 'with gitaly' do
it_behaves_like '#where'
end
context 'without gitaly', :skip_gitaly_mock do
it_behaves_like '#where'
end
end
end end
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
# We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want # We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want
# those stubs while testing the GitalyClient itself. # those stubs while testing the GitalyClient itself.
describe Gitlab::GitalyClient, skip_gitaly_mock: true do describe Gitlab::GitalyClient do
describe '.stub_class' do describe '.stub_class' do
it 'returns the gRPC health check stub' do it 'returns the gRPC health check stub' do
expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub) expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub)
...@@ -191,105 +191,16 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do ...@@ -191,105 +191,16 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
let(:feature_name) { 'my_feature' } let(:feature_name) { 'my_feature' }
let(:real_feature_name) { "gitaly_#{feature_name}" } let(:real_feature_name) { "gitaly_#{feature_name}" }
context 'when Gitaly is disabled' do
before do before do
allow(described_class).to receive(:enabled?).and_return(false) allow(Feature).to receive(:enabled?).and_return(false)
end end
it 'returns false' do it 'returns false' do
expect(Feature).to receive(:enabled?).with(real_feature_name)
expect(described_class.feature_enabled?(feature_name)).to be(false) expect(described_class.feature_enabled?(feature_name)).to be(false)
end end
end end
context 'when the feature status is DISABLED' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::DISABLED }
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context 'when the feature_status is OPT_IN' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::OPT_IN }
context "when the feature flag hasn't been set" do
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when the feature flag is set to disable" do
before do
Feature.get(real_feature_name).disable
end
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when the feature flag is set to enable" do
before do
Feature.get(real_feature_name).enable
end
it 'returns true' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
context "when the feature flag is set to a percentage of time" do
before do
Feature.get(real_feature_name).enable_percentage_of_time(70)
end
it 'bases the result on pseudo-random numbers' do
expect(Random).to receive(:rand).and_return(0.3)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
expect(Random).to receive(:rand).and_return(0.8)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
context "when a feature is not persisted" do
it 'returns false when opt_into_all_features is off' do
allow(Feature).to receive(:persisted?).and_return(false)
allow(described_class).to receive(:opt_into_all_features?).and_return(false)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
it 'returns true when the override is on' do
allow(Feature).to receive(:persisted?).and_return(false)
allow(described_class).to receive(:opt_into_all_features?).and_return(true)
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
end
context 'when the feature_status is OPT_OUT' do
let(:feature_status) { Gitlab::GitalyClient::MigrationStatus::OPT_OUT }
context "when the feature flag hasn't been set" do
it 'returns true' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(true)
end
end
context "when the feature flag is set to disable" do
before do
Feature.get(real_feature_name).disable
end
it 'returns false' do
expect(described_class.feature_enabled?(feature_name, status: feature_status)).to be(false)
end
end
end
end
describe 'timeouts' do describe 'timeouts' do
context 'with default values' do context 'with default values' do
before do before do
......
...@@ -30,7 +30,6 @@ describe MergeRequest do ...@@ -30,7 +30,6 @@ describe MergeRequest do
end end
describe '#squash_in_progress?' do describe '#squash_in_progress?' do
shared_examples 'checking whether a squash is in progress' do
let(:repo_path) do let(:repo_path) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do Gitlab::GitalyClient::StorageSettings.allow_disk_access do
subject.source_project.repository.path subject.source_project.repository.path
...@@ -66,15 +65,6 @@ describe MergeRequest do ...@@ -66,15 +65,6 @@ describe MergeRequest do
end end
end end
context 'when Gitaly squash_in_progress is enabled' do
it_behaves_like 'checking whether a squash is in progress'
end
context 'when Gitaly squash_in_progress is disabled', :disable_gitaly do
it_behaves_like 'checking whether a squash is in progress'
end
end
describe '#squash?' do describe '#squash?' do
let(:merge_request) { build(:merge_request, squash: squash) } let(:merge_request) { build(:merge_request, squash: squash) }
subject { merge_request.squash? } subject { merge_request.squash? }
...@@ -3016,14 +3006,6 @@ describe MergeRequest do ...@@ -3016,14 +3006,6 @@ describe MergeRequest do
expect(subject.rebase_in_progress?).to be_falsey expect(subject.rebase_in_progress?).to be_falsey
end end
end end
context 'when Gitaly rebase_in_progress is enabled' do
it_behaves_like 'checking whether a rebase is in progress'
end
context 'when Gitaly rebase_in_progress is enabled', :disable_gitaly do
it_behaves_like 'checking whether a rebase is in progress'
end
end end
describe '#allow_collaboration' do describe '#allow_collaboration' do
......
...@@ -138,7 +138,6 @@ describe ProjectWiki do ...@@ -138,7 +138,6 @@ describe ProjectWiki do
end end
describe "#find_page" do describe "#find_page" do
shared_examples 'finding a wiki page' do
before do before do
create_page("index page", "This is an awesome Gollum Wiki") create_page("index page", "This is an awesome Gollum Wiki")
end end
...@@ -189,15 +188,6 @@ describe ProjectWiki do ...@@ -189,15 +188,6 @@ describe ProjectWiki do
end end
end end
context 'when Gitaly wiki_find_page is enabled' do
it_behaves_like 'finding a wiki page'
end
context 'when Gitaly wiki_find_page is disabled', :skip_gitaly_mock do
it_behaves_like 'finding a wiki page'
end
end
describe '#find_sidebar' do describe '#find_sidebar' do
before do before do
create_page(described_class::SIDEBAR, 'This is an awesome Sidebar') create_page(described_class::SIDEBAR, 'This is an awesome Sidebar')
...@@ -215,7 +205,6 @@ describe ProjectWiki do ...@@ -215,7 +205,6 @@ describe ProjectWiki do
end end
describe '#find_file' do describe '#find_file' do
shared_examples 'finding a wiki file' do
let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) } let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) }
before do before do
...@@ -250,17 +239,7 @@ describe ProjectWiki do ...@@ -250,17 +239,7 @@ describe ProjectWiki do
end end
end end
context 'when Gitaly wiki_find_file is enabled' do
it_behaves_like 'finding a wiki file'
end
context 'when Gitaly wiki_find_file is disabled', :skip_gitaly_mock do
it_behaves_like 'finding a wiki file'
end
end
describe "#create_page" do describe "#create_page" do
shared_examples 'creating a wiki page' do
after do after do
destroy_page(subject.pages.first.page) destroy_page(subject.pages.first.page)
end end
...@@ -303,15 +282,6 @@ describe ProjectWiki do ...@@ -303,15 +282,6 @@ describe ProjectWiki do
end end
end end
context 'when Gitaly wiki_write_page is enabled' do
it_behaves_like 'creating a wiki page'
end
context 'when Gitaly wiki_write_page is disabled', :skip_gitaly_mock do
it_behaves_like 'creating a wiki page'
end
end
describe "#update_page" do describe "#update_page" do
before do before do
create_page("update-page", "some content") create_page("update-page", "some content")
...@@ -359,7 +329,6 @@ describe ProjectWiki do ...@@ -359,7 +329,6 @@ describe ProjectWiki do
end end
describe "#delete_page" do describe "#delete_page" do
shared_examples 'deleting a wiki page' do
before do before do
create_page("index", "some content") create_page("index", "some content")
@page = subject.wiki.page(title: "index") @page = subject.wiki.page(title: "index")
...@@ -388,15 +357,6 @@ describe ProjectWiki do ...@@ -388,15 +357,6 @@ describe ProjectWiki do
end end
end end
context 'when Gitaly wiki_delete_page is enabled' do
it_behaves_like 'deleting a wiki page'
end
context 'when Gitaly wiki_delete_page is disabled', :skip_gitaly_mock do
it_behaves_like 'deleting a wiki page'
end
end
describe '#create_repo!' do describe '#create_repo!' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -38,7 +38,6 @@ describe Repository do ...@@ -38,7 +38,6 @@ describe Repository do
end end
describe '#branch_names_contains' do describe '#branch_names_contains' do
shared_examples '#branch_names_contains' do
set(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
let(:repository) { project.repository } let(:repository) { project.repository }
...@@ -57,32 +56,13 @@ describe Repository do ...@@ -57,32 +56,13 @@ describe Repository do
end end
end end
context 'when gitaly is enabled' do
it_behaves_like '#branch_names_contains'
end
context 'when gitaly is disabled', :skip_gitaly_mock do
it_behaves_like '#branch_names_contains'
end
end
describe '#tag_names_contains' do describe '#tag_names_contains' do
shared_examples '#tag_names_contains' do
subject { repository.tag_names_contains(sample_commit.id) } subject { repository.tag_names_contains(sample_commit.id) }
it { is_expected.to include('v1.1.0') } it { is_expected.to include('v1.1.0') }
it { is_expected.not_to include('v1.0.0') } it { is_expected.not_to include('v1.0.0') }
end end
context 'when gitaly is enabled' do
it_behaves_like '#tag_names_contains'
end
context 'when gitaly is enabled', :skip_gitaly_mock do
it_behaves_like '#tag_names_contains'
end
end
describe 'tags_sorted_by' do describe 'tags_sorted_by' do
context 'name_desc' do context 'name_desc' do
subject { repository.tags_sorted_by('name_desc').map(&:name) } subject { repository.tags_sorted_by('name_desc').map(&:name) }
...@@ -238,7 +218,6 @@ describe Repository do ...@@ -238,7 +218,6 @@ describe Repository do
end end
describe '#last_commit_for_path' do describe '#last_commit_for_path' do
shared_examples 'getting last commit for path' do
subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id } subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id }
it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') } it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
...@@ -252,17 +231,7 @@ describe Repository do ...@@ -252,17 +231,7 @@ describe Repository do
end end
end end
context 'when Gitaly feature last_commit_for_path is enabled' do
it_behaves_like 'getting last commit for path'
end
context 'when Gitaly feature last_commit_for_path is disabled', :skip_gitaly_mock do
it_behaves_like 'getting last commit for path'
end
end
describe '#last_commit_id_for_path' do describe '#last_commit_id_for_path' do
shared_examples 'getting last commit ID for path' do
subject { repository.last_commit_id_for_path(sample_commit.id, '.gitignore') } subject { repository.last_commit_id_for_path(sample_commit.id, '.gitignore') }
it "returns last commit id for a given path" do it "returns last commit id for a given path" do
...@@ -286,15 +255,6 @@ describe Repository do ...@@ -286,15 +255,6 @@ describe Repository do
end end
end end
context 'when Gitaly feature last_commit_for_path is enabled' do
it_behaves_like 'getting last commit ID for path'
end
context 'when Gitaly feature last_commit_for_path is disabled', :skip_gitaly_mock do
it_behaves_like 'getting last commit ID for path'
end
end
describe '#commits' do describe '#commits' do
context 'when neither the all flag nor a ref are specified' do context 'when neither the all flag nor a ref are specified' do
it 'returns every commit from default branch' do it 'returns every commit from default branch' do
...@@ -374,8 +334,6 @@ describe Repository do ...@@ -374,8 +334,6 @@ describe Repository do
describe '#commits_by' do describe '#commits_by' do
set(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
shared_examples 'batch commits fetching' do
let(:oids) { TestEnv::BRANCH_SHA.values } let(:oids) { TestEnv::BRANCH_SHA.values }
subject { project.repository.commits_by(oids: oids) } subject { project.repository.commits_by(oids: oids) }
...@@ -411,17 +369,7 @@ describe Repository do ...@@ -411,17 +369,7 @@ describe Repository do
end end
end end
context 'when Gitaly list_commits_by_oid is enabled' do
it_behaves_like 'batch commits fetching'
end
context 'when Gitaly list_commits_by_oid is enabled', :disable_gitaly do
it_behaves_like 'batch commits fetching'
end
end
describe '#find_commits_by_message' do describe '#find_commits_by_message' do
shared_examples 'finding commits by message' do
it 'returns commits with messages containing a given string' do it 'returns commits with messages containing a given string' do
commit_ids = repository.find_commits_by_message('submodule').map(&:id) commit_ids = repository.find_commits_by_message('submodule').map(&:id)
...@@ -438,15 +386,6 @@ describe Repository do ...@@ -438,15 +386,6 @@ describe Repository do
expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e') expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
end end
end
context 'when Gitaly commits_by_message feature is enabled' do
it_behaves_like 'finding commits by message'
end
context 'when Gitaly commits_by_message feature is disabled', :skip_gitaly_mock do
it_behaves_like 'finding commits by message'
end
describe 'when storage is broken', :broken_storage do describe 'when storage is broken', :broken_storage do
it 'should raise a storage error' do it 'should raise a storage error' do
...@@ -1328,10 +1267,8 @@ describe Repository do ...@@ -1328,10 +1267,8 @@ describe Repository do
describe '#merge' do describe '#merge' do
let(:merge_request) { create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project) } let(:merge_request) { create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project) }
let(:message) { 'Test \r\n\r\n message' } let(:message) { 'Test \r\n\r\n message' }
shared_examples '#merge' do
it 'merges the code and returns the commit id' do it 'merges the code and returns the commit id' do
expect(merge_commit).to be_present expect(merge_commit).to be_present
expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
...@@ -1348,15 +1285,6 @@ describe Repository do ...@@ -1348,15 +1285,6 @@ describe Repository do
expect(repository.commit(merge_commit_id).message).to eq(message.delete("\r")) expect(repository.commit(merge_commit_id).message).to eq(message.delete("\r"))
end end
end
context 'with gitaly' do
it_behaves_like '#merge'
end
context 'without gitaly', :skip_gitaly_mock do
it_behaves_like '#merge'
end
def merge(repository, user, merge_request, message) def merge(repository, user, merge_request, message)
repository.merge(user, merge_request.diff_head_sha, merge_request, message) repository.merge(user, merge_request.diff_head_sha, merge_request, message)
...@@ -1392,7 +1320,6 @@ describe Repository do ...@@ -1392,7 +1320,6 @@ describe Repository do
end end
describe '#revert' do describe '#revert' do
shared_examples 'reverting a commit' do
let(:new_image_commit) { repository.commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9') } let(:new_image_commit) { repository.commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9') }
let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') } let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
let(:message) { 'revert message' } let(:message) { 'revert message' }
...@@ -1428,17 +1355,7 @@ describe Repository do ...@@ -1428,17 +1355,7 @@ describe Repository do
end end
end end
context 'when Gitaly revert feature is enabled' do
it_behaves_like 'reverting a commit'
end
context 'when Gitaly revert feature is disabled', :disable_gitaly do
it_behaves_like 'reverting a commit'
end
end
describe '#cherry_pick' do describe '#cherry_pick' do
shared_examples 'cherry-picking a commit' do
let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') } let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') }
let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') } let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') } let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') }
...@@ -1477,15 +1394,6 @@ describe Repository do ...@@ -1477,15 +1394,6 @@ describe Repository do
end end
end end
context 'when Gitaly cherry_pick feature is enabled' do
it_behaves_like 'cherry-picking a commit'
end
context 'when Gitaly cherry_pick feature is disabled', :disable_gitaly do
it_behaves_like 'cherry-picking a commit'
end
end
describe '#before_delete' do describe '#before_delete' do
describe 'when a repository does not exist' do describe 'when a repository does not exist' do
before do before do
...@@ -2190,7 +2098,6 @@ describe Repository do ...@@ -2190,7 +2098,6 @@ describe Repository do
let(:commit) { repository.commit } let(:commit) { repository.commit }
let(:ancestor) { commit.parents.first } let(:ancestor) { commit.parents.first }
shared_examples '#ancestor?' do
it 'it is an ancestor' do it 'it is an ancestor' do
expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true) expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true)
end end
...@@ -2211,15 +2118,6 @@ describe Repository do ...@@ -2211,15 +2118,6 @@ describe Repository do
end end
end end
context 'with Gitaly enabled' do
it_behaves_like('#ancestor?')
end
context 'with Gitaly disabled', :skip_gitaly_mock do
it_behaves_like('#ancestor?')
end
end
describe '#archive_metadata' do describe '#archive_metadata' do
let(:ref) { 'master' } let(:ref) { 'master' }
let(:storage_path) { '/tmp' } let(:storage_path) { '/tmp' }
......
...@@ -226,7 +226,7 @@ describe Todo do ...@@ -226,7 +226,7 @@ describe Todo do
create(:todo, target: create(:merge_request)) create(:todo, target: create(:merge_request))
expect(described_class.for_type(Issue)).to eq([todo]) expect(described_class.for_type(Issue.name)).to eq([todo])
end end
end end
......
...@@ -200,7 +200,6 @@ describe WikiPage do ...@@ -200,7 +200,6 @@ describe WikiPage do
end end
describe '#create' do describe '#create' do
shared_examples 'create method' do
context 'with valid attributes' do context 'with valid attributes' do
it 'raises an error if a page with the same path already exists' do it 'raises an error if a page with the same path already exists' do
create_page('New Page', 'content') create_page('New Page', 'content')
...@@ -222,17 +221,7 @@ describe WikiPage do ...@@ -222,17 +221,7 @@ describe WikiPage do
end end
end end
context 'when Gitaly is enabled' do
it_behaves_like 'create method'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'create method'
end
end
describe "#update" do describe "#update" do
shared_examples 'update method' do
before do before do
create_page("Update", "content") create_page("Update", "content")
@page = wiki.find_page("Update") @page = wiki.find_page("Update")
...@@ -331,7 +320,7 @@ describe WikiPage do ...@@ -331,7 +320,7 @@ describe WikiPage do
@page = wiki.find_page('foo/Existing Page') @page = wiki.find_page('foo/Existing Page')
end end
it 'moves the page to the root folder if the title is preceded by /', :skip_gitaly_mock do it 'moves the page to the root folder if the title is preceded by /' do
expect(@page.slug).to eq 'foo/Existing-Page' expect(@page.slug).to eq 'foo/Existing-Page'
expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy
expect(@page.slug).to eq 'Existing-Page' expect(@page.slug).to eq 'Existing-Page'
...@@ -368,15 +357,6 @@ describe WikiPage do ...@@ -368,15 +357,6 @@ describe WikiPage do
end end
end end
context 'when Gitaly is enabled' do
it_behaves_like 'update method'
end
context 'when Gitaly is disabled', :skip_gitaly_mock do
it_behaves_like 'update method'
end
end
describe "#destroy" do describe "#destroy" do
before do before do
create_page("Delete Page", "content") create_page("Delete Page", "content")
...@@ -394,7 +374,6 @@ describe WikiPage do ...@@ -394,7 +374,6 @@ describe WikiPage do
end end
describe "#versions" do describe "#versions" do
shared_examples 'wiki page versions' do
let(:page) { wiki.find_page("Update") } let(:page) { wiki.find_page("Update") }
before do before do
...@@ -416,15 +395,6 @@ describe WikiPage do ...@@ -416,15 +395,6 @@ describe WikiPage do
end end
end end
context 'when Gitaly is enabled' do
it_behaves_like 'wiki page versions'
end
context 'when Gitaly is disabled', :disable_gitaly do
it_behaves_like 'wiki page versions'
end
end
describe "#title" do describe "#title" do
before do before do
create_page("Title", "content") create_page("Title", "content")
...@@ -555,7 +525,6 @@ describe WikiPage do ...@@ -555,7 +525,6 @@ describe WikiPage do
end end
describe '#formatted_content' do describe '#formatted_content' do
shared_examples 'fetching page formatted content' do
it 'returns processed content of the page' do it 'returns processed content of the page' do
subject.create({ title: "RDoc", content: "*bold*", format: "rdoc" }) subject.create({ title: "RDoc", content: "*bold*", format: "rdoc" })
page = wiki.find_page('RDoc') page = wiki.find_page('RDoc')
...@@ -566,15 +535,6 @@ describe WikiPage do ...@@ -566,15 +535,6 @@ describe WikiPage do
end end
end end
context 'when Gitaly wiki_page_formatted_data is enabled' do
it_behaves_like 'fetching page formatted content'
end
context 'when Gitaly wiki_page_formatted_data is disabled', :disable_gitaly do
it_behaves_like 'fetching page formatted content'
end
end
describe '#hook_attrs' do describe '#hook_attrs' do
it 'adds absolute urls for images in the content' do it 'adds absolute urls for images in the content' do
create_page("test page", "test![WikiPage_Image](/uploads/abc/WikiPage_Image.png)") create_page("test page", "test![WikiPage_Image](/uploads/abc/WikiPage_Image.png)")
......
RSpec.configure do |config|
config.before(:each) do |example|
if example.metadata[:disable_gitaly]
# Use 'and_wrap_original' to make sure the arguments are valid
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_wrap_original { |m, *args| m.call(*args) && false }
else
next if example.metadata[:skip_gitaly_mock]
# Use 'and_wrap_original' to make sure the arguments are valid
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_wrap_original do |m, *args|
m.call(*args)
!Gitlab::GitalyClient.explicit_opt_in_required.include?(args.first)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment