-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added due_in_days column * Added validation for due_in_days * Allow editing due_in_days for default tasks * Set task due_date based on default task due_in_days * Added column for due_in_days to index view * Set a variety of due dates on the seed data tasks
- Loading branch information
Showing
12 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
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
5 changes: 5 additions & 0 deletions
5
db/migrate/20240201133430_add_due_in_days_to_default_tasks.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddDueInDaysToDefaultTasks < ActiveRecord::Migration[7.0] | ||
def change | ||
add_column :default_pet_tasks, :due_in_days, :integer, null: true | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
25 changes: 25 additions & 0 deletions
25
test/services/organizations/default_pet_task_service_test.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "test_helper" | ||
|
||
class Organizations::DefaultPetTaskServiceTest < ActiveSupport::TestCase | ||
test "creates tasks from the organization's default tasks" do | ||
organization = create(:organization) | ||
default_task = create(:default_pet_task, organization: organization) | ||
pet = create(:pet, organization: organization) | ||
|
||
Organizations::DefaultPetTaskService.new(pet).create_tasks | ||
|
||
assert_equal 1, pet.tasks.count | ||
assert_equal default_task.name, pet.tasks.first.name | ||
assert_nil pet.tasks.first.due_date | ||
end | ||
|
||
test "creates tasks with due_date set based on the default task's due_in_days" do | ||
organization = create(:organization) | ||
create(:default_pet_task, organization: organization, due_in_days: 5) | ||
pet = create(:pet, organization: organization) | ||
|
||
Organizations::DefaultPetTaskService.new(pet).create_tasks | ||
|
||
assert_equal 5.days.from_now.beginning_of_day, pet.tasks.first.due_date | ||
end | ||
end |