diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-06 16:38:37 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2018-08-07 13:02:55 -0300 |
commit | ef66a4a57c8e7591ef5015d594d8bcc4a1077e17 (patch) | |
tree | a5deb711caeb2acad07d05a5a4566aab9848121c /spec/controllers/projects/milestones_controller_spec.rb | |
parent | 415b2f943ba80ef3b6746af0a98c6dbe062e803c (diff) | |
download | gitlab-ce-ef66a4a57c8e7591ef5015d594d8bcc4a1077e17.tar.gz |
Fix missing and duplicates on project milestone listing page
Diffstat (limited to 'spec/controllers/projects/milestones_controller_spec.rb')
-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 |