Cleanup duplicates in deploymentEntityDetailed and add small spec tests
This commit is contained in:
parent
4469946105
commit
e8f2daae8e
3 changed files with 31 additions and 24 deletions
|
@ -1,15 +1,5 @@
|
|||
class DeploymentEntityDetailed < Grape::Entity
|
||||
include RequestAwareEntity
|
||||
|
||||
expose :id
|
||||
expose :iid
|
||||
expose :sha
|
||||
|
||||
class DeploymentEntityDetailed < DeploymentEntity
|
||||
expose :ref do
|
||||
expose :name do |deployment|
|
||||
deployment.ref
|
||||
end
|
||||
|
||||
expose :ref_path do |deployment|
|
||||
namespace_project_tree_path(
|
||||
deployment.project.namespace,
|
||||
|
@ -18,9 +8,6 @@ class DeploymentEntityDetailed < Grape::Entity
|
|||
end
|
||||
end
|
||||
|
||||
expose :created_at
|
||||
expose :tag
|
||||
expose :last?
|
||||
expose :user, using: UserEntity
|
||||
expose :commit, using: CommitEntity
|
||||
expose :deployable, using: BuildEntity
|
||||
|
|
26
spec/serializers/deployment_entity_detailed_spec.rb
Normal file
26
spec/serializers/deployment_entity_detailed_spec.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DeploymentEntityDetailed do
|
||||
let(:user) { create(:user) }
|
||||
let(:request) { double('request') }
|
||||
let(:deployment) { create(:deployment) }
|
||||
let(:entity) { described_class.new(deployment, request: request) }
|
||||
subject { entity.as_json }
|
||||
|
||||
before do
|
||||
allow(request).to receive(:user).and_return(user)
|
||||
end
|
||||
|
||||
it 'exposes internal deployment id' do
|
||||
expect(subject).to include(:iid)
|
||||
end
|
||||
|
||||
it 'exposes nested information about branch' do
|
||||
expect(subject[:ref][:name]).to eq 'master'
|
||||
expect(subject[:ref][:ref_path]).not_to be_empty
|
||||
end
|
||||
|
||||
it 'exposes creation date' do
|
||||
expect(subject).to include(:created_at)
|
||||
end
|
||||
end
|
|
@ -1,28 +1,22 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe DeploymentEntityDetailed do
|
||||
describe DeploymentEntity do
|
||||
let(:user) { create(:user) }
|
||||
let(:request) { double('request') }
|
||||
let(:deployment) { create(:deployment) }
|
||||
let(:entity) { described_class.new(deployment, request: request) }
|
||||
subject { entity.as_json }
|
||||
|
||||
before do
|
||||
allow(request).to receive(:user).and_return(user)
|
||||
end
|
||||
|
||||
let(:entity) do
|
||||
described_class.new(deployment, request: request)
|
||||
end
|
||||
|
||||
let(:deployment) { create(:deployment) }
|
||||
|
||||
subject { entity.as_json }
|
||||
|
||||
it 'exposes internal deployment id' do
|
||||
expect(subject).to include(:iid)
|
||||
end
|
||||
|
||||
it 'exposes nested information about branch' do
|
||||
expect(subject[:ref][:name]).to eq 'master'
|
||||
expect(subject[:ref][:ref_path]).not_to be_empty
|
||||
end
|
||||
|
||||
it 'exposes creation date' do
|
||||
|
|
Loading…
Reference in a new issue