Skip to content

Commit

Permalink
Remove FactoryBot.* prefix where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Jan 25, 2022
1 parent 642a586 commit f08bea3
Show file tree
Hide file tree
Showing 1,376 changed files with 8,553 additions and 8,551 deletions.
4 changes: 2 additions & 2 deletions app/seeders/development_data/custom_fields_seeder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def all_cfs
def create_types!(cfs)
# Create ALL CFs types
non_req_cfs = cfs.reject(&:is_required).map { |cf| "custom_field_#{cf.id}" }
type = FactoryBot.build :type, name: 'All CFS'
type = build :type, name: 'All CFS'
extend_group(type, ['Custom fields', non_req_cfs])
type.save!
print_status '.'

# Create type
req_cfs = cfs.select(&:is_required).map { |cf| "custom_field_#{cf.id}" }
type_req = FactoryBot.build :type, name: 'Required CF'
type_req = build :type, name: 'Required CF'
extend_group(type_req, ['Custom fields', req_cfs])
type_req.save!
print_status '.'
Expand Down
2 changes: 1 addition & 1 deletion modules/auth_plugins/spec/features/auth_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
end

describe 'in a public project', with_settings: { login_required: false } do
let(:public_project) { FactoryBot.build(:project, public: true) }
let(:public_project) { build(:project, public: true) }

it 'renders correctly' do
visit project_path(public_project)
Expand Down
2 changes: 1 addition & 1 deletion modules/auth_plugins/spec/views/base.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
describe 'authenticator plugin' do
include Redmine::MenuManager::MenuHelper
helper Redmine::MenuManager::MenuHelper
let(:anonymous) { FactoryBot.build_stubbed(:anonymous) }
let(:anonymous) { build_stubbed(:anonymous) }

before do
allow(view).to receive(:current_menu_item).and_return('overview')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

describe 'when logged in' do
let(:user) { FactoryBot.create :user }
let(:user) { create :user }

before do
login_as user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe ::Avatars::UsersController, type: :controller do
include_context "there are users with and without avatars"

let(:current_user) { FactoryBot.create :admin }
let(:current_user) { create :admin }
let(:enabled) { true }

before do
Expand All @@ -26,7 +26,7 @@
end

context 'as another user' do
let(:current_user) { FactoryBot.create :user }
let(:current_user) { create :user }
before do
get :show, params: { id: target_user.id }
end
Expand Down
2 changes: 1 addition & 1 deletion modules/avatars/spec/features/my_avatar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe 'My avatar management', type: :feature, js: true do
include Rails.application.routes.url_helpers

let(:user) { FactoryBot.create :user }
let(:user) { create :user }
let(:target_user) { user }
let(:avatar_management_path) { edit_my_avatar_path }

Expand Down
12 changes: 6 additions & 6 deletions modules/avatars/spec/features/user_avatar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
describe 'User avatar management', type: :feature, js: true do
include Rails.application.routes.url_helpers

let(:user) { FactoryBot.create :admin }
let(:user) { create :admin }
let(:avatar_management_path) { edit_user_path(target_user, tab: 'avatar') }

before do
login_as user
end

context 'when user is admin' do
let(:target_user) { FactoryBot.create :user }
let(:target_user) { create :user }
it_behaves_like 'avatar management'
end

context 'when user is self' do
let(:user) { FactoryBot.create :user }
let(:user) { create :user }
let(:target_user) { user }
it 'forbids the user to access' do
visit avatar_management_path
Expand All @@ -26,8 +26,8 @@
end

context 'when user is another user' do
let(:target_user) { FactoryBot.create :user }
let(:user) { FactoryBot.create :user }
let(:target_user) { create :user }
let(:user) { create :user }

it 'forbids the user to access' do
visit avatar_management_path
Expand All @@ -36,7 +36,7 @@
end

describe 'none enabled' do
let(:target_user) { FactoryBot.create :user }
let(:target_user) { create :user }

before do
allow(Setting)
Expand Down
4 changes: 2 additions & 2 deletions modules/avatars/spec/helpers/avatar_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe AvatarHelper, type: :helper, with_settings: { protocol: 'http' } do
include AngularHelper

let(:user) { FactoryBot.build_stubbed(:user) }
let(:user) { build_stubbed(:user) }
let(:mail_digest) { Digest::MD5.hexdigest(user.mail) }
let(:avatar_stub) { FactoryBot.build_stubbed(:avatar_attachment) }
let(:avatar_stub) { build_stubbed(:avatar_attachment) }

