Commit 77b42d92 authored by Yorick Peterse's avatar Yorick Peterse

Merge branch '692-repository-update-mirror-worker-fix' into 'master'

UpdateMirror service return an error status when no mirror

See merge request !482
parents d777b87b e6501b57
...@@ -10,6 +10,7 @@ v 8.9.0 (unreleased) ...@@ -10,6 +10,7 @@ v 8.9.0 (unreleased)
- Distribute RepositoryUpdateMirror jobs in time and add exclusive lease on them by project_id - Distribute RepositoryUpdateMirror jobs in time and add exclusive lease on them by project_id
- [Elastic] Move ES settings to application settings - [Elastic] Move ES settings to application settings
- Disable mirror flag for projects without import_url - 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 - Show flash notice when Git Hooks are updated successfully
- [Elastic] Project members with guest role can't access confidential issues - [Elastic] Project members with guest role can't access confidential issues
- Ability to lock file or folder in the repository - Ability to lock file or folder in the repository
......
...@@ -4,7 +4,9 @@ module Projects ...@@ -4,7 +4,9 @@ module Projects
class UpdateError < Error; end class UpdateError < Error; end
def execute 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) 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.") 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 ...@@ -73,6 +73,18 @@ describe Projects::UpdateMirrorService do
expect(result[:status]).to eq(:error) expect(result[:status]).to eq(:error)
end end
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 end
def stub_fetch_mirror(project, repository: project.repository) 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