debian-mirror-gitlab/spec/controllers/projects/service_hook_logs_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.5 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe Projects::ServiceHookLogsController do
2020-01-01 13:55:28 +05:30
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
2021-09-04 01:27:46 +05:30
let(:integration) { create(:drone_ci_integration, project: project) }
let(:log) { create(:web_hook_log, web_hook: integration.service_hook) }
2020-01-01 13:55:28 +05:30
let(:log_params) do
{
namespace_id: project.namespace,
project_id: project,
2022-03-02 08:16:31 +05:30
integration_id: integration.to_param,
2020-01-01 13:55:28 +05:30
id: log.id
}
end
before do
sign_in(user)
project.add_maintainer(user)
end
describe 'GET #show' do
subject { get :show, params: log_params }
2020-05-24 23:13:21 +05:30
specify do
2020-01-01 13:55:28 +05:30
expect(response).to be_successful
end
2021-09-30 23:02:18 +05:30
it 'renders a 404 if the hook does not exist' do
log_params
integration.service_hook.destroy!
subject
expect(response).to have_gitlab_http_status(:not_found)
end
2020-01-01 13:55:28 +05:30
end
describe 'POST #retry' do
subject { post :retry, params: log_params }
it 'executes the hook and redirects to the service form' do
expect_any_instance_of(ServiceHook).to receive(:execute)
expect_any_instance_of(described_class).to receive(:set_hook_execution_notice)
2022-03-02 08:16:31 +05:30
expect(subject).to redirect_to(edit_project_integration_path(project, integration))
2020-01-01 13:55:28 +05:30
end
2021-09-30 23:02:18 +05:30
it 'renders a 404 if the hook does not exist' do
log_params
integration.service_hook.destroy!
subject
expect(response).to have_gitlab_http_status(:not_found)
end
2020-01-01 13:55:28 +05:30
end
end