Commit cf15af31 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Add test, fix merge error

parent 6e509ae3
......@@ -409,12 +409,13 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.environments.map do |environment|
next unless can?(current_user, :read_environment, environment)
project = environment.project
deployment = environment.first_deployment_for(@merge_request.diff_head_commit)
{
id: environment.id,
name: environment.name,
url: namespace_project_environment_path(@project.namespace, @project, environment),
url: namespace_project_environment_path(project.namespace, project, environment),
external_url: environment.external_url,
external_url_formatted: environment.formatted_external_url,
deployed_at: deployment.try(:created_at),
......
......@@ -446,17 +446,6 @@ ActiveRecord::Schema.define(version: 20161007133303) do
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
create_table "integrations", force: :cascade do |t|
t.integer "project_id"
t.string "name"
t.string "external_token"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "integrations", ["external_token"], name: "index_integrations_on_external_token", unique: true, using: :btree
add_index "integrations", ["project_id"], name: "index_integrations_on_project_id", using: :btree
create_table "issue_metrics", force: :cascade do |t|
t.integer "issue_id", null: false
t.datetime "first_mentioned_in_commit_at"
......@@ -624,6 +613,7 @@ ActiveRecord::Schema.define(version: 20161007133303) do
t.datetime "updated_at", null: false
end
add_index "merge_request_metrics", ["first_deployed_to_production_at"], name: "index_merge_request_metrics_on_first_deployed_to_production_at", using: :btree
add_index "merge_request_metrics", ["merge_request_id"], name: "index_merge_request_metrics", using: :btree
create_table "merge_requests", force: :cascade do |t|
......
......@@ -756,4 +756,34 @@ describe Projects::MergeRequestsController do
post_assign_issues
end
end
describe 'GET ci_environments_status' do
context 'when the environment is from a forked project' do
let!(:forked) { create(:project) }
let!(:environment) { create(:environment, project: forked) }
let!(:deployment) { create(:deployment, environment: environment, sha: forked.commit.id, ref: 'master') }
let(:json_response) { JSON.parse(response.body) }
let(:admin) { create(:admin) }
let(:merge_request) do
create(:forked_project_link, forked_to_project: forked,
forked_from_project: project)
create(:merge_request, source_project: forked, target_project: project)
end
before do
forked.team << [user, :master]
get :ci_environments_status,
namespace_id: merge_request.project.namespace.to_param,
project_id: merge_request.project.to_param,
id: merge_request.iid, format: 'json'
end
it 'links to the environment on that project' do
expect(json_response.first['url']).to match /#{forked.path_with_namespace}/
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