Skip to content
Snippets Groups Projects
Commit 2f536c6f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets Committed by Dmytro Zaporozhets
Browse files

Rename find to execute in EnvironmentsFinder


To follow the same naming other finders have

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Signed-off-by: default avatarDmytro Zaporozhets <dzaporozhets@gitlab.com>
parent 3334ec9a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -58,7 +58,7 @@ def elasticsearch_params
def environment
strong_memoize(:environment) do
if cluster_params.key?(:environment_name)
EnvironmentsFinder.new(project, current_user, name: cluster_params[:environment_name]).find.first
EnvironmentsFinder.new(project, current_user, name: cluster_params[:environment_name]).execute.first
else
project.default_environment
end
Loading
Loading
Loading
Loading
@@ -9,12 +9,7 @@ def initialize(project, current_user, params = {})
@project, @current_user, @params = project, current_user, params
end
 
# This method will eventually take the place of `#execute` as an
# efficient way to get relevant environment entries.
# Currently, `#execute` method has a serious technical debt and
# we will likely rework on it in the future.
# See more https://gitlab.com/gitlab-org/gitlab-foss/issues/63381
def find
def execute
environments = project.environments
environments = by_name(environments)
environments = by_search(environments)
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ class EnvironmentsResolver < BaseResolver
def resolve(**args)
return unless project.present?
 
EnvironmentsFinder.new(project, context[:current_user], args).find
EnvironmentsFinder.new(project, context[:current_user], args).execute
rescue EnvironmentsFinder::InvalidStatesError => exception
raise Gitlab::Graphql::Errors::ArgumentError, exception.message
end
Loading
Loading
Loading
Loading
@@ -84,7 +84,7 @@ def alerts_by_identifier(environment)
 
def environment
strong_memoize(:environment) do
EnvironmentsFinder.new(project, nil, name: 'production').find.first ||
EnvironmentsFinder.new(project, nil, name: 'production').execute.first ||
project.environments.first
end
end
Loading
Loading
Loading
Loading
@@ -26,7 +26,7 @@ class Environments < ::API::Base
get ':id/environments' do
authorize! :read_environment, user_project
 
environments = ::EnvironmentsFinder.new(user_project, current_user, params).find
environments = ::EnvironmentsFinder.new(user_project, current_user, params).execute
 
present paginate(environments), with: Entities::Environment, current_user: current_user
end
Loading
Loading
Loading
Loading
@@ -132,7 +132,7 @@ def environment
 
EnvironmentsFinder
.new(project, nil, { name: environment_name })
.find
.execute
.first
end
end
Loading
Loading
Loading
Loading
@@ -11,37 +11,37 @@
project.add_maintainer(user)
end
 
describe '#find' do
describe '#execute' do
context 'with states parameter' do
let(:stopped_environment) { create(:environment, :stopped, project: project) }
 
it 'returns environments with the requested state' do
result = described_class.new(project, user, states: 'available').find
result = described_class.new(project, user, states: 'available').execute
 
expect(result).to contain_exactly(environment)
end
 
it 'returns environments with any of the requested states' do
result = described_class.new(project, user, states: %w(available stopped)).find
result = described_class.new(project, user, states: %w(available stopped)).execute
 
expect(result).to contain_exactly(environment, stopped_environment)
end
 
it 'raises exception when requested state is invalid' do
expect { described_class.new(project, user, states: %w(invalid stopped)).find }.to(
expect { described_class.new(project, user, states: %w(invalid stopped)).execute }.to(
raise_error(described_class::InvalidStatesError, 'Requested states are invalid')
)
end
 
context 'works with symbols' do
it 'returns environments with the requested state' do
result = described_class.new(project, user, states: :available).find
result = described_class.new(project, user, states: :available).execute
 
expect(result).to contain_exactly(environment)
end
 
it 'returns environments with any of the requested states' do
result = described_class.new(project, user, states: [:available, :stopped]).find
result = described_class.new(project, user, states: [:available, :stopped]).execute
 
expect(result).to contain_exactly(environment, stopped_environment)
end
Loading
Loading
@@ -53,7 +53,7 @@
let(:environment3) { create(:environment, :available, name: 'test3', project: project) }
 
it 'searches environments by name and state' do
result = described_class.new(project, user, search: 'test', states: :available).find
result = described_class.new(project, user, search: 'test', states: :available).execute
 
expect(result).to contain_exactly(environment3)
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment