Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests/projects/pipelines_controller_spec.rb')
-rw-r--r--spec/requests/projects/pipelines_controller_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/requests/projects/pipelines_controller_spec.rb b/spec/requests/projects/pipelines_controller_spec.rb
index 7bdb66755db..aa3fefdef14 100644
--- a/spec/requests/projects/pipelines_controller_spec.rb
+++ b/spec/requests/projects/pipelines_controller_spec.rb
@@ -75,6 +75,59 @@ RSpec.describe Projects::PipelinesController, feature_category: :continuous_inte
expect(response).to have_gitlab_http_status(:ok)
end
+ context 'when pipeline_stage_set_last_modified is disabled' do
+ before do
+ stub_feature_flags(pipeline_stage_set_last_modified: false)
+ end
+
+ it 'does not set Last-Modified' do
+ create(:ci_build, :retried, :failed, pipeline: pipeline, stage: 'build')
+
+ request_build_stage
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(response.headers['Last-Modified']).to be_nil
+ expect(response.headers['Cache-Control']).to eq('max-age=0, private, must-revalidate')
+ end
+ end
+
+ context 'when pipeline_stage_set_last_modified is enabled' do
+ before do
+ stub_feature_flags(pipeline_stage_set_last_modified: true)
+ stage.statuses.update_all(updated_at: status_timestamp)
+ end
+
+ let(:last_modified) { DateTime.parse(response.headers['Last-Modified']).utc }
+ let(:cache_control) { response.headers['Cache-Control'] }
+ let(:expected_cache_control) { 'max-age=0, private, must-revalidate' }
+
+ context 'when status.updated_at is before stage.updated' do
+ let(:stage) { pipeline.stage('build') }
+ let(:status_timestamp) { stage.updated_at - 10.minutes }
+
+ it 'sets correct Last-Modified of stage.updated_at' do
+ request_build_stage
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(last_modified).to be_within(1.second).of stage.updated_at
+ expect(cache_control).to eq(expected_cache_control)
+ end
+ end
+
+ context 'when status.updated_at is after stage.updated' do
+ let(:stage) { pipeline.stage('build') }
+ let(:status_timestamp) { stage.updated_at + 10.minutes }
+
+ it 'sets correct Last-Modified of max(status.updated_at)' do
+ request_build_stage
+
+ expect(response).to have_gitlab_http_status(:ok)
+ expect(last_modified).to be_within(1.second).of status_timestamp
+ expect(cache_control).to eq(expected_cache_control)
+ end
+ end
+ end
+
context 'with retried builds' do
it 'does not execute N+1 queries' do
create(:ci_build, :retried, :failed, pipeline: pipeline, stage: 'build')