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

Commit

Permalink
Adds tests to pull_request_number and changes type
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Tyler authored and McAfee, Patrick committed Jan 21, 2016
1 parent 1fa7daa commit 923e2b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/jenkins_pipeline_builder/pull_request_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(defaults = {})

def convert!(job_collection, pr)
job_collection.defaults[:value][:application_name] = "#{application_name}-PR#{pr}"
job_collection.defaults[:value][:pull_request_number] = pr
job_collection.defaults[:value][:pull_request_number] = pr.to_s
job_collection.jobs.each { |j| override j[:value], pr }
end

Expand Down
23 changes: 10 additions & 13 deletions spec/lib/jenkins_pipeline_builder/pull_request_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,28 @@
end

context '#convert!' do
it 'converts the job application name' do
before(:each) do
stub_request(:get, url)
.with(headers: { 'Accept' => '*/*',
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Host' => 'github.com',
'User-Agent' => 'Ruby' })
.to_return(status: 200, body: open_prs_json, headers: {})
end

it 'converts the job application name' do
collection = job_collection.clone
subject.convert! collection, 8
expect(collection.defaults[:value][:application_name]).to eq "#{application_name}-PR8"
end

it 'provides the PR number to the job settings' do
collection = job_collection.clone
subject.convert! collection, 8
expect(collection.defaults[:value][:pull_request_number]).to eq '8'
end

it 'overrides the git params' do
stub_request(:get, url)
.with(headers: { 'Accept' => '*/*',
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Host' => 'github.com',
'User-Agent' => 'Ruby' })
.to_return(status: 200, body: open_prs_json, headers: {})
pr = 8
collection = job_collection.clone
subject.convert! collection, pr
Expand All @@ -115,12 +118,6 @@
end

it 'does not override extra params' do
stub_request(:get, url)
.with(headers: { 'Accept' => '*/*',
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
'Host' => 'github.com',
'User-Agent' => 'Ruby' })
.to_return(status: 200, body: open_prs_json, headers: {})
pr = 8
collection = job_collection.clone
subject.convert! collection, pr
Expand Down

0 comments on commit 923e2b9

Please sign in to comment.