Skip to content

Commit

Permalink
Merge branch 'filter_modal' of github.com:khushiagl/Markus into filte…
Browse files Browse the repository at this point in the history
…r_modal
  • Loading branch information
khushiagl committed Jul 18, 2023
2 parents 700d01a + 89fc7ec commit 55b3acd
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions spec/controllers/results_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ def self.test_unauthorized(route_name)
create :ta_membership, role: ta, grouping: groupings[i]
end
end

context 'when annotation text filter is applied' do
let(:annotation_text) { create :annotation_text, content: 'aa_' }
before(:each) do
create :text_annotation, annotation_text: annotation_text, result: grouping1.current_result
create :text_annotation, annotation_text: annotation_text, result: grouping3.current_result
end

context 'when there are no more filtered submissions in the specified direction' do
it 'should return a response with next_grouping and next_result set to nil' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping3.id,
Expand All @@ -74,6 +76,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_result']).to be_nil
end
end

context 'when there is another filtered result after the current one' do
it 'should return a response with the next filtered group' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
Expand All @@ -82,6 +85,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id)
expect(response.parsed_body['next_result']['id']).to eq(grouping3.current_result.id)
end

it 'shouldn\'t return the next non-filtered group' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
Expand All @@ -90,6 +94,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_result']['id']).not_to eq(grouping2.current_result.id)
end
end

context 'when annotationValue contains special characters (in the context of a like clause)' do
it 'should sanitize the string and return the next relevant result' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
Expand All @@ -99,6 +104,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_result']['id']).to eq(grouping3.current_result.id)
end
end

context 'when we filter by a substring of the desired annotation text' do
it 'should return the next result containing the substring in one of its annotations' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
Expand All @@ -109,27 +115,31 @@ def self.test_unauthorized(route_name)
end
end
end

context 'section filter' do
let(:section) { create :section }
before(:each) do
groupings[0].inviter.update(section: section)
groupings[1].inviter.update(section: nil)
groupings[2].inviter.update(section: section)
end

context 'when a section has been picked' do
it 'should return the next group with a larger group name that satisfies the constraints' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { sectionValue: 'Section 1' } }
expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id)
end

it 'should not return the next group that doesn\'t satisfy the constraint' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { sectionValue: 'Section 1' } }
expect(response.parsed_body['next_grouping']['id']).not_to eq(grouping2.id)
end
end

context 'when section is left blank' do
it 'should return the next grouping without constraints' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
Expand All @@ -139,6 +149,7 @@ def self.test_unauthorized(route_name)
end
end
end

context 'marking state filter' do
context 'when remark request is selected' do
let(:grouping2) do
Expand All @@ -162,25 +173,29 @@ def self.test_unauthorized(route_name)
before(:each) do
grouping3.current_result.update(marking_state: Result::MARKING_STATES[:complete])
end

it 'should respond with the next grouping with a remark requested and who has a marking state of incomplete' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'Remark Requested' } }
expect(response.parsed_body['next_grouping']['id']).to eq(grouping4.id)
end

it 'should not respond with a grouping whose current result is a remark result but is complete' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'Remark Requested' } }
expect(response.parsed_body['next_grouping']['id']).not_to eq(grouping3.id)
end

it 'should not respond with a grouping whose current result is not a remark result' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'Remark Requested' } }
expect(response.parsed_body['next_grouping']['id']).not_to eq(grouping2.id)
end
end

context 'when released is selected' do
let(:grouping2) do
result = create :incomplete_result
Expand All @@ -200,13 +215,15 @@ def self.test_unauthorized(route_name)
remark_result.grouping.update(assignment: grouping1.assignment)
remark_result.grouping
end

it 'should respond with the next grouping whose submission has been released' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'Released' } }
expect(response.parsed_body['next_grouping']['id']).to eq(grouping4.id)
end
end

context 'when complete is selected' do
let(:grouping2) do
result = create :released_result
Expand All @@ -220,12 +237,14 @@ def self.test_unauthorized(route_name)
remark_result.grouping.update(assignment: grouping1.assignment)
remark_result.grouping
end

it 'should respond with the next grouping whose result is complete regardless of remark request status' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'Complete' } }
expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id)
end

it 'should not respond with a released result regardless of the result\'s marking status' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
Expand All @@ -252,12 +271,14 @@ def self.test_unauthorized(route_name)
remark_result.grouping.update(assignment: grouping1.assignment)
remark_result.grouping
end

