diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/features/commit_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/features/commit_spec.rb')
-rw-r--r-- | spec/features/commit_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/spec/features/commit_spec.rb b/spec/features/commit_spec.rb new file mode 100644 index 00000000000..02754cc803e --- /dev/null +++ b/spec/features/commit_spec.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Commit' do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { create(:user) } + + describe "single commit view" do + let(:commit) do + project.repository.commits(nil, limit: 100).find do |commit| + commit.diffs.size > 1 + end + end + + let(:files) { commit.diffs.diff_files.to_a } + + before do + stub_feature_flags(async_commit_diff_files: false) + project.add_maintainer(user) + sign_in(user) + end + + describe "commit details" do + before do + visit project_commit_path(project, commit) + end + + it "shows the short commit message" do + expect(page).to have_content(commit.title) + end + + it "reports the correct number of total changes" do + expect(page).to have_content("Changes #{commit.diffs.size}") + end + end + + context "pagination enabled" do + before do + stub_feature_flags(paginate_commit_view: true) + stub_const("Projects::CommitController::COMMIT_DIFFS_PER_PAGE", 1) + + visit project_commit_path(project, commit) + end + + it "shows an adjusted count for changed files on this page" do + expect(page).to have_content("Showing 1 changed file") + end + + it "shows only the first diff on the first page" do + expect(page).to have_selector(".files ##{files[0].file_hash}") + expect(page).not_to have_selector(".files ##{files[1].file_hash}") + end + + it "can navigate to the second page" do + within(".files .gl-pagination") do + click_on("2") + end + + expect(page).not_to have_selector(".files ##{files[0].file_hash}") + expect(page).to have_selector(".files ##{files[1].file_hash}") + end + end + + context "pagination disabled" do + before do + stub_feature_flags(paginate_commit_view: false) + + visit project_commit_path(project, commit) + end + + it "shows both diffs on the page" do + expect(page).to have_selector(".files ##{files[0].file_hash}") + expect(page).to have_selector(".files ##{files[1].file_hash}") + end + end + end +end |