From 8044e106e1f38aaa17ff1029009a301efb26bc44 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 9 Aug 2012 18:43:14 +0200 Subject: [PATCH] reject new pull requests that are not mergeable --- lib/travis/github/payload/pull_request.rb | 6 +++++- spec/travis/github/payload/pull_request_spec.rb | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/travis/github/payload/pull_request.rb b/lib/travis/github/payload/pull_request.rb index 19d4e7cf5..f0cfced63 100644 --- a/lib/travis/github/payload/pull_request.rb +++ b/lib/travis/github/payload/pull_request.rb @@ -15,7 +15,11 @@ def event end def accept? - [:opened, :reopened].include?(action) || action == :synchronize && head_change? + case action + when :opened, :reopened then !!merge_commit + when :synchronize then head_change? + else false + end end def head_change? diff --git a/spec/travis/github/payload/pull_request_spec.rb b/spec/travis/github/payload/pull_request_spec.rb index 9913064b8..ce4fac2b7 100644 --- a/spec/travis/github/payload/pull_request_spec.rb +++ b/spec/travis/github/payload/pull_request_spec.rb @@ -12,6 +12,11 @@ it 'returns true' do payload.accept?.should be_true end + + it 'rejects it if there is no merge commit' do + payload.event.data['pull_request']['merge_commit'] = nil + payload.should_not be_accept + end end describe 'given action is "reopened"' do