require File.dirname(__FILE__) + '/test_helper' class ActionControllerTest < Test::Unit::TestCase class ActionControllerMock def self.helper(args) @__helper = args end def self.helper_value @__helper end def self.before_filter(args) @__before_filter = args end def self.before_filter_value @__before_filter end extend TrackChanges::ActionController end def setup @action_controller = ActionControllerMock.new end def test_should_add_track_changes_class_method assert ActionControllerMock.respond_to?(:track_changes) end def test_should_set_a_before_filter ActionControllerMock.class_eval do track_changes :some_var end assert ActionControllerMock.before_filter_value.respond_to?(:filter) end def test_should_accept_multiple_arguments assert_nothing_raised do ActionControllerMock.class_eval do track_changes :foo end ActionControllerMock.class_eval do track_changes :foo, :bar end ActionControllerMock.class_eval do track_changes :foo, :bar, :baz end end end def test_should_define_a_method_that_returns_interested_vars ActionControllerMock.class_eval do track_changes :foo, :bar, :baz end interesting_vars = ActionControllerMock.new.__track_changes_to_models assert interesting_vars.include?(:foo), interesting_vars.inspect assert interesting_vars.include?(:bar), interesting_vars.inspect assert interesting_vars.include?(:baz), interesting_vars.inspect end def test_should_include_helpers ActionControllerMock.class_eval do track_changes :foo end assert_equal :audits, ActionControllerMock.helper_value end end