       [applicable_task] = Tasks.get_for_user(nil, volunteer.id, Timex.now())
       assert applicable_task.id == task.id
     end
+
+    test "return even if max_volunteers is surpassed" do
+      [volunteer1, volunteer2] = insert_list(2, :volunteer)
+      {:ok, task} =  adds_extra_volunteer_without_check(%{task: insert(:task, max_volunteers: 1),
+                                                        volunteers: [volunteer1, volunteer2]})
+
+      [applicable_task] = Tasks.get_for_user(nil, volunteer1.id, Timex.now())
+      assert length(applicable_task.volunteers) > applicable_task.max_volunteers
+      assert applicable_task.id == task.id
+    end
   end
 end


  alias CoursePlanner.{Tasks, Tasks.Task}
  import CoursePlanner.Factory

  describe "tests tasks sorting functionality when" do
    test "query without sort option" do

      volunteer = insert(:volunteer)
      insert_list(5, :task)
      assert [] == Tasks.get_past(nil, volunteer.id, Timex.shift(Timex.now(), days: 10))
    end

    test "return even if max_volunteers is surpassed" do
      [volunteer1, volunteer2] = insert_list(2, :volunteer)
      {:ok, task} =  adds_extra_volunteer_without_check(%{task: insert(:task, max_volunteers: 1),
                                                        volunteers: [volunteer1, volunteer2]})

      [applicable_task] = Tasks.get_past(nil, volunteer1.id, Timex.shift(Timex.now(), days: 20))
      assert length(applicable_task.volunteers) > applicable_task.max_volunteers
      assert applicable_task.id == task.id
    end
  end

