mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-26 12:08:47 +01:00
Merge pull request #208 from iangreenleaf/every_x_day_bug
Fix bug assigning value from every_x_day input
This commit is contained in:
commit
5af9678edb
2 changed files with 61 additions and 1 deletions
|
|
@ -147,7 +147,7 @@ class RecurringTodo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def daily_every_x_days=(x)
|
||||
every_other1 = x if recurring_period=='daily'
|
||||
self.every_other1 = x if recurring_period=='daily'
|
||||
end
|
||||
|
||||
def daily_every_x_days
|
||||
|
|
|
|||
|
|
@ -354,6 +354,66 @@ class RecurringTodoTest < ActiveSupport::TestCase
|
|||
assert !@every_month.valid?
|
||||
end
|
||||
|
||||
def test_set_every_n_days_from_form_input
|
||||
todo = RecurringTodo.new({
|
||||
:description => "Task every 2 days",
|
||||
:context => Context.first,
|
||||
:recurring_target => "show_from_date",
|
||||
:start_from => "01/01/01",
|
||||
:ends_on => "no_end_date",
|
||||
:recurring_period => "daily",
|
||||
:daily_selector => "daily_every_x_day",
|
||||
:daily_every_x_days => 2,
|
||||
})
|
||||
assert todo.valid?, todo.errors.full_messages
|
||||
assert_equal 2, todo.every_other1
|
||||
end
|
||||
|
||||
def test_set_every_n_weeks_from_form_input
|
||||
todo = RecurringTodo.new({
|
||||
:description => "Task every 3 weeks",
|
||||
:context => Context.first,
|
||||
:recurring_target => "show_from_date",
|
||||
:start_from => "01/01/01",
|
||||
:ends_on => "no_end_date",
|
||||
:recurring_period => "weekly",
|
||||
:weekly_every_x_week => 3,
|
||||
:weekly_return_monday => "m",
|
||||
})
|
||||
assert todo.valid?, todo.errors.full_messages
|
||||
assert_equal 3, todo.every_other1
|
||||
assert todo.on_monday
|
||||
end
|
||||
|
||||
def test_set_every_n_months_from_form_input
|
||||
todo = RecurringTodo.new({
|
||||
:description => "Task every 4 months",
|
||||
:context => Context.first,
|
||||
:recurring_target => "show_from_date",
|
||||
:start_from => "01/01/01",
|
||||
:ends_on => "no_end_date",
|
||||
:recurring_period => "monthly",
|
||||
:monthly_selector => "monthly_every_x_day",
|
||||
:monthly_every_x_day => 1,
|
||||
:monthly_every_x_month => 4,
|
||||
})
|
||||
assert todo.valid?, todo.errors.full_messages
|
||||
assert_equal 4, todo.every_other2
|
||||
end
|
||||
|
||||
def test_set_yearly_from_form_input
|
||||
todo = RecurringTodo.new({
|
||||
:description => "Task every year in May",
|
||||
:context => Context.first,
|
||||
:recurring_target => "show_from_date",
|
||||
:start_from => "01/01/01",
|
||||
:ends_on => "no_end_date",
|
||||
:recurring_period => "yearly",
|
||||
:yearly_selector => "yearly_every_x_day",
|
||||
:yearly_every_x_day => 15,
|
||||
:yearly_month_of_year => 5,
|
||||
})
|
||||
assert todo.valid?, todo.errors.full_messages
|
||||
assert_equal 5, todo.every_other2
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue