jsonapi-realizer 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jsonapi/realizer/version.rb +1 -1
- data/lib/jsonapi/realizer.rb +1 -1
- data/lib/jsonapi/realizer_spec.rb +47 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02f40c79b4a4ecf49431c220d161c065737e744f420250dec013011c11647af5
|
4
|
+
data.tar.gz: 923505a0c13a519bf0db6aa7b2ce260884a9bfd309476987e32e802f0affc0bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6c3c50ddb0321258311a199b4e2c4eb7946ec35981865696662cad16563d40bbdb8d745f9e215cfb5fdc894fa54897410cf3bf347ac7eeb14015271a74f38e5
|
7
|
+
data.tar.gz: 710585e9ed18604598d2eb52ac48e935ae3cfb85f462b84284fee06a2d660f2df3b6896a33ce3ba86a063843de28b5ea07c18e132666cda3e511e841fef9fcac
|
data/lib/jsonapi/realizer.rb
CHANGED
@@ -36,7 +36,7 @@ RSpec.describe JSONAPI::Realizer do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "returns an action that has N models" do
|
39
|
-
expect(subject).to have_attributes(models:
|
39
|
+
expect(subject).to have_attributes(models: [a_kind_of(Photo), a_kind_of(Photo)])
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -65,11 +65,6 @@ RSpec.describe JSONAPI::Realizer do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
before do
|
68
|
-
Photo::STORE["550e8400-e29b-41d4-a716-446655440000"] = {
|
69
|
-
id: "550e8400-e29b-41d4-a716-446655440000",
|
70
|
-
title: "Ember Hamster",
|
71
|
-
src: "http://example.com/images/productivity.png"
|
72
|
-
}
|
73
68
|
Photo::STORE["d09ae4c6-0fc3-4c42-8fe8-6029530c3bed"] = {
|
74
69
|
id: "d09ae4c6-0fc3-4c42-8fe8-6029530c3bed",
|
75
70
|
title: "Ember Fox",
|
@@ -82,4 +77,50 @@ RSpec.describe JSONAPI::Realizer do
|
|
82
77
|
end
|
83
78
|
end
|
84
79
|
end
|
80
|
+
|
81
|
+
describe ".create" do
|
82
|
+
subject { JSONAPI::Realizer.create(payload, headers: headers) }
|
83
|
+
|
84
|
+
context "with no top-level data and good headers"
|
85
|
+
context "with no top-level data and bad headers"
|
86
|
+
context "with a good payload and bad headers"
|
87
|
+
|
88
|
+
context "with a good payload and good headers" do
|
89
|
+
let(:payload) do
|
90
|
+
{
|
91
|
+
"data" => {
|
92
|
+
"id" => "550e8400-e29b-41d4-a716-446655440000",
|
93
|
+
"type" => "photos",
|
94
|
+
"attributes" => {
|
95
|
+
"title" => "Ember Hamster",
|
96
|
+
"alt-text" => "A hamster logo.",
|
97
|
+
"src" => "http://example.com/images/productivity.png"
|
98
|
+
},
|
99
|
+
"relationships" => {
|
100
|
+
"active-photographer" => {
|
101
|
+
"data" => { "type" => "photographer-people", "id" => "4b8a0af6-953d-4729-8b9a-1fa4eb18f3c9" }
|
102
|
+
}
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
end
|
107
|
+
let(:headers) do
|
108
|
+
{
|
109
|
+
"Content-Type" => "application/vnd.api+json",
|
110
|
+
"Accept" => "application/vnd.api+json"
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
114
|
+
before do
|
115
|
+
People::STORE["4b8a0af6-953d-4729-8b9a-1fa4eb18f3c9"] = {
|
116
|
+
id: "4b8a0af6-953d-4729-8b9a-1fa4eb18f3c9",
|
117
|
+
name: "Kurtis Rainbolt-Greene"
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
121
|
+
it "returns an action that a model" do
|
122
|
+
expect(subject).to have_attributes(model: a_kind_of(Photo))
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
85
126
|
end
|