Skip to content

Commit 4ac64f7

Browse files
committed
Prevents new issue assignments for inactive Repos
1 parent 70eea54 commit 4ac64f7

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

app/models/repo.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ def repo_path
226226
File.join 'repos', path
227227
end
228228

229+
def active?
230+
removed_from_github == false && archived == false
231+
end
232+
229233
def self.find_by_full_name(full_name)
230234
Repo.find_by!(full_name: full_name)
231235
end

app/models/user.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ def issue_assignments_to_deliver(assign: true)
201201
private
202202

203203
def issue_assigner
204-
@issue_assigner ||= IssueAssigner.new(self, repo_subscriptions)
204+
subs = repo_subscriptions.select { |s| s.repo.active? }
205+
@issue_assigner ||= IssueAssigner.new(self, subs)
205206
end
206207
end

test/fixtures/repo_subscriptions.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ jroes_to_rails:
2626
last_sent_at:
2727
email_limit: 5
2828

29+
empty_to_archived:
30+
repo: archived_repo
31+
user: empty
32+
created_at: 2013-10-29 21:09:48.351554000 Z
33+
updated_at: 2013-10-29 21:09:48.351554000 Z
34+
last_sent_at:
35+
email_limit: 5
36+
2937
read_doc_only:
3038
repo: issue_triage_sandbox
3139
user: foo_user

test/unit/user_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ class UserTest < ActiveSupport::TestCase
160160
test "#repos_fetcher" do
161161
assert users(:mockstar).repos_fetcher(GithubFetcher::Repos::OWNED).is_a? GithubFetcher::Repos
162162
end
163+
164+
test "#issue_assignments_to_deliver should ignore repos not active" do
165+
assert_empty users(:empty).issue_assignments_to_deliver
166+
end
163167
end

0 commit comments

Comments
 (0)