Commit b0d7832c authored by Robert May's avatar Robert May

Expand tests and other tweaks

parent 3af2cb0e
......@@ -18,7 +18,6 @@ module EE
reset_approvals_for_merge_requests(push.ref, push.newrev)
end
# Note: Closed merge requests also need approvals reset.
def reset_approvals_for_merge_requests(ref, newrev)
MergeRequestResetApprovalsWorker.perform_async(project.id, current_user.id, ref, newrev)
end
......
# frozen_string_literal: true
require 'spec_helper'
require "spec_helper"
RSpec.describe MergeRequestResetApprovalsWorker do
include RepoHelpers
let(:project) { create(:project, :repository) }
let(:project) { create(:project) }
let(:user) { create(:user) }
subject { described_class.new }
describe '#perform' do
describe "#perform" do
let(:newrev) { "789012" }
let(:ref) { "refs/heads/test" }
......@@ -18,12 +18,32 @@ RSpec.describe MergeRequestResetApprovalsWorker do
subject.perform(project.id, user.id, ref, newrev)
end
it 'executes MergeRequests::RefreshService with expected values' do
it "executes MergeRequests::RefreshService with expected values" do
expect_next_instance_of(EE::MergeRequests::ResetApprovalsService, project, user) do |refresh_service|
expect(refresh_service).to receive(:execute).with(ref, newrev)
end
perform
end
context "project is missing" do
let(:project) { double("project", id: "foo") }
it "doesn't execute the service" do
expect(EE::MergeRequests::ResetApprovalsService).not_to receive(:new)
perform
end
end
context "user is missing" do
let(:user) { double("user", id: "foo") }
it "doesn't execute the service" do
expect(EE::MergeRequests::ResetApprovalsService).not_to receive(:new)
perform
end
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