Created
July 10, 2019 16:52
-
-
Save KattyaCuevas/6e27fec34af41b11357ad390eef4aa56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user_1 = User.first | |
user_2 = User.second | |
manager = Manager.first | |
# usuario que solicita, el usuario y manager solicitado | |
# en qué día y qué turno? | |
Request.new( | |
requester_id: user_1.id, | |
requested_id: user_2.id, | |
type: "user", | |
status: "PENDING", | |
date_work_shift: "01-10-19", | |
requested_shift_id: 1, | |
current_shift_id: 3 | |
) | |
if type == "user" && status == "ACCEPTED" | |
# sucede despues | |
Request.new( | |
requester_id: user_1.id, | |
requested_id: manager.id, | |
type: "manager", | |
status: "PENDING", | |
date_work_shift: "01-10-19", | |
requested_shift_id: 1, | |
current_shift_id: 3 | |
) | |
end | |
schedule_1 = Schedule.new( | |
month: "October", | |
user_id: 2, | |
work_shifts: [ | |
{ | |
date: "01-10-19", | |
shift_id: 1 # mañana | |
}, | |
{ | |
date: "02-10-19", | |
shift_id: 1 # mañana | |
}, | |
{ | |
date: "03-10-19", | |
shift_id: 2 # tarde | |
}, | |
{ | |
date: "04-10-19", | |
shift_id: 4 # DAY OFF | |
} | |
] | |
) | |
schedule_1 = user_1.schedules.find_by_month("October") | |
work_shifts = schedule_1.work_shifts | |
work_shifts.map! do |work_shift| | |
work_shift[:shift_id] = 3 if work_shift[:date] == "01-10-19" | |
end | |
schedule_1.update(work_shifts: work_shifts) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment