Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Enable gh-pages testing if explicitly added to .travis.yml #137

Merged
merged 1 commit into from
Dec 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/travis/model/request/approval.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def accepted?
!repository.private? &&
!rails_fork? &&
!skipped? &&
!github_pages?
(github_pages_explicitly_enabled? || !github_pages?)
end

def approved?
Expand Down Expand Up @@ -48,6 +48,13 @@ def skipped?
commit.message.to_s =~ /\[ci(?: |:)([\w ]*)\]/i && $1.downcase == 'skip'
end

def github_pages_explicitly_enabled?
request.config &&
request.config['branches'] &&
request.config['branches']['only'] &&
request.config['branches']['only'].grep(/gh[-_]pages/i)
end

def github_pages?
commit.ref =~ /gh[-_]pages/i
end
Expand Down
6 changes: 6 additions & 0 deletions spec/travis/model/request/approval_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
request.commit.stubs(:ref).returns('gh_pages')
approval.should_not be_accepted
end

it 'accepts a request that belongs to the github_pages branch and is explicitly set to build that branch' do
request.commit.stubs(:ref).returns('gh_pages')
request.stubs(:config).returns({'branches' => {'only' => ['gh_pages']}})
approval.should be_accepted
end
end

describe 'approved?' do
Expand Down