Class: DefaultsClassMethodTest

Inherits:
ActiveSupport::TestCase
  • Object
show all
Defined in:
lib/vendor/plugins/inherited_resources/test/class_methods_test.rb

Instance Method Summary collapse

Instance Method Details

#test_defaults_are_setObject



57
58
59
60
61
# File 'lib/vendor/plugins/inherited_resources/test/class_methods_test.rb', line 57

def test_defaults_are_set
  assert Folder, FoldersController.send(:resource_class)
  assert :folder, FoldersController.send(:resources_configuration)[:self][:instance_name]
  assert :folders, FoldersController.send(:resources_configuration)[:self][:collection_name]
end

#test_defaults_can_be_overwritenObject



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/vendor/plugins/inherited_resources/test/class_methods_test.rb', line 63

def test_defaults_can_be_overwriten
  BooksController.send(:defaults, :resource_class => String, :instance_name => 'string', :collection_name => 'strings')

  assert String, BooksController.send(:resource_class)
  assert :string, BooksController.send(:resources_configuration)[:self][:instance_name]
  assert :strings, BooksController.send(:resources_configuration)[:self][:collection_name]

  BooksController.send(:defaults, :class_name => 'Fixnum', :instance_name => :fixnum, :collection_name => :fixnums)

  assert String, BooksController.send(:resource_class)
  assert :string, BooksController.send(:resources_configuration)[:self][:instance_name]
  assert :strings, BooksController.send(:resources_configuration)[:self][:collection_name]
end

#test_defaults_raises_invalid_keyObject



77
78
79
80
81
# File 'lib/vendor/plugins/inherited_resources/test/class_methods_test.rb', line 77

def test_defaults_raises_invalid_key
  assert_raise ArgumentError do
    BooksController.send(:defaults, :boom => String)
  end
end

#test_resource_class_is_set_to_nil_when_resource_model_cannot_be_foundObject



53
54
55
# File 'lib/vendor/plugins/inherited_resources/test/class_methods_test.rb', line 53

def test_resource_class_is_set_to_nil_when_resource_model_cannot_be_found
  assert_nil ReadersController.send(:resource_class)
end

#test_url_helpers_are_recreated_when_defaults_changeObject



83
84
85
86
# File 'lib/vendor/plugins/inherited_resources/test/class_methods_test.rb', line 83

def test_url_helpers_are_recreated_when_defaults_change
  BooksController.expects(:create_resources_url_helpers!).returns(true).once
  BooksController.send(:defaults, :instance_name => 'string', :collection_name => 'strings')
end