BigW Consortium Gitlab

Commit 88b03bb5 by Z.J. van de Weg

Rename method in test

parent 58368fbc
......@@ -404,29 +404,34 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end
def ci_environments_status
render json: @merge_request.environments.map do |environment|
next unless can?(current_user, :read_environment, environment)
deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
environments =
begin
@merge_request.environments.map do |environment|
next unless can?(current_user, :read_environment, environment)
deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
environment_data = {
name: environment.name,
id: environment.id,
url: namespace_project_environment_path(@project.namespace, @project, environment),
external_url: environment.external_url,
deployed_at: deployment ? deployment.created_at : nil
}
environment_data = {
name: environment.name,
id: environment.id,
url: namespace_project_environment_path(@project.namespace, @project, environment),
external_url: environment.external_url,
deployed_at: deployment ? deployment.created_at : nil
}
if environment_data[:external_url]
environment_data[:external_url_formatted] = environment_data[:external_url].gsub(/\A.*?:\/\//, '')
end
if environment_data[:external_url]
environment_data[:external_url_formatted] = environment_data[:external_url].gsub(/\A.*?:\/\//, '')
end
if environment_data[:deployed_at]
environment_data[:deployed_at_formatted] = environment_data[:deployed_at].to_time.in_time_zone.to_s(:medium)
end
if environment_data[:deployed_at]
environment_data[:deployed_at_formatted] = environment_data[:deployed_at].to_time.in_time_zone.to_s(:medium)
environment_data
end.compact
end
environment_data
end.compact
render json: environments
end
protected
......
......@@ -83,4 +83,9 @@ Rails.application.routes.draw do
draw :group
draw :user
draw :project
# Get all keys of user
get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: /.*/ }
root to: "root#index"
end
......@@ -64,7 +64,7 @@ describe Environment, models: true do
end
end
describe '#deployment_id_for' do
describe '#first_deployment_for' do
let(:project) { create(:project) }
let!(:environment) { create(:environment, project: project) }
let!(:deployment) { create(:deployment, environment: environment, ref: commit.parent.id) }
......@@ -73,11 +73,11 @@ describe Environment, models: true do
let(:commit) { project.commit.parent }
it 'returns deployment id for the environment' do
expect(environment.deployment_id_for(commit)).to eq deployment1.id
expect(environment.first_deployment_for(commit)).to eq deployment1
end
it 'return nil when no deployment is found' do
expect(environment.deployment_id_for(head_commit)).to eq nil
expect(environment.first_deployment_for(head_commit)).to eq nil
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