Module: NoFlyList::TestHelper
- Defined in:
- lib/no_fly_list/test_helper.rb
Instance Method Summary collapse
-
#assert_taggable_record(klass, *contexts) ⇒ Object
Asserts that a model class is properly set up for tagging in the given context.
-
#assert_tagging_context(klass, context, polymorphic: false) ⇒ Object
Asserts that a model class has proper tagging setup for a specific context.
Instance Method Details
#assert_taggable_record(klass, *contexts) ⇒ Object
Asserts that a model class is properly set up for tagging in the given context
6 7 8 9 10 11 12 13 14 |
# File 'lib/no_fly_list/test_helper.rb', line 6 def assert_taggable_record(klass, *contexts) contexts.each do |context| assert klass._no_fly_list.tag_contexts.key?(context), "#{klass} should have #{context} in its tag contexts" assert_respond_to klass.new, "#{context}_list", "#{klass} should respond to #{context}_list" end end |
#assert_tagging_context(klass, context, polymorphic: false) ⇒ Object
Asserts that a model class has proper tagging setup for a specific context
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/no_fly_list/test_helper.rb', line 17 def assert_tagging_context(klass, context, polymorphic: false) singular_name = context.to_s.singularize # Check the context is registered assert klass._no_fly_list.tag_contexts.key?(context), "#{context} is not registered as a tag context for #{klass}" # Check configuration context_config = klass._no_fly_list.tag_contexts[context] assert_equal polymorphic, context_config[:polymorphic], "#{context} should #{polymorphic ? '' : 'not '}be configured as polymorphic" # Check tagging associations assert_respond_to klass.new, "#{singular_name}_taggings", "Missing taggings association for #{context}" assert_respond_to klass.new, context, "Missing tags association for #{context}" # Check if correct classes exist if polymorphic assert_polymorphic_tag_classes_exist(klass, context) else assert_local_tag_classes_exist(klass, context) end end |