mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-18 05:08:09 +01:00
move mapping of form attributes to model attributes from pattern to builder to make
pattern independent of form
This commit is contained in:
parent
1f36c27af8
commit
776a046465
22 changed files with 463 additions and 446 deletions
|
|
@ -9,50 +9,6 @@ module RecurringTodos
|
|||
@admin = users(:admin_user)
|
||||
end
|
||||
|
||||
def test_valid_selector
|
||||
attributes = {
|
||||
'recurring_period' => 'daily'
|
||||
}
|
||||
|
||||
# should not raise
|
||||
%w{daily_every_x_day daily_every_work_day}.each do |selector|
|
||||
attributes['daily_selector'] = selector
|
||||
DailyRepeatPattern.new(@admin, attributes)
|
||||
end
|
||||
|
||||
# should raise
|
||||
attributes = {
|
||||
'recurring_period' => 'daily',
|
||||
'daily_selector' => 'wrong value'
|
||||
}
|
||||
|
||||
# should raise
|
||||
assert_raise(Exception, "should have exception since daily_selector has wrong value"){ DailyRepeatPattern.new(@admin, attributes) }
|
||||
end
|
||||
|
||||
def test_mapping_of_attributes
|
||||
attributes = {
|
||||
'recurring_period' => 'daily',
|
||||
'description' => 'a repeating todo', # generic
|
||||
'daily_selector' => 'daily_every_x_day', # daily specific --> mapped to only_work_days=false
|
||||
'daily_every_x_days' => '5' # mapped to every_other1
|
||||
}
|
||||
|
||||
pattern = DailyRepeatPattern.new(@admin, attributes)
|
||||
|
||||
assert_equal '5', pattern.mapped_attributes[:every_other1], "every_other1 should be set to daily_every_x_days"
|
||||
assert_equal false, pattern.mapped_attributes[:only_work_days], "only_work_days should be set to false for daily_every_x_day"
|
||||
|
||||
attributes = {
|
||||
'recurring_period' => 'daily',
|
||||
'description' => 'a repeating todo', # generic
|
||||
'daily_selector' => 'daily_every_work_day', # daily specific --> mapped to only_work_days=true
|
||||
}
|
||||
|
||||
pattern = DailyRepeatPattern.new(@admin, attributes)
|
||||
assert_equal true, pattern.mapped_attributes[:only_work_days]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue