diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 21:29:49 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-08-07 21:29:49 +0300 |
commit | 29203198b6537551b7165538846eb9124c6d9ff3 (patch) | |
tree | efb05684d8d9c160d2bc4ea9ebf81c9ed28afd82 /spec | |
parent | e22effd4a39d4e1f7883102dc2fedf2d9cef3b6c (diff) | |
parent | ef66a4a57c8e7591ef5015d594d8bcc4a1077e17 (diff) |
Merge branch 'osw-fix-missing-and-duplicated-milestones-on-list' into 'master'
Fix missing and duplicates on project milestone listing page
Closes #37078
See merge request gitlab-org/gitlab-ce!21058
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/milestones_controller_spec.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index 6c2d1c7e92b..3190f1ce9d4 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -42,16 +42,45 @@ describe Projects::MilestonesController do describe "#index" do context "as html" do - before do - get :index, namespace_id: project.namespace.id, project_id: project.id + def render_index(project:, page:) + get :index, namespace_id: project.namespace.id, + project_id: project.id, + page: page end it "queries only projects milestones" do + render_index project: project, page: 1 + milestones = assigns(:milestones) expect(milestones.count).to eq(1) expect(milestones.where(project_id: nil)).to be_empty end + + it 'renders paginated milestones without missing or duplicates' do + allow(Milestone).to receive(:default_per_page).and_return(2) + create_list(:milestone, 5, project: project) + + render_index project: project, page: 1 + page_1_milestones = assigns(:milestones) + expect(page_1_milestones.size).to eq(2) + + render_index project: project, page: 2 + page_2_milestones = assigns(:milestones) + expect(page_2_milestones.size).to eq(2) + + render_index project: project, page: 3 + page_3_milestones = assigns(:milestones) + expect(page_3_milestones.size).to eq(2) + + rendered_milestone_ids = + page_1_milestones.pluck(:id) + + page_2_milestones.pluck(:id) + + page_3_milestones.pluck(:id) + + expect(rendered_milestone_ids) + .to match_array(project.milestones.pluck(:id)) + end end context "as json" do |