Commit a502a900 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'replace-set-to-let_it_be-in-specs-batch-3' into 'master'

Replace set to let_it_be in specs

See merge request gitlab-org/gitlab!25429
parents 46c7fa2a 5d15b84c
...@@ -5,8 +5,7 @@ require 'spec_helper' ...@@ -5,8 +5,7 @@ require 'spec_helper'
describe 'Gitlab::Graphql::Authorization' do describe 'Gitlab::Graphql::Authorization' do
include GraphqlHelpers include GraphqlHelpers
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:permission_single) { :foo } let(:permission_single) { :foo }
let(:permission_collection) { [:foo, :bar] } let(:permission_collection) { [:foo, :bar] }
let(:test_object) { double(name: 'My name') } let(:test_object) { double(name: 'My name') }
......
...@@ -17,11 +17,11 @@ describe ResolvesPipelines do ...@@ -17,11 +17,11 @@ describe ResolvesPipelines do
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
set(:project) { create(:project, :private) } let_it_be(:project) { create(:project, :private) }
set(:pipeline) { create(:ci_pipeline, project: project) } let_it_be(:pipeline) { create(:ci_pipeline, project: project) }
set(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) } let_it_be(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
set(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') } let_it_be(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
set(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') } let_it_be(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') }
before do before do
project.add_developer(current_user) project.add_developer(current_user)
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
describe Resolvers::GroupResolver do describe Resolvers::GroupResolver do
include GraphqlHelpers include GraphqlHelpers
set(:group1) { create(:group) } let_it_be(:group1) { create(:group) }
set(:group2) { create(:group) } let_it_be(:group2) { create(:group) }
describe '#resolve' do describe '#resolve' do
it 'batch-resolves groups by full path' do it 'batch-resolves groups by full path' do
......
...@@ -8,11 +8,11 @@ describe Resolvers::IssuesResolver do ...@@ -8,11 +8,11 @@ describe Resolvers::IssuesResolver do
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
context "with a project" do context "with a project" do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
set(:issue1) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) } let_it_be(:issue1) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
set(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) } let_it_be(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
set(:label1) { create(:label, project: project) } let_it_be(:label1) { create(:label, project: project) }
set(:label2) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) }
before do before do
project.add_developer(current_user) project.add_developer(current_user)
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
describe Resolvers::MergeRequestPipelinesResolver do describe Resolvers::MergeRequestPipelinesResolver do
include GraphqlHelpers include GraphqlHelpers
set(:merge_request) { create(:merge_request) } let_it_be(:merge_request) { create(:merge_request) }
set(:pipeline) do let_it_be(:pipeline) do
create( create(
:ci_pipeline, :ci_pipeline,
project: merge_request.source_project, project: merge_request.source_project,
...@@ -14,8 +14,8 @@ describe Resolvers::MergeRequestPipelinesResolver do ...@@ -14,8 +14,8 @@ describe Resolvers::MergeRequestPipelinesResolver do
sha: merge_request.diff_head_sha sha: merge_request.diff_head_sha
) )
end end
set(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project) } let_it_be(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project) }
set(:other_pipeline) { create(:ci_pipeline) } let_it_be(:other_pipeline) { create(:ci_pipeline) }
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
before do before do
......
...@@ -5,16 +5,13 @@ require 'spec_helper' ...@@ -5,16 +5,13 @@ require 'spec_helper'
describe Resolvers::MergeRequestsResolver do describe Resolvers::MergeRequestsResolver do
include GraphqlHelpers include GraphqlHelpers
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:merge_request_1) { create(:merge_request, :simple, source_project: project, target_project: project) } let_it_be(:merge_request_1) { create(:merge_request, :simple, source_project: project, target_project: project) }
set(:merge_request_2) { create(:merge_request, :rebased, source_project: project, target_project: project) } let_it_be(:merge_request_2) { create(:merge_request, :rebased, source_project: project, target_project: project) }
let_it_be(:other_project) { create(:project, :repository) }
set(:other_project) { create(:project, :repository) } let_it_be(:other_merge_request) { create(:merge_request, source_project: other_project, target_project: other_project) }
set(:other_merge_request) { create(:merge_request, source_project: other_project, target_project: other_project) }
let(:iid_1) { merge_request_1.iid } let(:iid_1) { merge_request_1.iid }
let(:iid_2) { merge_request_2.iid } let(:iid_2) { merge_request_2.iid }
let(:other_iid) { other_merge_request.iid } let(:other_iid) { other_merge_request.iid }
describe '#resolve' do describe '#resolve' do
......
...@@ -5,9 +5,9 @@ require 'spec_helper' ...@@ -5,9 +5,9 @@ require 'spec_helper'
describe Resolvers::ProjectPipelinesResolver do describe Resolvers::ProjectPipelinesResolver do
include GraphqlHelpers include GraphqlHelpers
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) }
set(:other_pipeline) { create(:ci_pipeline) } let_it_be(:other_pipeline) { create(:ci_pipeline) }
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
before do before do
......
...@@ -5,10 +5,9 @@ require 'spec_helper' ...@@ -5,10 +5,9 @@ require 'spec_helper'
describe Resolvers::ProjectResolver do describe Resolvers::ProjectResolver do
include GraphqlHelpers include GraphqlHelpers
set(:project1) { create(:project) } let_it_be(:project1) { create(:project) }
set(:project2) { create(:project) } let_it_be(:project2) { create(:project) }
let_it_be(:other_project) { create(:project) }
set(:other_project) { create(:project) }
describe '#resolve' do describe '#resolve' do
it 'batch-resolves projects by full path' do it 'batch-resolves projects by full path' do
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe AutoDevopsHelper do describe AutoDevopsHelper do
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
describe '.show_auto_devops_callout?' do describe '.show_auto_devops_callout?' do
let(:allowed) { true } let(:allowed) { true }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
describe BoardsHelper do describe BoardsHelper do
set(:project) { create(:project) } let_it_be(:project) { create(:project) }
describe '#build_issue_link_base' do describe '#build_issue_link_base' do
context 'project board' do context 'project board' do
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe EnvironmentsHelper do describe EnvironmentsHelper do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:project) { create(:project, :repository) } let_it_be(:project, reload: true) { create(:project, :repository) }
set(:environment) { create(:environment, project: project) } let_it_be(:environment) { create(:environment, project: project) }
describe '#metrics_data' do describe '#metrics_data' do
before do before do
......
...@@ -35,7 +35,7 @@ describe LabelsHelper do ...@@ -35,7 +35,7 @@ describe LabelsHelper do
end end
context 'with a group label' do context 'with a group label' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
let(:label) { create(:group_label, group: group, title: 'bug') } let(:label) { create(:group_label, group: group, title: 'bug') }
context 'when asking for an issue link' do context 'when asking for an issue link' do
...@@ -135,7 +135,7 @@ describe LabelsHelper do ...@@ -135,7 +135,7 @@ describe LabelsHelper do
end end
describe 'create_label_title' do describe 'create_label_title' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
context 'with a group as subject' do context 'with a group as subject' do
it 'returns "Create group label"' do it 'returns "Create group label"' do
...@@ -144,7 +144,7 @@ describe LabelsHelper do ...@@ -144,7 +144,7 @@ describe LabelsHelper do
end end
context 'with a project as subject' do context 'with a project as subject' do
set(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, namespace: group) }
it 'returns "Create project label"' do it 'returns "Create project label"' do
expect(create_label_title(project)).to eq _('Create project label') expect(create_label_title(project)).to eq _('Create project label')
...@@ -159,7 +159,7 @@ describe LabelsHelper do ...@@ -159,7 +159,7 @@ describe LabelsHelper do
end end
describe 'manage_labels_title' do describe 'manage_labels_title' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
context 'with a group as subject' do context 'with a group as subject' do
it 'returns "Manage group labels"' do it 'returns "Manage group labels"' do
...@@ -168,7 +168,7 @@ describe LabelsHelper do ...@@ -168,7 +168,7 @@ describe LabelsHelper do
end end
context 'with a project as subject' do context 'with a project as subject' do
set(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, namespace: group) }
it 'returns "Manage project labels"' do it 'returns "Manage project labels"' do
expect(manage_labels_title(project)).to eq _('Manage project labels') expect(manage_labels_title(project)).to eq _('Manage project labels')
...@@ -183,7 +183,7 @@ describe LabelsHelper do ...@@ -183,7 +183,7 @@ describe LabelsHelper do
end end
describe 'view_labels_title' do describe 'view_labels_title' do
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
context 'with a group as subject' do context 'with a group as subject' do
it 'returns "View group labels"' do it 'returns "View group labels"' do
...@@ -192,7 +192,7 @@ describe LabelsHelper do ...@@ -192,7 +192,7 @@ describe LabelsHelper do
end end
context 'with a project as subject' do context 'with a project as subject' do
set(:project) { create(:project, namespace: group) } let_it_be(:project) { create(:project, namespace: group) }
it 'returns "View project labels"' do it 'returns "View project labels"' do
expect(view_labels_title(project)).to eq _('View project labels') expect(view_labels_title(project)).to eq _('View project labels')
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
require 'spec_helper' require 'spec_helper'
describe MarkupHelper do describe MarkupHelper do
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:user) do let_it_be(:user) do
user = create(:user, username: 'gfm') user = create(:user, username: 'gfm')
project.add_maintainer(user) project.add_maintainer(user)
user user
end end
set(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
set(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let_it_be(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
set(:snippet) { create(:project_snippet, project: project) } let_it_be(:snippet) { create(:project_snippet, project: project) }
let(:commit) { project.commit } let(:commit) { project.commit }
before do before do
...@@ -45,8 +45,8 @@ describe MarkupHelper do ...@@ -45,8 +45,8 @@ describe MarkupHelper do
describe "override default project" do describe "override default project" do
let(:actual) { issue.to_reference } let(:actual) { issue.to_reference }
set(:second_project) { create(:project, :public) } let_it_be(:second_project) { create(:project, :public) }
set(:second_issue) { create(:issue, project: second_project) } let_it_be(:second_issue) { create(:issue, project: second_project) }
it 'links to the issue' do it 'links to the issue' do
expected = urls.project_issue_path(second_project, second_issue) expected = urls.project_issue_path(second_project, second_issue)
...@@ -57,7 +57,7 @@ describe MarkupHelper do ...@@ -57,7 +57,7 @@ describe MarkupHelper do
describe 'uploads' do describe 'uploads' do
let(:text) { "![ImageTest](/uploads/test.png)" } let(:text) { "![ImageTest](/uploads/test.png)" }
set(:group) { create(:group) } let_it_be(:group) { create(:group) }
subject { helper.markdown(text) } subject { helper.markdown(text) }
...@@ -79,7 +79,7 @@ describe MarkupHelper do ...@@ -79,7 +79,7 @@ describe MarkupHelper do
end end
describe "with a group in the context" do describe "with a group in the context" do
set(:project_in_group) { create(:project, group: group) } let_it_be(:project_in_group) { create(:project, group: group) }
before do before do
helper.instance_variable_set(:@group, group) helper.instance_variable_set(:@group, group)
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
describe Projects::ErrorTrackingHelper do describe Projects::ErrorTrackingHelper do
include Gitlab::Routing.url_helpers include Gitlab::Routing.url_helpers
set(:project) { create(:project) } let_it_be(:project, reload: true) { create(:project) }
set(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
describe '#error_tracking_data' do describe '#error_tracking_data' do
let(:can_enable_error_tracking) { true } let(:can_enable_error_tracking) { true }
......
...@@ -7,8 +7,8 @@ describe Emails::PagesDomains do ...@@ -7,8 +7,8 @@ describe Emails::PagesDomains do
include EmailSpec::Matchers include EmailSpec::Matchers
include_context 'gitlab email notification' include_context 'gitlab email notification'
set(:domain) { create(:pages_domain, project: project) } let_it_be(:domain, reload: true) { create(:pages_domain, project: project) }
set(:user) { project.creator } let_it_be(:user) { project.creator }
shared_examples 'a pages domain email' do shared_examples 'a pages domain email' do
let(:recipient) { user } let(:recipient) { user }
......
...@@ -6,7 +6,7 @@ require 'email_spec' ...@@ -6,7 +6,7 @@ require 'email_spec'
describe Emails::Pipelines do describe Emails::Pipelines do
include EmailSpec::Matchers include EmailSpec::Matchers
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
shared_examples_for 'correct pipeline information' do shared_examples_for 'correct pipeline information' do
it 'has a correct information' do it 'has a correct information' do
......
...@@ -13,11 +13,11 @@ describe Notify do ...@@ -13,11 +13,11 @@ describe Notify do
let(:current_user_sanitized) { 'www_example_com' } let(:current_user_sanitized) { 'www_example_com' }
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') } let_it_be(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') }
set(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') } let_it_be(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') }
set(:merge_request) do let_it_be(:merge_request) do
create(:merge_request, source_project: project, create(:merge_request, source_project: project,
target_project: project, target_project: project,
author: current_user, author: current_user,
...@@ -25,7 +25,7 @@ describe Notify do ...@@ -25,7 +25,7 @@ describe Notify do
description: 'Awesome description') description: 'Awesome description')
end end
set(:issue) do let_it_be(:issue, reload: true) do
create(:issue, author: current_user, create(:issue, author: current_user,
assignees: [assignee], assignees: [assignee],
project: project, project: project,
...@@ -487,7 +487,7 @@ describe Notify do ...@@ -487,7 +487,7 @@ describe Notify do
end end
describe 'that are unmergeable' do describe 'that are unmergeable' do
set(:merge_request) do let_it_be(:merge_request) do
create(:merge_request, :conflict, create(:merge_request, :conflict,
source_project: project, source_project: project,
target_project: project, target_project: project,
...@@ -568,7 +568,7 @@ describe Notify do ...@@ -568,7 +568,7 @@ describe Notify do
end end
describe '#mail_thread' do describe '#mail_thread' do
set(:mail_thread_note) { create(:note) } let_it_be(:mail_thread_note) { create(:note) }
let(:headers) do let(:headers) do
{ {
...@@ -638,9 +638,9 @@ describe Notify do ...@@ -638,9 +638,9 @@ describe Notify do
let(:host) { Gitlab.config.gitlab.host } let(:host) { Gitlab.config.gitlab.host }
context 'in discussion' do context 'in discussion' do
set(:first_note) { create(:discussion_note_on_issue, project: project) } let_it_be(:first_note) { create(:discussion_note_on_issue, project: project) }
set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note, project: project) } let_it_be(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note, project: project) }
set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note, project: project) } let_it_be(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note, project: project) }
subject { described_class.note_issue_email(recipient.id, third_note.id) } subject { described_class.note_issue_email(recipient.id, third_note.id) }
...@@ -664,7 +664,7 @@ describe Notify do ...@@ -664,7 +664,7 @@ describe Notify do
end end
context 'individual issue comments' do context 'individual issue comments' do
set(:note) { create(:note_on_issue, project: project) } let_it_be(:note) { create(:note_on_issue, project: project) }
subject { described_class.note_issue_email(recipient.id, note.id) } subject { described_class.note_issue_email(recipient.id, note.id) }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
describe ApplicationSetting::TermPolicy do describe ApplicationSetting::TermPolicy do
include TermsHelper include TermsHelper
set(:term) { create(:term) } let_it_be(:term) { create(:term) }
let(:user) { create(:user) } let(:user) { create(:user) }
subject(:policy) { described_class.new(user, term) } subject(:policy) { described_class.new(user, term) }
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'spec_helper' require 'spec_helper'
describe Ci::PipelineSchedulePolicy, :models do describe Ci::PipelineSchedulePolicy, :models do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:project) { create(:project, :repository) } let_it_be(:project) { create(:project, :repository) }
set(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) } let_it_be(:pipeline_schedule, reload: true) { create(:ci_pipeline_schedule, :nightly, project: project) }
let(:policy) do let(:policy) do
described_class.new(user, pipeline_schedule) described_class.new(user, pipeline_schedule)
......
...@@ -5,12 +5,12 @@ require 'spec_helper' ...@@ -5,12 +5,12 @@ require 'spec_helper'
describe ProjectPolicy do describe ProjectPolicy do
include ExternalAuthorizationServiceHelpers include ExternalAuthorizationServiceHelpers
include_context 'ProjectPolicy context' include_context 'ProjectPolicy context'
set(:guest) { create(:user) } let_it_be(:guest) { create(:user) }
set(:reporter) { create(:user) } let_it_be(:reporter) { create(:user) }
set(:developer) { create(:user) } let_it_be(:developer) { create(:user) }
set(:maintainer) { create(:user) } let_it_be(:maintainer) { create(:user) }
set(:owner) { create(:user) } let_it_be(:owner) { create(:user) }
set(:admin) { create(:admin) } let_it_be(:admin) { create(:admin) }
let(:project) { create(:project, :public, namespace: owner.namespace) } let(:project) { create(:project, :public, namespace: owner.namespace) }
let(:base_guest_permissions) do let(:base_guest_permissions) do
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
require 'spec_helper' require 'spec_helper'
describe ResourceLabelEventPolicy do describe ResourceLabelEventPolicy do
set(:user) { create(:user) } let_it_be(:user) { create(:user) }
set(:project) { create(:project, :private) } let_it_be(:project) { create(:project, :private) }
set(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
set(:private_project) { create(:project, :private) } let_it_be(:private_project) { create(:project, :private) }
describe '#read_resource_label_event' do describe '#read_resource_label_event' do
context 'with non-member user' do context 'with non-member user' 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