summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-06-06 20:13:18 +1200
committercharlieablett <cablett@gitlab.com>2019-06-06 22:13:14 +1200
commit27dd0b8e3609aae92b8e59dd202a999fc1db5a4e (patch)
tree29728e4b5e439b1f284cb6a4f31d73749e808c25 /spec
parent7468ed5fd28d08907384787d657d2bbe9af77411 (diff)
downloadgitlab-ce-27dd0b8e3609aae92b8e59dd202a999fc1db5a4e.tar.gz
Use serialization for project boards
- Add serializers and Grape::Entity - Replace to_json - Add specs
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/concerns/boards_responses_spec.rb23
-rw-r--r--spec/serializers/board_serializer_spec.rb20
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/controllers/concerns/boards_responses_spec.rb b/spec/controllers/concerns/boards_responses_spec.rb
new file mode 100644
index 00000000000..1c837fe8755
--- /dev/null
+++ b/spec/controllers/concerns/boards_responses_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BoardsResponses do
+ let(:controller_class) do
+ Class.new do
+ include BoardsResponses
+ end
+ end
+
+ subject(:controller) { controller_class.new }
+
+ describe '#serialize_as_json' do
+ let!(:board) { create(:board) }
+
+ it 'serializes properly' do
+ expected = { id: board.id }
+
+ expect(subject.serialize_as_json(board).to_h).to include(expected)
+ end
+ end
+end
diff --git a/spec/serializers/board_serializer_spec.rb b/spec/serializers/board_serializer_spec.rb
new file mode 100644
index 00000000000..8a633e46316
--- /dev/null
+++ b/spec/serializers/board_serializer_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BoardSerializer do
+ let(:resource) { create(:board) }
+ let(:json_entity) do
+ described_class.new
+ .represent(resource, serializer: serializer)
+ .with_indifferent_access
+ end
+
+ context 'serialization' do
+ let(:serializer) { 'board' }
+
+ it 'matches issue_sidebar json schema' do
+ expect(json_entity).to match_schema('board')
+ end
+ end
+end