debian-mirror-gitlab/spec/requests/projects/environments_controller_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

35 lines
1.2 KiB
Ruby
Raw Normal View History

2022-07-23 23:45:48 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe Projects::EnvironmentsController, feature_category: :continuous_delivery do
2022-08-13 15:12:31 +05:30
let_it_be_with_refind(:project) { create(:project, :repository) }
2022-07-23 23:45:48 +05:30
let(:environment) { create(:environment, name: 'production', project: project) }
describe 'GET #show' do
subject { get project_environment_path(project, environment) }
before do
sign_in(project.owner)
end
include_examples 'avoids N+1 queries on environment detail page'
end
def environment_params(opts = {})
2023-07-09 08:55:56 +05:30
opts.reverse_merge(namespace_id: project.namespace, project_id: project, id: environment.id)
2022-07-23 23:45:48 +05:30
end
def create_deployment_with_associations(commit_depth:)
commit = project.commit("HEAD~#{commit_depth}")
create(:user, email: commit.author_email) unless User.find_by(email: commit.author_email)
deployer = create(:user)
pipeline = create(:ci_pipeline, project: environment.project)
build = create(:ci_build, environment: environment.name, pipeline: pipeline, user: deployer)
2022-10-11 01:57:18 +05:30
create(:deployment, :success,
environment: environment, deployable: build, user: deployer, project: project, sha: commit.sha)
2022-07-23 23:45:48 +05:30
end
end