summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-01-09 00:51:05 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-01-22 13:34:51 -0300
commit2e0951e93f15ab3437cb13a1a2be36f45f777c3c (patch)
tree02f91dfa9a177ae84829c1e30ce182222eb06c1b /spec
parent081a584a35eb44dafd77d212acd9317a7f1414ef (diff)
downloadgitlab-ce-2e0951e93f15ab3437cb13a1a2be36f45f777c3c.tar.gz
Incorporate Gitaly's OperationService.UserCommitFiles RPCgitaly-user-commit-files
Diffstat (limited to 'spec')
-rw-r--r--spec/services/files/update_service_spec.rb12
-rw-r--r--spec/support/cycle_analytics_helpers.rb31
2 files changed, 35 insertions, 8 deletions
diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb
index 43b0c9a63a9..16bfbdf3089 100644
--- a/spec/services/files/update_service_spec.rb
+++ b/spec/services/files/update_service_spec.rb
@@ -72,13 +72,15 @@ describe Files::UpdateService do
end
end
- context 'when target branch is different than source branch' do
- let(:branch_name) { "#{project.default_branch}-new" }
+ context 'with gitaly disabled', :skip_gitaly_mock do
+ context 'when target branch is different than source branch' do
+ let(:branch_name) { "#{project.default_branch}-new" }
- it 'fires hooks only once' do
- expect(Gitlab::Git::HooksService).to receive(:new).once.and_call_original
+ it 'fires hooks only once' do
+ expect(Gitlab::Git::HooksService).to receive(:new).once.and_call_original
- subject.execute
+ subject.execute
+ end
end
end
end
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index 26fd271ce31..d5ef80cfab2 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -5,10 +5,16 @@ module CycleAnalyticsHelpers
end
def create_commit(message, project, user, branch_name, count: 1)
- oldrev = project.repository.commit(branch_name).sha
+ repository = project.repository
+ oldrev = repository.commit(branch_name).sha
+
+ if Timecop.frozen? && Gitlab::GitalyClient.feature_enabled?(:operation_user_commit_files)
+ mock_gitaly_multi_action_dates(repository.raw)
+ end
+
commit_shas = Array.new(count) do |index|
- commit_sha = project.repository.create_file(user, generate(:branch), "content", message: message, branch_name: branch_name)
- project.repository.commit(commit_sha)
+ commit_sha = repository.create_file(user, generate(:branch), "content", message: message, branch_name: branch_name)
+ repository.commit(commit_sha)
commit_sha
end
@@ -98,6 +104,25 @@ module CycleAnalyticsHelpers
pipeline: dummy_pipeline,
protected: false)
end
+
+ def mock_gitaly_multi_action_dates(raw_repository)
+ allow(raw_repository).to receive(:multi_action).and_wrap_original do |m, *args|
+ new_date = Time.now
+ branch_update = m.call(*args)
+
+ if branch_update.newrev
+ _, opts = args
+ commit = raw_repository.commit(branch_update.newrev).rugged_commit
+ branch_update.newrev = commit.amend(
+ update_ref: "#{Gitlab::Git::BRANCH_REF_PREFIX}#{opts[:branch_name]}",
+ author: commit.author.merge(time: new_date),
+ committer: commit.committer.merge(time: new_date)
+ )
+ end
+
+ branch_update
+ end
+ end
end
RSpec.configure do |config|