mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 02:00:12 +01:00
add basis tests for patterns and remove doubles from recurring_todo_test.rb
This commit is contained in:
parent
a7807a4b66
commit
cbdbb792a5
9 changed files with 212 additions and 111 deletions
|
|
@ -8,6 +8,37 @@ module RecurringTodos
|
|||
def setup
|
||||
@admin = users(:admin_user)
|
||||
end
|
||||
|
||||
def test_every_x_week
|
||||
rt = @admin.recurring_todos.where(recurring_period: 'weekly').first
|
||||
|
||||
assert_equal rt.every_other1, rt.pattern.every_x_week
|
||||
end
|
||||
|
||||
def test_on_xday
|
||||
rt = @admin.recurring_todos.where(recurring_period: 'weekly').first
|
||||
assert rt.valid?, "should be valid at start: id= #{rt.id} --> #{rt.errors.full_messages}"
|
||||
|
||||
rt.every_day = 'smtwtfs'
|
||||
%w{monday tuesday wednesday thursday friday saturday sunday}.each do |day|
|
||||
assert rt.pattern.send("on_#{day}"), "on_#{day} should return true"
|
||||
end
|
||||
|
||||
rt.every_day = 'smt tfs' # no wednesday
|
||||
assert !rt.pattern.on_wednesday, "wednesday should be false"
|
||||
end
|
||||
|
||||
def test_validations
|
||||
rt = @admin.recurring_todos.where(recurring_period: 'weekly').first
|
||||
assert rt.valid?, "should be valid at start: #{rt.errors.full_messages}"
|
||||
|
||||
rt.every_other1 = nil
|
||||
assert !rt.valid?, "missing evert_x_week should not be valid"
|
||||
|
||||
rt.every_other1 = 1
|
||||
rt.every_day = ' '
|
||||
assert !rt.valid?, "missing selected days in every_day"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue