-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GL-465 Incorporate pseudo exemptions in serialized output
- Loading branch information
Showing
10 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Api | ||
module V2 | ||
module GreenLanes | ||
class ExemptionPresenter < WrapDelegator | ||
def id | ||
code | ||
end | ||
|
||
def formatted_description | ||
description | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/serializers/api/v2/green_lanes/exemption_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Api | ||
module V2 | ||
module GreenLanes | ||
class ExemptionSerializer | ||
include JSONAPI::Serializer | ||
|
||
set_id :code | ||
|
||
attributes :code, | ||
:description, | ||
:formatted_description | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
spec/presenters/api/v2/green_lanes/exemption_presenter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
RSpec.describe Api::V2::GreenLanes::ExemptionPresenter do | ||
subject { described_class.new(exemption) } | ||
|
||
let(:exemption) { create :green_lanes_exemption } | ||
|
||
it { is_expected.to have_attributes id: exemption.code } | ||
it { is_expected.to have_attributes code: exemption.code } | ||
it { is_expected.to have_attributes description: exemption.description } | ||
it { is_expected.to have_attributes formatted_description: exemption.description } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
spec/serializers/api/v2/green_lanes/exemption_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
RSpec.describe Api::V2::GreenLanes::ExemptionSerializer do | ||
subject { described_class.new(presented).serializable_hash.as_json } | ||
|
||
let(:exemption) { create :green_lanes_exemption } | ||
let(:presented) { Api::V2::GreenLanes::ExemptionPresenter.new exemption } | ||
|
||
let(:expected_pattern) do | ||
{ | ||
data: { | ||
id: exemption.code, | ||
type: 'exemption', | ||
attributes: { | ||
code: exemption.code, | ||
description: exemption.description, | ||
formatted_description: exemption.description, | ||
}, | ||
}, | ||
} | ||
end | ||
|
||
it { is_expected.to include_json(expected_pattern) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters