Sha256: 72db407428ac914f952bab317f4679b79e6ec2a5a6297188378d0e8956145658
Contents?: true
Size: 1001 Bytes
Versions: 8
Compression:
Stored size: 1001 Bytes
Contents
require File.expand_path('../../../test_helper', __FILE__) require File.expand_path('../../../fixtures/active_record', __FILE__) class ArticleResource < JSONAPI::Resource model_name 'Post' end class CatResource < JSONAPI::Resource attribute :id attribute :name attribute :breed has_one :mother, class_name: 'Cat' has_one :father, class_name: 'Cat' end class ResourceTest < MiniTest::Unit::TestCase def setup @post = Post.first end def test_model_name assert_equal(PostResource._model_name, 'Post') end def test_model assert_equal(PostResource._model_class, Post) end def test_model_alternate assert_equal(ArticleResource._model_class, Post) end def test_class_attributes attrs = CatResource._attributes assert_kind_of(Hash, attrs) assert_equal(attrs.keys.size, 3) end def test_class_assosications associations = CatResource._associations assert_kind_of(Hash, associations) assert_equal(associations.size, 2) end end
Version data entries
8 entries across 8 versions & 1 rubygems