Commit f1bf6c2b authored by Vijay Hawoldar's avatar Vijay Hawoldar Committed by Douglas Barbosa Alexandre

Add Ci::Minutes::AdditionalPack Grape entity

In order to return additional pack objects to API requests, we
require a new entity to represent the new model.
parent c6e6f50c
# frozen_string_literal: true
module EE
module API
module Entities
module Ci
module Minutes
class AdditionalPack < Grape::Entity
expose :namespace_id
expose :expires_at
expose :number_of_minutes
expose :purchase_xid
end
end
end
end
end
end
# frozen_string_literal: true
FactoryBot.define do
factory :ci_minutes_additional_pack, class: 'Ci::Minutes::AdditionalPack' do
namespace
number_of_minutes { 10_000 }
expires_at { Date.current + 1.year }
purchase_xid { SecureRandom.hex(16) }
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::EE::API::Entities::Ci::Minutes::AdditionalPack do
it 'contains the correct attributes', :aggregate_failures do
pack = build(:ci_minutes_additional_pack)
entity = described_class.new(pack).as_json
expect(entity[:expires_at]).to eq pack.expires_at
expect(entity[:namespace_id]).to eq pack.namespace_id
expect(entity[:number_of_minutes]).to eq pack.number_of_minutes
expect(entity[:purchase_xid]).to eq pack.purchase_xid
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment