diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/helpers/diff_helper_spec.rb | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/helpers/diff_helper_spec.rb')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 61 |
1 files changed, 51 insertions, 10 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 93efce6b58b..78c0d0a2b11 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -445,6 +445,19 @@ RSpec.describe DiffHelper do end end + describe '#params_with_whitespace' do + before do + controller.params[:protocol] = 'HACKED!' + controller.params[:host] = 'HACKED!' + end + + subject { helper.params_with_whitespace } + + it "filters with safe_params" do + expect(subject).to eq({ 'w' => 1 }) + end + end + describe "#render_fork_suggestion" do subject { helper.render_fork_suggestion } @@ -471,7 +484,6 @@ RSpec.describe DiffHelper do describe '#conflicts' do let(:merge_request) { instance_double(MergeRequest, cannot_be_merged?: true) } - 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')] } @@ -479,7 +491,6 @@ RSpec.describe DiffHelper do before do allow(helper).to receive(:merge_request).and_return(merge_request) - 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?) @@ -496,14 +507,6 @@ RSpec.describe DiffHelper 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 merge request can be merged' do let(:merge_request) { instance_double(MergeRequest, cannot_be_merged?: false) } @@ -536,4 +539,42 @@ RSpec.describe DiffHelper do end end end + + describe '#show_only_context_commits?' do + let(:params) { {} } + let(:merge_request) { build_stubbed(:merge_request) } + let(:has_no_commits) { true } + + subject(:result) { helper.show_only_context_commits? } + + before do + assign(:merge_request, merge_request) + allow(helper).to receive(:params).and_return(params) + allow(merge_request).to receive(:has_no_commits?).and_return(has_no_commits) + end + + context 'when only_context_commits param is set to true' do + let(:params) { { only_context_commits: true } } + + it { is_expected.to be_truthy } + + context 'when merge request has commits' do + let(:has_no_commits) { false } + + it { is_expected.to be_truthy } + end + end + + context 'when only_context_commits param is set to false' do + let(:params) { { only_context_commits: false } } + + it { is_expected.to be_truthy } + + context 'when merge request has commits' do + let(:has_no_commits) { false } + + it { is_expected.to be_falsey } + end + end + end end |