Commit e8f2daae authored by Pawel Chojnacki's avatar Pawel Chojnacki

Cleanup duplicates in deploymentEntityDetailed and add small spec tests

parent 44699461
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
......
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
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
......
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