it 'should respond with the next grouping whose result is incomplete' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
direction: 1, filterData: { markingStateValue: 'In Progress' } }
expect(response.parsed_body['next_grouping']['id']).to eq(grouping4.id)
end

it 'should not respond with a released or remark result' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
Expand All @@ -266,6 +287,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).not_to eq(grouping3.id)
end
end

context 'when markingStateValue is left blank' do
let(:grouping2) do
result = create :incomplete_result
Expand All @@ -285,6 +307,7 @@ def self.test_unauthorized(route_name)
remark_result.grouping.update(assignment: grouping1.assignment)
remark_result.grouping
end

it 'should return the next group regardless of marking state' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping1.id,
id: grouping1.current_result.id,
Expand Down Expand Up @@ -488,6 +511,7 @@ def self.test_unauthorized(route_name)
create :ta_membership, role: ta, grouping: groupings[i]
end
end

context 'order by group name' do
context 'Descending Order' do
context 'direction = 1' do
Expand All @@ -498,6 +522,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping1.id)
end
end

context 'direction = -1' do
it 'should return the previous grouping in descending order of group name' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping2.id,
Expand All @@ -508,6 +533,7 @@ def self.test_unauthorized(route_name)
end
end
end

context 'order by submission date' do
context 'Ascending Order' do
context 'when direction = 1' do
Expand All @@ -519,6 +545,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id)
end
end

context 'when the next ordered submission shares has the same submission date as the current one' do
let(:grouping1) { create :grouping_with_inviter_and_submission, is_collected: true }
let(:grouping2) do
Expand All @@ -527,6 +554,7 @@ def self.test_unauthorized(route_name)
let(:grouping3) do
create :grouping_with_inviter_and_submission, assignment: grouping1.assignment, is_collected: true
end

it 'should return the grouping with the next largest group name with the same submission date' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping2.id,
id: grouping2.current_result.id,
Expand All @@ -535,6 +563,7 @@ def self.test_unauthorized(route_name)
end
end
end

context 'direction = -1' do
context 'when the previous ordered submission has a different submission date from the current one' do
it 'should return the grouping with the next earliest submission date' do
Expand All @@ -544,6 +573,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping1.id)
end
end

context 'when the previous ordered submission shares has the same submission date as the current one' do
let(:grouping1) { create :grouping_with_inviter_and_submission, is_collected: true }
let(:grouping2) do
Expand All @@ -552,6 +582,7 @@ def self.test_unauthorized(route_name)
let(:grouping3) do
create :grouping_with_inviter_and_submission, assignment: grouping1.assignment, is_collected: true
end

it 'should return the grouping with the next smallest group name with the same submission date' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping2.id,
id: grouping2.current_result.id,
Expand All @@ -561,6 +592,7 @@ def self.test_unauthorized(route_name)
end
end
end

context 'Descending Order' do
context 'direction = 1' do
context 'when the next ordered submission has a different submission date from the current one' do
Expand All @@ -571,6 +603,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping1.id)
end
end

context 'when the next ordered submission shares has the same submission date as the current one' do
let(:grouping1) { create :grouping_with_inviter_and_submission, is_collected: true }
let(:grouping2) do
Expand All @@ -579,6 +612,7 @@ def self.test_unauthorized(route_name)
let(:grouping3) do
create :grouping_with_inviter_and_submission, assignment: grouping1.assignment, is_collected: true
end

it 'should return the grouping with the next smallest group name with the same submission date' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping2.id,
id: grouping2.current_result.id,
Expand All @@ -587,6 +621,7 @@ def self.test_unauthorized(route_name)
end
end
end

context 'direction = -1' do
context 'when the previous ordered submission has a different submission date from the current one' do
it 'should return the grouping with the next latest submission date' do
Expand All @@ -598,6 +633,7 @@ def self.test_unauthorized(route_name)
expect(response.parsed_body['next_grouping']['id']).to eq(grouping3.id)
end
end

context 'when the previous ordered submission shares has the same submission date as the current one' do
let(:grouping1) { create :grouping_with_inviter_and_submission, is_collected: true }
let(:grouping2) do
Expand All @@ -606,6 +642,7 @@ def self.test_unauthorized(route_name)
let(:grouping3) do
create :grouping_with_inviter_and_submission, assignment: grouping1.assignment, is_collected: true
end

it 'should return the grouping with the next largest group name with the same submission date' do
get :next_grouping, params: { course_id: course.id, grouping_id: grouping2.id,
id: grouping2.current_result.id,
Expand Down

0 comments on commit 55b3acd

Please sign in to comment.