Reduce CE/EE diff in spec/controllers/projects/environments_controller_spec.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
981b8ab7bd
commit
660439e968
2 changed files with 17 additions and 0 deletions
|
@ -7,6 +7,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
|||
before_action :authorize_admin_environment!, only: [:terminal, :terminal_websocket_authorize]
|
||||
before_action :environment, only: [:show, :edit, :update, :stop, :terminal, :terminal_websocket_authorize, :metrics]
|
||||
before_action :verify_api_request!, only: :terminal_websocket_authorize
|
||||
before_action :expire_etag_cache, only: [:index]
|
||||
|
||||
def index
|
||||
@environments = project.environments
|
||||
|
@ -148,6 +149,15 @@ class Projects::EnvironmentsController < Projects::ApplicationController
|
|||
Gitlab::Workhorse.verify_api_request!(request.headers)
|
||||
end
|
||||
|
||||
def expire_etag_cache
|
||||
return if request.format.json?
|
||||
|
||||
# this forces to reload json content
|
||||
Gitlab::EtagCaching::Store.new.tap do |store|
|
||||
store.touch(project_environments_path(project, format: :json))
|
||||
end
|
||||
end
|
||||
|
||||
def environment_params
|
||||
params.require(:environment).permit(:name, :external_url)
|
||||
end
|
||||
|
|
|
@ -21,6 +21,13 @@ describe Projects::EnvironmentsController do
|
|||
|
||||
expect(response).to have_gitlab_http_status(:ok)
|
||||
end
|
||||
|
||||
it 'expires etag cache to force reload environments list' do
|
||||
expect_any_instance_of(Gitlab::EtagCaching::Store)
|
||||
.to receive(:touch).with(project_environments_path(project, format: :json))
|
||||
|
||||
get :index, environment_params
|
||||
end
|
||||
end
|
||||
|
||||
context 'when requesting JSON response for folders' do
|
||||
|
|
Loading…
Reference in a new issue