diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/helpers/diff_helper_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/helpers/diff_helper_spec.rb')
-rw-r--r-- | spec/helpers/diff_helper_spec.rb | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 3580959fde0..20fa8d62884 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -169,9 +169,9 @@ RSpec.describe DiffHelper do it "returns strings with marked inline diffs" do marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) - expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">'def'</span>}) + expect(marked_old_line).to eq(%q{abc <span class="idiff left deletion">'</span>def<span class="idiff right deletion">'</span>}) expect(marked_old_line).to be_html_safe - expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">"def"</span>}) + expect(marked_new_line).to eq(%q{abc <span class="idiff left addition">"</span>def<span class="idiff right addition">"</span>}) expect(marked_new_line).to be_html_safe end @@ -358,4 +358,48 @@ RSpec.describe DiffHelper do expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb") end end + + describe "#collapsed_diff_url" do + let(:params) do + { + controller: "projects/commit", + action: "show", + namespace_id: "foo", + project_id: "bar", + id: commit.sha + } + end + + subject { helper.collapsed_diff_url(diff_file) } + + it "returns a valid URL" do + allow(helper).to receive(:safe_params).and_return(params) + + expect(subject).to match(/foo\/bar\/-\/commit\/#{commit.sha}\/diff_for_path/) + end + end + + describe "#render_fork_suggestion" do + subject { helper.render_fork_suggestion } + + before do + allow(helper).to receive(:current_user).and_return(current_user) + end + + context "user signed in" do + let(:current_user) { build(:user) } + + it "renders the partial" do + expect(helper).to receive(:render).with(partial: "projects/fork_suggestion").exactly(:once) + + 5.times { subject } + end + end + + context "guest" do + let(:current_user) { nil } + + it { is_expected.to be_nil } + end + end end |