Commit 1168fbb0 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'replace-set-with-let_it_be-in-spec-models-batch-2' into 'master'

Replace set with let_it_be in spec/models

See merge request gitlab-org/gitlab!24879
parents 689b4b34 04d9fb3f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe ChatName do describe ChatName do
set(:chat_name) { create(:chat_name) } let_it_be(:chat_name) { create(:chat_name) }
subject { chat_name } subject { chat_name }
it { is_expected.to belong_to(:service) } it { is_expected.to belong_to(:service) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe ChatTeam do describe ChatTeam do
set(:chat_team) { create(:chat_team) } let_it_be(:chat_team) { create(:chat_team) }
subject { chat_team } subject { chat_team }
# Associations # Associations
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe Ci::Bridge do describe Ci::Bridge do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
set(:target_project) { create(:project, name: 'project', namespace: create(:namespace, name: 'my')) } let_it_be(:target_project) { create(:project, name: 'project', namespace: create(:namespace, name: 'my')) }
set(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
let(:bridge) do let(:bridge) do
create(:ci_bridge, :variables, status: :created, create(:ci_bridge, :variables, status: :created,
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe Ci::BuildMetadata do describe Ci::BuildMetadata do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
set(:project) { create(:project, :repository, group: group, build_timeout: 2000) } let_it_be(:project) { create(:project, :repository, group: group, build_timeout: 2000) }
set(:pipeline) do let_it_be(:pipeline) do
create(:ci_pipeline, project: project, create(:ci_pipeline, project: project,
sha: project.commit.id, sha: project.commit.id,
ref: project.default_branch, ref: project.default_branch,
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
require 'spec_helper' require 'spec_helper'
describe Ci::Build do describe Ci::Build do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:group) { create(:group) } let_it_be(:group, reload: true) { create(:group) }
set(:project) { create(:project, :repository, group: group) } let_it_be(:project, reload: true) { create(:project, :repository, group: group) }
set(:pipeline) do let_it_be(:pipeline, reload: true) do
create(:ci_pipeline, project: project, create(:ci_pipeline, project: project,
sha: project.commit.id, sha: project.commit.id,
ref: project.default_branch, ref: project.default_branch,
...@@ -3612,7 +3612,7 @@ describe Ci::Build do ...@@ -3612,7 +3612,7 @@ describe Ci::Build do
end end
describe '.matches_tag_ids' do describe '.matches_tag_ids' do
set(:build) { create(:ci_build, project: project, user: user) } let_it_be(:build, reload: true) { create(:ci_build, project: project, user: user) }
let(:tag_ids) { ::ActsAsTaggableOn::Tag.named_any(tag_list).ids } let(:tag_ids) { ::ActsAsTaggableOn::Tag.named_any(tag_list).ids }
subject { described_class.where(id: build).matches_tag_ids(tag_ids) } subject { described_class.where(id: build).matches_tag_ids(tag_ids) }
...@@ -3659,7 +3659,7 @@ describe Ci::Build do ...@@ -3659,7 +3659,7 @@ describe Ci::Build do
end end
describe '.matches_tags' do describe '.matches_tags' do
set(:build) { create(:ci_build, project: project, user: user) } let_it_be(:build, reload: true) { create(:ci_build, project: project, user: user) }
subject { described_class.where(id: build).with_any_tags } subject { described_class.where(id: build).with_any_tags }
...@@ -3685,7 +3685,7 @@ describe Ci::Build do ...@@ -3685,7 +3685,7 @@ describe Ci::Build do
end end
describe 'pages deployments' do describe 'pages deployments' do
set(:build) { create(:ci_build, project: project, user: user) } let_it_be(:build, reload: true) { create(:ci_build, project: project, user: user) }
context 'when job is "pages"' do context 'when job is "pages"' do
before do before do
...@@ -3852,7 +3852,7 @@ describe Ci::Build do ...@@ -3852,7 +3852,7 @@ describe Ci::Build do
end end
describe '#artifacts_metadata_entry' do describe '#artifacts_metadata_entry' do
set(:build) { create(:ci_build, project: project) } let_it_be(:build) { create(:ci_build, project: project) }
let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' } let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
around do |example| around do |example|
...@@ -3952,7 +3952,7 @@ describe Ci::Build do ...@@ -3952,7 +3952,7 @@ describe Ci::Build do
end end
describe '#supported_runner?' do describe '#supported_runner?' do
set(:build) { create(:ci_build) } let_it_be(:build) { create(:ci_build) }
subject { build.supported_runner?(runner_features) } subject { build.supported_runner?(runner_features) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers include ExclusiveLeaseHelpers
set(:build) { create(:ci_build, :running) } let_it_be(:build) { create(:ci_build, :running) }
let(:chunk_index) { 0 } let(:chunk_index) { 0 }
let(:data_store) { :redis } let(:data_store) { :redis }
let(:raw_data) { nil } let(:raw_data) { nil }
...@@ -24,7 +24,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do ...@@ -24,7 +24,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
context 'FastDestroyAll' do context 'FastDestroyAll' do
let(:parent) { create(:project) } let(:parent) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: parent) } let(:pipeline) { create(:ci_pipeline, project: parent) }
let(:build) { create(:ci_build, :running, :trace_live, pipeline: pipeline, project: parent) } let!(:build) { create(:ci_build, :running, :trace_live, pipeline: pipeline, project: parent) }
let(:subjects) { build.trace_chunks } let(:subjects) { build.trace_chunks }
describe 'Forbid #destroy and #destroy_all' do describe 'Forbid #destroy and #destroy_all' do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Ci::Processable do describe Ci::Processable do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
set(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
describe '#aggregated_needs_names' do describe '#aggregated_needs_names' do
let(:with_aggregated_needs) { pipeline.processables.select_with_aggregated_needs(project) } let(:with_aggregated_needs) { pipeline.processables.select_with_aggregated_needs(project) }
......
...@@ -38,8 +38,8 @@ describe Ci::Runner do ...@@ -38,8 +38,8 @@ describe Ci::Runner do
end end
context 'runner_type validations' do context 'runner_type validations' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) } let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let(:project_runner) { create(:ci_runner, :project, projects: [project]) } let(:project_runner) { create(:ci_runner, :project, projects: [project]) }
let(:instance_runner) { create(:ci_runner, :instance) } let(:instance_runner) { create(:ci_runner, :instance) }
...@@ -322,7 +322,7 @@ describe Ci::Runner do ...@@ -322,7 +322,7 @@ describe Ci::Runner do
end end
describe '#can_pick?' do describe '#can_pick?' do
set(:pipeline) { create(:ci_pipeline) } let_it_be(:pipeline) { create(:ci_pipeline) }
let(:build) { create(:ci_build, pipeline: pipeline) } let(:build) { create(:ci_build, pipeline: pipeline) }
let(:runner_project) { build.project } let(:runner_project) { build.project }
let(:runner) { create(:ci_runner, :project, projects: [runner_project], tag_list: tag_list, run_untagged: run_untagged) } let(:runner) { create(:ci_runner, :project, projects: [runner_project], tag_list: tag_list, run_untagged: run_untagged) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe DiffViewer::ServerSide do describe DiffViewer::ServerSide do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
let(:commit) { project.commit_by(oid: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d') } let(:commit) { project.commit_by(oid: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
let!(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') } let!(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
......
...@@ -4,10 +4,10 @@ require 'spec_helper' ...@@ -4,10 +4,10 @@ require 'spec_helper'
describe EventCollection do describe EventCollection do
describe '#to_a' do describe '#to_a' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
set(:project) { create(:project_empty_repo, group: group) } let_it_be(:project) { create(:project_empty_repo, group: group) }
set(:projects) { Project.where(id: project.id) } let_it_be(:projects) { Project.where(id: project.id) }
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
context 'with project events' do context 'with project events' do
before do before do
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe Guest do describe Guest do
set(:public_project) { create(:project, :public) } let_it_be(:public_project, reload: true) { create(:project, :public) }
set(:private_project) { create(:project, :private) } let_it_be(:private_project) { create(:project, :private) }
set(:internal_project) { create(:project, :internal) } let_it_be(:internal_project) { create(:project, :internal) }
describe '.can_pull?' do describe '.can_pull?' do
context 'when project is private' do context 'when project is private' do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe ListUserPreference do describe ListUserPreference do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:list) { create(:list) } let_it_be(:list) { create(:list) }
before do before do
list.update_preferences_for(user, { collapsed: true }) list.update_preferences_for(user, { collapsed: true })
......
...@@ -352,9 +352,9 @@ describe PagesDomain do ...@@ -352,9 +352,9 @@ describe PagesDomain do
end end
context 'configuration updates when attributes change' do context 'configuration updates when attributes change' do
set(:project1) { create(:project) } let_it_be(:project1) { create(:project) }
set(:project2) { create(:project) } let_it_be(:project2) { create(:project) }
set(:domain) { create(:pages_domain) } let_it_be(:domain) { create(:pages_domain) }
where(:attribute, :old_value, :new_value, :update_expected) do where(:attribute, :old_value, :new_value, :update_expected) do
now = Time.now now = Time.now
...@@ -402,8 +402,8 @@ describe PagesDomain do ...@@ -402,8 +402,8 @@ describe PagesDomain do
end end
context 'TLS configuration' do context 'TLS configuration' do
set(:domain_without_tls) { create(:pages_domain, :without_certificate, :without_key) } let_it_be(:domain_without_tls) { create(:pages_domain, :without_certificate, :without_key) }
set(:domain) { create(:pages_domain) } let_it_be(:domain) { create(:pages_domain) }
let(:cert1) { domain.certificate } let(:cert1) { domain.certificate }
let(:cert2) { cert1 + ' ' } let(:cert2) { cert1 + ' ' }
......
...@@ -37,9 +37,9 @@ describe MicrosoftTeamsService do ...@@ -37,9 +37,9 @@ describe MicrosoftTeamsService do
end end
describe "#execute" do describe "#execute" do
let(:user) { create(:user) } let(:user) { create(:user) }
set(:project) { create(:project, :repository, :wiki_repo) } let_it_be(:project) { create(:project, :repository, :wiki_repo) }
before do before do
allow(chat_service).to receive_messages( allow(chat_service).to receive_messages(
......
...@@ -169,7 +169,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do ...@@ -169,7 +169,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
end end
context 'cluster belongs to projects group' do context 'cluster belongs to projects group' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
let(:project) { create(:prometheus_project, group: group) } let(:project) { create(:prometheus_project, group: group) }
let(:cluster) { create(:cluster_for_group, :with_installed_helm, groups: [group]) } let(:cluster) { create(:cluster_for_group, :with_installed_helm, groups: [group]) }
......
...@@ -3901,7 +3901,7 @@ describe Project do ...@@ -3901,7 +3901,7 @@ describe Project do
end end
context 'legacy storage' do context 'legacy storage' do
set(:project) { create(:project, :repository, :legacy_storage) } let_it_be(:project) { create(:project, :repository, :legacy_storage) }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_storage) { project.send(:storage) } let(:project_storage) { project.send(:storage) }
...@@ -4000,7 +4000,7 @@ describe Project do ...@@ -4000,7 +4000,7 @@ describe Project do
end end
context 'hashed storage' do context 'hashed storage' do
set(:project) { create(:project, :repository, skip_disk_validation: true) } let_it_be(:project) { create(:project, :repository, skip_disk_validation: true) }
let(:gitlab_shell) { Gitlab::Shell.new } let(:gitlab_shell) { Gitlab::Shell.new }
let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) } let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) }
let(:hashed_prefix) { File.join('@hashed', hash[0..1], hash[2..3]) } let(:hashed_prefix) { File.join('@hashed', hash[0..1], hash[2..3]) }
...@@ -4090,7 +4090,7 @@ describe Project do ...@@ -4090,7 +4090,7 @@ describe Project do
end end
describe '#has_ci?' do describe '#has_ci?' do
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
let(:repository) { double } let(:repository) { double }
before do before do
...@@ -4134,7 +4134,7 @@ describe Project do ...@@ -4134,7 +4134,7 @@ describe Project do
Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(0) Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(0)
end end
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
subject { project.auto_devops_enabled? } subject { project.auto_devops_enabled? }
...@@ -4269,7 +4269,7 @@ describe Project do ...@@ -4269,7 +4269,7 @@ describe Project do
end end
describe '#has_auto_devops_implicitly_enabled?' do describe '#has_auto_devops_implicitly_enabled?' do
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
context 'when disabled in settings' do context 'when disabled in settings' do
before do before do
...@@ -4330,7 +4330,7 @@ describe Project do ...@@ -4330,7 +4330,7 @@ describe Project do
end end
describe '#has_auto_devops_implicitly_disabled?' do describe '#has_auto_devops_implicitly_disabled?' do
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
before do before do
allow(Feature).to receive(:enabled?).and_call_original allow(Feature).to receive(:enabled?).and_call_original
...@@ -4408,7 +4408,7 @@ describe Project do ...@@ -4408,7 +4408,7 @@ describe Project do
end end
describe '#api_variables' do describe '#api_variables' do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
it 'exposes API v4 URL' do it 'exposes API v4 URL' do
expect(project.api_variables.first[:key]).to eq 'CI_API_V4_URL' expect(project.api_variables.first[:key]).to eq 'CI_API_V4_URL'
...@@ -4605,7 +4605,7 @@ describe Project do ...@@ -4605,7 +4605,7 @@ describe Project do
end end
describe '#write_repository_config' do describe '#write_repository_config' do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
it 'writes full path in .git/config when key is missing' do it 'writes full path in .git/config when key is missing' do
project.write_repository_config project.write_repository_config
...@@ -4696,7 +4696,7 @@ describe Project do ...@@ -4696,7 +4696,7 @@ describe Project do
end end
describe '#has_active_hooks?' do describe '#has_active_hooks?' do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
it { expect(project.has_active_hooks?).to be_falsey } it { expect(project.has_active_hooks?).to be_falsey }
...@@ -4723,7 +4723,7 @@ describe Project do ...@@ -4723,7 +4723,7 @@ describe Project do
end end
describe '#has_active_services?' do describe '#has_active_services?' do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
it { expect(project.has_active_services?).to be_falsey } it { expect(project.has_active_services?).to be_falsey }
...@@ -5009,8 +5009,8 @@ describe Project do ...@@ -5009,8 +5009,8 @@ describe Project do
describe '#members_among' do describe '#members_among' do
let(:users) { create_list(:user, 3) } let(:users) { create_list(:user, 3) }
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
set(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, namespace: group) }
before do before do
project.add_guest(users.first) project.add_guest(users.first)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe Releases::Source do describe Releases::Source do
set(:project) { create(:project, :repository, name: 'finance-cal') } let_it_be(:project) { create(:project, :repository, name: 'finance-cal') }
let(:tag_name) { 'v1.0' } let(:tag_name) { 'v1.0' }
describe '.all' do describe '.all' 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