jsonapi-realizer 2.0.0 → 2.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38b5321aa71d6cd99b39ddb9fb9a3e09679239a8eed202403a82fe0191d1eb06
4
- data.tar.gz: e0ff4d86639cef636a852196af3cca83d10e335eda4bbaf322e7b79f63da56f9
3
+ metadata.gz: 9e72cdbc01521b2454b71163a42709f62c44a0c68cb7278696d4b547a0d34dd9
4
+ data.tar.gz: ee5ba23558d88677206bef2564735d4d0f7050366bbf23fe702bd145b4b66b90
5
5
  SHA512:
6
- metadata.gz: 6bfa065c4d7b383210a0be470f5d95e497da056e4df74beb10ced42920d6e66c09d9b9025c2397a98bad14268d330faaa021320b8fbae0d8144be5d77c3d095b
7
- data.tar.gz: 9e2c5b864c0b3d067a88863bdc23f3bf839ecb3bb1da93b0423948f02e0b2dc8b8789cecb4bd1d677055ac0c83d5f25eb5c50b6bed7a60e8044dd2c299dfca3e
6
+ metadata.gz: ebd81b1e851ca61e8c1d8f29d4838b0a034b5475a18d16cd722f78a8020cb62f268d82c3d54ebcefabf3528021739698426580a5d870cd7b47fd92ceff12868b
7
+ data.tar.gz: e307d10a04c8384b76687dbe353540e983d93f480d6c31664e6f9dd87869f62d903312f5fd21a04cc22758b7908eaa8f739adfc14aa98ff6ef296733e37701db
@@ -6,9 +6,9 @@ RSpec.describe JSONAPI::Realizer::Action::Create do
6
6
  describe "#call" do
7
7
  subject { action.call }
8
8
 
9
- context "with no top-level data" do
10
-
11
- end
9
+ context "with no top-level data and good headers"
10
+ context "with no top-level data and bad headers"
11
+ context "with a good payload and bad headers"
12
12
 
13
13
  context "with a good payload and good headers" do
14
14
  let(:payload) do
@@ -6,9 +6,9 @@ RSpec.describe JSONAPI::Realizer::Action::Index do
6
6
  describe "#models" do
7
7
  subject { action.models }
8
8
 
9
- context "with no top-level data" do
10
-
11
- end
9
+ context "with no top-level data and good headers"
10
+ context "with no top-level data and bad headers"
11
+ context "with a good payload and bad headers"
12
12
 
13
13
  context "with a good payload and good headers" do
14
14
  let(:payload) do
@@ -6,9 +6,9 @@ RSpec.describe JSONAPI::Realizer::Action::Show do
6
6
  describe "#model" do
7
7
  subject { action.model }
8
8
 
9
- context "with no top-level data" do
10
-
11
- end
9
+ context "with no top-level data and good headers"
10
+ context "with no top-level data and bad headers"
11
+ context "with a good payload and bad headers"
12
12
 
13
13
  context "with a good payload and good headers" do
14
14
  let(:payload) do
@@ -6,9 +6,9 @@ RSpec.describe JSONAPI::Realizer::Action::Update do
6
6
  describe "#call" do
7
7
  subject { action.call }
8
8
 
9
- context "with no top-level data" do
10
-
11
- end
9
+ context "with no top-level data and good headers"
10
+ context "with no top-level data and bad headers"
11
+ context "with a good payload and bad headers"
12
12
 
13
13
  context "with a good payload and good headers" do
14
14
  let(:payload) do
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Realizer
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
@@ -34,18 +34,18 @@ module JSONAPI
34
34
  end
35
35
 
36
36
  def self.update(payload, headers:)
37
- enact(Update.new(payload: payload, headers: headers))
37
+ enact(Action::Update.new(payload: payload, headers: headers))
38
38
  end
39
39
 
40
40
  def self.show(payload, headers:, type:)
41
- enact(Show.new(payload: payload, headers: headers, type: type))
41
+ enact(Action::Show.new(payload: payload, headers: headers, type: type))
42
42
  end
43
43
 
44
44
  def self.index(payload, headers:, type:)
45
- enact(Index.new(payload: payload, headers: headers, type: type))
45
+ enact(Action::Index.new(payload: payload, headers: headers, type: type))
46
46
  end
47
47
 
48
- private_class_method def self.inact(action)
48
+ private_class_method def self.enact(action)
49
49
  action.tap(&:call)
50
50
  end
51
51
  end
@@ -1,6 +1,85 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe JSONAPI::Realizer do
4
- it "on create generates a model with a relationship and a client id" do
4
+ describe ".index" do
5
+ subject { JSONAPI::Realizer.index(payload, headers: headers, type: type) }
6
+
7
+ context "with no top-level data and good headers"
8
+ context "with no top-level data and bad headers"
9
+ context "with a good payload and bad headers"
10
+
11
+ context "with a good payload and good headers" do
12
+ let(:payload) do
13
+ {}
14
+ end
15
+ let(:headers) do
16
+ {
17
+ "Content-Type" => "application/vnd.api+json",
18
+ "Accept" => "application/vnd.api+json"
19
+ }
20
+ end
21
+ let(:type) do
22
+ :photos
23
+ end
24
+
25
+ before do
26
+ Photo::STORE["550e8400-e29b-41d4-a716-446655440000"] = {
27
+ id: "550e8400-e29b-41d4-a716-446655440000",
28
+ title: "Ember Hamster",
29
+ src: "http://example.com/images/productivity.png"
30
+ }
31
+ Photo::STORE["d09ae4c6-0fc3-4c42-8fe8-6029530c3bed"] = {
32
+ id: "d09ae4c6-0fc3-4c42-8fe8-6029530c3bed",
33
+ title: "Ember Fox",
34
+ src: "http://example.com/images/productivity-2.png"
35
+ }
36
+ end
37
+
38
+ it "returns an action that has N models" do
39
+ expect(subject).to have_attributes(models: array_including(a_kind_of(Photo)))
40
+ end
41
+ end
42
+ end
43
+
44
+ describe ".show" do
45
+ subject { JSONAPI::Realizer.show(payload, headers: headers, type: type) }
46
+
47
+ context "with no top-level data and good headers"
48
+ context "with no top-level data and bad headers"
49
+ context "with a good payload and bad headers"
50
+
51
+ context "with a good payload and good headers" do
52
+ let(:payload) do
53
+ {
54
+ "id" => "d09ae4c6-0fc3-4c42-8fe8-6029530c3bed"
55
+ }
56
+ end
57
+ let(:headers) do
58
+ {
59
+ "Content-Type" => "application/vnd.api+json",
60
+ "Accept" => "application/vnd.api+json"
61
+ }
62
+ end
63
+ let(:type) do
64
+ :photos
65
+ end
66
+
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
+ Photo::STORE["d09ae4c6-0fc3-4c42-8fe8-6029530c3bed"] = {
74
+ id: "d09ae4c6-0fc3-4c42-8fe8-6029530c3bed",
75
+ title: "Ember Fox",
76
+ src: "http://example.com/images/productivity-2.png"
77
+ }
78
+ end
79
+
80
+ it "returns an action that a model" do
81
+ expect(subject).to have_attributes(model: a_kind_of(Photo))
82
+ end
83
+ end
5
84
  end
6
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-realizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene