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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-22 15:19:06 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-22 15:19:06 +0300
commit333fa9db65f77649bb872243fc242f85f7a479cb (patch)
treef7cb3536d311a618d7d9a9c4f5f1cd07ac3edac6
parent4adb78c7c294c3aebbd4d79a93c111e3c0857c49 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/models/event.rb4
-rw-r--r--lib/gitlab/github_import/importer/pull_requests_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/repository_importer.rb2
-rw-r--r--spec/lib/gitlab/github_import/importer/repository_importer_spec.rb4
-rw-r--r--spec/models/event_spec.rb16
5 files changed, 15 insertions, 13 deletions
diff --git a/app/models/event.rb b/app/models/event.rb
index 409bc66c66c..a8cf2e2dfb0 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -354,7 +354,7 @@ class Event < ApplicationRecord
# hence we add the extra WHERE clause for last_activity_at.
Project.unscoped.where(id: project_id)
.where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago)
- .update_all(last_activity_at: created_at)
+ .touch_all(:last_activity_at, time: created_at) # rubocop: disable Rails/SkipsModelValidations
end
def authored_by?(user)
@@ -430,7 +430,7 @@ class Event < ApplicationRecord
def set_last_repository_updated_at
Project.unscoped.where(id: project_id)
.where("last_repository_updated_at < ? OR last_repository_updated_at IS NULL", REPOSITORY_UPDATED_AT_INTERVAL.ago)
- .update_all(last_repository_updated_at: created_at)
+ .touch_all(:last_repository_updated_at, time: created_at) # rubocop: disable Rails/SkipsModelValidations
end
def design_action_names
diff --git a/lib/gitlab/github_import/importer/pull_requests_importer.rb b/lib/gitlab/github_import/importer/pull_requests_importer.rb
index 2812fbd3dfe..9648ad8dec4 100644
--- a/lib/gitlab/github_import/importer/pull_requests_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_requests_importer.rb
@@ -38,7 +38,7 @@ module Gitlab
# deliberate. If we were to update this column after the fetch we may
# miss out on changes pushed during the fetch or between the fetch and
# updating the timestamp.
- project.update_column(:last_repository_updated_at, Time.zone.now)
+ project.touch(:last_repository_updated_at) # rubocop: disable Rails/SkipsModelValidations
project.repository.fetch_remote(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: false)
diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb
index 20068a33019..aba4729e9c8 100644
--- a/lib/gitlab/github_import/importer/repository_importer.rb
+++ b/lib/gitlab/github_import/importer/repository_importer.rb
@@ -80,7 +80,7 @@ module Gitlab
end
def update_clone_time
- project.update_column(:last_repository_updated_at, Time.zone.now)
+ project.touch(:last_repository_updated_at) # rubocop: disable Rails/SkipsModelValidations
end
private
diff --git a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
index 58a8fb1b7e4..f2730ba74ec 100644
--- a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
@@ -264,8 +264,8 @@ RSpec.describe Gitlab::GithubImport::Importer::RepositoryImporter do
it 'sets the timestamp for when the cloning process finished' do
freeze_time do
expect(project)
- .to receive(:update_column)
- .with(:last_repository_updated_at, Time.zone.now)
+ .to receive(:touch)
+ .with(:last_repository_updated_at)
importer.update_clone_time
end
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 97854086162..9119ef83034 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -31,14 +31,15 @@ RSpec.describe Event do
describe 'after_create :set_last_repository_updated_at' do
context 'with a push event' do
- it 'updates the project last_repository_updated_at' do
- project.update!(last_repository_updated_at: 1.year.ago)
+ it 'updates the project last_repository_updated_at and updated_at' do
+ project.touch(:last_repository_updated_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations
- create_push_event(project, project.owner)
+ event = create_push_event(project, project.owner)
project.reload
- expect(project.last_repository_updated_at).to be_within(1.minute).of(Time.current)
+ expect(project.last_repository_updated_at).to be_like_time(event.created_at)
+ expect(project.updated_at).to be_like_time(event.created_at)
end
end
@@ -835,13 +836,14 @@ RSpec.describe Event do
context 'when a project was updated more than 1 hour ago' do
it 'updates the project' do
- project.update!(last_activity_at: 1.year.ago)
+ project.touch(:last_activity_at, time: 1.year.ago) # rubocop: disable Rails/SkipsModelValidations
- create_push_event(project, project.owner)
+ event = create_push_event(project, project.owner)
project.reload
- expect(project.last_activity_at).to be_within(1.minute).of(Time.current)
+ expect(project.last_activity_at).to be_like_time(event.created_at)
+ expect(project.updated_at).to be_like_time(event.created_at)
end
end
end