diff options
author | Robert Speicher <robert@gitlab.com> | 2016-02-18 06:21:58 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-02-18 06:21:58 +0000 |
commit | 90a6783d0a1338336ffc268d268afbebb25f4293 (patch) | |
tree | 1643a1a67d18a57953aa523b06a2d4d33c8e108b | |
parent | 66c03e0e2948159793bf0f288a5253a7ad56869a (diff) | |
parent | 2770de961711076d1e8374bd943382eb14c90ad5 (diff) | |
download | gitlab-ce-90a6783d0a1338336ffc268d268afbebb25f4293.tar.gz |
Merge branch 'issue_13539' into 'master'
Reopened MRs should also be considered as open.
Fixes #13539
See merge request !2866
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 34 |
2 files changed, 35 insertions, 1 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 1be8061e53d..ea2b0e075f6 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -137,7 +137,7 @@ class MergeRequest < ActiveRecord::Base scope :by_milestone, ->(milestone) { where(milestone_id: milestone) } scope :in_projects, ->(project_ids) { where("source_project_id in (:project_ids) OR target_project_id in (:project_ids)", project_ids: project_ids) } scope :of_projects, ->(ids) { where(target_project_id: ids) } - scope :opened, -> { with_state(:opened) } + scope :opened, -> { with_states(:opened, :reopened) } scope :merged, -> { with_state(:merged) } scope :closed, -> { with_state(:closed) } scope :closed_and_merged, -> { with_states(:closed, :merged) } diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 9450a389d81..e82fe26c7a6 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -123,6 +123,40 @@ describe Projects::MergeRequestsController do end end + describe 'GET #index' do + def get_merge_requests + get :index, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + state: 'opened' + end + + context 'when filtering by opened state' do + + context 'with opened merge requests' do + it 'should list those merge requests' do + get_merge_requests + + expect(assigns(:merge_requests)).to include(merge_request) + end + end + + context 'with reopened merge requests' do + before do + merge_request.close! + merge_request.reopen! + end + + it 'should list those merge requests' do + get_merge_requests + + expect(assigns(:merge_requests)).to include(merge_request) + end + end + + end + end + describe 'GET diffs' do def go(format: 'html') get :diffs, |