-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
597252b
commit a9773ac
Showing
4 changed files
with
80 additions
and
2 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
17 changes: 17 additions & 0 deletions
17
app/serializers/v1/progressive_billing_treshold_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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
class ProgressiveBillingTresholdSerializer < ModelSerializer | ||
def serialize | ||
{ | ||
lago_id: model.id, | ||
treshold_display_name: model.treshold_display_name, | ||
amount_cents: model.amount_cents, | ||
amount_currency: model.amount_currency, | ||
recurring: model.recurring, | ||
created_at: model.created_at.iso8601, | ||
updated_at: model.updated_at.iso8601 | ||
} | ||
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
25 changes: 25 additions & 0 deletions
25
spec/serializers/v1/progressive_billing_treshold_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,25 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe ::V1::ProgressiveBillingTresholdSerializer do | ||
subject(:serializer) { described_class.new(progressive_billing_treshold, root_name: 'progressive_billing_treshold') } | ||
|
||
let(:progressive_billing_treshold) { create(:progressive_billing_treshold) } | ||
|
||
it 'serializes the object' do | ||
result = JSON.parse(serializer.to_json) | ||
|
||
aggregate_failures do | ||
expect(result['progressive_billing_treshold']).to include( | ||
'lago_id' => progressive_billing_treshold.id, | ||
'treshold_display_name' => progressive_billing_treshold.treshold_display_name, | ||
'amount_cents' => progressive_billing_treshold.amount_cents, | ||
'amount_currency' => progressive_billing_treshold.amount_currency, | ||
'recurring' => progressive_billing_treshold.recurring?, | ||
'created_at' => progressive_billing_treshold.created_at.iso8601, | ||
'updated_at' => progressive_billing_treshold.updated_at.iso8601 | ||
) | ||
end | ||
end | ||
end |