fix past courses being shown
This commit is contained in:
parent
3f7e6b6175
commit
0d966f3f6f
|
@ -1,6 +1,6 @@
|
|||
module AppliesHelper
|
||||
def course_select
|
||||
Course.all.order(:name).map { |c| [c.full_name, c.id ] }
|
||||
Course.where("start > ?" , Time.now).order(:start).map { |c| [c.full_name, c.id ] }
|
||||
end
|
||||
|
||||
def plan_select
|
||||
|
|
|
@ -5,7 +5,7 @@ FactoryGirl.define do
|
|||
end
|
||||
extra "With Extras"
|
||||
sequence :start do |n|
|
||||
Time.now - 2.weeks + (n*2).weeks
|
||||
end
|
||||
Time.now - 3.weeks + (n*2).weeks
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ feature 'Applies' do
|
|||
scenario 'Send Application' do
|
||||
within "#apply_primary_choice_course_id" do
|
||||
courses = page.find_all("option")
|
||||
expect(courses.length).to be 3
|
||||
expect(courses.length).to be 2
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
RSpec.describe AppliesHelper, type: :helper do
|
||||
|
||||
def make_list(times)
|
||||
times.each do |t|
|
||||
create( :course , start: Time.now + t.weeks)
|
||||
end
|
||||
end
|
||||
it "shows 2 courses when 3 are created (because 1 is in the past)" do
|
||||
make_list [-2 , 2, 2]
|
||||
expect(helper.course_select.length).to eq( 2 )
|
||||
end
|
||||
|
||||
it "shows 5 of 5 future courses" do
|
||||
make_list [2, 4 , 6 , 8 , 10]
|
||||
helper.course_select.each do |options|
|
||||
course = Course.find options[1]
|
||||
expect((course.start - DateTime.now).to_i).to be < 150
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,6 +22,6 @@ RSpec.describe Course, type: :model do
|
|||
it "the second course is in the future" do
|
||||
create :course
|
||||
course2 = create :course
|
||||
expect((course2.start - DateTime.now).to_i).to be < 250
|
||||
expect((course2.start - DateTime.now).to_i).to be < 400
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue