diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2017-05-05 22:47:32 +0000 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2017-05-05 22:47:32 +0000 |
commit | b51f2a60800829ee7585f10451a41bc4db0359a9 (patch) | |
tree | 2ea7ea74e3fa867b2eadf5ffc8652022b25b2321 /spec/serializers | |
parent | 9e041f2185ecb957e1f3d1205ea3bac54a5eb803 (diff) | |
download | gitlab-ce-b51f2a60800829ee7585f10451a41bc4db0359a9.tar.gz |
Colorize labels in issue search field
Diffstat (limited to 'spec/serializers')
-rw-r--r-- | spec/serializers/label_serializer_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/serializers/label_serializer_spec.rb b/spec/serializers/label_serializer_spec.rb new file mode 100644 index 00000000000..c58c7da1f9e --- /dev/null +++ b/spec/serializers/label_serializer_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe LabelSerializer do + let(:user) { create(:user) } + + let(:serializer) do + described_class.new(user: user) + end + + subject { serializer.represent(resource) } + + describe '#represent' do + context 'when a single object is being serialized' do + let(:resource) { create(:label) } + + it 'serializes the label object' do + expect(subject[:id]).to eq resource.id + end + end + + context 'when multiple objects are being serialized' do + let(:num_labels) { 2 } + let(:resource) { create_list(:label, num_labels) } + + it 'serializes the array of labels' do + expect(subject.size).to eq(num_labels) + end + end + end + + describe '#represent_appearance' do + context 'when represents only appearance' do + let(:resource) { create(:label) } + + subject { serializer.represent_appearance(resource) } + + it 'serializes only attributes used for appearance' do + expect(subject.keys).to eq([:id, :title, :color, :text_color]) + expect(subject[:id]).to eq(resource.id) + expect(subject[:title]).to eq(resource.title) + expect(subject[:color]).to eq(resource.color) + expect(subject[:text_color]).to eq(resource.text_color) + end + end + end +end |