about summary refs log tree commit diff
path: root/spec/serializers/rest/keys
diff options
context:
space:
mode:
Diffstat (limited to 'spec/serializers/rest/keys')
-rw-r--r--spec/serializers/rest/keys/claim_result_serializer_spec.rb20
-rw-r--r--spec/serializers/rest/keys/device_serializer_spec.rb20
-rw-r--r--spec/serializers/rest/keys/query_result_serializer_spec.rb20
3 files changed, 60 insertions, 0 deletions
diff --git a/spec/serializers/rest/keys/claim_result_serializer_spec.rb b/spec/serializers/rest/keys/claim_result_serializer_spec.rb
new file mode 100644
index 000000000..cf9416f03
--- /dev/null
+++ b/spec/serializers/rest/keys/claim_result_serializer_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe REST::Keys::ClaimResultSerializer do
+  let(:serialization) do
+    JSON.parse(
+      ActiveModelSerializers::SerializableResource.new(
+        record, serializer: described_class
+      ).to_json
+    )
+  end
+  let(:record) { Keys::ClaimService::Result.new(Account.new(id: 123), 456) }
+
+  describe 'account' do
+    it 'returns the associated account' do
+      expect(serialization['account_id']).to eq('123')
+    end
+  end
+end
diff --git a/spec/serializers/rest/keys/device_serializer_spec.rb b/spec/serializers/rest/keys/device_serializer_spec.rb
new file mode 100644
index 000000000..c15e197cb
--- /dev/null
+++ b/spec/serializers/rest/keys/device_serializer_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe REST::Keys::DeviceSerializer do
+  let(:serialization) do
+    JSON.parse(
+      ActiveModelSerializers::SerializableResource.new(
+        record, serializer: described_class
+      ).to_json
+    )
+  end
+  let(:record) { Device.new(name: 'Device name') }
+
+  describe 'name' do
+    it 'returns the name' do
+      expect(serialization['name']).to eq('Device name')
+    end
+  end
+end
diff --git a/spec/serializers/rest/keys/query_result_serializer_spec.rb b/spec/serializers/rest/keys/query_result_serializer_spec.rb
new file mode 100644
index 000000000..983780ae9
--- /dev/null
+++ b/spec/serializers/rest/keys/query_result_serializer_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+describe REST::Keys::QueryResultSerializer do
+  let(:serialization) do
+    JSON.parse(
+      ActiveModelSerializers::SerializableResource.new(
+        record, serializer: described_class
+      ).to_json
+    )
+  end
+  let(:record) { Keys::QueryService::Result.new(Account.new(id: 123), []) }
+
+  describe 'account' do
+    it 'returns the associated account id' do
+      expect(serialization['account_id']).to eq('123')
+    end
+  end
+end