fix failing specs

This commit is contained in:
Jarka Kadlecova 2017-05-29 11:29:43 +02:00
parent b71025c014
commit 6fad5640e7
3 changed files with 6 additions and 41 deletions

View File

@ -64,14 +64,14 @@ describe Projects::ServicesController do
end end
context 'failure' do context 'failure' do
it 'returns 500 status code and the error message' do it 'returns success status code and the error message' do
expect(HipChat::Client).to receive(:new).with('hipchat_token_p', anything).and_raise('Bad test') expect(HipChat::Client).to receive(:new).with('hipchat_token_p', anything).and_raise('Bad test')
put :test, namespace_id: project.namespace.id, project_id: project.id, id: service.id, service: service_params put :test, namespace_id: project.namespace.id, project_id: project.id, id: service.id, service: service_params
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(JSON.parse(response.body)). expect(JSON.parse(response.body)).
to eq('error' => true, 'message' => 'Test failed', 'service_response' => 'Bad test') to eq('error' => true, 'message' => 'Test failed.', 'service_response' => 'Bad test')
end end
end end
end end

View File

@ -35,7 +35,7 @@ feature 'Setup Jira service', :feature, :js do
click_link('JIRA') click_link('JIRA')
fill_form fill_form
click_button('Test settings and save changes') click_button('Test settings and save changes')
wait_for_ajax wait_for_requests
expect(page).to have_content('JIRA activated.') expect(page).to have_content('JIRA activated.')
expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project))
@ -51,12 +51,12 @@ feature 'Setup Jira service', :feature, :js do
click_link('JIRA') click_link('JIRA')
fill_form fill_form
click_button('Test settings and save changes') click_button('Test settings and save changes')
wait_for_ajax wait_for_requests
expect(page).to have_content('Test failed.Save anyway') expect(page).to have_content('Test failed.Save anyway')
click_on('Save anyway') find('.flash-alert .flash-action').trigger('click')
wait_for_ajax wait_for_requests
expect(page).to have_content('JIRA activated.') expect(page).to have_content('JIRA activated.')
expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project))

View File

@ -69,41 +69,6 @@ describe JiraService, models: true do
end end
end end
describe '#can_test?' do
let(:jira_service) { described_class.new }
it 'returns false if username is blank' do
allow(jira_service).to receive_messages(
url: 'http://jira.example.com',
username: '',
password: '12345678'
)
expect(jira_service.can_test?).to be_falsy
end
it 'returns false if password is blank' do
allow(jira_service).to receive_messages(
url: 'http://jira.example.com',
username: 'tester',
password: ''
)
expect(jira_service.can_test?).to be_falsy
end
it 'returns true if password and username are present' do
jira_service = described_class.new
allow(jira_service).to receive_messages(
url: 'http://jira.example.com',
username: 'tester',
password: '12345678'
)
expect(jira_service.can_test?).to be_truthy
end
end
describe '#close_issue' do describe '#close_issue' do
let(:custom_base_url) { 'http://custom_url' } let(:custom_base_url) { 'http://custom_url' }
let(:user) { create(:user) } let(:user) { create(:user) }