-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix filtering on new saved annotation page #5838
Changes from 1 commit
8bc4623
fb3f620
1bb1884
5cc5dd7
40633be
2e997f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,25 @@ def setup | |
|
||
assert_response :forbidden | ||
end | ||
|
||
test 'staff should be able to filter existing annotations on new page' do | ||
get new_saved_annotation_path | ||
|
||
assert_response :success | ||
|
||
get new_saved_annotation_path, params: { exercise_id: 1 } | ||
|
||
assert_response :success | ||
end | ||
|
||
test 'zeus should be able to filter existing annotations on new page' do | ||
sign_in users(:zeus) | ||
get new_saved_annotation_path | ||
|
||
assert_response :success | ||
|
||
get new_saved_annotation_path, params: { exercise_id: 1 } | ||
|
||
assert_response :success | ||
end | ||
Comment on lines
+63
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Refactor zeus test and enhance coverage The zeus test is very similar to the staff test, which suggests an opportunity for refactoring to reduce code duplication. Additionally, it has the same limitations in terms of verifying the actual filtering functionality. Consider the following improvements:
Here's a suggested refactoring and improvement: def assert_can_filter_annotations(user)
sign_in user
exercise1 = create(:exercise)
exercise2 = create(:exercise)
annotation1 = create(:saved_annotation, user: user, course: @course, exercise: exercise1)
annotation2 = create(:saved_annotation, user: user, course: @course, exercise: exercise2)
get new_saved_annotation_path
assert_response :success
assert_select 'your-selector-for-annotation', 2
get new_saved_annotation_path, params: { exercise_id: exercise1.id }
assert_response :success
assert_select 'your-selector-for-annotation', 1
assert_select 'your-selector-for-annotation-title', annotation1.title
end
test 'staff should be able to filter existing annotations on new page' do
assert_can_filter_annotations(@user)
end
test 'zeus should be able to filter existing annotations on new page' do
assert_can_filter_annotations(users(:zeus))
end This refactoring reduces duplication and ensures consistent testing across user types. Adjust the selectors and assertions as needed to match your actual view structure. |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Enhance test coverage for staff filtering
The test correctly checks if staff can access the new saved annotation page with and without filtering. However, it could be improved to verify the actual filtering functionality.
Consider the following improvements:
Here's a suggested improvement:
Replace 'your-selector-for-annotation' with the actual CSS selector used in your view to represent annotations.