Skip to content

Commit f425741

Browse files
NaragodMateo
authored andcommitted
TICKET-575: Remove get_repo_auth_records function as it is now deprecated
1 parent aa339d5 commit f425741

2 files changed

Lines changed: 0 additions & 99 deletions

File tree

app/lib/repository.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,28 +224,6 @@ def self.update_permissions_after(only_on_request: false, &block)
224224
nil
225225
end
226226

227-
# Returns the assignments for which students have repository access.
228-
#
229-
# Repository authentication subtleties:
230-
# 1) a repository is associated with a Group, but..
231-
# 2) ..students are associated with a Grouping (an "instance" of Group for a specific Assignment)
232-
# That creates a problem since authentication in git is at the repository level, while Markus handles it at
233-
# the assignment level, allowing the same Group repo to have different students according to the assignment.
234-
# The two extremes to implement it are using the union of all students (permissive) or the intersection
235-
# (restrictive). Instead, we are going to take a last-deadline approach, where we assume that the valid students at
236-
# any point in time are the ones valid for the last assignment due. (Basically, it's nice for a group to share a
237-
# repo among assignments, but at a certain point during the course we may want to add or [more frequently] remove
238-
# some students from it)
239-
def self.get_repo_auth_records
240-
records = Assignment.joins(:assignment_properties, :course)
241-
.includes(groupings: [:group, { accepted_students: :section }])
242-
.where(assignment_properties: { vcs_submit: true }, 'courses.is_hidden': false)
243-
.order(due_date: :desc)
244-
records.where(assignment_properties: { is_timed: false })
245-
.or(records.where.not(groupings: { start_time: nil }))
246-
.or(records.where(groupings: { start_time: nil }, due_date: Time.utc(0)..Time.current))
247-
end
248-
249227
# Return a nested hash of the form { assignment_id => { section_id => visibility } } where visibility
250228
# is a boolean indicating whether the given assignment is visible to the given section.
251229
def self.visibility_hash

spec/lib/repo/repository/abstract_repository_spec.rb

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -188,83 +188,6 @@
188188
end
189189
end
190190

191-
describe '#get_repo_auth_records' do
192-
let(:assignment1) { create(:assignment, assignment_properties_attributes: { vcs_submit: false }) }
193-
let(:assignment2) { create(:assignment, assignment_properties_attributes: { vcs_submit: false }) }
194-
195-
before do
196-
create_list(:grouping_with_inviter, 3, assignment: assignment1)
197-
create_list(:grouping_with_inviter, 3, assignment: assignment2)
198-
end
199-
200-
context 'all assignments with vcs_submit == false' do
201-
it 'should be empty' do
202-
expect(Repository.get_class.get_repo_auth_records).to be_empty
203-
end
204-
end
205-
206-
context 'one assignment with vcs_submit == true' do
207-
let(:assignment1) { create(:assignment, assignment_properties_attributes: { vcs_submit: true }) }
208-
209-
it 'should only contain valid memberships' do
210-
ids = assignment1.groupings.map { |g| g.inviter.id }
211-
expect(Repository.get_class.get_repo_auth_records.pluck('roles.id')).to match_array(ids)
212-
end
213-
214-
context 'when there is a pending membership' do
215-
before { create(:student_membership, grouping: assignment1.groupings.first) }
216-
217-
it 'should not contain the pending membership' do
218-
ids = assignment1.groupings.map { |g| g.inviter.id }
219-
expect(Repository.get_class.get_repo_auth_records.pluck('roles.id')).to match_array(ids)
220-
end
221-
end
222-
223-
context 'when the assignment belongs to a hidden course' do
224-
let(:assignment1) do
225-
course = create(:course, is_hidden: true)
226-
create(:assignment, assignment_properties_attributes: { vcs_submit: true }, course: course)
227-
end
228-
229-
it 'should be empty' do
230-
expect(Repository.get_class.get_repo_auth_records).to be_empty
231-
end
232-
end
233-
end
234-
235-
context 'both assignments with vcs_submit == true and is_timed == true' do
236-
let(:assignment1) { create(:timed_assignment, assignment_properties_attributes: { vcs_submit: true }) }
237-
let(:assignment2) { create(:timed_assignment, assignment_properties_attributes: { vcs_submit: true }) }
238-
239-
it 'should be empty' do
240-
expect(Repository.get_class.get_repo_auth_records).to be_empty
241-
end
242-
243-
context 'when one grouping has started their assignment' do
244-
let!(:grouping) do
245-
g = assignment1.groupings.first
246-
g.update!(start_time: 1.hour.ago)
247-
g.reload
248-
end
249-
250-
it 'should contain only the members of that group' do
251-
expect(Repository.get_class.get_repo_auth_records.pluck('roles.id')).to contain_exactly(grouping.inviter.id)
252-
end
253-
254-
context 'when the timed assessment due date has ended' do
255-
let(:assignment1) do
256-
create(:timed_assignment, assignment_properties_attributes: { vcs_submit: true }, due_date: 1.minute.ago)
257-
end
258-
259-
it 'should contain all members of all groups' do
260-
inviter_ids = assignment1.groupings.map { |g| g.inviter.id }
261-
expect(Repository.get_class.get_repo_auth_records.pluck('roles.id')).to match_array(inviter_ids)
262-
end
263-
end
264-
end
265-
end
266-
end
267-
268191
describe '#get_all_permissions' do
269192
let!(:course) { create(:course) }
270193
let(:assignment) { create(:assignment_with_criteria_and_results_and_tas) }

0 commit comments

Comments
 (0)