Skip to content

Commit cec1b1d

Browse files
committed
Show creation with relation test failure
1 parent 3c8edef commit cec1b1d

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

test/unit/creation_test.rb

-38
Original file line numberDiff line numberDiff line change
@@ -272,42 +272,4 @@ def test_callbacks_on_update
272272
callback_test = CallbackTest.create({foo: 1, bar: 1})
273273
assert_equal 100, callback_test.bar
274274
end
275-
276-
def test_create_with_relationships_in_payload
277-
stub_request(:post, 'http://example.com/articles')
278-
.with(headers: {content_type: 'application/vnd.api+json', accept: 'application/vnd.api+json'}, body: {
279-
data: {
280-
type: 'articles',
281-
attributes: {
282-
title: 'Rails is Omakase'
283-
},
284-
relationships: {
285-
comments: {
286-
data: [
287-
{
288-
id: '2',
289-
type: 'comments'
290-
}
291-
]
292-
}
293-
}
294-
}
295-
}.to_json)
296-
.to_return(headers: {content_type: 'application/vnd.api+json'}, body: {
297-
data: {
298-
type: 'articles',
299-
id: '1',
300-
attributes: {
301-
title: 'Rails is Omakase'
302-
}
303-
}
304-
}.to_json)
305-
306-
article = Article.new(title: 'Rails is Omakase', relationships: {comments: [Comment.new(id: 2)]})
307-
308-
assert article.save
309-
assert article.persisted?
310-
assert_equal "1", article.id
311-
end
312-
313275
end
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'test_helper'
2+
3+
class CreationWithRelationTest < MiniTest::Test
4+
def test_create_with_relationships_in_payload
5+
stub_request(:post, 'http://example.com/articles')
6+
.with(headers: {content_type: 'application/vnd.api+json', accept: 'application/vnd.api+json'}, body: {
7+
data: {
8+
type: 'articles',
9+
attributes: {
10+
title: 'Rails is Omakase'
11+
},
12+
relationships: {
13+
comments: {
14+
data: [
15+
{
16+
id: '2',
17+
type: 'comments'
18+
}
19+
]
20+
}
21+
}
22+
}
23+
}.to_json)
24+
.to_return(headers: {content_type: 'application/vnd.api+json'}, body: {
25+
data: {
26+
type: 'articles',
27+
id: '1',
28+
attributes: {
29+
title: 'Rails is Omakase'
30+
}
31+
}
32+
}.to_json)
33+
34+
article = Article.new(title: 'Rails is Omakase', relationships: {comments: [Comment.new(id: 2)]})
35+
36+
assert article.save
37+
assert article.persisted?
38+
assert_equal "1", article.id
39+
end
40+
end

0 commit comments

Comments
 (0)