diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-10-10 20:38:48 +0200 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-10-14 11:07:01 +0200 |
commit | 88b03bb542a8480d61c260a9dc3769ab791995e5 (patch) | |
tree | 69017bb97fc5dd84e52a71ca526c9b59d0441956 | |
parent | 58368fbc53bfe7c2a9b425626819eae576afff09 (diff) | |
download | gitlab-ce-88b03bb542a8480d61c260a9dc3769ab791995e5.tar.gz |
Rename method in test
-rw-r--r-- | app/controllers/projects/merge_requests_controller.rb | 41 | ||||
-rw-r--r-- | config/routes.rb | 5 | ||||
-rw-r--r-- | spec/models/environment_spec.rb | 6 |
3 files changed, 31 insertions, 21 deletions
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index e17d560138f..5f7f46cf566 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 68dc84d9c9e..83c3a42c19f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index fb9629ac47a..e172ee8e590 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -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 |