Commit 3df33d69 authored by Tiger's avatar Tiger Committed by Tiger Watson

Move Terraform::StateVersion.with_files_stored_locally to Core

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50740
parent f1a4ee68
......@@ -9,6 +9,7 @@ module Terraform
belongs_to :build, class_name: 'Ci::Build', optional: true, foreign_key: :ci_build_id
scope :ordered_by_version_desc, -> { order(version: :desc) }
scope :with_files_stored_locally, -> { where(file_store: Terraform::StateUploader::Store::LOCAL) }
default_value_for(:file_store) { StateUploader.default_store }
......
......@@ -9,7 +9,6 @@ module EE
include ::Gitlab::Geo::ReplicableModel
with_replicator Geo::TerraformStateVersionReplicator
scope :with_files_stored_locally, -> { where(file_store: ::ObjectStorage::Store::LOCAL) }
scope :project_id_in, ->(ids) { joins(:terraform_state).where('terraform_states.project_id': ids) }
end
......
......@@ -9,22 +9,6 @@ RSpec.describe Terraform::StateVersion do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
describe '.with_files_stored_locally' do
it 'includes states with local storage' do
create_list(:terraform_state_version, 5)
expect(described_class.with_files_stored_locally).to have_attributes(count: 5)
end
it 'excludes states without local storage' do
stub_terraform_state_object_storage
create_list(:terraform_state_version, 5)
expect(described_class.with_files_stored_locally).to have_attributes(count: 0)
end
end
describe '.replicables_for_current_secondary' do
where(:selective_sync_enabled, :object_storage_sync_enabled, :terraform_object_storage_enabled, :synced_states) do
true | true | true | 5
......
......@@ -24,6 +24,24 @@ RSpec.describe Terraform::StateVersion do
it { expect(subject.map(&:version)).to eq(versions.sort.reverse) }
end
describe '.with_files_stored_locally' do
subject { described_class.with_files_stored_locally }
it 'includes states with local storage' do
create_list(:terraform_state_version, 5)
expect(subject).to have_attributes(count: 5)
end
it 'excludes states without local storage' do
stub_terraform_state_object_storage
create_list(:terraform_state_version, 5)
expect(subject).to have_attributes(count: 0)
end
end
end
context 'file storage' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment