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 class DeploymentEntityDetailed < DeploymentEntity
include RequestAwareEntity
expose :id
expose :iid
expose :sha
expose :ref do expose :ref do
expose :name do |deployment|
deployment.ref
end
expose :ref_path do |deployment| expose :ref_path do |deployment|
namespace_project_tree_path( namespace_project_tree_path(
deployment.project.namespace, deployment.project.namespace,
...@@ -18,9 +8,6 @@ class DeploymentEntityDetailed < Grape::Entity ...@@ -18,9 +8,6 @@ class DeploymentEntityDetailed < Grape::Entity
end end
end end
expose :created_at
expose :tag
expose :last?
expose :user, using: UserEntity expose :user, using: UserEntity
expose :commit, using: CommitEntity expose :commit, using: CommitEntity
expose :deployable, using: BuildEntity 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' require 'spec_helper'
describe DeploymentEntityDetailed do describe DeploymentEntity do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:request) { double('request') } let(:request) { double('request') }
let(:deployment) { create(:deployment) }
let(:entity) { described_class.new(deployment, request: request) }
subject { entity.as_json }
before do before do
allow(request).to receive(:user).and_return(user) allow(request).to receive(:user).and_return(user)
end 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 it 'exposes internal deployment id' do
expect(subject).to include(:iid) expect(subject).to include(:iid)
end end
it 'exposes nested information about branch' do it 'exposes nested information about branch' do
expect(subject[:ref][:name]).to eq 'master' expect(subject[:ref][:name]).to eq 'master'
expect(subject[:ref][:ref_path]).not_to be_empty
end end
it 'exposes creation date' do 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