Commit eafadaf3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Tests for Jenkins CI service and few fixes

parent c0a7f876
......@@ -50,11 +50,11 @@ class JenkinsService < CiService
]
end
def build_page sha
def build_page(sha, ref = nil)
project_url + "/scm/bySHA1/#{sha}"
end
def commit_status sha
def commit_status(sha, ref = nil)
parsed_url = URI.parse(build_page(sha))
if parsed_url.userinfo.blank?
......
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# properties :text
# template :boolean default(FALSE)
# push_events :boolean default(TRUE)
# issues_events :boolean default(TRUE)
# merge_requests_events :boolean default(TRUE)
# tag_push_events :boolean default(TRUE)
#
require 'spec_helper'
describe JenkinsService do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
describe 'commits methods' do
before do
@service = JenkinsService.new
@service.stub(
service_hook: true,
project_url: 'http://jenkins.gitlab.org/projects/2',
token: 'verySecret'
)
body =<<eos
<h1 class="build-caption page-headline"><img style="width: 48px; height: 48px; " alt="Success" class="icon-blue icon-xlg" src="/static/855d7c3c/images/48x48/blue.png" tooltip="Success" title="Success">
Build #188
(Oct 15, 2014 9:45:21 PM)
</h1>
eos
stub_request(:get, "http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c").
to_return(status: 200, body: body, headers: {})
end
describe :commit_status do
it { expect(@service.commit_status("2ab7834c", 'master')).to eq("success") }
end
describe :build_page do
it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://jenkins.gitlab.org/projects/2/scm/bySHA1/2ab7834c") }
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment