Skip to content

Commit

Permalink
Update queue pop button functionality
Browse files Browse the repository at this point in the history
to allow popping people from the queue that are pinned by others.

The pop order is now: pinned by you, not pinned, pinned by others, which
mirrors the way it is displayed in the UI.

Since the queue pop button can now pop up to $requests.length requests,
this closes #98.
  • Loading branch information
mterwill committed Jan 7, 2018
1 parent 65e65bd commit e133bd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/models/course_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def pop!(user)
first_pinned.resolve_by!(user)
elsif first_non_pinned = self.outstanding_requests.where(resolver: nil).first
first_non_pinned.resolve_by!(user)
elsif first_pinned_by_others = self.outstanding_requests.where.not(resolver: user).first
first_pinned_by_others.resolve_by!(user)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/models/course_queue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class CourseQueueTest < ActiveSupport::TestCase

assert request == course_queue_entries(:unresolved_entry)

# pinned by matt shouldn't be resolvable by jim
assert_nil @queue.pop!(users(:jim))
# if the queue is empty we will allow entries pinned by others to be popped
assert @queue.pop!(users(:jim)) == pinned_by_matt
end

test "request validates duplicates in group mode" do
Expand Down

0 comments on commit e133bd2

Please sign in to comment.