Commit b40c5b31 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'fix-specs-to-support-parent-strategy-in-factories-3' into 'master'

Refactor tests to support Parent Strategy in factories

See merge request gitlab-org/gitlab!41758
parents a0672b2b 1b683006
...@@ -5,9 +5,11 @@ require 'spec_helper' ...@@ -5,9 +5,11 @@ require 'spec_helper'
RSpec.describe ProjectImportData do RSpec.describe ProjectImportData do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) }
let(:import_url) { 'ssh://example.com' } let(:import_url) { 'ssh://example.com' }
let(:import_data_attrs) { { auth_method: 'ssh_public_key' } } let(:import_data_attrs) { { auth_method: 'ssh_public_key' } }
let(:project) { build(:project, :mirror, import_url: import_url, import_data_attributes: import_data_attrs) } let(:project) { build(:project, :mirror, creator: user, import_url: import_url, import_data_attributes: import_data_attrs) }
subject(:import_data) { project.import_data } subject(:import_data) { project.import_data }
...@@ -33,8 +35,6 @@ RSpec.describe ProjectImportData do ...@@ -33,8 +35,6 @@ RSpec.describe ProjectImportData do
end end
describe '#ssh_known_hosts_verified_by' do describe '#ssh_known_hosts_verified_by' do
let(:user) { project.owner }
subject { import_data.ssh_known_hosts_verified_by } subject { import_data.ssh_known_hosts_verified_by }
it 'is a user when ssh_known_hosts_verified_by_id is a valid id' do it 'is a user when ssh_known_hosts_verified_by_id is a valid id' do
......
...@@ -270,11 +270,11 @@ RSpec.describe Project do ...@@ -270,11 +270,11 @@ RSpec.describe Project do
describe 'setting up a mirror' do describe 'setting up a mirror' do
context 'when new project' do context 'when new project' do
it 'creates import_state and sets next_execution_timestamp to now' do it 'creates import_state and sets next_execution_timestamp to now' do
project = build(:project, :mirror) project = build(:project, :mirror, creator: create(:user))
Timecop.freeze do Timecop.freeze do
expect do expect do
project.save project.save!
end.to change { ProjectImportState.count }.by(1) end.to change { ProjectImportState.count }.by(1)
expect(project.import_state.next_execution_timestamp).to be_like_time(Time.current) expect(project.import_state.next_execution_timestamp).to be_like_time(Time.current)
......
...@@ -22,11 +22,12 @@ RSpec.describe StorageHelper do ...@@ -22,11 +22,12 @@ RSpec.describe StorageHelper do
end end
describe "#storage_counters_details" do describe "#storage_counters_details" do
let(:namespace) { create :namespace } let_it_be(:namespace) { create(:namespace) }
let(:project) do let_it_be(:project) do
create(:project, create(:project,
namespace: namespace, namespace: namespace,
statistics: build(:project_statistics, statistics: build(:project_statistics,
namespace: namespace,
repository_size: 10.kilobytes, repository_size: 10.kilobytes,
wiki_size: 10.bytes, wiki_size: 10.bytes,
lfs_objects_size: 20.gigabytes, lfs_objects_size: 20.gigabytes,
......
...@@ -175,12 +175,13 @@ RSpec.describe Namespace do ...@@ -175,12 +175,13 @@ RSpec.describe Namespace do
end end
describe '.with_statistics' do describe '.with_statistics' do
let(:namespace) { create :namespace } let_it_be(:namespace) { create(:namespace) }
let(:project1) do let(:project1) do
create(:project, create(:project,
namespace: namespace, namespace: namespace,
statistics: build(:project_statistics, statistics: build(:project_statistics,
namespace: namespace,
repository_size: 101, repository_size: 101,
wiki_size: 505, wiki_size: 505,
lfs_objects_size: 202, lfs_objects_size: 202,
...@@ -193,6 +194,7 @@ RSpec.describe Namespace do ...@@ -193,6 +194,7 @@ RSpec.describe Namespace do
create(:project, create(:project,
namespace: namespace, namespace: namespace,
statistics: build(:project_statistics, statistics: build(:project_statistics,
namespace: namespace,
repository_size: 10, repository_size: 10,
wiki_size: 50, wiki_size: 50,
lfs_objects_size: 20, lfs_objects_size: 20,
......
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