diff --git a/app/controllers/enrollments_api_controller.rb b/app/controllers/enrollments_api_controller.rb index bee02d0d256..381b9e843a7 100644 --- a/app/controllers/enrollments_api_controller.rb +++ b/app/controllers/enrollments_api_controller.rb @@ -998,7 +998,7 @@ class EnrollmentsApiController < ApplicationController def enrollment_states_for_state_param states = Array(params[:state]).uniq states.concat(%w(active invited)) if states.delete 'current_and_invited' - states.concat(%w(active invited creation_pending)) if states.delete 'current_and_future' + states.concat(%w(active invited creation_pending pending_active pending_invited)) if states.delete 'current_and_future' states.concat(%w(active completed)) if states.delete 'current_and_concluded' states.uniq end diff --git a/spec/apis/v1/enrollments_api_spec.rb b/spec/apis/v1/enrollments_api_spec.rb index 8f5b29bdb57..831d65002dd 100644 --- a/spec/apis/v1/enrollments_api_spec.rb +++ b/spec/apis/v1/enrollments_api_spec.rb @@ -1803,7 +1803,7 @@ describe EnrollmentsApiController, type: :request do it "should show enrollments for courses that aren't published if state[]=current_and_future" do course_factory @course.claim - enrollment = course_factory.enroll_student(@user) + enrollment = @course.enroll_student(@user) enrollment.update_attribute(:workflow_state, 'active') json = api_call(:get, @user_path, @@ -1811,6 +1811,18 @@ describe EnrollmentsApiController, type: :request do expect(json.map { |e| e['id'] }).to include enrollment.id end + it "should show enrollments for courses with future start dates if state[]=current_and_future" do + course_factory + @course.update_attributes(:start_at => 1.week.from_now, :restrict_enrollments_to_course_dates => true) + enrollment = @course.enroll_student(@user) + enrollment.update_attribute(:workflow_state, 'active') + expect(enrollment.enrollment_state.state).to eq "pending_active" + + json = api_call(:get, @user_path, + @user_params.merge(:state => %w{current_and_future}, :type => %w{StudentEnrollment})) + expect(json.map { |e| e['id'] }).to include enrollment.id + end + it "should accept multiple state[] filters" do course_factory @course.offer!