Commit 585e6aa5 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'bugfix/ruby2.4-compat' into 'master'

ruby 2.4 compat: update to webmock 2.3.2

See merge request !12471
parents 471a40ac a274359e
...@@ -355,7 +355,7 @@ group :test do ...@@ -355,7 +355,7 @@ group :test do
gem 'shoulda-matchers', '~> 2.8.0', require: false gem 'shoulda-matchers', '~> 2.8.0', require: false
gem 'email_spec', '~> 1.6.0' gem 'email_spec', '~> 1.6.0'
gem 'json-schema', '~> 2.6.2' gem 'json-schema', '~> 2.6.2'
gem 'webmock', '~> 1.24.0' gem 'webmock', '~> 2.3.2'
gem 'test_after_commit', '~> 1.1' gem 'test_after_commit', '~> 1.1'
gem 'sham_rack', '~> 1.3.6' gem 'sham_rack', '~> 1.3.6'
gem 'timecop', '~> 0.8.0' gem 'timecop', '~> 0.8.0'
......
...@@ -368,7 +368,7 @@ GEM ...@@ -368,7 +368,7 @@ GEM
temple (~> 0.7.6) temple (~> 0.7.6)
thor thor
tilt tilt
hashdiff (0.3.2) hashdiff (0.3.4)
hashie (3.5.5) hashie (3.5.5)
hashie-forbidden_attributes (0.1.1) hashie-forbidden_attributes (0.1.1)
hashie (>= 3.0) hashie (>= 3.0)
...@@ -891,7 +891,7 @@ GEM ...@@ -891,7 +891,7 @@ GEM
vmstat (2.3.0) vmstat (2.3.0)
warden (1.2.6) warden (1.2.6)
rack (>= 1.0) rack (>= 1.0)
webmock (1.24.6) webmock (2.3.2)
addressable (>= 2.3.6) addressable (>= 2.3.6)
crack (>= 0.3.2) crack (>= 0.3.2)
hashdiff hashdiff
...@@ -1122,7 +1122,7 @@ DEPENDENCIES ...@@ -1122,7 +1122,7 @@ DEPENDENCIES
version_sorter (~> 2.1.0) version_sorter (~> 2.1.0)
virtus (~> 1.0.1) virtus (~> 1.0.1)
vmstat (~> 2.3.0) vmstat (~> 2.3.0)
webmock (~> 1.24.0) webmock (~> 2.3.2)
webpack-rails (~> 0.9.10) webpack-rails (~> 0.9.10)
wikicloth (= 0.8.1) wikicloth (= 0.8.1)
......
...@@ -6,7 +6,11 @@ feature 'Setup Jira service', :feature, :js do ...@@ -6,7 +6,11 @@ feature 'Setup Jira service', :feature, :js do
let(:service) { project.create_jira_service } let(:service) { project.create_jira_service }
let(:url) { 'http://jira.example.com' } let(:url) { 'http://jira.example.com' }
let(:project_url) { 'http://username:password@jira.example.com/rest/api/2/project/GitLabProject' }
def stub_project_url
WebMock.stub_request(:get, 'http://jira.example.com/rest/api/2/project/GitLabProject')
.with(basic_auth: %w(username password))
end
def fill_form(active = true) def fill_form(active = true)
check 'Active' if active check 'Active' if active
...@@ -28,7 +32,7 @@ feature 'Setup Jira service', :feature, :js do ...@@ -28,7 +32,7 @@ feature 'Setup Jira service', :feature, :js do
describe 'user sets and activates Jira Service' do describe 'user sets and activates Jira Service' do
context 'when Jira connection test succeeds' do context 'when Jira connection test succeeds' do
before do before do
WebMock.stub_request(:get, project_url) stub_project_url
end end
it 'activates the JIRA service' do it 'activates the JIRA service' do
...@@ -44,7 +48,7 @@ feature 'Setup Jira service', :feature, :js do ...@@ -44,7 +48,7 @@ feature 'Setup Jira service', :feature, :js do
context 'when Jira connection test fails' do context 'when Jira connection test fails' do
before do before do
WebMock.stub_request(:get, project_url).to_return(status: 401) stub_project_url.to_return(status: 401)
end end
it 'shows errors when some required fields are not filled in' do it 'shows errors when some required fields are not filled in' do
......
...@@ -217,13 +217,13 @@ describe BambooService, models: true, caching: true do ...@@ -217,13 +217,13 @@ describe BambooService, models: true, caching: true do
end end
def stub_request(status: 200, body: nil) def stub_request(status: 200, body: nil)
bamboo_full_url = 'http://mic:password@gitlab.com/bamboo/rest/api/latest/result?label=123&os_authType=basic' bamboo_full_url = 'http://gitlab.com/bamboo/rest/api/latest/result?label=123&os_authType=basic'
WebMock.stub_request(:get, bamboo_full_url).to_return( WebMock.stub_request(:get, bamboo_full_url).to_return(
status: status, status: status,
headers: { 'Content-Type' => 'application/json' }, headers: { 'Content-Type' => 'application/json' },
body: body body: body
) ).with(basic_auth: %w(mic password))
end end
def bamboo_response(result_key: 42, build_state: 'success', size: 1) def bamboo_response(result_key: 42, build_state: 'success', size: 1)
......
...@@ -39,21 +39,22 @@ describe CampfireService, models: true do ...@@ -39,21 +39,22 @@ describe CampfireService, models: true do
room: 'test-room' room: 'test-room'
) )
@sample_data = Gitlab::DataBuilder::Push.build_sample(project, user) @sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
@rooms_url = 'https://verySecret:X@project-name.campfirenow.com/rooms.json' @rooms_url = 'https://project-name.campfirenow.com/rooms.json'
@auth = %w(verySecret X)
@headers = { 'Content-Type' => 'application/json; charset=utf-8' } @headers = { 'Content-Type' => 'application/json; charset=utf-8' }
end end
it "calls Campfire API to get a list of rooms and speak in a room" do it "calls Campfire API to get a list of rooms and speak in a room" do
# make sure a valid list of rooms is returned # make sure a valid list of rooms is returned
body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms.json') body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms.json')
WebMock.stub_request(:get, @rooms_url).to_return( WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return(
body: body, body: body,
status: 200, status: 200,
headers: @headers headers: @headers
) )
# stub the speak request with the room id found in the previous request's response # stub the speak request with the room id found in the previous request's response
speak_url = 'https://verySecret:X@project-name.campfirenow.com/room/123/speak.json' speak_url = 'https://project-name.campfirenow.com/room/123/speak.json'
WebMock.stub_request(:post, speak_url) WebMock.stub_request(:post, speak_url).with(basic_auth: @auth)
@campfire_service.execute(@sample_data) @campfire_service.execute(@sample_data)
...@@ -66,7 +67,7 @@ describe CampfireService, models: true do ...@@ -66,7 +67,7 @@ describe CampfireService, models: true do
it "calls Campfire API to get a list of rooms but shouldn't speak in a room" do it "calls Campfire API to get a list of rooms but shouldn't speak in a room" do
# return a list of rooms that do not contain a room named 'test-room' # return a list of rooms that do not contain a room named 'test-room'
body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms2.json') body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms2.json')
WebMock.stub_request(:get, @rooms_url).to_return( WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return(
body: body, body: body,
status: 200, status: 200,
headers: @headers headers: @headers
......
...@@ -106,15 +106,15 @@ describe JiraService, models: true do ...@@ -106,15 +106,15 @@ describe JiraService, models: true do
@jira_service.save @jira_service.save
project_issues_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123' project_issues_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123'
@transitions_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/transitions' @transitions_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/transitions'
@comment_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/comment' @comment_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/comment'
@remote_link_url = 'http://gitlab_jira_username:gitlab_jira_password@jira.example.com/rest/api/2/issue/JIRA-123/remotelink' @remote_link_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/remotelink'
WebMock.stub_request(:get, project_issues_url) WebMock.stub_request(:get, project_issues_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
WebMock.stub_request(:post, @transitions_url) WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
WebMock.stub_request(:post, @comment_url) WebMock.stub_request(:post, @comment_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
WebMock.stub_request(:post, @remote_link_url) WebMock.stub_request(:post, @remote_link_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
end end
it "calls JIRA API" do it "calls JIRA API" do
...@@ -202,9 +202,9 @@ describe JiraService, models: true do ...@@ -202,9 +202,9 @@ describe JiraService, models: true do
end end
def test_settings(api_url) def test_settings(api_url)
project_url = "http://jira_username:jira_password@#{api_url}/rest/api/2/project/GitLabProject" project_url = "http://#{api_url}/rest/api/2/project/GitLabProject"
WebMock.stub_request(:get, project_url) WebMock.stub_request(:get, project_url).with(basic_auth: %w(jira_username jira_password))
jira_service.test_settings jira_service.test_settings
end end
......
...@@ -205,10 +205,12 @@ describe TeamcityService, models: true, caching: true do ...@@ -205,10 +205,12 @@ describe TeamcityService, models: true, caching: true do
end end
def stub_request(status: 200, body: nil, build_status: 'success') def stub_request(status: 200, body: nil, build_status: 'success')
teamcity_full_url = 'http://mic:password@gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,number:123' teamcity_full_url = 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,number:123'
auth = %w(mic password)
body ||= %Q({"build":{"status":"#{build_status}","id":"666"}}) body ||= %Q({"build":{"status":"#{build_status}","id":"666"}})
WebMock.stub_request(:get, teamcity_full_url).to_return( WebMock.stub_request(:get, teamcity_full_url).with(basic_auth: auth).to_return(
status: status, status: status,
headers: { 'Content-Type' => 'application/json' }, headers: { 'Content-Type' => 'application/json' },
body: body body: body
......
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