File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -409,6 +409,7 @@ def save
409409 mark_as_persisted!
410410 if updated = last_result_set . first
411411 self . attributes = updated . attributes
412+ self . links . attributes = updated . links . attributes
412413 self . relationships . attributes = updated . relationships . attributes
413414 clear_changes_information
414415 end
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ def setup
3535 id : "1" ,
3636 attributes : {
3737 title : "Rails is Omakase"
38+ } ,
39+ links : {
40+ self : "http://example.com/articles/1" ,
41+ other : {
42+ href : "http://example.com/other"
43+ }
3844 }
3945 }
4046 } . to_json )
@@ -68,6 +74,16 @@ def test_can_create_with_new_record_and_save
6874 assert_equal "1" , article . id
6975 end
7076
77+ def test_can_create_with_links
78+ article = Article . new ( {
79+ title : "Rails is Omakase"
80+ } )
81+
82+ assert article . save
83+ assert article . persisted?
84+ assert_equal "http://example.com/articles/1" , article . links . self
85+ end
86+
7187 def test_can_create_with_new_record_with_relationships_and_save
7288 stub_request ( :post , "http://example.com/articles" )
7389 . with ( headers : { content_type : "application/vnd.api+json" , accept : "application/vnd.api+json" } , body : {
You can’t perform that action at this time.
0 commit comments