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:
Diffstat (limited to 'spec/services/git')
-rw-r--r--spec/services/git/branch_hooks_service_spec.rb2
-rw-r--r--spec/services/git/branch_push_service_spec.rb8
-rw-r--r--spec/services/git/wiki_push_service_spec.rb32
3 files changed, 31 insertions, 11 deletions
diff --git a/spec/services/git/branch_hooks_service_spec.rb b/spec/services/git/branch_hooks_service_spec.rb
index 5de1c0e27be..973ead28462 100644
--- a/spec/services/git/branch_hooks_service_spec.rb
+++ b/spec/services/git/branch_hooks_service_spec.rb
@@ -596,7 +596,7 @@ RSpec.describe Git::BranchHooksService, :clean_gitlab_redis_shared_state do
end
end
- project.repository.multi_action(
+ project.repository.commit_files(
user, message: 'message', branch_name: branch, actions: actions
)
end
diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb
index 6280f1263c3..a9f5b07fef4 100644
--- a/spec/services/git/branch_push_service_spec.rb
+++ b/spec/services/git/branch_push_service_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe Git::BranchPushService, services: true do
+RSpec.describe Git::BranchPushService, :use_clean_rails_redis_caching, services: true do
include RepoHelpers
let_it_be(:user) { create(:user) }
@@ -285,7 +285,7 @@ RSpec.describe Git::BranchPushService, services: true do
author_email: commit_author.email
)
- allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit)
+ allow(Commit).to receive(:build_from_sidekiq_hash)
.and_return(commit)
allow(project.repository).to receive(:commits_between).and_return([commit])
@@ -348,7 +348,7 @@ RSpec.describe Git::BranchPushService, services: true do
committed_date: commit_time
)
- allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit)
+ allow(Commit).to receive(:build_from_sidekiq_hash)
.and_return(commit)
allow(project.repository).to receive(:commits_between).and_return([commit])
@@ -387,7 +387,7 @@ RSpec.describe Git::BranchPushService, services: true do
allow(project.repository).to receive(:commits_between)
.and_return([closing_commit])
- allow_any_instance_of(ProcessCommitWorker).to receive(:build_commit)
+ allow(Commit).to receive(:build_from_sidekiq_hash)
.and_return(closing_commit)
project.add_maintainer(commit_author)
diff --git a/spec/services/git/wiki_push_service_spec.rb b/spec/services/git/wiki_push_service_spec.rb
index 7e5d7066e89..878a5c4ccf0 100644
--- a/spec/services/git/wiki_push_service_spec.rb
+++ b/spec/services/git/wiki_push_service_spec.rb
@@ -9,9 +9,13 @@ RSpec.describe Git::WikiPushService, services: true do
let_it_be(:key_id) { create(:key, user: current_user).shell_id }
let(:wiki) { create(:project_wiki, user: current_user) }
- let(:git_wiki) { wiki.wiki }
+ let(:default_branch) { wiki.default_branch }
let(:repository) { wiki.repository }
+ before do
+ repository.create_if_not_exists(default_branch)
+ end
+
describe '#execute' do
it 'executes model-specific callbacks' do
expect(wiki).to receive(:after_post_receive)
@@ -351,7 +355,12 @@ RSpec.describe Git::WikiPushService, services: true do
# that have not gone through our services.
def write_new_page
- generate(:wiki_page_title).tap { |t| git_wiki.write_page(t, 'markdown', 'Hello', commit_details) }
+ generate(:wiki_page_title).tap do |t|
+ repository.create_file(
+ current_user, ::Wiki.sluggified_full_path(t, 'md'), 'Hello',
+ **commit_details
+ )
+ end
end
# We write something to the wiki-repo that is not a page - as, for example, an
@@ -368,15 +377,26 @@ RSpec.describe Git::WikiPushService, services: true do
def update_page(title, new_title = nil)
new_title = title unless new_title.present?
- page = git_wiki.page(title: title)
- git_wiki.update_page(page.path, new_title, 'markdown', 'Hey', commit_details)
+
+ old_path = ::Wiki.sluggified_full_path(title, 'md')
+ new_path = ::Wiki.sluggified_full_path(new_title, 'md')
+
+ repository.update_file(
+ current_user, new_path, 'Hey',
+ **commit_details.merge(previous_path: old_path)
+ )
end
def delete_page(page)
- wiki.delete_page(page, 'commit message')
+ repository.delete_file(current_user, page.path, **commit_details)
end
def commit_details
- create(:git_wiki_commit_details, author: current_user)
+ {
+ branch_name: default_branch,
+ message: "commit message",
+ author_email: current_user.email,
+ author_name: current_user.name
+ }
end
end