mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-29 21:38:49 +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
|
|
@ -5,42 +5,10 @@ module RecurringTodos
|
|||
class AbstractRepeatPatternTest < ActiveSupport::TestCase
|
||||
fixtures :users
|
||||
|
||||
class TestRepeatPattern < AbstractRepeatPattern
|
||||
def valid_selector?(selector)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
@admin = users(:admin_user)
|
||||
end
|
||||
|
||||
def test_map_removes_mapped_key
|
||||
attributes = { :source => "value"}
|
||||
|
||||
arp = AbstractRepeatPattern.new(@admin, attributes)
|
||||
attributes = arp.map(attributes, :target, :source)
|
||||
|
||||
assert_equal "value", attributes[:target]
|
||||
assert_nil attributes[:source]
|
||||
assert !attributes.key?(:source)
|
||||
end
|
||||
|
||||
def test_get_selector_removes_selector_from_hash
|
||||
attributes = { :selector => "weekly" }
|
||||
arp = TestRepeatPattern.new(@admin, attributes)
|
||||
|
||||
assert "weekly", arp.get_selector(:selector)
|
||||
assert !arp.attributes.key?(:selector)
|
||||
end
|
||||
|
||||
def test_get_selector_raises_exception_when_missing_selector
|
||||
attributes = { }
|
||||
arp = TestRepeatPattern.new(@admin, attributes)
|
||||
|
||||
assert_raise(Exception, "should raise exception when recurrence selector is missing"){ arp.get_selector(:selector) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue