Skip to content

Commit 7151d9e

Browse files
authored
[4.1-stable] feat: Add IngredientColorSerializer (#157) (#158)
# Backport This will backport the following commits from `main` to `4.1-stable`: - [feat: Add IngredientColorSerializer (#157)](#157) <!--- Backport version: 9.5.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport)
2 parents 3f6f164 + 5a13241 commit 7151d9e

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
require "alchemy/json_api/ingredient_serializer"
4+
5+
module Alchemy
6+
module JsonApi
7+
class IngredientColorSerializer < BaseSerializer
8+
include IngredientSerializer
9+
end
10+
end
11+
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# frozen_string_literal: true
2+
3+
require "rails_helper"
4+
5+
RSpec.describe Alchemy::JsonApi::IngredientColorSerializer do
6+
let(:ingredient) do
7+
Alchemy::Ingredients::Color.new(role: "color", value: "green")
8+
end
9+
10+
subject(:serializer) { described_class.new(ingredient) }
11+
12+
it_behaves_like "an ingredient serializer"
13+
14+
describe "attributes" do
15+
subject { serializer.serializable_hash[:data][:attributes] }
16+
17+
it "has the right keys and values" do
18+
expect(subject[:value]).to eq("green")
19+
end
20+
end
21+
end

0 commit comments

Comments
 (0)