summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/mailers/emails/pipelines.rb2
-rw-r--r--app/models/ci/pipeline.rb6
-rw-r--r--app/models/merge_request.rb4
-rw-r--r--spec/models/ci/pipeline_spec.rb31
-rw-r--r--spec/models/merge_request_spec.rb8
5 files changed, 1 insertions, 50 deletions
diff --git a/app/mailers/emails/pipelines.rb b/app/mailers/emails/pipelines.rb
index 92f1431ce66..601c8b5cd62 100644
--- a/app/mailers/emails/pipelines.rb
+++ b/app/mailers/emails/pipelines.rb
@@ -13,7 +13,7 @@ module Emails
def pipeline_mail(pipeline, to, status)
@project = pipeline.project
@pipeline = pipeline
- @merge_request = pipeline.merge_requests_with_active_first.first
+ @merge_request = pipeline.merge_requests.first
add_headers
mail(to: to, subject: pipeline_subject(status), skip_premailer: true) do |format|
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 042b1c04054..957f6755b2e 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -302,12 +302,6 @@ module Ci
.select { |merge_request| merge_request.pipeline.try(:id) == self.id }
end
- def merge_requests_with_active_first
- merge_requests.sort_by do |merge_request|
- [merge_request.state_priority, -merge_request.updated_at.to_i]
- end
- end
-
private
def pipeline_data
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 3efb7aead77..5ccfe11a2a2 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -169,10 +169,6 @@ class MergeRequest < ActiveRecord::Base
work_in_progress?(title) ? title : "WIP: #{title}"
end
- def state_priority
- %w[opened reopened closed merged locked].index(state)
- end
-
def to_reference(from_project = nil)
reference = "#{self.class.reference_prefix}#{iid}"
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index 2a0b00dc545..550a890797e 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -523,35 +523,4 @@ describe Ci::Pipeline, models: true do
expect(pipeline.merge_requests).to be_empty
end
end
-
- describe '#merge_requests_with_active_first' do
- let(:project) { create(:project) }
-
- let(:pipeline) do
- create(:ci_empty_pipeline,
- status: 'created',
- project: project,
- ref: 'master',
- sha: project.repository.commit('master').sha)
- end
-
- let!(:merge_requests) do
- [create_merge_request(:merged, Time.at(0)),
- create_merge_request(:merged, Time.at(9)),
- create_merge_request(:opened, Time.at(0))]
- end
-
- it 'returns opened/recent merge requests first, then closed ones' do
- expect(pipeline.merge_requests_with_active_first).
- to eq(merge_requests.reverse)
- end
-
- def create_merge_request(state, updated_at)
- create(:merge_request,
- source_project: project,
- source_branch: pipeline.ref,
- state: state,
- updated_at: updated_at)
- end
- end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index a570e42c6ac..2167a988f99 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -58,14 +58,6 @@ describe MergeRequest, models: true do
it { is_expected.to respond_to(:merge_when_build_succeeds) }
end
- describe '#state_priority' do
- it 'returns the priority of state' do
- %w[opened reopened closed merged locked].each.with_index do |state, idx|
- expect(MergeRequest.new(state: state).state_priority).to eq(idx)
- end
- end
- end
-
describe '.in_projects' do
it 'returns the merge requests for a set of projects' do
expect(described_class.in_projects(Project.all)).to eq([subject])