mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-02 14:11:46 +01:00
dry form_helper using meta programming.
not sure if this improves readability, but codeclimate should be happier...
This commit is contained in:
parent
5de96d7eda
commit
a7807a4b66
2 changed files with 40 additions and 13 deletions
24
test/models/recurring_todos/form_helper_test.rb
Normal file
24
test/models/recurring_todos/form_helper_test.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
require_relative '../../test_helper'
|
||||
|
||||
module RecurringTodos
|
||||
|
||||
class AttributeHandlerTest < ActiveSupport::TestCase
|
||||
fixtures :users
|
||||
|
||||
def test_method_missing
|
||||
rt = users(:admin_user).recurring_todos.first
|
||||
rt.every_other1 = 42
|
||||
rt.every_day = 'smtwtfs'
|
||||
rt.save
|
||||
|
||||
h = FormHelper.new(rt)
|
||||
|
||||
assert_equal 42, h.daily_every_x_days, "should be passed to DailyRepeatPattern"
|
||||
assert_equal 42, h.weekly_every_x_week, "should be passed to WeeklyRepeatPattern"
|
||||
assert_equal 42, h.monthly_every_x_day, "should be passed to MonthlyRepeatPattern"
|
||||
assert_equal 42, h.yearly_every_x_day, "should be passed to YearlyRepeatPattern"
|
||||
assert h.on_monday, "should be passed to WeeklyRepeatPattern"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue