Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Fix "Assign to all" when runner already assigned to some projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Zhylinski committed Mar 21, 2014
1 parent 1a92de7 commit 079ad59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/admin/runners_controller.rb
Expand Up @@ -29,7 +29,7 @@ def destroy
end

def assign_all
Project.all.each { |project| @runner.assign_to(project, current_user) }
Project.unassigned(@runner).all.each { |project| @runner.assign_to(project, current_user) }

respond_to do |format|
format.js
Expand Down
6 changes: 6 additions & 0 deletions app/models/project.rb
Expand Up @@ -90,6 +90,12 @@ def from_gitlab(user, page, per_page, scope = :owned)
def already_added?(project)
where(gitlab_url: project.web_url).any?
end

def unassigned(runner)
joins('LEFT JOIN runner_projects ON runner_projects.project_id = projects.id ' \
"AND runner_projects.runner_id = #{runner.id}").
where('runner_projects.project_id' => nil)
end
end

def set_default_values
Expand Down

0 comments on commit 079ad59

Please sign in to comment.