Commit 3996bd75 authored by Phil Hughes's avatar Phil Hughes

Fixed failing diffs action specs

Stubbed feature flag in the ruby specs
parent cca0b3be
...@@ -62,6 +62,7 @@ module Gitlab ...@@ -62,6 +62,7 @@ module Gitlab
@merge_request_diff.merge_request_diff_files @merge_request_diff.merge_request_diff_files
end end
# rubocop: disable CodeReuse/ActiveRecord
def load_paginated_collection(batch_page, batch_size, diff_options) def load_paginated_collection(batch_page, batch_size, diff_options)
batch_page ||= DEFAULT_BATCH_PAGE batch_page ||= DEFAULT_BATCH_PAGE
batch_size = [batch_size.to_i, DEFAULT_BATCH_SIZE].min batch_size = [batch_size.to_i, DEFAULT_BATCH_SIZE].min
...@@ -69,14 +70,16 @@ module Gitlab ...@@ -69,14 +70,16 @@ module Gitlab
paths = diff_options&.fetch(:paths, nil) paths = diff_options&.fetch(:paths, nil)
paginated_collection = if batch_gradual_load? paginated_collection = if batch_gradual_load?
relation.offset(batch_page).limit(batch_size) relation.offset(batch_page).limit(batch_size)
else else
relation.page(batch_page).per(batch_size) relation.page(batch_page).per(batch_size)
end end
paginated_collection = paginated_collection.by_paths(paths) if paths paginated_collection = paginated_collection.by_paths(paths) if paths
paginated_collection paginated_collection
end end
# rubocop: enable CodeReuse/ActiveRecord
def batch_gradual_load? def batch_gradual_load?
Feature.enabled?(:diffs_gradual_load, @merge_request_diff.project) Feature.enabled?(:diffs_gradual_load, @merge_request_diff.project)
......
...@@ -5,6 +5,10 @@ require 'spec_helper' ...@@ -5,6 +5,10 @@ require 'spec_helper'
RSpec.describe Projects::MergeRequests::DiffsController do RSpec.describe Projects::MergeRequests::DiffsController do
include ProjectForksHelper include ProjectForksHelper
before do
stub_feature_flags(diffs_gradual_load: false)
end
shared_examples '404 for unexistent diffable' do shared_examples '404 for unexistent diffable' do
context 'when diffable does not exists' do context 'when diffable does not exists' do
it 'returns 404' do it 'returns 404' do
......
...@@ -17,6 +17,8 @@ RSpec.describe 'Merge request > User sees versions', :js do ...@@ -17,6 +17,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
let!(:params) { {} } let!(:params) { {} }
before do before do
stub_feature_flags(diffs_gradual_load: false)
project.add_maintainer(user) project.add_maintainer(user)
sign_in(user) sign_in(user)
visit diffs_project_merge_request_path(project, merge_request, params) visit diffs_project_merge_request_path(project, merge_request, params)
......
...@@ -159,10 +159,10 @@ describe('DiffsStoreActions', () => { ...@@ -159,10 +159,10 @@ describe('DiffsStoreActions', () => {
.onGet( .onGet(
mergeUrlParams( mergeUrlParams(
{ {
per_page: DIFFS_PER_PAGE,
w: '1', w: '1',
view: 'inline', view: 'inline',
page: 1, page: 1,
per_page: DIFFS_PER_PAGE,
}, },
endpointBatch, endpointBatch,
), ),
...@@ -171,10 +171,10 @@ describe('DiffsStoreActions', () => { ...@@ -171,10 +171,10 @@ describe('DiffsStoreActions', () => {
.onGet( .onGet(
mergeUrlParams( mergeUrlParams(
{ {
per_page: DIFFS_PER_PAGE,
w: '1', w: '1',
view: 'inline', view: 'inline',
page: 2, page: 2,
per_page: DIFFS_PER_PAGE,
}, },
endpointBatch, endpointBatch,
), ),
......
...@@ -9,6 +9,10 @@ RSpec.describe MergeRequestDiff do ...@@ -9,6 +9,10 @@ RSpec.describe MergeRequestDiff do
let(:diff_with_commits) { create(:merge_request).merge_request_diff } let(:diff_with_commits) { create(:merge_request).merge_request_diff }
before do
stub_feature_flags(diffs_gradual_load: false)
end
describe 'validations' do describe 'validations' do
subject { diff_with_commits } subject { diff_with_commits }
......
...@@ -19,6 +19,10 @@ RSpec.describe PaginatedDiffEntity do ...@@ -19,6 +19,10 @@ RSpec.describe PaginatedDiffEntity do
subject { entity.as_json } subject { entity.as_json }
before do
stub_feature_flags(diffs_gradual_load: false)
end
it 'exposes diff_files' do it 'exposes diff_files' do
expect(subject[:diff_files]).to be_present expect(subject[:diff_files]).to be_present
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment