debian-mirror-gitlab/spec/features/commit_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
1.9 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Commit', feature_category: :source_code_management do
2021-03-11 19:13:27 +05:30
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
2023-05-27 22:25:52 +05:30
shared_examples "single commit view" do
2021-03-11 19:13:27 +05:30
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
project.add_maintainer(user)
sign_in(user)
end
describe "commit details" do
2023-03-17 16:20:25 +05:30
subject { page }
2021-03-11 19:13:27 +05:30
before do
visit project_commit_path(project, commit)
end
2023-05-27 22:25:52 +05:30
it "shows the short commit message, number of total changes and stats", :js, :aggregate_failures do
2021-03-11 19:13:27 +05:30
expect(page).to have_content(commit.title)
expect(page).to have_content("Changes #{commit.diffs.size}")
2022-06-21 17:19:12 +05:30
expect(page).to have_selector(".diff-stats")
end
2023-03-17 16:20:25 +05:30
it_behaves_like 'code highlight'
2021-03-11 19:13:27 +05:30
end
2021-04-17 20:07:23 +05:30
describe "pagination" do
2021-03-11 19:13:27 +05:30
before do
stub_const("Projects::CommitController::COMMIT_DIFFS_PER_PAGE", 1)
visit project_commit_path(project, commit)
end
2023-05-27 22:25:52 +05:30
def diff_files_on_page
page.all('.files .diff-file').pluck(:id)
2021-03-11 19:13:27 +05:30
end
2023-05-27 22:25:52 +05:30
it "shows paginated content and controls to navigate", :js, :aggregate_failures do
expect(page).to have_content("Showing 1 changed file")
wait_for_requests
expect(diff_files_on_page).to eq([files[0].file_hash])
2021-03-11 19:13:27 +05:30
within(".files .gl-pagination") do
click_on("2")
end
2023-05-27 22:25:52 +05:30
wait_for_requests
expect(diff_files_on_page).to eq([files[1].file_hash])
2021-03-11 19:13:27 +05:30
end
end
end
2023-05-27 22:25:52 +05:30
it_behaves_like "single commit view"
context "when super sidebar is enabled" do
before do
user.update!(use_new_navigation: true)
stub_feature_flags(super_sidebar_nav: true)
end
it_behaves_like "single commit view"
end
2021-03-11 19:13:27 +05:30
end