dry form_helper using meta programming.

not sure if this improves readability, but codeclimate should be happier...
This commit is contained in:
Reinier Balt 2014-02-10 22:30:06 +01:00
parent 5de96d7eda
commit a7807a4b66
2 changed files with 40 additions and 13 deletions

View 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