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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-05 21:08:43 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-05 21:08:43 +0300
commite129eff88309eca18f3902afd710e2e07393fe45 (patch)
tree2dd9399fdcfdee719d51e63cd821adc58165ccb3 /spec/helpers
parent205b6baf2677879c35968d2b659225b58e8a1227 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/diff_helper_spec.rb51
-rw-r--r--spec/helpers/namespace_storage_limit_alert_helper_spec.rb11
-rw-r--r--spec/helpers/projects_helper_spec.rb2
-rw-r--r--spec/helpers/todos_helper_spec.rb10
4 files changed, 56 insertions, 18 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index cf16807723b..b6efced698d 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -471,21 +471,60 @@ RSpec.describe DiffHelper do
describe '#conflicts' do
let(:merge_request) { instance_double(MergeRequest) }
+ let(:merge_ref_head_diff) { true }
+ let(:can_be_resolved_in_ui?) { true }
+ let(:allow_tree_conflicts) { false }
+ let(:files) { [instance_double(Gitlab::Conflict::File, path: 'a')] }
+ let(:exception) { nil }
before do
allow(helper).to receive(:merge_request).and_return(merge_request)
- allow(helper).to receive(:options).and_return(merge_ref_head_diff: true)
+ allow(helper).to receive(:options).and_return(merge_ref_head_diff: merge_ref_head_diff)
+
+ allow_next_instance_of(MergeRequests::Conflicts::ListService, merge_request, allow_tree_conflicts: allow_tree_conflicts) do |svc|
+ allow(svc).to receive(:can_be_resolved_in_ui?).and_return(can_be_resolved_in_ui?)
+
+ if exception.present?
+ allow(svc).to receive_message_chain(:conflicts, :files).and_raise(exception)
+ else
+ allow(svc).to receive_message_chain(:conflicts, :files).and_return(files)
+ end
+ end
end
- context 'when Gitlab::Git::Conflict::Resolver::ConflictSideMissing exception is raised' do
- before do
- allow_next_instance_of(MergeRequests::Conflicts::ListService, merge_request, allow_tree_conflicts: true) do |svc|
- allow(svc).to receive_message_chain(:conflicts, :files).and_raise(Gitlab::Git::Conflict::Resolver::ConflictSideMissing)
+ it 'returns list of conflicts indexed by path' do
+ expect(helper.conflicts).to eq('a' => files.first)
+ end
+
+ context 'when merge_ref_head_diff option is false' do
+ let(:merge_ref_head_diff) { false }
+
+ it 'returns nil' do
+ expect(helper.conflicts).to be_nil
+ end
+ end
+
+ context 'when conflicts cannot be resolved in UI' do
+ let(:can_be_resolved_in_ui?) { false }
+
+ it 'returns nil' do
+ expect(helper.conflicts).to be_nil
+ end
+
+ context 'when allow_tree_conflicts is true' do
+ let(:allow_tree_conflicts) { true }
+
+ it 'returns list of conflicts' do
+ expect(helper.conflicts(allow_tree_conflicts: allow_tree_conflicts)).to eq('a' => files.first)
end
end
+ end
+
+ context 'when Gitlab::Git::Conflict::Resolver::ConflictSideMissing exception is raised' do
+ let(:exception) { Gitlab::Git::Conflict::Resolver::ConflictSideMissing }
it 'returns an empty hash' do
- expect(helper.conflicts(allow_tree_conflicts: true)).to eq({})
+ expect(helper.conflicts).to eq({})
end
end
end
diff --git a/spec/helpers/namespace_storage_limit_alert_helper_spec.rb b/spec/helpers/namespace_storage_limit_alert_helper_spec.rb
deleted file mode 100644
index ab3cf96edef..00000000000
--- a/spec/helpers/namespace_storage_limit_alert_helper_spec.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe NamespaceStorageLimitAlertHelper do
- describe '#display_namespace_storage_limit_alert!' do
- it 'is defined in CE' do
- expect { helper.display_namespace_storage_limit_alert! }.not_to raise_error
- end
- end
-end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 4502729866c..42c97b61d19 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -698,7 +698,7 @@ RSpec.describe ProjectsHelper do
def grant_user_access(project, user, access)
case access
when :developer, :maintainer
- project.add_user(user, access)
+ project.add_member(user, access)
when :owner
project.namespace.update!(owner: user)
end
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 73a454fd9f7..bbabfedc3ee 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -133,6 +133,16 @@ RSpec.describe TodosHelper do
expect(path).to eq("/#{todo.project.full_path}/-/work_items/#{todo.target.id}")
end
end
+
+ context 'when given an issue with a note anchor' do
+ let(:todo) { create(:todo, project: issue.project, target: issue, note: note) }
+
+ it 'responds with an appropriate path' do
+ path = helper.todo_target_path(todo)
+
+ expect(path).to eq("/#{issue.project.full_path}/-/issues/#{issue.iid}##{dom_id(note)}")
+ end
+ end
end
describe '#todo_target_type_name' do