debian-mirror-gitlab/spec/serializers/paginated_diff_entity_spec.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe PaginatedDiffEntity do
2019-12-21 20:55:43 +05:30
let(:user) { create(:user) }
let(:request) { double('request', current_user: user) }
let(:merge_request) { create(:merge_request, :with_diffs) }
let(:diff_batch) { merge_request.merge_request_diff.diffs_in_batch(2, 3, diff_options: nil) }
let(:options) do
{
request: request,
merge_request: merge_request,
pagination_data: diff_batch.pagination_data
}
end
let(:entity) { described_class.new(diff_batch, options) }
subject { entity.as_json }
it 'exposes diff_files' do
expect(subject[:diff_files]).to be_present
end
it 'exposes pagination data' do
expect(subject[:pagination]).to eq(
current_page: 2,
next_page: 3,
2020-03-13 15:44:24 +05:30
next_page_href: "/#{merge_request.project.full_path}/-/merge_requests/#{merge_request.iid}/diffs_batch.json?page=3",
2019-12-21 20:55:43 +05:30
total_pages: 7
)
end
2020-06-23 00:09:42 +05:30
context 'when code_navigation feature flag is disabled' do
it 'does not execute Gitlab::CodeNavigationPath' do
stub_feature_flags(code_navigation: false)
expect(Gitlab::CodeNavigationPath).not_to receive(:new)
subject
end
end
2019-12-21 20:55:43 +05:30
end