Skip to content

Commit

Permalink
Merge pull request #565 from togglepro/non_abstract_resource_subclass…
Browse files Browse the repository at this point in the history
…_model_name

correctly set model_name of subclasses of non-abstract resources
  • Loading branch information
lgebhardt committed Dec 7, 2015
2 parents 21a8688 + c2a3723 commit bbd4138
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/jsonapi/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def inherited(subclass)
subclass.abstract(false)
subclass.immutable(false)
subclass._attributes = (_attributes || {}).dup
subclass.model_name(_model_name, add_model_hint: false) unless _model_name == ''
subclass._model_hints = (_model_hints || {}).dup

subclass._relationships = {}
Expand Down
6 changes: 5 additions & 1 deletion test/unit/resource/resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def setup
end

def test_model_name
assert_equal(PostResource._model_name, 'Post')
assert_equal("Post", PostResource._model_name)
end

def test_model_name_of_subclassed_non_abstract_resource
assert_equal("Firm", FirmResource._model_name)
end

def test_model
Expand Down

0 comments on commit bbd4138

Please sign in to comment.