Commit e6501b57 authored by Paco Guzman's avatar Paco Guzman

UpdateMirror service return an error status when no mirror

parent d777b87b
......@@ -10,6 +10,7 @@ v 8.9.0 (unreleased)
- Distribute RepositoryUpdateMirror jobs in time and add exclusive lease on them by project_id
- [Elastic] Move ES settings to application settings
- Disable mirror flag for projects without import_url
- UpdateMirror service return an error status when no mirror
- Show flash notice when Git Hooks are updated successfully
- [Elastic] Project members with guest role can't access confidential issues
- Ability to lock file or folder in the repository
......
......@@ -4,7 +4,9 @@ module Projects
class UpdateError < Error; end
def execute
return false unless project.mirror?
unless project.mirror?
return error("The project has no mirror to update")
end
unless can?(current_user, :push_code_to_protected_branches, project)
return error("The mirror user is not allowed to push code to all branches on this project.")
......
......@@ -73,6 +73,18 @@ describe Projects::UpdateMirrorService do
expect(result[:status]).to eq(:error)
end
end
describe "when is no mirror" do
let(:project) { build_stubbed(:project) }
it "fails" do
expect(project.mirror?).to eq(false)
result = described_class.new(project, build_stubbed(:user)).execute
expect(result[:status]).to eq(:error)
end
end
end
def stub_fetch_mirror(project, repository: project.repository)
......
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