Commit c3dae798 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extend tests for environments serializer

parent 7dd6485a
......@@ -10,7 +10,7 @@ class EnvironmentEntity < Grape::Entity
expose :last_deployment, using: DeploymentEntity
expose :stoppable?
expose :environmenturl do |environment|
expose :environment_url do |environment|
@urls.namespace_project_environment_url(
environment.project.namespace,
environment.project,
......
......@@ -24,21 +24,30 @@ describe EnvironmentSerializer do
let(:project) { deployment.project }
let(:resource) { deployment.environment }
it 'shows json' do
pp serializer.as_json
end
it 'it generates payload for single object' do
expect(serializer.as_json).to be_an_instance_of Hash
end
it 'contains important elements of environment' do
expect(serializer.as_json)
.to include(:name, :external_url, :environment_url, :last_deployment)
end
it 'contains relevant information about last deployment' do
last_deployment = serializer.as_json.fetch(:last_deployment)
expect(last_deployment)
.to include(:ref, :user, :commit, :deployable, :manual_actions)
end
end
context 'when there is a collection of objects provided' do
let(:project) { create(:empty_project) }
let(:resource) { create_list(:environment, 2) }
it 'shows json' do
puts serializer.as_json
it 'contains important elements of environment' do
expect(serializer.as_json.first)
.to include(:last_deployment, :name, :external_url)
end
it 'generates payload for collection' 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