Skip to content

Commit eb44dd1

Browse files
committed
All tests pass
1 parent bc91a5f commit eb44dd1

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

app/Policies/QuestionPolicy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function viewAny(User $user)
5757

5858
public function refreshProperties(User $user)
5959
{
60-
return ($user->role !== 2)
60+
return ($user->role === 2)
6161
? Response::allow()
6262
: Response::deny('You are not allowed to refresh the question properties from the database.');
6363

tests/Feature/Instructors/QuestionsSummaryTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function setup(): void
3030
parent::setUp();
3131
$this->user = factory(User::class)->create();
3232
$this->user_2 = factory(User::class)->create();
33+
$this->student_user = factory(User::class)->create(['role' =>3]);
3334
$course = factory(Course::class)->create(['user_id' => $this->user->id]);
3435
$this->assignment = factory(Assignment::class)->create(['course_id' => $course->id, 'solutions_released' => 0]);
3536
$this->question = factory(Question::class)->create(['page_id' => 1]);
@@ -58,7 +59,7 @@ public function setup(): void
5859

5960
public function non_instructor_cannot_refresh_question_properties()
6061
{
61-
$this->actingAs($this->user_2)->patchJson("/api/questions/{$this->question->id}/refresh-properties")
62+
$this->actingAs($this->student_user)->patchJson("/api/questions/{$this->question->id}/refresh-properties")
6263
->assertJson(['message' => 'You are not allowed to refresh the question properties from the database.']);
6364

6465
}
@@ -67,8 +68,8 @@ public function non_instructor_cannot_refresh_question_properties()
6768

6869
public function instructor_can_refresh_question_properties()
6970
{
70-
$this->actingAs($this->user_2)->patchJson("/api/questions/{$this->question->id}/refresh-properties")
71-
->assertJson(['message' => 'You are not allowed to refresh the question properties from the database.']);
71+
$this->actingAs($this->user)->patchJson("/api/questions/{$this->question->id}/refresh-properties")
72+
->assertJson(['type' => 'success']);
7273

7374
}
7475

0 commit comments

Comments
 (0)