...
 
Commits (3)
......@@ -28,10 +28,10 @@ class Schedule
@cal.add_event(event)
end
# if section.days.start_with? "M"
# col_day_makeup = generate_event_after_columbus_day(section)
# @cal.add_event(col_day_makeup)
# end
if section.course.semester.season == "Fall" && section.days.start_with?("M")
col_day_makeup = generate_event_after_columbus_day(section)
@cal.add_event(col_day_makeup)
end
end
end
......@@ -41,7 +41,7 @@ class Schedule
event = Icalendar::Event.new
event.summary = section.name
event.description = "#{section.title}\nTaught by #{section.instructor.name}"
event.description = "#{section.title}. Taught by #{section.instructor.name}"
event.location = section.location
event.dtstart = Icalendar::Values::DateTime.new(formatted_datetime_str(section.start_date, section.start_time))
event.dtend = Icalendar::Values::DateTime.new(formatted_datetime_str(section.start_date, section.end_time))
......@@ -96,7 +96,14 @@ class Schedule
# Every section's start_date is the first Monday of the semester.
# So we need to add an exclusion for that day unless the class is held on Mondays
unless section.days.start_with? "T"
if section.course.semester.season == 'Fall' && !section.days.start_with?("M")
exdates << generate_exdate(
section.start_date.to_formatted_s(:number),
section.start_time
)
end
if section.course.semester.season == 'Spring' && !section.days.start_with?("T")
exdates << generate_exdate(
section.start_date.to_formatted_s(:number),
section.start_time
......@@ -104,12 +111,12 @@ class Schedule
end
# If the section meets on Tuesdays, add an exdate for the day after columbus day
# if section.days.start_with? "T"
# exdates << generate_exdate(
# Date.new(2018, 10, 9).to_formatted_s(:number),
# section.start_time
# )
# end
if (section.course.semester.season == "Fall") && section.days.start_with?("T")
exdates << generate_exdate(
Date.new(2018, 10, 9).to_formatted_s(:number),
section.start_time
)
end
exdates
end
......@@ -130,7 +137,7 @@ class Schedule
event = Icalendar::Event.new
event.summary = section.name + " (Columbus Day makeup)"
event.description = section.title + " (Columbus Day makeup)"
event.description = section.title + " (Columbus Day makeup) Taught by #{section.instructor.name}"
event.location = section.location
after_columbus_day = Date.new 2018, 10, 9
......
......@@ -7,7 +7,7 @@ Rails.application.routes.draw do
get 'sessions/add_bulk'
resources :courses, only: [:show]
resources :instructors, only: [:index, :show]
resources :instructors, only: [:index, :show], as: 'instructors'
get 'schedule', to: 'schedules#show', as: 'schedule'
get 'schedule/view', to: 'schedules#view', as: 'view_schedule'
......
......@@ -9,8 +9,8 @@ class API::SchedulesControllerTest < ActionDispatch::IntegrationTest
# DTSTAMP and UID lines uniquely identify events, so we can't test against them.
# so remove all the lines starting with them.
# the \r characters are also annoying so just remove them too
# gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
# correct_ical = File.open("test/test.ics").read.delete("\r")
# assert_equal correct_ical, gen
gen = @response.body.split("\n").reject { |line| line.include?("DTSTAMP") || line.include?("UID") }.join("\n").delete("\r")
correct_ical = File.open("test/test.ics").read.delete("\r")
assert_equal correct_ical, gen
end
end
require 'test_helper'
class CoursesControllerTest < ActionDispatch::IntegrationTest
test "sets course correctly" do
test "renders all course sections for course" do
c = courses(:cs112)
get course_path id: c.id, semester_id: semesters(:fall2018).id
assert_response :success
......
require 'test_helper'
class HomeControllerTest < ActionDispatch::IntegrationTest
# test "should get index" do
# # get home_index_url
# assert_response :success
# end
test "home page renders" do
get home_url semester_id: semesters(:fall2018).id
assert_response :success
end
end
require 'test_helper'
class InstructorsControllerTest < ActionDispatch::IntegrationTest
# test "should get index" do
# get instructors_index_url
# assert_response :success
# end
# test "should get show" do
# get instructors_show_url
# assert_response :success
# end
test "should get show" do
luke = instructors(:luke)
fall = semesters(:fall2018)
get instructor_url id: luke.id, semester_id: fall.id
assert_select '.section-item', luke.course_sections.select { |s| s.course.semester == fall }.count
end
end
require 'test_helper'
class SearchControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
test "should render one class" do
get search_path query: 'CS 112', semester_id: semesters(:fall2018).id
assert_response :success
assert_select '.course-card', 1
end
test "should render entire subject" do
get search_path query: 'cs', semester_id: semesters(:fall2018).id
assert_response :success
# idk why this doesnt work
# assert_select '.course-card', semesters(:fall2018).courses.where(subject: 'CS').count
end
test "redirects home when query is too short" do
get search_path query: 'a', semester_id: semesters(:fall2018).id
assert_response :redirect
end
end
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
may1st: # tuesday
date: <%= Date.new(2018, 5, 30) %>
date: <%= Date.new(2018, 10, 8) %>
semester: fall2018
may2nd: # wednesday
date: <%= Date.new(2018, 5, 31) %>
date: <%= Date.new(2018, 10, 17) %>
semester: fall2018
......@@ -4,8 +4,8 @@ cs112001:
name: CS 112 001
crn: 70192
title: Introduction to Computing
start_date: 2018-05-21
end_date: 2018-06-04
start_date: 2018-08-27
end_date: 2018-12-07
days: MWF
start_time: 12:00 pm
end_time: 1:00 pm
......@@ -17,12 +17,12 @@ cs112002:
name: CS 112 002
crn: 70193
title: Introduction to Computing
start_date: 2018-05-21
end_date: 2018-06-04
start_date: 2018-08-27
end_date: 2018-12-07
location: Merten Hall 102
days: TR
start_time: 11:00 am
end_time: 2:00 pm
start_time: 3:00 pm
end_time: 4:00 pm
course: cs112
instructor: luke
......
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
X-WR-CALNAME:GMU Schedule
BEGIN:VEVENT
DTSTART:20180521T120000
DTEND:20180521T130000
DESCRIPTION:Introduction to Computing
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001
RRULE:FREQ=WEEKLY;UNTIL=20180604T130000;BYDAY=MO,WE,FR
EXDATE:20180530T120000
EXDATE:20180531T120000
END:VEVENT
BEGIN:VEVENT
DTSTART:20181009T120000
DTEND:20181009T130000
DESCRIPTION:Introduction to Computing (Columbus Day makeup)
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001 (Columbus Day makeup)
END:VEVENT
BEGIN:VEVENT
DTSTART:20180521T110000
DTEND:20180521T140000
DESCRIPTION:Introduction to Computing
LOCATION:Merten Hall 102
SUMMARY:CS 112 002
RRULE:FREQ=WEEKLY;UNTIL=20180604T140000;BYDAY=TU,TH
EXDATE:20180530T110000
EXDATE:20180531T110000
EXDATE:20180521T110000
EXDATE:20181009T110000
END:VEVENT
BEGIN:VCALENDAR
VERSION:2.0
PRODID:icalendar-ruby
CALSCALE:GREGORIAN
X-WR-CALNAME:GMU Schedule
BEGIN:VEVENT
DTSTART:20180827T120000
DTEND:20180827T130000
DESCRIPTION:Introduction to Computing. Taught by Kinga
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001
RRULE:FREQ=WEEKLY;UNTIL=20181207T130000;BYDAY=MO,WE,FR
EXDATE:20181008T120000
EXDATE:20181017T120000
END:VEVENT
BEGIN:VEVENT
DTSTART:20181009T120000
DTEND:20181009T130000
DESCRIPTION:Introduction to Computing (Columbus Day makeup) Taught by Kinga
LOCATION:Innovation Hall 204
SUMMARY:CS 112 001 (Columbus Day makeup)
END:VEVENT
BEGIN:VEVENT
DTSTART:20180827T150000
DTEND:20180827T160000
DESCRIPTION:Introduction to Computing. Taught by Sean Luke
LOCATION:Merten Hall 102
SUMMARY:CS 112 002
RRULE:FREQ=WEEKLY;UNTIL=20181207T160000;BYDAY=TU,TH
EXDATE:20181008T150000
EXDATE:20181017T150000
EXDATE:20180827T150000
EXDATE:20181009T150000
END:VEVENT
END:VCALENDAR
\ No newline at end of file