BigW Consortium Gitlab

Commit a2c1178c by Grzegorz Bizon

Expose commit author if author exists

parent f203ca5c
class CommitEntity < API::Entities::RepoCommit class CommitEntity < API::Entities::RepoCommit
include RequestAwareEntity include RequestAwareEntity
expose :author, using: API::Entities::UserBasic
expose :commit_url do |commit| expose :commit_url do |commit|
@urls.namespace_project_tree_url( @urls.namespace_project_tree_url(
@request.project.namespace, @request.project.namespace,
......
...@@ -7,6 +7,7 @@ describe EnvironmentSerializer do ...@@ -7,6 +7,7 @@ describe EnvironmentSerializer do
.represent(resource) .represent(resource)
end end
let(:json) { serializer.as_json }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
...@@ -27,16 +28,16 @@ describe EnvironmentSerializer do ...@@ -27,16 +28,16 @@ describe EnvironmentSerializer do
let(:resource) { deployment.environment } let(:resource) { deployment.environment }
it 'it generates payload for single object' do it 'it generates payload for single object' do
expect(serializer.as_json).to be_an_instance_of Hash expect(json).to be_an_instance_of Hash
end end
it 'contains important elements of environment' do it 'contains important elements of environment' do
expect(serializer.as_json) expect(json)
.to include(:name, :external_url, :environment_url, :last_deployment) .to include(:name, :external_url, :environment_url, :last_deployment)
end end
it 'contains relevant information about last deployment' do it 'contains relevant information about last deployment' do
last_deployment = serializer.as_json.fetch(:last_deployment) last_deployment = json.fetch(:last_deployment)
expect(last_deployment) expect(last_deployment)
.to include(:ref, :user, :commit, :deployable, :manual_actions) .to include(:ref, :user, :commit, :deployable, :manual_actions)
...@@ -48,12 +49,12 @@ describe EnvironmentSerializer do ...@@ -48,12 +49,12 @@ describe EnvironmentSerializer do
let(:resource) { create_list(:environment, 2) } let(:resource) { create_list(:environment, 2) }
it 'contains important elements of environment' do it 'contains important elements of environment' do
expect(serializer.as_json.first) expect(json.first)
.to include(:last_deployment, :name, :external_url) .to include(:last_deployment, :name, :external_url)
end end
it 'generates payload for collection' do it 'generates payload for collection' do
expect(serializer.as_json).to be_an_instance_of Array expect(json).to be_an_instance_of Array
end end
end end
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