let(:enable_gravatars) { false }
let(:enable_local_avatars) { false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
require 'spec_helper'

describe ::API::V3::Users::UserRepresenter do
let(:user) { FactoryBot.build_stubbed(:user, status: 1) }
let(:current_user) { FactoryBot.build_stubbed(:user) }
let(:user) { build_stubbed(:user, status: 1) }
let(:current_user) { build_stubbed(:user) }
let(:representer) { described_class.new(user, current_user: current_user) }

context 'generation' do
Expand Down
2 changes: 1 addition & 1 deletion modules/avatars/spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

describe User, type: :model do
include_examples "there are users with and without avatars"
let(:user) { FactoryBot.build :user }
let(:user) { build :user }

specify { expect(user.attachments).to all be_a_kind_of Attachment }

Expand Down
8 changes: 4 additions & 4 deletions modules/avatars/spec/requests/user_avatar_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
include Rack::Test::Methods
include API::V3::Utilities::PathHelper

let(:current_user) { FactoryBot.create(:admin) }
let(:other_user) { FactoryBot.create(:user) }
let(:current_user) { create(:admin) }
let(:other_user) { create(:user) }

subject(:response) { last_response }

Expand Down Expand Up @@ -93,8 +93,8 @@
let(:local_avatars) { true }

let(:other_user) do
u = FactoryBot.create :user
u.attachments = [FactoryBot.build(:avatar_attachment, author: u)]
u = create :user
u.attachments = [build(:avatar_attachment, author: u)]
u
end

Expand Down
6 changes: 3 additions & 3 deletions modules/avatars/spec/services/avatars/update_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe ::Avatars::UpdateService do
let(:user_without_avatar) { FactoryBot.build_stubbed :user }
let(:user_without_avatar) { build_stubbed :user }
let(:user_with_avatar) do
u = FactoryBot.create :user
u.attachments = [FactoryBot.build(:avatar_attachment, author: u)]
u = create :user
u.attachments = [build(:avatar_attachment, author: u)]
u
end

Expand Down
12 changes: 6 additions & 6 deletions modules/avatars/spec/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

shared_examples_for "an action requiring login" do
let(:current) { FactoryBot.create(:user) }
let(:current) { create(:user) }

before do
allow(User).to receive(:current).and_return(current)
Expand All @@ -49,7 +49,7 @@
end

shared_examples_for "an action requiring admin" do
let(:current) { FactoryBot.create(:admin) }
let(:current) { create(:admin) }

before do
allow(User).to receive(:current).and_return(current)
Expand All @@ -67,7 +67,7 @@

describe "with being logged in as a normal user" do
before do
allow(User).to receive(:current).and_return FactoryBot.create(:user)
allow(User).to receive(:current).and_return create(:user)

action
end
Expand All @@ -91,10 +91,10 @@
end
shared_context "there are users with and without avatars" do
let(:base_path) { File.expand_path 'fixtures', __dir__ }
let(:user_without_avatar) { FactoryBot.create :user }
let(:user_without_avatar) { create :user }
let(:user_with_avatar) do
u = FactoryBot.create :user
u.attachments = [FactoryBot.build(:avatar_attachment, author: u)]
u = create :user
u.attachments = [build(:avatar_attachment, author: u)]
u
end
let(:avatar_file) do
Expand Down
8 changes: 4 additions & 4 deletions modules/backlogs/spec/api/work_package_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
include Rack::Test::Methods
include Capybara::RSpecMatchers

let(:current_user) { FactoryBot.create(:admin) }
let(:project) { FactoryBot.create(:project) }
let(:current_user) { create(:admin) }
let(:project) { create(:project) }
let(:work_package) do
FactoryBot.create(:work_package,
create(:work_package,
project: project,
story_points: 8,
remaining_hours: 5)
Expand Down Expand Up @@ -67,7 +67,7 @@

context 'backlogs deactivated' do
let(:project) do
FactoryBot.create(:project, disable_modules: 'backlogs')
create(:project, disable_modules: 'backlogs')
end

include_context 'query work package'
Expand Down
8 changes: 4 additions & 4 deletions modules/backlogs/spec/api/work_packages/form_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
include Rack::Test::Methods
include Capybara::RSpecMatchers

let(:project) { FactoryBot.create(:project, public: false) }
let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:authorized_user) { FactoryBot.create(:user, member_in_project: project) }
let(:unauthorized_user) { FactoryBot.create(:user) }
let(:project) { create(:project, public: false) }
let(:work_package) { create(:work_package, project: project) }
let(:authorized_user) { create(:user, member_in_project: project) }
let(:unauthorized_user) { create(:user) }

before do
allow(Story).to receive(:types).and_return([work_package.type_id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@
require 'spec_helper'

describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
let(:project) { FactoryBot.build(:project) }
let(:type) { FactoryBot.build(:type) }
let(:project) { build(:project) }
let(:type) { build(:type) }
let(:work_package) do
FactoryBot.build(:work_package,
build(:work_package,
project: project,
type: type)
end
let(:current_user) do
FactoryBot.build_stubbed(:user).tap do |u|
build_stubbed(:user).tap do |u|
allow(u)
.to receive(:allowed_to?)
.and_return(true)
end
end

shared_examples_for 'with parent which is a BACKLOGS type' do |writable|
let(:parent) { FactoryBot.create(:work_package, type: type_task) }
let(:parent) { create(:work_package, type: type_task) }

before do
work_package.parent_id = parent.id
Expand All @@ -58,7 +58,7 @@
end

shared_examples_for 'with parent which is not a BACKLOGS type' do
let(:parent) { FactoryBot.create(:work_package, type: type_feature) }
let(:parent) { create(:work_package, type: type_feature) }

before do
work_package.parent_id = parent.id
Expand Down Expand Up @@ -100,8 +100,8 @@

describe '#version_writable?' do
subject { described_class.new(work_package: work_package) }
let(:type_task) { FactoryBot.create(:type_task) }
let(:type_feature) { FactoryBot.create(:type_feature) }
let(:type_task) { create(:type_task) }
let(:type_feature) { create(:type_feature) }

before do
allow(WorkPackage).to receive(:backlogs_types).and_return([type_task.id])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
require 'spec_helper'

describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:custom_field) { FactoryBot.build(:custom_field) }
let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package, type: FactoryBot.build_stubbed(:type)) }
let(:custom_field) { build(:custom_field) }
let(:work_package) { build_stubbed(:stubbed_work_package, type: build_stubbed(:type)) }
let(:current_user) do
FactoryBot.build_stubbed(:user, member_in_project: work_package.project).tap do |u|
build_stubbed(:user, member_in_project: work_package.project).tap do |u|
allow(u)
.to receive(:allowed_to?)
.and_return(false)
Expand Down
Loading

0 comments on commit f08bea3

Please sign in to comment.