diff --git a/Gemfile b/Gemfile index df96ebf989..30389565e5 100644 --- a/Gemfile +++ b/Gemfile @@ -178,12 +178,12 @@ group :test do gem 'shoulda-context', '~> 1.2' gem 'launchy', '~> 2.4.3' - # Require factory_girl for usage with openproject plugins testing - # FactoryGirl needs to be available when loading app otherwise factory + # Require factory_bot for usage with openproject plugins testing + # FactoryBot needs to be available when loading app otherwise factory # definitions from core are not available in the plugin thus specs break - gem 'factory_girl', '~> 4.5' - # require factory_girl_rails for convenience in core development - gem 'factory_girl_rails', '~> 4.7', require: false + gem 'factory_bot', '~> 4.8' + # require factory_bot_rails for convenience in core development + gem 'factory_bot_rails', '~> 4.8', require: false # Test prof provides factories from code # and other niceties diff --git a/Gemfile.lock b/Gemfile.lock index 4dd9178dfc..d9c658739f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -263,10 +263,10 @@ GEM eventmachine (1.2.5) excon (0.52.0) execjs (2.7.0) - factory_girl (4.9.0) + factory_bot (4.8.2) activesupport (>= 3.0.0) - factory_girl_rails (4.9.0) - factory_girl (~> 4.9.0) + factory_bot_rails (4.8.2) + factory_bot (~> 4.8.2) railties (>= 3.0.0) faker (1.8.4) i18n (~> 0.5) @@ -654,8 +654,8 @@ DEPENDENCIES date_validator (~> 0.9.0) delayed_job_active_record (~> 4.1.1) equivalent-xml (~> 0.6) - factory_girl (~> 4.5) - factory_girl_rails (~> 4.7) + factory_bot (~> 4.8) + factory_bot_rails (~> 4.8) faker fog-aws friendly_id (~> 5.2.1) diff --git a/app/seeders/development_data/custom_fields_seeder.rb b/app/seeders/development_data/custom_fields_seeder.rb index f49d352bb8..9c0e542da8 100644 --- a/app/seeders/development_data/custom_fields_seeder.rb +++ b/app/seeders/development_data/custom_fields_seeder.rb @@ -46,14 +46,14 @@ module DevelopmentData def create_types!(cfs) # Create ALL CFs types non_req_cfs = cfs.reject(&:is_required).map { |cf| "custom_field_#{cf.id}" } - type = FactoryGirl.build :type_with_workflow, name: 'All CFS' + type = FactoryBot.build :type_with_workflow, name: 'All CFS' extend_group(type, ['Custom fields', non_req_cfs]) type.save! print '.' # Create type req_cfs = cfs.select(&:is_required).map { |cf| "custom_field_#{cf.id}" } - type_req = FactoryGirl.build :type_with_workflow, name: 'Required CF' + type_req = FactoryBot.build :type_with_workflow, name: 'Required CF' extend_group(type_req, ['Custom fields', req_cfs]) type_req.save! print '.' diff --git a/app/seeders/root_seeder.rb b/app/seeders/root_seeder.rb index 47a81f10c7..b59028583c 100644 --- a/app/seeders/root_seeder.rb +++ b/app/seeders/root_seeder.rb @@ -63,9 +63,9 @@ class RootSeeder < Seeder if Rails.env.development? puts '*** Seeding development data' - require 'factory_girl' - # Load FactoryGirl factories - ::FactoryGirl.find_definitions + require 'factory_bot' + # Load FactoryBot factories + ::FactoryBot.find_definitions DevelopmentDataSeeder.new.seed! end diff --git a/features/step_definitions/board_steps.rb b/features/step_definitions/board_steps.rb index 9e41d1159b..b1f99bfd46 100644 --- a/features/step_definitions/board_steps.rb +++ b/features/step_definitions/board_steps.rb @@ -28,7 +28,7 @@ #++ Given(/^there is a board "(.*?)" for project "(.*?)"$/) do |board_name, project_identifier| - FactoryGirl.create :board, project: get_project(project_identifier), name: board_name + FactoryBot.create :board, project: get_project(project_identifier), name: board_name end Given(/^the board "(.*?)" has the following messages:$/) do |board_name, table| @@ -47,7 +47,7 @@ private def create_messages(names, board, parent = nil) names.each do |name| - FactoryGirl.create :message, + FactoryBot.create :message, board: board, subject: name, parent: parent diff --git a/features/step_definitions/common_steps.rb b/features/step_definitions/common_steps.rb index 56ff177119..7f64d99cee 100644 --- a/features/step_definitions/common_steps.rb +++ b/features/step_definitions/common_steps.rb @@ -44,7 +44,7 @@ Given /^the [pP]roject(?: "([^\"]+?)")? uses the following types:$/ do |project, name = line.first type = ::Type.find_by(name: name) - type = FactoryGirl.create(:type, name: name) if type.blank? + type = FactoryBot.create(:type, name: name) if type.blank? type } diff --git a/features/step_definitions/custom_field_steps.rb b/features/step_definitions/custom_field_steps.rb index bc9ad114ea..095d904837 100644 --- a/features/step_definitions/custom_field_steps.rb +++ b/features/step_definitions/custom_field_steps.rb @@ -48,7 +48,7 @@ Given /^the following (user|issue|work package) custom fields are defined:$/ do attr_hash[:default_value] = r[:default_value] ? r[:default_value] : nil attr_hash[:is_for_all] = r[:is_for_all] || true - FactoryGirl.create type, attr_hash + FactoryBot.create type, attr_hash end end end diff --git a/features/step_definitions/general_steps.rb b/features/step_definitions/general_steps.rb index e9a5b0ebf7..3766e86c96 100644 --- a/features/step_definitions/general_steps.rb +++ b/features/step_definitions/general_steps.rb @@ -32,14 +32,14 @@ require 'rack_session_access/capybara' Before do |scenario| unless ScenarioDisabler.empty_if_disabled(scenario) - FactoryGirl.create(:admin) unless User.find_by_login('admin') - FactoryGirl.create(:anonymous) unless AnonymousUser.count > 0 + FactoryBot.create(:admin) unless User.find_by_login('admin') + FactoryBot.create(:anonymous) unless AnonymousUser.count > 0 Setting.notified_events = [] # can not test mailer end end Given /^I am logged in$/ do - @user = FactoryGirl.create :user + @user = FactoryBot.create :user page.set_rack_session(user_id: @user.id, updated_at: Time.now) end @@ -86,7 +86,7 @@ Given /^(?:|I )am (not )?impaired$/ do |bool| end Given /^there is 1 [pP]roject with(?: the following)?:$/ do |table| - p = FactoryGirl.build(:project) + p = FactoryBot.build(:project) send_table_to_object(p, table) end @@ -121,8 +121,8 @@ Given /^the [Uu]ser "([^\"]*)" has 1 time [eE]ntry$/ do |user| u = User.find_by login: user p = u.projects.last raise 'This user must be member of a project to have issues' unless p - i = FactoryGirl.create(:work_package, project: p) - t = FactoryGirl.build(:time_entry) + i = FactoryBot.create(:work_package, project: p) + t = FactoryBot.build(:time_entry) t.user = u t.issue = i t.project = p @@ -134,8 +134,8 @@ end Given /^the [Uu]ser "([^\"]*)" has 1 time entry with (\d+\.?\d*) hours? at the project "([^\"]*)"$/ do |user, hours, project| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin do - t = FactoryGirl.build(:time_entry) - i = FactoryGirl.create(:work_package, project: p) + t = FactoryBot.build(:time_entry) + i = FactoryBot.create(:work_package, project: p) t.project = p t.issue = i t.hours = hours.to_f @@ -149,8 +149,8 @@ end Given /^the [Pp]roject "([^\"]*)" has (\d+) [tT]ime(?: )?[eE]ntr(?:ies|y) with the following:$/ do |project, count, table| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin count do - t = FactoryGirl.build(:time_entry) - i = FactoryGirl.create(:work_package, project: p) + t = FactoryBot.build(:time_entry) + i = FactoryBot.create(:work_package, project: p) t.project = p t.work_package = i t.activity.project = p @@ -173,14 +173,14 @@ end Given /^the [pP]roject "([^\"]*)" has 1 [sS]ubproject$/ do |project| parent = Project.find_by(name: project) - p = FactoryGirl.create(:project) + p = FactoryBot.create(:project) p.set_parent!(parent) p.save! end Given /^the [pP]roject "([^\"]*)" has 1 [sS]ubproject with the following:$/ do |project, table| parent = Project.find_by(name: project) - p = FactoryGirl.build(:project) + p = FactoryBot.build(:project) as_admin do send_table_to_object(p, table) end @@ -231,7 +231,7 @@ Given /^the [iI]ssue "([^\"]*)" has (\d+) [tT]ime(?: )?[eE]ntr(?:ies|y) with the i = WorkPackage.where(["subject = '#{issue}'"]).last raise "No such issue: #{issue}" unless i as_admin count do - t = FactoryGirl.build(:time_entry) + t = FactoryBot.build(:time_entry) t.project = i.project t.spent_on = DateTime.now t.work_package = i diff --git a/features/step_definitions/group_steps.rb b/features/step_definitions/group_steps.rb index cf78756d14..1eabf7ac90 100644 --- a/features/step_definitions/group_steps.rb +++ b/features/step_definitions/group_steps.rb @@ -28,7 +28,7 @@ #++ Given /^there is 1 group with the following:$/ do |table| - group = FactoryGirl.build(:group) + group = FactoryBot.build(:group) send_table_to_object group, table, name: Proc.new { |group, name| group.lastname = name } end @@ -63,11 +63,11 @@ When /^I add the user "(.+)" to the group$/ do |user_login| end Given /^We have the group "(.*?)"/ do |name| - group = FactoryGirl.create(:group, lastname: name) + group = FactoryBot.create(:group, lastname: name) end Given /^there is a group named "(.*?)" with the following members:$/ do |name, table| - group = FactoryGirl.create(:group, lastname: name) + group = FactoryBot.create(:group, lastname: name) table.raw.flatten.each do |login| group.users << User.find_by!(login: login) diff --git a/features/step_definitions/issue_category_steps.rb b/features/step_definitions/issue_category_steps.rb index 1c613f550c..cbb1f58f3d 100644 --- a/features/step_definitions/issue_category_steps.rb +++ b/features/step_definitions/issue_category_steps.rb @@ -33,7 +33,7 @@ Given /^the [Pp]roject "([^\"]*)" has (\d+) [cC]ategor(?:ies|y)? with(?: the fol p = Project.find_by(name: project) || Project.find_by(identifier: project) table.rows_hash['assigned_to'] = Principal.like(table.rows_hash['assigned_to']).first if table.rows_hash['assigned_to'] as_admin count do - ic = FactoryGirl.build(:category, project: p) + ic = FactoryBot.build(:category, project: p) send_table_to_object(ic, table) ic.save end @@ -42,7 +42,7 @@ end Given /^the [Pp]roject "([^\"]*)" has (\d+) [cC]ategor(?:ies|y)?$/ do |project, count| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin count do - ic = FactoryGirl.build(:category, project: p) + ic = FactoryBot.build(:category, project: p) ic.save end end diff --git a/features/step_definitions/issue_steps.rb b/features/step_definitions/issue_steps.rb index 2230c164b0..38f7445684 100644 --- a/features/step_definitions/issue_steps.rb +++ b/features/step_definitions/issue_steps.rb @@ -46,7 +46,7 @@ Given(/^the issue "(.*?)" has an attachment "(.*?)"$/) do |issue_subject, file_n issue = WorkPackage.where(subject: issue_subject).order(:created_at).last file = OpenProject::Files.create_temp_file name: file_name, content: 'random content which is not actually a gif' - attachment = FactoryGirl.create :attachment, + attachment = FactoryBot.create :attachment, author: issue.author, content_type: content_type, file: file, @@ -60,11 +60,11 @@ Given /^the [Uu]ser "([^\"]*)" has (\d+) [iI]ssue(?:s)? with(?: the following)?: u = User.find_by login: user raise 'This user must be member of a project to have issues' unless u.projects.last as_admin count do - i = FactoryGirl.create(:work_package, + i = FactoryBot.create(:work_package, project: u.projects.last, author: u, assigned_to: u, - status: Status.default || FactoryGirl.create(:status)) + status: Status.default || FactoryBot.create(:status)) i.type = ::Type.find_by(name: table.rows_hash.delete('type')) if table.rows_hash['type'] @@ -76,7 +76,7 @@ end Given /^the [Pp]roject "([^\"]*)" has (\d+) [iI]ssue(?:s)? with(?: the following)?:$/ do |project, count, table| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin count do - i = FactoryGirl.build(:work_package, project: p, + i = FactoryBot.build(:work_package, project: p, type: p.types.first) send_table_to_object(i, table, {}, method(:add_custom_value_to_issue)) end @@ -121,7 +121,7 @@ Given (/^there are the following issues with attributes:$/) do |table| category = Category.find_by(name: attributes.delete('category')) attributes.merge! category_id: category.id if category - issue = FactoryGirl.create(:work_package, attributes) + issue = FactoryBot.create(:work_package, attributes) if watchers watchers.split(',').each do |w| issue.add_watcher User.find_by_login(w) end diff --git a/features/step_definitions/priority_steps.rb b/features/step_definitions/priority_steps.rb index add6c41323..7f5f444457 100644 --- a/features/step_definitions/priority_steps.rb +++ b/features/step_definitions/priority_steps.rb @@ -32,7 +32,7 @@ InstanceFinder.register(IssuePriority, Proc.new { |name| IssuePriority.find_by(n Given /^there is a(?:n)? (default )?issuepriority with:$/ do |default, table| name = table.raw.find { |ary| ary.include? 'name' }[table.raw.first.index('name') + 1].to_s project = get_project - FactoryGirl.build(:priority).tap do |prio| + FactoryBot.build(:priority).tap do |prio| prio.name = name prio.is_default = !!default prio.project = project @@ -43,7 +43,7 @@ Given /^there are the following priorities:$/ do |table| table.hashes.each do |row| project = get_project - FactoryGirl.build(:priority).tap do |prio| + FactoryBot.build(:priority).tap do |prio| prio.name = row[:name] prio.is_default = row[:default] == 'true' prio.project = project diff --git a/features/step_definitions/project_steps.rb b/features/step_definitions/project_steps.rb index 6050a4c22f..f625af44ef 100644 --- a/features/step_definitions/project_steps.rb +++ b/features/step_definitions/project_steps.rb @@ -35,5 +35,5 @@ Given /^there is a project named "([^"]*)"(?: of type "([^"]*)")?$/ do |name, pr attributes.merge!(project_type: ProjectType.find_by!(name: project_type_name)) end - FactoryGirl.create(:project, attributes) + FactoryBot.create(:project, attributes) end diff --git a/features/step_definitions/query_steps.rb b/features/step_definitions/query_steps.rb index 9fa558fb7d..530ab38345 100644 --- a/features/step_definitions/query_steps.rb +++ b/features/step_definitions/query_steps.rb @@ -30,7 +30,7 @@ Given /^the [Pp]roject "([^\"]*)" has (\d+) [wW]ork [pP]ackage [qQ]uer(?:ies|y)? with(?: the following)?:$/ do |project, count, table| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin count do - i = FactoryGirl.build(:query, project: p) + i = FactoryBot.build(:query, project: p) send_table_to_object(i, table) i.save end @@ -39,7 +39,7 @@ end Given /^the [Pp]roject "([^\"]*)" has (\d+) [wW]ork [pP]ackage [qQ]uer(?:ies|y)?$/ do |project, count| p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin count do - i = FactoryGirl.build(:query, project: p) + i = FactoryBot.build(:query, project: p) i.save end end diff --git a/features/step_definitions/repository_steps.rb b/features/step_definitions/repository_steps.rb index dd2a08f61e..c622d7a5de 100644 --- a/features/step_definitions/repository_steps.rb +++ b/features/step_definitions/repository_steps.rb @@ -30,7 +30,7 @@ Given(/^the project "(.*?)" has a repository$/) do |project_name| project = Project.find(project_name) - repo = FactoryGirl.build(:repository_subversion, + repo = FactoryBot.build(:repository_subversion, project: project) Setting.enabled_scm = Setting.enabled_scm << repo.vendor diff --git a/features/step_definitions/role_steps.rb b/features/step_definitions/role_steps.rb index 50cbbbc3bc..bf52c39ac0 100644 --- a/features/step_definitions/role_steps.rb +++ b/features/step_definitions/role_steps.rb @@ -41,16 +41,16 @@ Given /^the [Uu]ser "([^\"]*)" is a "([^\"]*)" (?:in|of) the [Pp]roject "([^\"]* end Given /^there is a [rR]ole "([^\"]*)"$/ do |name, _table = nil| - FactoryGirl.create(:role, name: name) unless Role.find_by(name: name) + FactoryBot.create(:role, name: name) unless Role.find_by(name: name) end Given /^there is a [rR]ole "([^\"]*)" with the following permissions:?$/ do |name, table| - FactoryGirl.create(:role, name: name, permissions: table.raw.flatten) unless Role.find_by(name: name) + FactoryBot.create(:role, name: name, permissions: table.raw.flatten) unless Role.find_by(name: name) end Given /^there are the following roles:$/ do |table| table.raw.flatten.each do |name| - FactoryGirl.create(:role, name: name) unless Role.find_by(name: name) + FactoryBot.create(:role, name: name) unless Role.find_by(name: name) end end diff --git a/features/step_definitions/search_steps.rb b/features/step_definitions/search_steps.rb index 27004ec59c..44832d13e1 100644 --- a/features/step_definitions/search_steps.rb +++ b/features/step_definitions/search_steps.rb @@ -28,7 +28,7 @@ #++ Given(/^there are (\d+) work packages with "(.*?)" in their description$/) do |num, desc| - work_packages = FactoryGirl.create_list :work_package, num.to_i, description: desc + work_packages = FactoryBot.create_list :work_package, num.to_i, description: desc time = Time.now # ensure temporal order: work_packages.reverse.each_with_index do |wp, i| diff --git a/features/step_definitions/status_steps.rb b/features/step_definitions/status_steps.rb index 1be7dc1208..27dcf312e1 100644 --- a/features/step_definitions/status_steps.rb +++ b/features/step_definitions/status_steps.rb @@ -37,7 +37,7 @@ Given /^there are the following status:$/ do |table| attributes = row.inject({}) { |mem, (k, v)| mem[k.to_sym] = v if v.present?; mem } attributes[:is_default] = attributes.delete(:default) == 'true' - FactoryGirl.create(:status, attributes) + FactoryBot.create(:status, attributes) end end diff --git a/features/step_definitions/time_entry_steps.rb b/features/step_definitions/time_entry_steps.rb index 82aad938b5..9773e1f1af 100644 --- a/features/step_definitions/time_entry_steps.rb +++ b/features/step_definitions/time_entry_steps.rb @@ -29,11 +29,11 @@ Given(/^there is a time entry for "(.*?)" with (\d+) hours$/) do |subject, hours| work_package = WorkPackage.find_by(subject: subject) - time_entry = FactoryGirl.create(:time_entry, work_package: work_package, hours: hours, project: work_package.project) + time_entry = FactoryBot.create(:time_entry, work_package: work_package, hours: hours, project: work_package.project) end Given(/^there is an activity "(.*?)"$/) do |name| - FactoryGirl.create(:time_entry_activity, name: name) + FactoryBot.create(:time_entry_activity, name: name) end When(/^I log (\d+) hours with the comment "(.*?)"$/) do |hours, comment| diff --git a/features/step_definitions/type_steps.rb b/features/step_definitions/type_steps.rb index 9a989b8f82..71bd5c702a 100644 --- a/features/step_definitions/type_steps.rb +++ b/features/step_definitions/type_steps.rb @@ -35,7 +35,7 @@ RouteMap.register(::Type, '/types') Given /^the following types are enabled for the project called "(.*?)":$/ do |project_name, type_name_table| types = type_name_table.raw.flatten.map { |type_name| - ::Type.find_by(name: type_name) || FactoryGirl.create(:type, name: type_name) + ::Type.find_by(name: type_name) || FactoryBot.create(:type, name: type_name) } project = Project.find_by(identifier: project_name) diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 98d5a6fd87..b1310fc331 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -73,7 +73,7 @@ Given /^there is 1 [Uu]ser with(?: the following)?:$/ do |table| user = User.find_by_login(login) unless login.blank? if !user - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) user.pref user.password = user.password_confirmation = nil end @@ -110,7 +110,7 @@ end Given /^there are the following users:$/ do |table| table.raw.flatten.each do |login| - FactoryGirl.create(:user, login: login) + FactoryBot.create(:user, login: login) end end diff --git a/features/step_definitions/version_steps.rb b/features/step_definitions/version_steps.rb index 3b0128b597..83e3d9b017 100644 --- a/features/step_definitions/version_steps.rb +++ b/features/step_definitions/version_steps.rb @@ -34,7 +34,7 @@ Given /^the [Pp]roject (.+) has 1 version with(?: the following)?:$/ do |project p = Project.find_by(name: project) || Project.find_by(identifier: project) as_admin do - v = FactoryGirl.build(:version) { |v| + v = FactoryBot.build(:version) { |v| v.project = p } send_table_to_object(v, table) diff --git a/features/step_definitions/wiki_steps.rb b/features/step_definitions/wiki_steps.rb index 743dff4bff..22c3cb6d2c 100644 --- a/features/step_definitions/wiki_steps.rb +++ b/features/step_definitions/wiki_steps.rb @@ -32,8 +32,8 @@ Given /^the [Pp]roject "([^\"]*)" has 1 [wW]iki(?: )?[pP]age with the following: p.wiki = Wiki.create unless p.wiki - page = FactoryGirl.create(:wiki_page, wiki: p.wiki) - content = FactoryGirl.create(:wiki_content, page: page) + page = FactoryBot.create(:wiki_page, wiki: p.wiki) + content = FactoryBot.create(:wiki_content, page: page) send_table_to_object(page, table) end @@ -43,7 +43,7 @@ Given /^there are no wiki menu items$/ do end Given /^the project "(.*?)" has (?:1|a) wiki menu item with the following:$/ do |project_name, table| - item = FactoryGirl.build(:wiki_menu_item) + item = FactoryBot.build(:wiki_menu_item) send_table_to_object(item, table) item.wiki = Project.find_by(name: project_name).wiki item.save! @@ -51,11 +51,11 @@ end Given /^the project "(.*?)" has a child wiki page of "(.*?)" with the following:$/ do |project_name, parent_page_title, table| wiki = Project.find_by(name: project_name).wiki - wikipage = FactoryGirl.build(:wiki_page, wiki: wiki) + wikipage = FactoryBot.build(:wiki_page, wiki: wiki) send_table_to_object(wikipage, table) - FactoryGirl.create(:wiki_content, page: wikipage) + FactoryBot.create(:wiki_content, page: wikipage) parent_page = WikiPage.find_by(wiki_id: wiki.id, title: parent_page_title) wikipage.parent_id = parent_page.id @@ -87,15 +87,15 @@ Given /^the wiki page "([^"]*)" of the project "([^"]*)" has (\d+) versions{0,1} wiki = project.wiki wp = wiki.pages.find_or_create_by(title: page) wp.save! unless wp.persisted? - wc = wp.content || FactoryGirl.create(:wiki_content, page: wp) + wc = wp.content || FactoryBot.create(:wiki_content, page: wp) last_version = wc.journals.max(&:version).version version_count.to_i.times.each do |v| version = last_version + v + 1 - data = FactoryGirl.build(:journal_wiki_content_journal, + data = FactoryBot.build(:journal_wiki_content_journal, text: "This is version #{version}") - FactoryGirl.create(:wiki_content_journal, + FactoryBot.create(:wiki_content_journal, version: version, data: data, journable_id: wc.id) diff --git a/features/step_definitions/work_package_changesets_steps.rb b/features/step_definitions/work_package_changesets_steps.rb index 2861f0b3c1..2a0b90434e 100644 --- a/features/step_definitions/work_package_changesets_steps.rb +++ b/features/step_definitions/work_package_changesets_steps.rb @@ -33,7 +33,7 @@ Given(/^the work package "(.*?)" has the following changesets:$/) do |subject, t repo = wp.project.repository wp_changesets = table.hashes.map { |row| - FactoryGirl.build(:changeset, row.merge(repository: repo)) + FactoryBot.build(:changeset, row.merge(repository: repo)) } wp.changesets = wp_changesets diff --git a/features/step_definitions/work_package_steps.rb b/features/step_definitions/work_package_steps.rb index 808ac2deaa..175251e7cb 100644 --- a/features/step_definitions/work_package_steps.rb +++ b/features/step_definitions/work_package_steps.rb @@ -48,7 +48,7 @@ Given /^a relation between "(.*?)" and "(.*?)"$/ do |work_package_from, work_pac from = WorkPackage.find_by(subject: work_package_from) to = WorkPackage.find_by(subject: work_package_to) - FactoryGirl.create :relation, from: from, to: to + FactoryBot.create :relation, from: from, to: to end Given /^user is already watching "(.*?)"$/ do |work_package_subject| diff --git a/features/support/env.rb b/features/support/env.rb index 374b3d5a12..ee322419ed 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -42,7 +42,7 @@ end require 'cucumber/rails' require 'cucumber/rspec/doubles' require 'capybara-screenshot/cucumber' -require 'factory_girl_rails' +require 'factory_bot_rails' # Load paths to ensure they are loaded before the plugin's paths.rbs. # Plugin's path_to functions rely on being loaded after the core's path_to @@ -150,8 +150,8 @@ Before do end Before do - FactoryGirl.create(:non_member) - FactoryGirl.create(:anonymous_role) + FactoryBot.create(:non_member) + FactoryBot.create(:anonymous_role) end World(Capybara::Select2) diff --git a/lib/open_project/plugins/acts_as_op_engine.rb b/lib/open_project/plugins/acts_as_op_engine.rb index d814d420e4..901fd1ca3a 100644 --- a/lib/open_project/plugins/acts_as_op_engine.rb +++ b/lib/open_project/plugins/acts_as_op_engine.rb @@ -65,8 +65,8 @@ module OpenProject::Plugins end # adds our factories to factory girl's load path - initializer "#{engine_name}.register_factories", after: 'factory_girl.set_factory_paths' do |_app| - FactoryGirl.definition_file_paths << File.expand_path(root.to_s + '/spec/factories') if defined?(FactoryGirl) + initializer "#{engine_name}.register_factories", after: 'factory_bot.set_factory_paths' do |_app| + FactoryBot.definition_file_paths << File.expand_path(root.to_s + '/spec/factories') if defined?(FactoryBot) end initializer "#{engine_name}.append_migrations" do |app| diff --git a/spec/contracts/custom_actions/cu_contract_spec.rb b/spec/contracts/custom_actions/cu_contract_spec.rb index 513b354697..d09f1129d8 100644 --- a/spec/contracts/custom_actions/cu_contract_spec.rb +++ b/spec/contracts/custom_actions/cu_contract_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe CustomActions::CUContract do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:action) do - FactoryGirl.build_stubbed(:custom_action, actions: + FactoryBot.build_stubbed(:custom_action, actions: [CustomActions::Actions::AssignedTo.new]) end let(:instance) { described_class.new(action) } diff --git a/spec/contracts/relations/create_contract_spec.rb b/spec/contracts/relations/create_contract_spec.rb index b1679dd06c..0d8b482056 100644 --- a/spec/contracts/relations/create_contract_spec.rb +++ b/spec/contracts/relations/create_contract_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe Relations::CreateContract do - let(:from) { FactoryGirl.build_stubbed :work_package } - let(:to) { FactoryGirl.build_stubbed :work_package } - let(:user) { FactoryGirl.build_stubbed :admin } + let(:from) { FactoryBot.build_stubbed :work_package } + let(:to) { FactoryBot.build_stubbed :work_package } + let(:user) { FactoryBot.build_stubbed :admin } let(:relation) do Relation.new from: from, to: to, relation_type: "follows", delay: 42 diff --git a/spec/contracts/users/create_contract_spec.rb b/spec/contracts/users/create_contract_spec.rb index 661522cf89..1927f19b00 100644 --- a/spec/contracts/users/create_contract_spec.rb +++ b/spec/contracts/users/create_contract_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe Users::CreateContract do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } subject(:contract) { described_class.new(user, current_user) } @@ -49,7 +49,7 @@ describe Users::CreateContract do end context 'when admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } it_behaves_like 'is valid' @@ -74,7 +74,7 @@ describe Users::CreateContract do end context 'when not admin' do - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } it 'is invalid' do expect_valid(false, base: %i(error_unauthorized)) diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rb index d9cca01b0a..cdaff9c360 100644 --- a/spec/contracts/work_packages/base_contract_spec.rb +++ b/spec/contracts/work_packages/base_contract_spec.rb @@ -30,15 +30,15 @@ require 'spec_helper' describe WorkPackages::BaseContract do let(:work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, type: type, done_ratio: 50, estimated_hours: 6.0, project: project) end - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:member) do - u = FactoryGirl.build_stubbed(:user) + u = FactoryBot.build_stubbed(:user) allow(u) .to receive(:allowed_to?) @@ -53,7 +53,7 @@ describe WorkPackages::BaseContract do u end - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:current_user) { member } let(:permissions) do %i( @@ -237,7 +237,7 @@ describe WorkPackages::BaseContract do context 'before soonest start date of parent' do before do - work_package.parent = FactoryGirl.build_stubbed(:work_package) + work_package.parent = FactoryBot.build_stubbed(:work_package) allow(work_package) .to receive(:soonest_start) .and_return(Date.today + 4.days) @@ -299,8 +299,8 @@ describe WorkPackages::BaseContract do describe 'fixed_version' do subject(:contract) { described_class.new(work_package, current_user) } - let(:assignable_version) { FactoryGirl.build_stubbed(:version) } - let(:invalid_version) { FactoryGirl.build_stubbed(:version) } + let(:assignable_version) { FactoryBot.build_stubbed(:version) } + let(:invalid_version) { FactoryBot.build_stubbed(:version) } before do allow(work_package) @@ -331,7 +331,7 @@ describe WorkPackages::BaseContract do end context 'for a closed version' do - let(:assignable_version) { FactoryGirl.build_stubbed(:version, status: 'closed') } + let(:assignable_version) { FactoryBot.build_stubbed(:version, status: 'closed') } context 'when reopening a work package' do before do @@ -362,8 +362,8 @@ describe WorkPackages::BaseContract do end describe 'parent' do - let(:child) { FactoryGirl.build_stubbed(:stubbed_work_package) } - let(:parent) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:child) { FactoryBot.build_stubbed(:stubbed_work_package) } + let(:parent) { FactoryBot.build_stubbed(:stubbed_work_package) } before do work_package.parent = parent @@ -428,7 +428,7 @@ describe WorkPackages::BaseContract do end describe 'changing the type' do - let(:other_type) { FactoryGirl.build_stubbed(:type) } + let(:other_type) { FactoryBot.build_stubbed(:type) } it 'is invalid' do work_package.type = other_type @@ -441,7 +441,7 @@ describe WorkPackages::BaseContract do end describe 'changing the project (and that one not having the type)' do - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } it 'is invalid' do work_package.project = other_project @@ -456,7 +456,7 @@ describe WorkPackages::BaseContract do end describe 'category' do - let(:category) { FactoryGirl.build_stubbed(:category) } + let(:category) { FactoryBot.build_stubbed(:category) } context "one of the project's categories" do before do @@ -520,8 +520,8 @@ describe WorkPackages::BaseContract do end describe 'priority' do - let (:active_priority) { FactoryGirl.build_stubbed(:priority) } - let (:inactive_priority) { FactoryGirl.build_stubbed(:priority, active: false) } + let (:active_priority) { FactoryBot.build_stubbed(:priority) } + let (:inactive_priority) { FactoryBot.build_stubbed(:priority, active: false) } context 'active priority' do before do @@ -565,9 +565,9 @@ describe WorkPackages::BaseContract do end describe 'status' do - let(:roles) { [FactoryGirl.build_stubbed(:role)] } + let(:roles) { [FactoryBot.build_stubbed(:role)] } let(:valid_transition_result) { true } - let(:new_status) { FactoryGirl.build_stubbed(:status) } + let(:new_status) { FactoryBot.build_stubbed(:status) } let(:from_id) { work_package.status_id } let(:to_id) { new_status.id } let(:status_change) { work_package.status = new_status } @@ -619,7 +619,7 @@ describe WorkPackages::BaseContract do let(:valid_transition_result) { false } let(:status_change) do work_package.status = new_status - work_package.type = FactoryGirl.build_stubbed(:type) + work_package.type = FactoryBot.build_stubbed(:type) end it 'is valid' do diff --git a/spec/contracts/work_packages/create_contract_spec.rb b/spec/contracts/work_packages/create_contract_spec.rb index 5d65bfcd62..9ce1ac4951 100644 --- a/spec/contracts/work_packages/create_contract_spec.rb +++ b/spec/contracts/work_packages/create_contract_spec.rb @@ -32,8 +32,8 @@ require 'contracts/work_packages/shared_base_contract' describe WorkPackages::CreateContract do let(:work_package) { WorkPackage.new } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user) { FactoryBot.build_stubbed(:user) } subject(:contract) { described_class.new(work_package, user) } let(:validated_contract) { @@ -125,7 +125,7 @@ describe WorkPackages::CreateContract do end it 'is invalid if the user is different from the user the contract is evaluated for' do - work_package.author = FactoryGirl.build_stubbed(:user) + work_package.author = FactoryBot.build_stubbed(:user) expect(validated_contract.errors.symbols_for(:author_id)) .to match_array [:invalid] diff --git a/spec/contracts/work_packages/create_note_contract_spec.rb b/spec/contracts/work_packages/create_note_contract_spec.rb index 8382841398..4693e995d1 100644 --- a/spec/contracts/work_packages/create_note_contract_spec.rb +++ b/spec/contracts/work_packages/create_note_contract_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe WorkPackages::CreateNoteContract do let(:work_package) do # As we only want to test the contract, we mock checking whether the work_package is valid - wp = FactoryGirl.build_stubbed(:work_package) + wp = FactoryBot.build_stubbed(:work_package) # we need to clear the changes information because otherwise the # contract will complain about all the changes to read_only attributes wp.send(:clear_changes_information) @@ -39,7 +39,7 @@ describe WorkPackages::CreateNoteContract do wp end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:policy_instance) { double('WorkPackagePolicyInstance') } subject(:contract) { diff --git a/spec/contracts/work_packages/shared_base_contract.rb b/spec/contracts/work_packages/shared_base_contract.rb index e06ba83e73..fd75cbb9f1 100644 --- a/spec/contracts/work_packages/shared_base_contract.rb +++ b/spec/contracts/work_packages/shared_base_contract.rb @@ -29,9 +29,9 @@ #++ shared_examples_for 'work package contract' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:other_user) { FactoryGirl.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:other_user) { FactoryBot.build_stubbed(:user) } let(:policy) { double(WorkPackagePolicy, allowed?: true) } subject(:contract) { described_class.new(work_package, user) } diff --git a/spec/contracts/work_packages/update_contract_spec.rb b/spec/contracts/work_packages/update_contract_spec.rb index 1865b6c9c4..5ef52c5c24 100644 --- a/spec/contracts/work_packages/update_contract_spec.rb +++ b/spec/contracts/work_packages/update_contract_spec.rb @@ -30,16 +30,16 @@ require 'spec_helper' require 'contracts/work_packages/shared_base_contract' describe WorkPackages::UpdateContract do - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages, :edit_work_packages] } subject(:contract) { described_class.new(work_package, user) } it_behaves_like 'work package contract' do - let(:work_package) { FactoryGirl.build_stubbed(:work_package) } + let(:work_package) { FactoryBot.build_stubbed(:work_package) } end describe 'lock_version' do @@ -93,14 +93,14 @@ describe WorkPackages::UpdateContract do end describe 'project_id' do - let(:target_project) { FactoryGirl.create(:project) } + let(:target_project) { FactoryBot.create(:project) } let(:target_permissions) { [:move_work_packages] } before do - FactoryGirl.create :member, + FactoryBot.create :member, user: user, project: target_project, - roles: [FactoryGirl.create(:role, permissions: target_permissions)] + roles: [FactoryBot.create(:role, permissions: target_permissions)] work_package.project = target_project @@ -120,7 +120,7 @@ describe WorkPackages::UpdateContract do end describe 'parent_id' do - let(:parent) { FactoryGirl.create(:work_package) } + let(:parent) { FactoryBot.create(:work_package) } before do work_package.parent_id = parent.id diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb index 716dc0f317..14390fa337 100644 --- a/spec/controllers/account_controller_spec.rb +++ b/spec/controllers/account_controller_spec.rb @@ -33,7 +33,7 @@ describe AccountController, type: :controller do User.delete_all User.current = nil end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } context 'GET #login' do let(:setup) {} @@ -80,7 +80,7 @@ describe AccountController, type: :controller do end context 'POST #login' do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } describe 'wrong password' do it 'redirects back to login' do @@ -229,7 +229,7 @@ describe AccountController, type: :controller do end context 'GET #logout' do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } it 'calls reset_session' do expect(@controller).to receive(:reset_session).once @@ -293,7 +293,7 @@ describe AccountController, type: :controller do end describe 'Login for user with forced password change' do - let(:admin) { FactoryGirl.create(:admin, force_password_change: true) } + let(:admin) { FactoryBot.create(:admin, force_password_change: true) } before do allow_any_instance_of(User).to receive(:change_password_allowed?).and_return(false) @@ -389,7 +389,7 @@ describe AccountController, type: :controller do end context 'with self registration off but an ongoing invitation activation' do - let(:token) { FactoryGirl.create :invitation_token } + let(:token) { FactoryBot.create :invitation_token } before do allow(Setting).to receive(:self_registration).and_return('0') @@ -654,7 +654,7 @@ describe AccountController, type: :controller do } end - let(:user) { FactoryGirl.create :user, status: 2 } + let(:user) { FactoryBot.create :user, status: 2 } before do session[:auth_source_sso_failure] = failure @@ -674,9 +674,9 @@ describe AccountController, type: :controller do end context "with an invalid user" do - let!(:duplicate) { FactoryGirl.create :user, mail: "login@DerpLAP.net" } + let!(:duplicate) { FactoryBot.create :user, mail: "login@DerpLAP.net" } let(:user) do - FactoryGirl.build(:user, mail: duplicate.mail).tap(&:valid?) + FactoryBot.build(:user, mail: duplicate.mail).tap(&:valid?) end it "should show the account creation form with an error" do @@ -733,13 +733,13 @@ describe AccountController, type: :controller do context 'with an invited user' do it_behaves_like 'account activation' do - let(:user) { FactoryGirl.create :user, status: 4 } + let(:user) { FactoryBot.create :user, status: 4 } end end context 'with an registered user' do it_behaves_like 'account activation' do - let(:user) { FactoryGirl.create :user, status: 2 } + let(:user) { FactoryBot.create :user, status: 2 } end end end diff --git a/spec/controllers/activities_controller_spec.rb b/spec/controllers/activities_controller_spec.rb index 71ae3e3a9e..72d4a66026 100644 --- a/spec/controllers/activities_controller_spec.rb +++ b/spec/controllers/activities_controller_spec.rb @@ -32,7 +32,7 @@ describe ActivitiesController, type: :controller do before :each do allow(@controller).to receive(:set_localization) - admin = FactoryGirl.create(:admin) + admin = FactoryBot.create(:admin) allow(User).to receive(:current).and_return admin @params = {} @@ -46,13 +46,13 @@ describe ActivitiesController, type: :controller do end describe 'global' do - let(:work_package) { FactoryGirl.create(:work_package) } + let(:work_package) { FactoryBot.create(:work_package) } let!(:journal) { - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, journable_id: work_package.id, created_at: 3.days.ago.to_date.to_s(:db), version: Journal.maximum(:version) + 1, - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: work_package.subject, status_id: work_package.status_id, type_id: work_package.type_id, @@ -92,7 +92,7 @@ describe ActivitiesController, type: :controller do describe 'with activated activity module' do let(:project) { - FactoryGirl.create(:project, + FactoryBot.create(:project, enabled_module_names: %w[activity wiki]) } @@ -105,7 +105,7 @@ describe ActivitiesController, type: :controller do describe 'without activated activity module' do let(:project) { - FactoryGirl.create(:project, + FactoryBot.create(:project, enabled_module_names: %w[wiki]) } @@ -123,12 +123,12 @@ describe ActivitiesController, type: :controller do end describe '#atom_feed' do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } context 'work_package' do let!(:wp_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: user) } @@ -147,7 +147,7 @@ describe ActivitiesController, type: :controller do describe 'list' do let!(:wp_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: user) } @@ -167,15 +167,15 @@ describe ActivitiesController, type: :controller do context 'boards' do let(:board) { - FactoryGirl.create(:board, + FactoryBot.create(:board, project: project) } let!(:message_1) { - FactoryGirl.create(:message, + FactoryBot.create(:message, board: board) } let!(:message_2) { - FactoryGirl.create(:message, + FactoryBot.create(:message, board: board) } let(:params) { diff --git a/spec/controllers/announcements_controller_spec.rb b/spec/controllers/announcements_controller_spec.rb index ea81b1fd97..31fdacc6e8 100644 --- a/spec/controllers/announcements_controller_spec.rb +++ b/spec/controllers/announcements_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe AnnouncementsController, type: :controller do - let(:announcement) { FactoryGirl.build :announcement } + let(:announcement) { FactoryBot.build :announcement } before do allow(controller).to receive(:check_if_login_required) expect(controller).to receive(:require_admin) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index d54253447b..e6e5176aba 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ApplicationController, type: :controller do - let(:user) { FactoryGirl.create(:user, lastname: "Crazy! Name with \r\n Newline") } + let(:user) { FactoryBot.create(:user, lastname: "Crazy! Name with \r\n Newline") } # Fake controller to test calling an action controller do @@ -109,7 +109,7 @@ describe ApplicationController, type: :controller do end it 'logs out the user' do - @controller.send(:logged_user=, FactoryGirl.create(:user)) + @controller.send(:logged_user=, FactoryBot.create(:user)) allow(@controller).to receive(:render_error) @controller.send :handle_unverified_request diff --git a/spec/controllers/attachments_controller_spec.rb b/spec/controllers/attachments_controller_spec.rb index 355d83e9b5..ca422f84d5 100644 --- a/spec/controllers/attachments_controller_spec.rb +++ b/spec/controllers/attachments_controller_spec.rb @@ -29,16 +29,16 @@ require 'spec_helper' describe AttachmentsController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:edit_work_packages, :view_work_packages, :delete_wiki_pages_attachments]) } let!(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) @@ -48,7 +48,7 @@ describe AttachmentsController, type: :controller do describe '#destroy' do let(:attachment) { - FactoryGirl.create(:attachment, + FactoryBot.create(:attachment, container: container) } @@ -68,7 +68,7 @@ describe AttachmentsController, type: :controller do context 'work_package' do let(:container) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, project: project) } @@ -85,7 +85,7 @@ describe AttachmentsController, type: :controller do context 'wiki' do let(:container) { - FactoryGirl.create(:wiki_page, + FactoryBot.create(:wiki_page, wiki: project.wiki) } let(:redirect_path) { project_wiki_path(project, project.wiki) } @@ -104,7 +104,7 @@ describe AttachmentsController, type: :controller do describe '#download' do let(:file) { FileHelpers.mock_uploaded_file name: 'foobar.txt' } - let(:work_package) { FactoryGirl.create :work_package, project: project } + let(:work_package) { FactoryBot.create :work_package, project: project } let(:uploader) { nil } ## diff --git a/spec/controllers/attribute_help_texts_controller_spec.rb b/spec/controllers/attribute_help_texts_controller_spec.rb index 565038699b..fe42b06c9d 100644 --- a/spec/controllers/attribute_help_texts_controller_spec.rb +++ b/spec/controllers/attribute_help_texts_controller_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe AttributeHelpTextsController, type: :controller do - let(:model) { FactoryGirl.build :work_package_help_text } + let(:model) { FactoryBot.build :work_package_help_text } let(:relation_columns_allowed) { true } let(:find_expectation) do diff --git a/spec/controllers/auth_sources_controller_spec.rb b/spec/controllers/auth_sources_controller_spec.rb index 4f8e9a8b69..003f79aaf3 100644 --- a/spec/controllers/auth_sources_controller_spec.rb +++ b/spec/controllers/auth_sources_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe AuthSourcesController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(false) @@ -74,7 +74,7 @@ describe AuthSourcesController, type: :controller do describe 'edit' do before do - @auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit') + @auth_source = FactoryBot.create(:auth_source, name: 'TestEdit') get :edit, params: { id: @auth_source.id } end @@ -85,7 +85,7 @@ describe AuthSourcesController, type: :controller do describe 'update' do before do - @auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit') + @auth_source = FactoryBot.create(:auth_source, name: 'TestEdit') post :update, params: { id: @auth_source.id, auth_source: { name: 'TestUpdate' } } end @@ -96,7 +96,7 @@ describe AuthSourcesController, type: :controller do describe 'destroy' do before do - @auth_source = FactoryGirl.create(:auth_source, name: 'TestEdit') + @auth_source = FactoryBot.create(:auth_source, name: 'TestEdit') end context 'without users' do @@ -111,7 +111,7 @@ describe AuthSourcesController, type: :controller do context 'with users' do before do - FactoryGirl.create(:user, auth_source: @auth_source) + FactoryBot.create(:user, auth_source: @auth_source) post :destroy, params: { id: @auth_source.id } end diff --git a/spec/controllers/boards_controller_spec.rb b/spec/controllers/boards_controller_spec.rb index 2285c982a9..80eb5bcf66 100644 --- a/spec/controllers/boards_controller_spec.rb +++ b/spec/controllers/boards_controller_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe BoardsController, type: :controller do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.create(:project) } let!(:board) { - FactoryGirl.build(:board, + FactoryBot.build(:board, project: project) } @@ -95,14 +95,14 @@ describe BoardsController, type: :controller do end describe '#move' do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let!(:board_1) { - FactoryGirl.create(:board, + FactoryBot.create(:board, project: project, position: 1) } let!(:board_2) { - FactoryGirl.create(:board, + FactoryBot.create(:board, project: project, position: 2) } @@ -129,7 +129,7 @@ describe BoardsController, type: :controller do describe '#update' do let!(:board) { - FactoryGirl.create(:board, name: 'Board name', + FactoryBot.create(:board, name: 'Board name', description: 'Board description') } @@ -186,10 +186,10 @@ describe BoardsController, type: :controller do end describe '#sticky' do - let!(:message1) { FactoryGirl.create(:message, board: board) } - let!(:message2) { FactoryGirl.create(:message, board: board) } + let!(:message1) { FactoryBot.create(:message, board: board) } + let!(:message2) { FactoryBot.create(:message, board: board) } let!(:sticked_message1) { - FactoryGirl.create(:message, board_id: board.id, + FactoryBot.create(:message, board_id: board.id, subject: 'How to', content: 'How to install this cool app', sticky: '1', @@ -197,7 +197,7 @@ describe BoardsController, type: :controller do } let!(:sticked_message2) { - FactoryGirl.create(:message, board_id: board.id, + FactoryBot.create(:message, board_id: board.id, subject: 'FAQ', content: 'Frequestly asked question', sticky: '1', diff --git a/spec/controllers/categories_controller_spec.rb b/spec/controllers/categories_controller_spec.rb index 391a4db1a9..20a5afa959 100644 --- a/spec/controllers/categories_controller_spec.rb +++ b/spec/controllers/categories_controller_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe CategoriesController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:manage_categories]) } let(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) @@ -93,7 +93,7 @@ describe CategoriesController, type: :controller do describe '#edit' do let(:category) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } @@ -120,7 +120,7 @@ describe CategoriesController, type: :controller do context 'valid category' do let(:category) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } @@ -162,11 +162,11 @@ describe CategoriesController, type: :controller do describe '#destroy' do let(:category) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, category: category) } @@ -211,7 +211,7 @@ describe CategoriesController, type: :controller do describe '#reassign' do let(:target) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } before do diff --git a/spec/controllers/concerns/auth_source_sso_spec.rb b/spec/controllers/concerns/auth_source_sso_spec.rb index f2ff1577ac..46e2aa433e 100644 --- a/spec/controllers/concerns/auth_source_sso_spec.rb +++ b/spec/controllers/concerns/auth_source_sso_spec.rb @@ -45,7 +45,7 @@ describe MyController, type: :controller do let(:secret) { "42" } let(:auth_source) { DummyAuthSource.create name: "Dummy LDAP" } - let(:user) { FactoryGirl.create :user, login: login, auth_source_id: auth_source.id } + let(:user) { FactoryBot.create :user, login: login, auth_source_id: auth_source.id } let(:login) { "h.wurst" } before do @@ -95,7 +95,7 @@ describe MyController, type: :controller do end context "with a non-active user user" do - let(:user) { FactoryGirl.create :user, login: login, auth_source_id: auth_source.id, status: 2 } + let(:user) { FactoryBot.create :user, login: login, auth_source_id: auth_source.id, status: 2 } it_should_behave_like "auth source sso failure" end @@ -103,11 +103,11 @@ describe MyController, type: :controller do context "with an invalid user" do let(:auth_source) { DummyAuthSource.create name: "Onthefly LDAP", onthefly_register: true } - let!(:duplicate) { FactoryGirl.create :user, mail: "login@DerpLAP.net" } + let!(:duplicate) { FactoryBot.create :user, mail: "login@DerpLAP.net" } let(:login) { "dummy_dupuser" } let(:user) do - FactoryGirl.build :user, login: login, mail: duplicate.mail, auth_source_id: auth_source.id + FactoryBot.build :user, login: login, mail: duplicate.mail, auth_source_id: auth_source.id end it_should_behave_like "auth source sso failure" diff --git a/spec/controllers/concerns/omniauth_login_spec.rb b/spec/controllers/concerns/omniauth_login_spec.rb index 230e434d8b..6dbdf3d2a6 100644 --- a/spec/controllers/concerns/omniauth_login_spec.rb +++ b/spec/controllers/concerns/omniauth_login_spec.rb @@ -264,7 +264,7 @@ describe AccountController, type: :controller do end let(:user) do - FactoryGirl.build(:user, force_password_change: false, + FactoryBot.build(:user, force_password_change: false, identity_url: 'google:123545') end diff --git a/spec/controllers/concerns/user_invitation_spec.rb b/spec/controllers/concerns/user_invitation_spec.rb index 70287ec437..9c2db2758d 100644 --- a/spec/controllers/concerns/user_invitation_spec.rb +++ b/spec/controllers/concerns/user_invitation_spec.rb @@ -48,8 +48,8 @@ describe UserInvitation do end describe '.reinvite_user' do - let(:user) { FactoryGirl.create :invited_user } - let!(:token) { FactoryGirl.create :invitation_token, user: user } + let(:user) { FactoryBot.create :invited_user } + let!(:token) { FactoryBot.create :invitation_token, user: user } it 'notifies listeners of the re-invite' do expect(OpenProject::Notifications).to receive(:send) do |event, new_token| diff --git a/spec/controllers/copy_projects_controller_spec.rb b/spec/controllers/copy_projects_controller_spec.rb index 01e53866d6..65a7afdc24 100644 --- a/spec/controllers/copy_projects_controller_spec.rb +++ b/spec/controllers/copy_projects_controller_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe CopyProjectsController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } let(:redirect_path) { "/projects/#{project.id}/settings" } let(:permission) { :copy_projects } - let(:project) { FactoryGirl.create(:project_with_types, is_public: false) } + let(:project) { FactoryBot.create(:project_with_types, is_public: false) } let(:copy_project_params) { { 'description' => 'Some pretty description', @@ -139,7 +139,7 @@ describe CopyProjectsController, type: :controller do end let(:permission) { [:copy_projects, :add_project] } - let(:project) { FactoryGirl.create(:project, is_public: false) } + let(:project) { FactoryBot.create(:project, is_public: false) } it_should_behave_like 'a controller action which needs project permissions' end diff --git a/spec/controllers/custom_actions_controller_spec.rb b/spec/controllers/custom_actions_controller_spec.rb index e704728d9a..241e2ccc1a 100644 --- a/spec/controllers/custom_actions_controller_spec.rb +++ b/spec/controllers/custom_actions_controller_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe CustomActionsController, type: :controller do - let(:admin) { FactoryGirl.build(:admin) } - let(:non_admin) { FactoryGirl.build(:user) } - let(:action) { FactoryGirl.build_stubbed(:custom_action) } + let(:admin) { FactoryBot.build(:admin) } + let(:non_admin) { FactoryBot.build(:user) } + let(:action) { FactoryBot.build_stubbed(:custom_action) } let(:params) do { custom_action: { name: 'blubs', actions: { assigned_to: 1 } } } diff --git a/spec/controllers/custom_fields_controller_spec.rb b/spec/controllers/custom_fields_controller_spec.rb index ddb6cde109..ee2e504768 100644 --- a/spec/controllers/custom_fields_controller_spec.rb +++ b/spec/controllers/custom_fields_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe CustomFieldsController, type: :controller do - let(:custom_field) { FactoryGirl.build_stubbed(:custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:custom_field) } before do allow(@controller).to receive(:authorize) diff --git a/spec/controllers/custom_styles_controller_spec.rb b/spec/controllers/custom_styles_controller_spec.rb index 0815491f02..3027fd904f 100644 --- a/spec/controllers/custom_styles_controller_spec.rb +++ b/spec/controllers/custom_styles_controller_spec.rb @@ -34,7 +34,7 @@ describe CustomStylesController, type: :controller do end context 'with admin' do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } describe '#show' do subject { get :show } @@ -108,7 +108,7 @@ describe CustomStylesController, type: :controller do end describe "#update" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_logo) } + let(:custom_style) { FactoryBot.build(:custom_style_with_logo) } let(:params) do { custom_style: { logo: 'foo', favicon: 'bar', icon_touch: 'yay' } @@ -152,7 +152,7 @@ describe CustomStylesController, type: :controller do end context "when logo is present" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_logo) } + let(:custom_style) { FactoryBot.build(:custom_style_with_logo) } it 'will send a file' do expect(response.status).to eq(200) @@ -169,7 +169,7 @@ describe CustomStylesController, type: :controller do end context "when no logo is present" do - let(:custom_style) { FactoryGirl.build_stubbed(:custom_style) } + let(:custom_style) { FactoryBot.build_stubbed(:custom_style) } it 'renders with error' do expect(controller).to_not receive(:send_file) @@ -179,7 +179,7 @@ describe CustomStylesController, type: :controller do end describe "#logo_delete" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_logo) } + let(:custom_style) { FactoryBot.build(:custom_style_with_logo) } before do with_enterprise_token(:define_custom_style) @@ -219,7 +219,7 @@ describe CustomStylesController, type: :controller do end context "when favicon is present" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_favicon) } + let(:custom_style) { FactoryBot.build(:custom_style_with_favicon) } it 'will send a file' do expect(response.status).to eq(200) @@ -236,7 +236,7 @@ describe CustomStylesController, type: :controller do end context "when no favicon is present" do - let(:custom_style) { FactoryGirl.build(:custom_style) } + let(:custom_style) { FactoryBot.build(:custom_style) } it 'renders with error' do expect(controller).to_not receive(:send_file) @@ -246,7 +246,7 @@ describe CustomStylesController, type: :controller do end describe "#favicon_delete" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_favicon) } + let(:custom_style) { FactoryBot.build(:custom_style_with_favicon) } before do with_enterprise_token(:define_custom_style) @@ -286,7 +286,7 @@ describe CustomStylesController, type: :controller do end context "when touch icon is present" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_touch_icon) } + let(:custom_style) { FactoryBot.build(:custom_style_with_touch_icon) } it 'will send a file' do expect(response.status).to eq(200) @@ -303,7 +303,7 @@ describe CustomStylesController, type: :controller do end context "when no touch icon is present" do - let(:custom_style) { FactoryGirl.build(:custom_style) } + let(:custom_style) { FactoryBot.build(:custom_style) } it 'renders with error' do expect(controller).to_not receive(:send_file) @@ -313,7 +313,7 @@ describe CustomStylesController, type: :controller do end describe "#touch_icon_delete" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_touch_icon) } + let(:custom_style) { FactoryBot.build(:custom_style_with_touch_icon) } before do with_enterprise_token(:define_custom_style) @@ -381,7 +381,7 @@ describe CustomStylesController, type: :controller do end context 'regular user' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } describe '#get' do before do @@ -407,7 +407,7 @@ describe CustomStylesController, type: :controller do end context "when logo is present" do - let(:custom_style) { FactoryGirl.build(:custom_style_with_logo) } + let(:custom_style) { FactoryBot.build(:custom_style_with_logo) } it 'will send a file' do expect(response.status).to eq(200) diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index bc551aff9b..13dc94b3fa 100644 --- a/spec/controllers/enterprises_controller_spec.rb +++ b/spec/controllers/enterprises_controller_spec.rb @@ -46,7 +46,7 @@ describe EnterprisesController, type: :controller do end context 'with admin' do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } describe '#show' do render_views @@ -142,7 +142,7 @@ describe EnterprisesController, type: :controller do end context 'regular user' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } before do get :show diff --git a/spec/controllers/enumerations_controller.rb b/spec/controllers/enumerations_controller.rb index 15d759fac1..1821a97c04 100644 --- a/spec/controllers/enumerations_controller.rb +++ b/spec/controllers/enumerations_controller.rb @@ -33,7 +33,7 @@ describe EnumerationsController, type: :controller do describe '#destroy' do describe '#priority' do - let(:enum_to_delete) { FactoryGirl.create(:priority_normal) } + let(:enum_to_delete) { FactoryBot.create(:priority_normal) } shared_examples_for 'successful delete' do it { expect(Enumeration.find_by(id: enum_to_delete.id)).to be_nil } @@ -50,9 +50,9 @@ describe EnumerationsController, type: :controller do end describe 'in use' do - let!(:enum_to_reassign) { FactoryGirl.create(:priority_high) } + let!(:enum_to_reassign) { FactoryBot.create(:priority_high) } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, priority: enum_to_delete) } diff --git a/spec/controllers/homescreen_controller_spec.rb b/spec/controllers/homescreen_controller_spec.rb index 67007ef434..2e2a8ffa8e 100644 --- a/spec/controllers/homescreen_controller_spec.rb +++ b/spec/controllers/homescreen_controller_spec.rb @@ -70,7 +70,7 @@ describe HomescreenController, type: :controller do it 'shows the news when available' do expect(News).to receive(:latest).with(any_args) - .and_return(FactoryGirl.build_stubbed_list(:news, 5, created_on: Time.now)) + .and_return(FactoryBot.build_stubbed_list(:news, 5, created_on: Time.now)) get :index expect(response).to render_template(partial: 'homescreen/blocks/_news') @@ -81,7 +81,7 @@ describe HomescreenController, type: :controller do end context 'with enabled announcement' do - let!(:announcement) { FactoryGirl.create :active_announcement } + let!(:announcement) { FactoryBot.create :active_announcement } it 'renders the announcement' do expect(response).to render_template(partial: 'announcements/_show') end @@ -109,14 +109,14 @@ describe HomescreenController, type: :controller do end context 'with admin' do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } it_behaves_like 'renders blocks' do let(:shown) { all_blocks } end end context 'regular user' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } it_behaves_like 'renders blocks' do let(:shown) { all_blocks - %w(administration users) } end diff --git a/spec/controllers/journals_controller_spec.rb b/spec/controllers/journals_controller_spec.rb index eceb75cc9a..19f5c4e464 100644 --- a/spec/controllers/journals_controller_spec.rb +++ b/spec/controllers/journals_controller_spec.rb @@ -29,22 +29,22 @@ require 'spec_helper' describe JournalsController, type: :controller do - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project_with_types) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:project) { FactoryBot.create(:project_with_types) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } let(:work_package) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, author: user, project: project, description: '') } let(:journal) { - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, journable: work_package, user: user) } diff --git a/spec/controllers/ldap_auth_sources_controller_spec.rb b/spec/controllers/ldap_auth_sources_controller_spec.rb index 3efdd71aef..7703e18cac 100644 --- a/spec/controllers/ldap_auth_sources_controller_spec.rb +++ b/spec/controllers/ldap_auth_sources_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe LdapAuthSourcesController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return current_user diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb index 7ef70cee61..0e88f0efc1 100644 --- a/spec/controllers/members_controller_spec.rb +++ b/spec/controllers/members_controller_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe MembersController, type: :controller do - let(:admin) { FactoryGirl.create(:admin) } - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project, identifier: 'pet_project') } - let(:role) { FactoryGirl.create(:role) } + let(:admin) { FactoryBot.create(:admin) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project, identifier: 'pet_project') } + let(:role) { FactoryBot.create(:role) } let(:member) { - FactoryGirl.create(:member, project: project, + FactoryBot.create(:member, project: project, user: user, roles: [role]) } @@ -44,8 +44,8 @@ describe MembersController, type: :controller do end describe 'create' do - let(:admin) { FactoryGirl.create(:admin) } - let(:project_2) { FactoryGirl.create(:project) } + let(:admin) { FactoryBot.create(:admin) } + let(:project_2) { FactoryBot.create(:project) } before do allow(User).to receive(:current).and_return(admin) @@ -75,12 +75,12 @@ describe MembersController, type: :controller do end describe 'update' do - let(:admin) { FactoryGirl.create(:admin) } - let(:project_2) { FactoryGirl.create(:project) } - let(:role_1) { FactoryGirl.create(:role) } - let(:role_2) { FactoryGirl.create(:role) } + let(:admin) { FactoryBot.create(:admin) } + let(:project_2) { FactoryBot.create(:project) } + let(:role_1) { FactoryBot.create(:role) } + let(:role_2) { FactoryBot.create(:role) } let(:member_2) do - FactoryGirl.create( + FactoryBot.create( :member, project: project_2, user: admin, @@ -136,9 +136,9 @@ describe MembersController, type: :controller do describe '#create' do render_views - let(:user2) { FactoryGirl.create(:user) } - let(:user3) { FactoryGirl.create(:user) } - let(:user4) { FactoryGirl.create(:user) } + let(:user2) { FactoryBot.create(:user) } + let(:user3) { FactoryBot.create(:user) } + let(:user4) { FactoryBot.create(:user) } context 'post :create' do context 'single member' do @@ -218,7 +218,7 @@ describe MembersController, type: :controller do member: { role_ids: [role2.id], user_id: user.id } } } - let(:role2) { FactoryGirl.create(:role) } + let(:role2) { FactoryBot.create(:role) } before do member diff --git a/spec/controllers/messages_controller_spec.rb b/spec/controllers/messages_controller_spec.rb index e5007c0783..3fa6092a78 100644 --- a/spec/controllers/messages_controller_spec.rb +++ b/spec/controllers/messages_controller_spec.rb @@ -29,17 +29,17 @@ require 'spec_helper' describe MessagesController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role) } let!(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) } let!(:board) { - FactoryGirl.create(:board, + FactoryBot.create(:board, project: project) } @@ -81,8 +81,8 @@ describe MessagesController, type: :controller do end describe '#update' do - let(:message) { FactoryGirl.create :message, board: board } - let(:other_board) { FactoryGirl.create :board, project: project } + let(:message) { FactoryBot.create :message, board: board } + let(:other_board) { FactoryBot.create :board, project: project } before do role.add_permission!(:edit_messages) and user.reload @@ -96,7 +96,7 @@ describe MessagesController, type: :controller do end describe '#attachment' do - let!(:message) { FactoryGirl.create(:message) } + let!(:message) { FactoryBot.create(:message) } let(:attachment_id) { "attachments_#{message.attachments.first.id}" } let(:params) { { id: message.id, @@ -158,13 +158,13 @@ describe MessagesController, type: :controller do describe '#remove' do let!(:attachment) { - FactoryGirl.create(:attachment, + FactoryBot.create(:attachment, container: message, author: user, filename: filename) } let!(:attachable_journal) { - FactoryGirl.create(:journal_attachable_journal, + FactoryBot.create(:journal_attachable_journal, journal: message.journals.last, attachment: attachment, filename: filename) @@ -208,16 +208,16 @@ describe MessagesController, type: :controller do end it_behaves_like 'authorizes object access' do - let(:message) { FactoryGirl.create :message, board: board } + let(:message) { FactoryBot.create :message, board: board } let(:preview_params) { { board_id: board.id, id: message.id, message: {} } } end end describe 'quote' do - let(:message) { FactoryGirl.create :message, content: 'foo', subject: 'subject', board: board } + let(:message) { FactoryBot.create :message, content: 'foo', subject: 'subject', board: board } context 'when allowed' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } before do login_as user diff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rb index 6d10ac471e..3e4f20852d 100644 --- a/spec/controllers/my_controller_spec.rb +++ b/spec/controllers/my_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe MyController, type: :controller do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before(:each) do login_as(user) end @@ -118,7 +118,7 @@ describe MyController, type: :controller do end describe 'account' do - let(:custom_field) { FactoryGirl.create :text_user_custom_field } + let(:custom_field) { FactoryBot.create :text_user_custom_field } before do custom_field as_logged_in_user user do diff --git a/spec/controllers/news/comments_controller_spec.rb b/spec/controllers/news/comments_controller_spec.rb index 1df4bf3a7b..9c4c252d5d 100644 --- a/spec/controllers/news/comments_controller_spec.rb +++ b/spec/controllers/news/comments_controller_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe News::CommentsController, type: :controller do render_views - let(:user) { FactoryGirl.create(:admin) } - let(:news) { FactoryGirl.create(:news) } + let(:user) { FactoryBot.create(:admin) } + let(:news) { FactoryBot.create(:news) } before do allow(User).to receive(:current).and_return user @@ -60,7 +60,7 @@ describe News::CommentsController, type: :controller do describe '#destroy' do it 'deletes the comment and redirects to the news page' do - comment = FactoryGirl.create :comment, commented: news + comment = FactoryBot.create :comment, commented: news expect { delete :destroy, params: { id: comment.id } diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb index ce5a90ac86..6dbab89fe0 100644 --- a/spec/controllers/news_controller_spec.rb +++ b/spec/controllers/news_controller_spec.rb @@ -34,14 +34,14 @@ describe NewsController, type: :controller do include BecomeMember let(:user) { - user = FactoryGirl.create(:admin) + user = FactoryBot.create(:admin) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) user } - let(:project) { FactoryGirl.create(:project) } - let(:news) { FactoryGirl.create(:news) } + let(:project) { FactoryBot.create(:project) } + let(:news) { FactoryBot.create(:news) } before do allow(User).to receive(:current).and_return user diff --git a/spec/controllers/planning_element_type_colors_controller_spec.rb b/spec/controllers/planning_element_type_colors_controller_spec.rb index 03cf541625..0109bd8f42 100644 --- a/spec/controllers/planning_element_type_colors_controller_spec.rb +++ b/spec/controllers/planning_element_type_colors_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe PlanningElementTypeColorsController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return current_user @@ -51,7 +51,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'create.html' do def fetch - post 'create', params: { color: FactoryGirl.build(:color).attributes } + post 'create', params: { color: FactoryBot.build(:color).attributes } end def expect_redirect_to @@ -62,7 +62,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'edit.html' do def fetch - @available_color = FactoryGirl.create(:color, id: '1337') + @available_color = FactoryBot.create(:color, id: '1337') get 'edit', params: { id: '1337' } end it_should_behave_like 'a controller action with require_admin' @@ -70,7 +70,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'update.html' do def fetch - @available_color = FactoryGirl.create(:color, id: '1337') + @available_color = FactoryBot.create(:color, id: '1337') put 'update', params: { id: '1337', color: { 'name' => 'blubs' } } end @@ -82,7 +82,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'move.html' do def fetch - @available_color = FactoryGirl.create(:color, id: '1337') + @available_color = FactoryBot.create(:color, id: '1337') post 'move', params: { id: '1337', color: { move_to: 'highest' } } end @@ -94,7 +94,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'confirm_destroy.html' do def fetch - @available_color = FactoryGirl.create(:color, id: '1337') + @available_color = FactoryBot.create(:color, id: '1337') get 'confirm_destroy', params: { id: '1337' } end it_should_behave_like 'a controller action with require_admin' @@ -102,7 +102,7 @@ describe PlanningElementTypeColorsController, type: :controller do describe 'destroy.html' do def fetch - @available_color = FactoryGirl.create(:color, id: '1337') + @available_color = FactoryBot.create(:color, id: '1337') post 'destroy', params: { id: '1337' } end diff --git a/spec/controllers/project_types_controller_spec.rb b/spec/controllers/project_types_controller_spec.rb index 7b9122af8d..8dfc071eec 100644 --- a/spec/controllers/project_types_controller_spec.rb +++ b/spec/controllers/project_types_controller_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ProjectTypesController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return current_user @@ -51,7 +51,7 @@ describe ProjectTypesController, type: :controller do describe 'create.html' do def fetch - post 'create', params: { project_type: FactoryGirl.build(:project_type).attributes } + post 'create', params: { project_type: FactoryBot.build(:project_type).attributes } end def expect_redirect_to @@ -62,7 +62,7 @@ describe ProjectTypesController, type: :controller do describe 'edit.html' do def fetch - FactoryGirl.create(:project_type, id: '1337') + FactoryBot.create(:project_type, id: '1337') get 'edit', params: { id: '1337' } end it_should_behave_like 'a controller action with require_admin' @@ -70,7 +70,7 @@ describe ProjectTypesController, type: :controller do describe 'update.html' do def fetch - FactoryGirl.create(:project_type, id: '1337') + FactoryBot.create(:project_type, id: '1337') put 'update', params: { id: '1337', project_type: { 'name' => 'blubs' } } end @@ -82,7 +82,7 @@ describe ProjectTypesController, type: :controller do describe 'move.html' do def fetch - FactoryGirl.create(:project_type, id: '1337') + FactoryBot.create(:project_type, id: '1337') post 'move', params: { id: '1337', project_type: { move_to: 'highest' } } end @@ -94,7 +94,7 @@ describe ProjectTypesController, type: :controller do describe 'confirm_destroy.html' do def fetch - FactoryGirl.create(:project_type, id: '1337') + FactoryBot.create(:project_type, id: '1337') get 'confirm_destroy', params: { id: '1337' } end it_should_behave_like 'a controller action with require_admin' @@ -102,7 +102,7 @@ describe ProjectTypesController, type: :controller do describe 'destroy.html' do def fetch - FactoryGirl.create(:project_type, id: '1337') + FactoryBot.create(:project_type, id: '1337') post 'destroy', params: { id: '1337' } end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 25a5362a47..7e355b22c9 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -37,8 +37,8 @@ describe ProjectsController, type: :controller do before do allow(@controller).to receive(:set_localization) - @role = FactoryGirl.create(:non_member) - @user = FactoryGirl.create(:admin) + @role = FactoryBot.create(:non_member) + @user = FactoryBot.create(:admin) allow(User).to receive(:current).and_return @user @params = {} @@ -49,7 +49,7 @@ describe ProjectsController, type: :controller do describe 'without wiki' do before do - @project = FactoryGirl.create(:project) + @project = FactoryBot.create(:project) @project.reload # project contains wiki by default @project.wiki.destroy @project.reload @@ -71,7 +71,7 @@ describe ProjectsController, type: :controller do describe 'with wiki' do before do - @project = FactoryGirl.create(:project) + @project = FactoryBot.create(:project) @project.reload # project contains wiki by default @params[:id] = @project.id end @@ -92,8 +92,8 @@ describe ProjectsController, type: :controller do describe 'with custom wiki menu item' do before do - main_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'example', title: 'Example Title') - sub_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'sub', title: 'Sub Title', parent_id: main_item.id) + main_item = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'example', title: 'Example Title') + sub_item = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'sub', title: 'Sub Title', parent_id: main_item.id) end it 'renders show' do @@ -118,7 +118,7 @@ describe ProjectsController, type: :controller do describe 'with activated activity module' do before do - @project = FactoryGirl.create(:project, enabled_module_names: %w[activity]) + @project = FactoryBot.create(:project, enabled_module_names: %w[activity]) @params[:id] = @project.id end @@ -136,7 +136,7 @@ describe ProjectsController, type: :controller do describe 'without activated activity module' do before do - @project = FactoryGirl.create(:project, enabled_module_names: %w[wiki]) + @project = FactoryBot.create(:project, enabled_module_names: %w[wiki]) @params[:id] = @project.id end @@ -162,10 +162,10 @@ describe ProjectsController, type: :controller do end describe 'index.html' do - let(:project_a) { FactoryGirl.create(:project, name: 'Project A', is_public: false, status: true) } - let(:project_b) { FactoryGirl.create(:project, name: 'Project B', is_public: false, status: true) } - let(:project_c) { FactoryGirl.create(:project, name: 'Project C', is_public: true, status: true) } - let(:project_d) { FactoryGirl.create(:project, name: 'Project D', is_public: true, status: false) } + let(:project_a) { FactoryBot.create(:project, name: 'Project A', is_public: false, status: true) } + let(:project_b) { FactoryBot.create(:project, name: 'Project B', is_public: false, status: true) } + let(:project_c) { FactoryBot.create(:project, name: 'Project C', is_public: true, status: true) } + let(:project_d) { FactoryBot.create(:project, name: 'Project D', is_public: true, status: false) } let(:projects) { [project_a, project_b, project_c, project_d] } @@ -187,7 +187,7 @@ describe ProjectsController, type: :controller do end context 'as admin' do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } it_behaves_like 'successful index' @@ -209,7 +209,7 @@ describe ProjectsController, type: :controller do end context 'as user' do - let(:user) { FactoryGirl.build(:user, member_in_project: project_b) } + let(:user) { FactoryBot.build(:user, member_in_project: project_b) } it_behaves_like 'successful index' @@ -221,7 +221,7 @@ describe ProjectsController, type: :controller do end describe 'index.html' do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } before do login_as(user) @@ -245,9 +245,9 @@ describe ProjectsController, type: :controller do service end - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } let(:project) do - project = FactoryGirl.build_stubbed(:project) + project = FactoryBot.build_stubbed(:project) allow(Project).to receive(:find).and_return(project) @@ -296,9 +296,9 @@ describe ProjectsController, type: :controller do end describe '#custom_fields' do - let(:project) { FactoryGirl.create(:project) } - let(:custom_field_1) { FactoryGirl.create(:work_package_custom_field) } - let(:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } + let(:project) { FactoryBot.create(:project) } + let(:custom_field_1) { FactoryBot.create(:work_package_custom_field) } + let(:custom_field_2) { FactoryBot.create(:work_package_custom_field) } let(:params) do { diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb index dce6f9b2be..8267a18443 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/repositories_controller_spec.rb @@ -31,20 +31,20 @@ require 'spec_helper' describe RepositoriesController, type: :controller do let(:project) do - project = FactoryGirl.create(:project) + project = FactoryBot.create(:project) allow(Project).to receive(:find).and_return(project) project end let(:user) do - FactoryGirl.create(:user, member_in_project: project, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } let (:url) { 'file:///tmp/something/does/not/exist.svn' } let(:repository) do allow(Setting).to receive(:enabled_scm).and_return(['subversion']) - repo = FactoryGirl.build_stubbed(:repository_subversion, + repo = FactoryBot.build_stubbed(:repository_subversion, scm_type: 'local', url: url, project: project) @@ -61,7 +61,7 @@ describe RepositoriesController, type: :controller do end describe 'manages the repository' do - let(:role) { FactoryGirl.create(:role, permissions: [:manage_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:manage_repository]) } before do # authorization checked in spec/permissions/manage_repositories_spec.rb @@ -107,7 +107,7 @@ describe RepositoriesController, type: :controller do end describe 'with empty repository' do - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } before do allow(repository.scm) .to receive(:check_availability!) @@ -155,7 +155,7 @@ describe RepositoriesController, type: :controller do let(:url) { "file://#{root_url}" } let(:repository) { - FactoryGirl.create(:repository_subversion, project: project, url: url, root_url: url) + FactoryBot.create(:repository_subversion, project: project, url: url, root_url: url) } describe 'commits per author graph' do @@ -165,7 +165,7 @@ describe RepositoriesController, type: :controller do context 'requested by an authorized user' do let(:role) { - FactoryGirl.create(:role, permissions: [:browse_repository, + FactoryBot.create(:role, permissions: [:browse_repository, :view_commit_author_statistics]) } @@ -179,7 +179,7 @@ describe RepositoriesController, type: :controller do end context 'requested by an unauthorized user' do - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } it 'should return 403' do expect(response.code).to eq('403') @@ -188,7 +188,7 @@ describe RepositoriesController, type: :controller do end describe 'committers' do - let(:role) { FactoryGirl.create(:role, permissions: [:manage_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:manage_repository]) } describe '#get' do before do @@ -222,7 +222,7 @@ describe RepositoriesController, type: :controller do describe 'requested by a user with view_commit_author_statistics permission' do let(:role) { - FactoryGirl.create(:role, permissions: [:browse_repository, + FactoryBot.create(:role, permissions: [:browse_repository, :view_commit_author_statistics]) } @@ -232,7 +232,7 @@ describe RepositoriesController, type: :controller do end describe 'requested by a user without view_commit_author_statistics permission' do - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } it 'should NOT show the commits per author graph' do expect(assigns(:show_commits_per_author)).to eq(false) @@ -249,7 +249,7 @@ describe RepositoriesController, type: :controller do describe 'show' do render_views - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } before do get :show, params: { project_id: project.identifier, repo_path: path } @@ -268,7 +268,7 @@ describe RepositoriesController, type: :controller do describe 'changes' do render_views - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } before do get :changes, params: { project_id: project.identifier, repo_path: path } @@ -289,7 +289,7 @@ describe RepositoriesController, type: :controller do describe 'checkout path' do render_views - let(:role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } + let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) } let(:checkout_hash) { { 'subversion' => { 'enabled' => '1', @@ -316,7 +316,7 @@ describe RepositoriesController, type: :controller do end describe 'when not being logged in' do - let(:anonymous) { FactoryGirl.build_stubbed(:anonymous) } + let(:anonymous) { FactoryBot.build_stubbed(:anonymous) } before do login_as(anonymous) diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index 6d8dec9d0a..ced4d759f7 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -30,11 +30,11 @@ require 'spec_helper' describe SearchController, type: :controller do let!(:project) { - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'eCookbook') } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project) } @@ -62,7 +62,7 @@ describe SearchController, type: :controller do end context 'is a work package reference' do - let!(:work_package) { FactoryGirl.create :work_package, project: project } + let!(:work_package) { FactoryBot.create :work_package, project: project } subject { get :index, params: { q: "##{work_package.id}" } } @@ -81,15 +81,15 @@ describe SearchController, type: :controller do describe 'work package search' do let!(:work_package_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: 'This is a test issue', project: project) } let!(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: 'Issue test 2', project: project, - status: FactoryGirl.create(:closed_status)) + status: FactoryBot.create(:closed_status)) } context 'when not searching for a note' do @@ -118,7 +118,7 @@ describe SearchController, type: :controller do context 'when searching for a note' do let!(:note_1) { - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: work_package_1.id, notes: 'Test note 1', version: 2 @@ -127,7 +127,7 @@ describe SearchController, type: :controller do before do allow_any_instance_of(Journal).to receive_messages(predecessor: note_1) end let!(:note_2) { - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: work_package_1.id, notes: 'Special note 2', version: 3 diff --git a/spec/controllers/settings_controller_spec.rb b/spec/controllers/settings_controller_spec.rb index 6dac184c25..eb8403a382 100644 --- a/spec/controllers/settings_controller_spec.rb +++ b/spec/controllers/settings_controller_spec.rb @@ -33,7 +33,7 @@ describe SettingsController, type: :controller do allow(@controller).to receive(:set_localization) @params = {} - @user = FactoryGirl.create(:admin) + @user = FactoryBot.create(:admin) allow(User).to receive(:current).and_return @user end diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 695b4ce36d..abbd1f9fc3 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe StatusesController, type: :controller do - let(:user) { FactoryGirl.create(:admin) } - let(:status) { FactoryGirl.create(:status) } + let(:user) { FactoryBot.create(:admin) } + let(:status) { FactoryBot.create(:status) } before do allow(User).to receive(:current).and_return user end @@ -90,7 +90,7 @@ describe StatusesController, type: :controller do context 'default' do let!(:status_default) { - FactoryGirl.create(:status, + FactoryBot.create(:status, is_default: true) } @@ -172,7 +172,7 @@ describe StatusesController, type: :controller do context 'used' do let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, status: status) } @@ -189,7 +189,7 @@ describe StatusesController, type: :controller do context 'default' do let!(:status_default) { - FactoryGirl.create(:status, + FactoryBot.create(:status, is_default: true) } diff --git a/spec/controllers/sys_controller_spec.rb b/spec/controllers/sys_controller_spec.rb index 688739799d..a6de0cd3a4 100644 --- a/spec/controllers/sys_controller_spec.rb +++ b/spec/controllers/sys_controller_spec.rb @@ -30,13 +30,13 @@ require 'spec_helper' describe SysController, type: :controller do let(:commit_role) { - FactoryGirl.create(:role, permissions: %i[commit_access browse_repository]) + FactoryBot.create(:role, permissions: %i[commit_access browse_repository]) } - let(:browse_role) { FactoryGirl.create(:role, permissions: [:browse_repository]) } - let(:guest_role) { FactoryGirl.create(:role, permissions: []) } + let(:browse_role) { FactoryBot.create(:role, permissions: [:browse_repository]) } + let(:guest_role) { FactoryBot.create(:role, permissions: []) } let(:valid_user_password) { 'Top Secret Password' } let(:valid_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'johndoe', password: valid_user_password, password_confirmation: valid_user_password) @@ -45,14 +45,14 @@ describe SysController, type: :controller do let(:api_key) { '12345678' } let(:public) { false } - let(:project) { FactoryGirl.create(:project, is_public: public) } + let(:project) { FactoryBot.create(:project, is_public: public) } before(:each) do - FactoryGirl.create(:non_member, permissions: [:browse_repository]) + FactoryBot.create(:non_member, permissions: [:browse_repository]) DeletedUser.first # creating it first in order to avoid problems with should_receive - random_project = FactoryGirl.create(:project, is_public: false) - FactoryGirl.create(:member, + random_project = FactoryBot.create(:project, is_public: false) + FactoryBot.create(:member, user: valid_user, roles: [browse_role], project: random_project) @@ -65,7 +65,7 @@ describe SysController, type: :controller do end describe 'svn' do - let!(:repository) { FactoryGirl.create(:repository_subversion, project: project) } + let!(:repository) { FactoryBot.create(:repository_subversion, project: project) } describe 'repo_auth' do context 'for valid login, but no access to repo_auth' do @@ -89,7 +89,7 @@ describe SysController, type: :controller do context 'for valid login and user has read permission (role reporter) for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [browse_role], project: project) @@ -120,7 +120,7 @@ describe SysController, type: :controller do context 'for valid login and user has rw permission (role developer) for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [commit_role], project: project) @@ -151,7 +151,7 @@ describe SysController, type: :controller do context 'for invalid login and user has role manager for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [commit_role], project: project) @@ -193,8 +193,8 @@ describe SysController, type: :controller do let(:public) { true } before(:each) do - random_project = FactoryGirl.create(:project, is_public: false) - FactoryGirl.create(:member, + random_project = FactoryBot.create(:project, is_public: false) + FactoryBot.create(:member, user: valid_user, roles: [browse_role], project: random_project) @@ -264,7 +264,7 @@ describe SysController, type: :controller do end describe 'git' do - let!(:repository) { FactoryGirl.create(:repository_git, project: project) } + let!(:repository) { FactoryBot.create(:repository_git, project: project) } describe 'repo_auth' do context 'for valid login, but no access to repo_auth' do before(:each) do @@ -290,7 +290,7 @@ describe SysController, type: :controller do context 'for valid login and user has read permission (role reporter) for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [browse_role], project: project) @@ -327,7 +327,7 @@ describe SysController, type: :controller do context 'for valid login and user has rw permission (role developer) for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [commit_role], project: project) @@ -365,7 +365,7 @@ describe SysController, type: :controller do context 'for invalid login and user has role manager for project' do before(:each) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: valid_user, roles: [commit_role], project: project) @@ -391,7 +391,7 @@ describe SysController, type: :controller do context 'for valid login and user is not member for project' do before(:each) do - project = FactoryGirl.create(:project, is_public: false) + project = FactoryBot.create(:project, is_public: false) request.env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials( valid_user.login, @@ -414,8 +414,8 @@ describe SysController, type: :controller do context 'for valid login and project is public' do let(:public) { true } before(:each) do - random_project = FactoryGirl.create(:project, is_public: false) - FactoryGirl.create(:member, + random_project = FactoryBot.create(:project, is_public: false) + FactoryBot.create(:member, user: valid_user, roles: [browse_role], project: random_project) @@ -562,7 +562,7 @@ describe SysController, type: :controller do end context 'available project, but missing repository' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:id) { project.id } before do allow(Project).to receive(:find).and_return(project) @@ -576,10 +576,10 @@ describe SysController, type: :controller do end context 'stubbed repository' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:id) { project.id } let(:repository) { - FactoryGirl.build_stubbed(:repository_subversion, url: url, root_url: url) + FactoryBot.build_stubbed(:repository_subversion, url: url, root_url: url) } before do @@ -617,10 +617,10 @@ describe SysController, type: :controller do let(:root_url) { repo_dir } let(:url) { "file://#{root_url}" } - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:id) { project.id } let(:repository) { - FactoryGirl.create(:repository_subversion, project: project, url: url, root_url: url) + FactoryBot.create(:repository_subversion, project: project, url: url, root_url: url) } before do diff --git a/spec/controllers/timelog_controller_spec.rb b/spec/controllers/timelog_controller_spec.rb index 3c94ed06ca..64d382976d 100644 --- a/spec/controllers/timelog_controller_spec.rb +++ b/spec/controllers/timelog_controller_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe TimelogController, type: :controller do - let!(:activity) { FactoryGirl.create(:default_activity) } - let(:project) { FactoryGirl.create(:project) } + let!(:activity) { FactoryBot.create(:default_activity) } + let(:project) { FactoryBot.create(:project) } let(:user) do - FactoryGirl.create(:admin, + FactoryBot.create(:admin, member_in_project: project) end let(:params) do @@ -78,7 +78,7 @@ describe TimelogController, type: :controller do context 'with a required custom field' do let(:custom_field) do - FactoryGirl.build_stubbed :time_entry_custom_field, + FactoryBot.build_stubbed :time_entry_custom_field, name: 'supplies', is_required: true end @@ -110,7 +110,7 @@ describe TimelogController, type: :controller do context 'work_package' do describe '#valid' do let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) end let(:work_package_id) { work_package.id } diff --git a/spec/controllers/types_controller_spec.rb b/spec/controllers/types_controller_spec.rb index e61a345851..1c7c0e3656 100644 --- a/spec/controllers/types_controller_spec.rb +++ b/spec/controllers/types_controller_spec.rb @@ -30,20 +30,20 @@ require 'spec_helper' describe TypesController, type: :controller do let(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, work_package_custom_fields: [custom_field_2]) end let(:custom_field_1) do - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, field_format: 'string', is_for_all: true) end - let(:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } - let(:status_0) { FactoryGirl.create(:status) } - let(:status_1) { FactoryGirl.create(:status) } + let(:custom_field_2) { FactoryBot.create(:work_package_custom_field) } + let(:status_0) { FactoryBot.create(:status) } + let(:status_1) { FactoryBot.create(:status) } context 'with an unauthorized account' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do allow(User).to receive(:current).and_return(current_user) @@ -107,7 +107,7 @@ describe TypesController, type: :controller do end context 'with an authorized account' do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return(current_user) @@ -165,9 +165,9 @@ describe TypesController, type: :controller do end describe 'WITH workflow copy' do - let!(:existing_type) { FactoryGirl.create(:type, name: 'Existing type') } + let!(:existing_type) { FactoryBot.create(:type, name: 'Existing type') } let!(:workflow) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: status_0, new_status: status_1, type_id: existing_type.id) @@ -199,7 +199,7 @@ describe TypesController, type: :controller do describe 'GET edit settings' do render_views let(:type) do - FactoryGirl.create(:type, name: 'My type', + FactoryBot.create(:type, name: 'My type', is_milestone: true, projects: [project]) end @@ -218,7 +218,7 @@ describe TypesController, type: :controller do describe 'GET edit projects' do render_views let(:type) do - FactoryGirl.create(:type, name: 'My type', + FactoryBot.create(:type, name: 'My type', is_milestone: true, projects: [project]) end @@ -234,9 +234,9 @@ describe TypesController, type: :controller do end describe 'POST update' do - let(:project2) { FactoryGirl.create(:project) } + let(:project2) { FactoryBot.create(:project) } let(:type) do - FactoryGirl.create(:type, name: 'My type', + FactoryBot.create(:type, name: 'My type', is_milestone: true, projects: [project, project2]) end @@ -287,8 +287,8 @@ describe TypesController, type: :controller do end describe 'POST move' do - let!(:type) { FactoryGirl.create(:type, name: 'My type', position: '1') } - let!(:type2) { FactoryGirl.create(:type, name: 'My type 2', position: '2') } + let!(:type) { FactoryBot.create(:type, name: 'My type', position: '1') } + let!(:type2) { FactoryBot.create(:type, name: 'My type 2', position: '2') } let(:params) { { 'id' => type.id, 'type' => { move_to: 'lower' } } } before do @@ -303,9 +303,9 @@ describe TypesController, type: :controller do end describe 'DELETE destroy' do - let(:type) { FactoryGirl.create(:type, name: 'My type') } - let(:type2) { FactoryGirl.create(:type, name: 'My type 2', projects: [project]) } - let(:type3) { FactoryGirl.create(:type, name: 'My type 3', is_standard: true) } + let(:type) { FactoryBot.create(:type, name: 'My type') } + let(:type2) { FactoryBot.create(:type, name: 'My type 2', projects: [project]) } + let(:type3) { FactoryBot.create(:type, name: 'My type 3', is_standard: true) } describe 'successful detroy' do let(:params) { { 'id' => type.id } } @@ -326,12 +326,12 @@ describe TypesController, type: :controller do describe 'detroy type in use should fail' do let(:project2) do - FactoryGirl.create(:project, + FactoryBot.create(:project, work_package_custom_fields: [custom_field_2], types: [type2]) end let!(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: current_user, type: type2, project: project2) diff --git a/spec/controllers/users/memberships_controller_spec.rb b/spec/controllers/users/memberships_controller_spec.rb index 369f87c841..3fcde944df 100644 --- a/spec/controllers/users/memberships_controller_spec.rb +++ b/spec/controllers/users/memberships_controller_spec.rb @@ -30,13 +30,13 @@ require 'spec_helper' require 'work_package' describe Users::MembershipsController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:admin) { FactoryGirl.create(:admin) } - let(:anonymous) { FactoryGirl.create(:anonymous) } + let(:user) { FactoryBot.create(:user) } + let(:admin) { FactoryBot.create(:admin) } + let(:anonymous) { FactoryBot.create(:anonymous) } describe 'update memberships' do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role) } it 'works' do # i.e. it should successfully add a user to a project's members diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index a1a5200ae9..7fb1f821d8 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -40,14 +40,14 @@ describe UsersController, type: :controller do let(:user_password) {'bob!' * 4} let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'bob', password: user_password, password_confirmation: user_password, ) end - let(:admin) { FactoryGirl.create(:admin) } - let(:anonymous) { FactoryGirl.create(:anonymous) } + let(:admin) { FactoryBot.create(:admin) } + let(:anonymous) { FactoryBot.create(:anonymous) } describe 'GET deletion_info' do describe "WHEN the current user is the requested user @@ -133,10 +133,10 @@ describe UsersController, type: :controller do end describe 'POST resend_invitation' do - let(:invited_user) { FactoryGirl.create :invited_user } + let(:invited_user) { FactoryBot.create :invited_user } context 'without admin rights' do - let(:normal_user) { FactoryGirl.create :user } + let(:normal_user) { FactoryBot.create :user } before do as_logged_in_user normal_user do @@ -150,7 +150,7 @@ describe UsersController, type: :controller do end context 'with admin rights' do - let(:admin_user) { FactoryGirl.create :admin } + let(:admin_user) { FactoryBot.create :admin } before do expect(ActionMailer::Base.deliveries).to be_empty @@ -245,7 +245,7 @@ describe UsersController, type: :controller do describe "WHEN the current user is the admin WHEN the given password does not match WHEN the setting users_deletable_by_admins is set to true" do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } before do disable_flash_sweep @@ -269,7 +269,7 @@ describe UsersController, type: :controller do let(:admin_password) {'admin!' * 4} let(:admin) do - FactoryGirl.create(:admin, + FactoryBot.create(:admin, password: admin_password, password_confirmation: admin_password) end @@ -289,7 +289,7 @@ describe UsersController, type: :controller do describe "WHEN the current user is the admin WHEN the setting users_deletable_by_admins is set to false" do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } before do disable_flash_sweep @@ -307,7 +307,7 @@ describe UsersController, type: :controller do describe '#change_status_info' do let!(:registered_user) do - FactoryGirl.create(:user, status: User::STATUSES[:registered]) + FactoryBot.create(:user, status: User::STATUSES[:registered]) end before do @@ -360,7 +360,7 @@ describe UsersController, type: :controller do } do describe 'WHEN activating a registered user' do let!(:registered_user) do - FactoryGirl.create(:user, status: User::STATUSES[:registered], + FactoryBot.create(:user, status: User::STATUSES[:registered], language: 'de') end @@ -495,7 +495,7 @@ describe UsersController, type: :controller do describe 'update' do context 'fields' do let(:user) { - FactoryGirl.create(:user, firstname: 'Firstname', + FactoryBot.create(:user, firstname: 'Firstname', admin: true, login: 'testlogin', mail_notification: 'all', @@ -545,7 +545,7 @@ describe UsersController, type: :controller do end context 'with external authentication' do - let(:user) { FactoryGirl.create(:user, identity_url: 'some:identity') } + let(:user) { FactoryBot.create(:user, identity_url: 'some:identity') } before do as_logged_in_user(admin) do @@ -560,7 +560,7 @@ describe UsersController, type: :controller do end context 'ldap auth source' do - let(:ldap_auth_source) { FactoryGirl.create(:ldap_auth_source) } + let(:ldap_auth_source) { FactoryBot.create(:ldap_auth_source) } it 'switchting to internal authentication on a password change' do user.auth_source = ldap_auth_source @@ -638,33 +638,33 @@ describe UsersController, type: :controller do render_views let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user) } let!(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: work_package.project, principal: user, - roles: [FactoryGirl.create(:role, + roles: [FactoryBot.create(:role, permissions: [:view_work_packages])]) } let!(:journal_1) { - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, user: user, journable_id: work_package.id, version: Journal.maximum(:version) + 1, - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: work_package.subject, status_id: work_package.status_id, type_id: work_package.type_id, project_id: work_package.project_id)) } let!(:journal_2) { - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, user: user, journable_id: work_package.id, version: Journal.maximum(:version) + 1, - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: work_package.subject, status_id: work_package.status_id, type_id: work_package.type_id, diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb index d8876f009c..65a05d52cc 100644 --- a/spec/controllers/versions_controller_spec.rb +++ b/spec/controllers/versions_controller_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe VersionsController, type: :controller do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:public_project) } - let(:version1) { FactoryGirl.create(:version, project: project, effective_date: nil) } - let(:version2) { FactoryGirl.create(:version, project: project) } - let(:version3) { FactoryGirl.create(:version, project: project, effective_date: (Date.today - 14.days)) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:public_project) } + let(:version1) { FactoryBot.create(:version, project: project, effective_date: nil) } + let(:version2) { FactoryBot.create(:version, project: project) } + let(:version3) { FactoryBot.create(:version, project: project, effective_date: (Date.today - 14.days)) } describe '#index' do render_views @@ -87,8 +87,8 @@ describe VersionsController, type: :controller do end context 'with showing subprojects versions' do - let(:sub_project) { FactoryGirl.create(:public_project, parent_id: project.id) } - let(:version4) { FactoryGirl.create(:version, project: sub_project) } + let(:sub_project) { FactoryBot.create(:public_project, parent_id: project.id) } + let(:version4) { FactoryBot.create(:version, project: sub_project) } before do login_as(user) diff --git a/spec/controllers/wiki_controller_spec.rb b/spec/controllers/wiki_controller_spec.rb index c93db5d448..63ae438d11 100644 --- a/spec/controllers/wiki_controller_spec.rb +++ b/spec/controllers/wiki_controller_spec.rb @@ -39,20 +39,20 @@ describe WikiController, type: :controller do before do allow(@controller).to receive(:set_localization) - @role = FactoryGirl.create(:non_member) - @user = FactoryGirl.create(:admin) + @role = FactoryBot.create(:non_member) + @user = FactoryBot.create(:admin) allow(User).to receive(:current).and_return @user - @project = FactoryGirl.create(:project) + @project = FactoryBot.create(:project) @project.reload # to get the wiki into the proxy # creating pages - @existing_page = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + @existing_page = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, title: 'ExistingPage') # creating page contents - FactoryGirl.create(:wiki_content, page_id: @existing_page.id, + FactoryBot.create(:wiki_content, page_id: @existing_page.id, author_id: @user.id) end @@ -201,7 +201,7 @@ describe WikiController, type: :controller do let(:redirect_page_after_destroy) { wiki.find_page(wiki.start_page) || wiki.pages.first } before do - another_wiki_page = FactoryGirl.create :wiki_page, wiki: wiki + another_wiki_page = FactoryBot.create :wiki_page, wiki: wiki end it 'redirects to wiki#index' do @@ -227,44 +227,44 @@ describe WikiController, type: :controller do allow(@controller).to receive(:set_localization) allow(Setting).to receive(:login_required?).and_return(false) - @role = FactoryGirl.create(:non_member) - @user = FactoryGirl.create(:admin) + @role = FactoryBot.create(:non_member) + @user = FactoryBot.create(:admin) - @anon = User.anonymous.nil? ? FactoryGirl.create(:anonymous) : User.anonymous + @anon = User.anonymous.nil? ? FactoryBot.create(:anonymous) : User.anonymous Role.anonymous.update_attributes name: I18n.t(:default_role_anonymous), permissions: [:view_wiki_pages] allow(User).to receive(:current).and_return @user - @project = FactoryGirl.create(:public_project) + @project = FactoryBot.create(:public_project) @project.reload # to get the wiki into the proxy # creating pages - @page_default = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + @page_default = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, title: 'Wiki') - @page_with_content = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + @page_with_content = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, title: 'PagewithContent') - @page_without_content = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + @page_without_content = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, title: 'PagewithoutContent') - @unrelated_page = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + @unrelated_page = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, title: 'UnrelatedPage') # creating page contents - FactoryGirl.create(:wiki_content, page_id: @page_default.id, + FactoryBot.create(:wiki_content, page_id: @page_default.id, author_id: @user.id) - FactoryGirl.create(:wiki_content, page_id: @page_with_content.id, + FactoryBot.create(:wiki_content, page_id: @page_with_content.id, author_id: @user.id) - FactoryGirl.create(:wiki_content, page_id: @unrelated_page.id, + FactoryBot.create(:wiki_content, page_id: @unrelated_page.id, author_id: @user.id) # creating some child pages @children = {} [@page_with_content].each do |page| - child_page = FactoryGirl.create(:wiki_page, wiki_id: @project.wiki.id, + child_page = FactoryBot.create(:wiki_page, wiki_id: @project.wiki.id, parent_id: page.id, title: page.title + ' child') - FactoryGirl.create(:wiki_content, page_id: child_page.id, + FactoryBot.create(:wiki_content, page_id: child_page.id, author_id: @user.id) @children[page] = child_page @@ -273,15 +273,15 @@ describe WikiController, type: :controller do describe '- main menu links' do before do - @main_menu_item_for_page_with_content = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, + @main_menu_item_for_page_with_content = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, title: 'Item for Page with Content', name: @page_with_content.slug) - @main_menu_item_for_new_wiki_page = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, + @main_menu_item_for_new_wiki_page = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, title: 'Item for new WikiPage', name: 'new-wiki-page') - @other_menu_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, + @other_menu_item = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, title: 'Item for other page', name: @unrelated_page.slug) end @@ -373,7 +373,7 @@ describe WikiController, type: :controller do describe '- wiki_menu_item containing special chars only' do before do - @wiki_menu_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, + @wiki_menu_item = FactoryBot.create(:wiki_menu_item, navigatable_id: @project.wiki.id, title: '?', name: 'help') @other_wiki_menu_item = @other_menu_item @@ -510,7 +510,7 @@ describe WikiController, type: :controller do end describe 'preview' do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:text) { 'Wiki content' } it_behaves_like 'valid preview' do @@ -522,7 +522,7 @@ describe WikiController, type: :controller do end it_behaves_like 'authorizes object access' do - let(:wiki_page) { FactoryGirl.create(:wiki_page) } + let(:wiki_page) { FactoryBot.create(:wiki_page) } let(:preview_params) { { project_id: wiki_page.wiki.project.id, id: wiki_page.id, diff --git a/spec/controllers/wiki_menu_authentication_spec.rb b/spec/controllers/wiki_menu_authentication_spec.rb index 6f0f7cc662..593ae6eee4 100644 --- a/spec/controllers/wiki_menu_authentication_spec.rb +++ b/spec/controllers/wiki_menu_authentication_spec.rb @@ -33,22 +33,22 @@ describe WikiMenuItemsController, type: :controller do User.delete_all Role.delete_all - @project = FactoryGirl.create(:project) + @project = FactoryBot.create(:project) @project.reload # project contains wiki by default @params = {} @params[:project_id] = @project.id - page = FactoryGirl.create(:wiki_page, wiki: @project.wiki) + page = FactoryBot.create(:wiki_page, wiki: @project.wiki) @params[:id] = page.title end describe 'w/ valid auth' do it 'renders the edit action' do - admin_user = FactoryGirl.create(:admin) + admin_user = FactoryBot.create(:admin) allow(User).to receive(:current).and_return admin_user - permission_role = FactoryGirl.create(:role, name: 'accessgranted', permissions: [:manage_wiki_menu]) - member = FactoryGirl.create(:member, principal: admin_user, user: admin_user, project: @project, roles: [permission_role]) + permission_role = FactoryBot.create(:role, name: 'accessgranted', permissions: [:manage_wiki_menu]) + member = FactoryBot.create(:member, principal: admin_user, user: admin_user, project: @project, roles: [permission_role]) get 'edit', params: @params @@ -58,7 +58,7 @@ describe WikiMenuItemsController, type: :controller do describe 'w/o valid auth' do it 'be forbidden' do - allow(User).to receive(:current).and_return FactoryGirl.create(:user) + allow(User).to receive(:current).and_return FactoryBot.create(:user) get 'edit', params: @params diff --git a/spec/controllers/wiki_menu_items_controller_spec.rb b/spec/controllers/wiki_menu_items_controller_spec.rb index a9fe148b11..d77594bf1b 100644 --- a/spec/controllers/wiki_menu_items_controller_spec.rb +++ b/spec/controllers/wiki_menu_items_controller_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe WikiMenuItemsController, type: :controller do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } # create project with wiki - let(:project) { FactoryGirl.create(:project).reload } # a wiki is created for project, but the object doesn't know of it (FIXME?) + let(:project) { FactoryBot.create(:project).reload } # a wiki is created for project, but the object doesn't know of it (FIXME?) let(:wiki) { project.wiki } - let(:wiki_page) { FactoryGirl.create(:wiki_page, wiki: wiki) } # first wiki page without child pages - let!(:top_level_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, :with_menu_item_options, wiki: wiki, name: wiki_page.slug) } + let(:wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki) } # first wiki page without child pages + let!(:top_level_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, :with_menu_item_options, wiki: wiki, name: wiki_page.slug) } before :each do # log in user @@ -45,17 +45,17 @@ describe WikiMenuItemsController, type: :controller do describe '#edit' do # more wiki pages with menu items - let(:another_wiki_page) { FactoryGirl.create(:wiki_page, wiki: wiki) } # second wiki page with two child pages - let!(:another_wiki_page_top_level_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: another_wiki_page.slug) } + let(:another_wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki) } # second wiki page with two child pages + let!(:another_wiki_page_top_level_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_wiki_page.slug) } # child pages of another_wiki_page - let(:child_page) { FactoryGirl.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } - let!(:child_page_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: child_page.slug) } - let(:another_child_page) { FactoryGirl.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } - let!(:another_child_page_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: another_child_page.slug, parent: top_level_wiki_menu_item) } + let(:child_page) { FactoryBot.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } + let!(:child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: child_page.slug) } + let(:another_child_page) { FactoryBot.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } + let!(:another_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_child_page.slug, parent: top_level_wiki_menu_item) } - let(:grand_child_page) { FactoryGirl.create(:wiki_page, parent: child_page, wiki: wiki) } - let!(:grand_child_page_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) } + let(:grand_child_page) { FactoryBot.create(:wiki_page, parent: child_page, wiki: wiki) } + let!(:grand_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) } context 'when no parent wiki menu item has been configured yet' do context 'and it is a child page' do @@ -94,10 +94,10 @@ describe WikiMenuItemsController, type: :controller do end shared_context 'when there is one more wiki page with a child page' do - let!(:child_page) { FactoryGirl.create(:wiki_page, parent: wiki_page, wiki: wiki) } + let!(:child_page) { FactoryBot.create(:wiki_page, parent: wiki_page, wiki: wiki) } - let!(:another_wiki_page) { FactoryGirl.create(:wiki_page, wiki: wiki) } # second wiki page with two child pages - let!(:another_child_page) { FactoryGirl.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } + let!(:another_wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki) } # second wiki page with two child pages + let!(:another_child_page) { FactoryBot.create(:wiki_page, parent: another_wiki_page, wiki: wiki) } end describe '#select_main_menu_item' do diff --git a/spec/controllers/work_packages/auto_completes_controller_spec.rb b/spec/controllers/work_packages/auto_completes_controller_spec.rb index f1066e5483..907d339e37 100644 --- a/spec/controllers/work_packages/auto_completes_controller_spec.rb +++ b/spec/controllers/work_packages/auto_completes_controller_spec.rb @@ -29,30 +29,30 @@ require 'spec_helper' describe WorkPackages::AutoCompletesController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) } let(:work_package_1) do - FactoryGirl.create(:work_package, subject: "Can't print recipes", + FactoryBot.create(:work_package, subject: "Can't print recipes", project: project) end let(:work_package_2) do - FactoryGirl.create(:work_package, subject: 'Error when updating a recipe', + FactoryBot.create(:work_package, subject: 'Error when updating a recipe', project: project) end let(:work_package_3) do - FactoryGirl.create(:work_package, subject: 'Lorem ipsum', + FactoryBot.create(:work_package, subject: 'Lorem ipsum', project: project) end @@ -166,7 +166,7 @@ describe WorkPackages::AutoCompletesController, type: :controller do describe 'returns work package for given id' do render_views let(:work_package_4) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: "", project: project) } @@ -191,17 +191,17 @@ describe WorkPackages::AutoCompletesController, type: :controller do describe 'in different projects' do let(:project_2) { - FactoryGirl.create(:project, + FactoryBot.create(:project, parent: project) } let(:member_2) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_2, principal: user, roles: [role]) } let(:work_package_4) do - FactoryGirl.create(:work_package, subject: 'Foo Bar Baz', + FactoryBot.create(:work_package, subject: 'Foo Bar Baz', project: project_2) end diff --git a/spec/controllers/work_packages/bulk_controller_spec.rb b/spec/controllers/work_packages/bulk_controller_spec.rb index 8839f70c67..2bbe1e9fbd 100644 --- a/spec/controllers/work_packages/bulk_controller_spec.rb +++ b/spec/controllers/work_packages/bulk_controller_spec.rb @@ -29,56 +29,56 @@ require 'spec_helper' describe WorkPackages::BulkController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:user2) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } + let(:user2) { FactoryBot.create(:user) } let(:custom_field_value) { '125' } let(:custom_field_1) { - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, field_format: 'string', is_for_all: true) } - let(:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } - let(:custom_field_user) { FactoryGirl.create(:user_issue_custom_field) } - let(:status) { FactoryGirl.create(:status) } + let(:custom_field_2) { FactoryBot.create(:work_package_custom_field) } + let(:custom_field_user) { FactoryBot.create(:user_issue_custom_field) } + let(:status) { FactoryBot.create(:status) } let(:type) { - FactoryGirl.create(:type_standard, + FactoryBot.create(:type_standard, custom_fields: [custom_field_1, custom_field_2, custom_field_user]) } let(:project_1) { - FactoryGirl.create(:project, + FactoryBot.create(:project, types: [type], work_package_custom_fields: [custom_field_2]) } let(:project_2) { - FactoryGirl.create(:project, + FactoryBot.create(:project, types: [type]) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:edit_work_packages, :view_work_packages, :manage_subtasks]) } let(:member1_p1) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_1, principal: user, roles: [role]) } let(:member2_p1) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_1, principal: user2, roles: [role]) } let(:member1_p2) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_2, principal: user, roles: [role]) } let(:work_package_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, assigned_to: user, responsible: user2, @@ -88,7 +88,7 @@ describe WorkPackages::BulkController, type: :controller do project: project_1) } let(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, assigned_to: user, responsible: user2, @@ -98,7 +98,7 @@ describe WorkPackages::BulkController, type: :controller do project: project_1) } let(:work_package_3) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, type: type, status: status, @@ -106,7 +106,7 @@ describe WorkPackages::BulkController, type: :controller do project: project_2) } - let(:stub_work_package) { FactoryGirl.build_stubbed(:work_package) } + let(:stub_work_package) { FactoryBot.build_stubbed(:work_package) } before do custom_field_1 @@ -189,7 +189,7 @@ describe WorkPackages::BulkController, type: :controller do describe '#update' do let(:work_package_ids) { [work_package_1.id, work_package_2.id] } let(:work_packages) { WorkPackage.where(id: work_package_ids) } - let(:priority) { FactoryGirl.create(:priority_immediate) } + let(:priority) { FactoryBot.create(:priority_immediate) } let(:group_id) { '' } let(:responsible_id) { '' } @@ -222,17 +222,17 @@ describe WorkPackages::BulkController, type: :controller do context 'when updating two work packages with differing whitelisted params' do let!(:work_package_ids) { [work_package_1.id, work_package_3.id] } - let!(:role_with_permission_to_add_watchers) { FactoryGirl.create(:role, permissions: role.permissions + [:add_work_package_watchers]) } - let!(:other_user) { FactoryGirl.create :user } + let!(:role_with_permission_to_add_watchers) { FactoryBot.create(:role, permissions: role.permissions + [:add_work_package_watchers]) } + let!(:other_user) { FactoryBot.create :user } let!(:other_member_1) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_1, principal: other_user, roles: [role_with_permission_to_add_watchers]) } let!(:other_member_2) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_2, principal: other_user, roles: [role]) @@ -376,7 +376,7 @@ describe WorkPackages::BulkController, type: :controller do describe '#properties' do describe '#groups' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } let(:group_id) { group.id } include_context 'update_request' @@ -397,9 +397,9 @@ describe WorkPackages::BulkController, type: :controller do end describe '#status' do - let(:closed_status) { FactoryGirl.create(:closed_status) } + let(:closed_status) { FactoryBot.create(:closed_status) } let(:workflow) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, role: role, type_id: type.id, old_status: status, @@ -423,7 +423,7 @@ describe WorkPackages::BulkController, type: :controller do describe '#parent' do let(:parent) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, project: project_1) } @@ -493,13 +493,13 @@ describe WorkPackages::BulkController, type: :controller do describe '#version' do describe 'set fixed_version_id attribute to some version' do let(:version) { - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', sharing: 'tree', project: subproject) } let(:subproject) { - FactoryGirl.create(:project, + FactoryBot.create(:project, parent: project_1, types: [type]) } diff --git a/spec/controllers/work_packages/calendars_controller_spec.rb b/spec/controllers/work_packages/calendars_controller_spec.rb index 31b8e958d5..9f07ecb448 100644 --- a/spec/controllers/work_packages/calendars_controller_spec.rb +++ b/spec/controllers/work_packages/calendars_controller_spec.rb @@ -29,18 +29,18 @@ require 'spec_helper' describe WorkPackages::CalendarsController, type: :controller do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_calendar]) } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) } @@ -81,7 +81,7 @@ describe WorkPackages::CalendarsController, type: :controller do context 'custom query' do let (:query) { - FactoryGirl.create(:query, + FactoryBot.create(:query, project: nil, user: user) } diff --git a/spec/controllers/work_packages/moves_controller_spec.rb b/spec/controllers/work_packages/moves_controller_spec.rb index ebdeb39ca8..2266839eee 100644 --- a/spec/controllers/work_packages/moves_controller_spec.rb +++ b/spec/controllers/work_packages/moves_controller_spec.rb @@ -29,35 +29,35 @@ require 'spec_helper' describe WorkPackages::MovesController, type: :controller do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i(move_work_packages view_work_packages add_work_packages edit_work_packages manage_subtasks) end - let(:type) { FactoryGirl.create :type } - let(:type_2) { FactoryGirl.create :type } - let(:status) { FactoryGirl.create :default_status } - let(:target_status) { FactoryGirl.create :status } - let(:priority) { FactoryGirl.create :priority } - let(:target_priority) { FactoryGirl.create :priority } + let(:type) { FactoryBot.create :type } + let(:type_2) { FactoryBot.create :type } + let(:status) { FactoryBot.create :default_status } + let(:target_status) { FactoryBot.create :status } + let(:priority) { FactoryBot.create :priority } + let(:target_priority) { FactoryBot.create :priority } let(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, is_public: false, types: [type, type_2]) end let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project_id: project.id, type: type, author: user, priority: priority) end - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do allow(User).to receive(:current).and_return current_user @@ -116,11 +116,11 @@ describe WorkPackages::MovesController, type: :controller do end describe '#create' do - let!(:source_member) { FactoryGirl.create(:member, user: current_user, project: project, roles: [role]) } - let!(:target_member) { FactoryGirl.create(:member, user: current_user, project: target_project, roles: [role]) } - let(:target_project) { FactoryGirl.create(:project, is_public: false) } + let!(:source_member) { FactoryBot.create(:member, user: current_user, project: project, roles: [role]) } + let!(:target_member) { FactoryBot.create(:member, user: current_user, project: target_project, roles: [role]) } + let(:target_project) { FactoryBot.create(:project, is_public: false) } let(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project_id: project.id, type: type_2, priority: priority) @@ -329,9 +329,9 @@ describe WorkPackages::MovesController, type: :controller do let(:start_date) { Date.today } let(:due_date) { Date.today + 1 } let(:target_user) do - user = FactoryGirl.create :user + user = FactoryBot.create :user - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: target_project, roles: [role]) @@ -418,17 +418,17 @@ describe WorkPackages::MovesController, type: :controller do context 'child work package from one project to other' do let(:to_project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, types: [type]) end let!(:member) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: current_user, roles: [role], project: to_project) end let!(:child_wp) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, type: type, project: project, parent: work_package) diff --git a/spec/controllers/work_packages/reports_controller_spec.rb b/spec/controllers/work_packages/reports_controller_spec.rb index 4d5d56211c..0a5c2f08b4 100644 --- a/spec/controllers/work_packages/reports_controller_spec.rb +++ b/spec/controllers/work_packages/reports_controller_spec.rb @@ -29,32 +29,32 @@ require 'spec_helper' describe WorkPackages::ReportsController, type: :controller do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create(:project) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) } let(:work_package_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, id: 21, subject: "Can't print recipes", project: project) } let(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, id: 2101, subject: 'Error 281 when updating a recipe', project: project) } let(:work_package_3) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, id: 2102, project: project) } diff --git a/spec/controllers/work_packages_controller_spec.rb b/spec/controllers/work_packages_controller_spec.rb index f9f70e98c7..f10eb1cffa 100644 --- a/spec/controllers/work_packages_controller_spec.rb +++ b/spec/controllers/work_packages_controller_spec.rb @@ -38,11 +38,11 @@ describe WorkPackagesController, type: :controller do allow(UserMailer).to receive(:new).and_return(double('mailer').as_null_object) end - let(:project) { FactoryGirl.create(:project, identifier: 'test_project', is_public: false) } - let(:stub_project) { FactoryGirl.build_stubbed(:project, identifier: 'test_project', is_public: false) } + let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) } + let(:stub_project) { FactoryBot.build_stubbed(:project, identifier: 'test_project', is_public: false) } let(:stub_work_package) { double('work_package', id: 1337, project: stub_project).as_null_object } - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } def self.requires_permission_in_project(&block) describe 'w/o the permission to see the project/work_package' do @@ -118,7 +118,7 @@ describe WorkPackagesController, type: :controller do end describe 'index' do - let(:query) { FactoryGirl.build_stubbed(:query).tap(&:add_default_filter) } + let(:query) { FactoryBot.build_stubbed(:query).tap(&:add_default_filter) } let(:work_packages) { double('work packages').as_null_object } let(:results) { double('results').as_null_object } @@ -320,14 +320,14 @@ describe WorkPackagesController, type: :controller do # ISO-8859-1. Since this can happen, though, it is more sensible to encode everything # in UTF-8 which gets rid of this problem altogether. let(:work_package) do - FactoryGirl.create( + FactoryBot.create( :work_package, subject: "Ruby encodes ß as '\\xDF' in ISO-8859-1.", description: "\u2022 requires unicode.", assigned_to: current_user ) end - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } it 'performs a successful export' do wp = work_package.reload diff --git a/spec/decorators/single_spec.rb b/spec/decorators/single_spec.rb index d37c5ea8cf..76e47ba939 100644 --- a/spec/decorators/single_spec.rb +++ b/spec/decorators/single_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe ::API::Decorators::Single do - let(:user) { FactoryGirl.build(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project_with_types) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:user) { FactoryBot.build(:user, member_in_project: project, member_through_role: role) } + let(:project) { FactoryBot.create(:project_with_types) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:model) { Object.new } diff --git a/spec/factories/announcement_factory.rb b/spec/factories/announcement_factory.rb index 393e3bb126..54e9e802d3 100644 --- a/spec/factories/announcement_factory.rb +++ b/spec/factories/announcement_factory.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :announcement do text 'Announcement text' show_until Date.today + 14.days diff --git a/spec/factories/attachment_factory.rb b/spec/factories/attachment_factory.rb index 8b2a6b8384..fa39c3056b 100644 --- a/spec/factories/attachment_factory.rb +++ b/spec/factories/attachment_factory.rb @@ -28,7 +28,7 @@ require Rails.root + 'spec/support/file_helpers' -FactoryGirl.define do +FactoryBot.define do factory :attachment do container factory: :work_package author factory: :user diff --git a/spec/factories/attribute_help_text_factory.rb b/spec/factories/attribute_help_text_factory.rb index a0110be811..d1266958b8 100644 --- a/spec/factories/attribute_help_text_factory.rb +++ b/spec/factories/attribute_help_text_factory.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :work_package_help_text, class: AttributeHelpText::WorkPackage do type 'AttributeHelpText::WorkPackage' help_text 'Attribute help text' diff --git a/spec/factories/auth_source_factory.rb b/spec/factories/auth_source_factory.rb index 9dc2216361..5eb08010c9 100644 --- a/spec/factories/auth_source_factory.rb +++ b/spec/factories/auth_source_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :auth_source do name 'Test AuthSource' end diff --git a/spec/factories/board_factory.rb b/spec/factories/board_factory.rb index eb9fb7df99..55376624f6 100644 --- a/spec/factories/board_factory.rb +++ b/spec/factories/board_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :board do project sequence(:name) do |n| "Board No. #{n}" end diff --git a/spec/factories/category_factory.rb b/spec/factories/category_factory.rb index e7a34f4bcb..01cff8b629 100644 --- a/spec/factories/category_factory.rb +++ b/spec/factories/category_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :category do sequence(:name) do |n| "Issue category #{n}" end project diff --git a/spec/factories/changeset_factory.rb b/spec/factories/changeset_factory.rb index 8c164c3dac..8a0cb3e194 100644 --- a/spec/factories/changeset_factory.rb +++ b/spec/factories/changeset_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :changeset do sequence(:revision) do |n| "#{n}" end committed_on Time.now diff --git a/spec/factories/comment_factory.rb b/spec/factories/comment_factory.rb index 7c5b316ead..8c471adeb2 100644 --- a/spec/factories/comment_factory.rb +++ b/spec/factories/comment_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :comment do author factory: :user sequence(:comments) do |n| "I am a comment No. #{n}" end diff --git a/spec/factories/custom_action_factory.rb b/spec/factories/custom_action_factory.rb index 429bcd05dd..d993302800 100644 --- a/spec/factories/custom_action_factory.rb +++ b/spec/factories/custom_action_factory.rb @@ -26,7 +26,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :custom_action do sequence(:name) { |n| "Custom action #{n} - name" } sequence(:description) { |n| "Custom action #{n} - description" } diff --git a/spec/factories/custom_field_factory.rb b/spec/factories/custom_field_factory.rb index 9db6397b36..ccadabc4c8 100644 --- a/spec/factories/custom_field_factory.rb +++ b/spec/factories/custom_field_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :custom_field do name 'Custom Field' regexp '' diff --git a/spec/factories/custom_option_factory.rb b/spec/factories/custom_option_factory.rb index 6afde61b0e..75b9bbcd3e 100644 --- a/spec/factories/custom_option_factory.rb +++ b/spec/factories/custom_option_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :custom_option do sequence(:value) { |n| "Custom Option #{n}" } end diff --git a/spec/factories/custom_style_factory.rb b/spec/factories/custom_style_factory.rb index e55747db10..ca9f5fb231 100644 --- a/spec/factories/custom_style_factory.rb +++ b/spec/factories/custom_style_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :custom_style factory :custom_style_with_logo, class: CustomStyle do diff --git a/spec/factories/custom_value_factory.rb b/spec/factories/custom_value_factory.rb index ee9caa3052..d851844baa 100644 --- a/spec/factories/custom_value_factory.rb +++ b/spec/factories/custom_value_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :custom_value do custom_field value '' diff --git a/spec/factories/design_color_factory.rb b/spec/factories/design_color_factory.rb index fc14f2e084..611a56efb6 100644 --- a/spec/factories/design_color_factory.rb +++ b/spec/factories/design_color_factory.rb @@ -26,14 +26,14 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory(:design_color, class: DesignColor) do hexcode { ('#%0.6x' % rand(0xFFFFFF)).upcase } end end { "primary-color" => "#3493B3" }.each do |name, code| - FactoryGirl.define do + FactoryBot.define do factory(:"design_color_#{name}", parent: :design_color) do variable name hexcode code diff --git a/spec/factories/enumerations_factory.rb b/spec/factories/enumerations_factory.rb index 27787d1a32..36379d7943 100644 --- a/spec/factories/enumerations_factory.rb +++ b/spec/factories/enumerations_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :default_enumeration, class: Enumeration do initialize_with do Enumeration.where(type: 'Enumeration', is_default: true).first || Enumeration.new diff --git a/spec/factories/file_factory.rb b/spec/factories/file_factory.rb index 313c598906..39cbe3b525 100644 --- a/spec/factories/file_factory.rb +++ b/spec/factories/file_factory.rb @@ -26,11 +26,11 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do ## # Yields fixture files. factory :file, class: File do - # Skip the create callback to be able to use non-AR models. Otherwise FactoryGirl will + # Skip the create callback to be able to use non-AR models. Otherwise FactoryBot will # try to call #save! on any created object. skip_create diff --git a/spec/factories/group_factory.rb b/spec/factories/group_factory.rb index b7779fb18f..23a4543dec 100644 --- a/spec/factories/group_factory.rb +++ b/spec/factories/group_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :group, parent: :principal, class: Group do # groups have lastnames? hmm... sequence(:lastname) { |g| "Group #{g}" } diff --git a/spec/factories/issue_priority_factory.rb b/spec/factories/issue_priority_factory.rb index e31bf4ad58..356f3a2cc0 100644 --- a/spec/factories/issue_priority_factory.rb +++ b/spec/factories/issue_priority_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :issue_priority do sequence(:name) { |n| "IssuePriority #{n}" } end diff --git a/spec/factories/journal/attachable_journal_factory.rb b/spec/factories/journal/attachable_journal_factory.rb index 74bdb4052b..aa02809c56 100644 --- a/spec/factories/journal/attachable_journal_factory.rb +++ b/spec/factories/journal/attachable_journal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :journal_attachable_journal, class: Journal::AttachableJournal do end end diff --git a/spec/factories/journal/message_journal_factory.rb b/spec/factories/journal/message_journal_factory.rb index 1c959200a9..f03108d0fa 100644 --- a/spec/factories/journal/message_journal_factory.rb +++ b/spec/factories/journal/message_journal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :journal_message_journal, class: Journal::MessageJournal do end end diff --git a/spec/factories/journal/wiki_content_journal_factory.rb b/spec/factories/journal/wiki_content_journal_factory.rb index 1d35f072d3..6d7f039c20 100644 --- a/spec/factories/journal/wiki_content_journal_factory.rb +++ b/spec/factories/journal/wiki_content_journal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :journal_wiki_content_journal, class: Journal::WikiContentJournal do page_id 1 end diff --git a/spec/factories/journal/work_package_journal_factory.rb b/spec/factories/journal/work_package_journal_factory.rb index 2970f5ce5c..192db00126 100644 --- a/spec/factories/journal/work_package_journal_factory.rb +++ b/spec/factories/journal/work_package_journal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :journal_work_package_journal, class: Journal::WorkPackageJournal do end end diff --git a/spec/factories/journal_factory.rb b/spec/factories/journal_factory.rb index 58a87dbff2..e21fb2e4dc 100644 --- a/spec/factories/journal_factory.rb +++ b/spec/factories/journal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :journal do user factory: :user created_at Time.now @@ -35,19 +35,19 @@ FactoryGirl.define do factory :work_package_journal, class: Journal do journable_type 'WorkPackage' activity_type 'work_packages' - data FactoryGirl.build(:journal_work_package_journal) + data FactoryBot.build(:journal_work_package_journal) end factory :wiki_content_journal, class: Journal do journable_type 'WikiContent' activity_type 'wiki_edits' - data FactoryGirl.build(:journal_wiki_content_journal) + data FactoryBot.build(:journal_wiki_content_journal) end factory :message_journal, class: Journal do journable_type 'Message' activity_type 'messages' - data FactoryGirl.build(:journal_message_journal) + data FactoryBot.build(:journal_message_journal) end end end diff --git a/spec/factories/member_factory.rb b/spec/factories/member_factory.rb index 14ffa4601a..44bdcdcc1c 100644 --- a/spec/factories/member_factory.rb +++ b/spec/factories/member_factory.rb @@ -28,17 +28,17 @@ # Create memberships like this: # -# project = FactoryGirl.create(:project) -# user = FactoryGirl.create(:user) -# role = FactoryGirl.create(:role, permissions: [:view_wiki_pages, :edit_wiki_pages]) +# project = FactoryBot.create(:project) +# user = FactoryBot.create(:user) +# role = FactoryBot.create(:role, permissions: [:view_wiki_pages, :edit_wiki_pages]) # -# member = FactoryGirl.create(:member, user: user, project: project) +# member = FactoryBot.create(:member, user: user, project: project) # member.role_ids = [role.id] # member.save! # # It looks like you cannot create member_role models directly. -FactoryGirl.define do +FactoryBot.define do factory :member do user project diff --git a/spec/factories/menu_item_factory.rb b/spec/factories/menu_item_factory.rb index 48be33862e..bd67b927ce 100644 --- a/spec/factories/menu_item_factory.rb +++ b/spec/factories/menu_item_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :menu_item do sequence(:name) do |n| "Item No. #{n}" end sequence(:title) do |n| "Menu item Title #{n}" end @@ -43,7 +43,7 @@ FactoryGirl.define do factory :wiki_menu_item_with_parent do callback(:after_build) do |wiki_menu_item| - parent = FactoryGirl.build(:wiki_menu_item, wiki: wiki_menu_item.wiki) + parent = FactoryBot.build(:wiki_menu_item, wiki: wiki_menu_item.wiki) wiki_menu_item.wiki.wiki_menu_items << parent wiki_menu_item.parent = parent end diff --git a/spec/factories/message_factory.rb b/spec/factories/message_factory.rb index ab445cf1ae..bd475664bb 100644 --- a/spec/factories/message_factory.rb +++ b/spec/factories/message_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :message do board sequence(:content) do |n| "Message content #{n}" end diff --git a/spec/factories/news_factory.rb b/spec/factories/news_factory.rb index 64f30e7bc6..71e371c0af 100644 --- a/spec/factories/news_factory.rb +++ b/spec/factories/news_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :news do sequence(:title) do |n| "News title#{n}" end sequence(:summary) do |n| "News summary#{n}" end diff --git a/spec/factories/planning_element_type_color_factory.rb b/spec/factories/planning_element_type_color_factory.rb index 42477a8d95..696222e6c4 100644 --- a/spec/factories/planning_element_type_color_factory.rb +++ b/spec/factories/planning_element_type_color_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory(:color, class: PlanningElementTypeColor) do sequence(:name) do |n| "Color No. #{n}" end hexcode do ('#%0.6x' % rand(0xFFFFFF)).upcase end @@ -51,7 +51,7 @@ end 'black' => '#000000', 'silver' => '#C0C0C0', 'gray' => '#808080' }.each do |name, code| - FactoryGirl.define do + FactoryBot.define do factory(:"color_#{name}", parent: :color) do name name hexcode code diff --git a/spec/factories/principal_factory.rb b/spec/factories/principal_factory.rb index 8af1c2786b..0887f20ca5 100644 --- a/spec/factories/principal_factory.rb +++ b/spec/factories/principal_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :principal do transient do member_in_project nil @@ -43,7 +43,7 @@ FactoryGirl.define do (projects = evaluator.member_in_projects || []) projects << evaluator.member_in_project if evaluator.member_in_project if !projects.empty? - role = evaluator.member_through_role || FactoryGirl.build(:role, permissions: [:view_work_packages, :edit_work_packages]) + role = evaluator.member_through_role || FactoryBot.build(:role, permissions: [:view_work_packages, :edit_work_packages]) projects.each do |project| project.add_member! user, role if project end diff --git a/spec/factories/project_factory.rb b/spec/factories/project_factory.rb index 156239cc3f..be5caa1ba6 100644 --- a/spec/factories/project_factory.rb +++ b/spec/factories/project_factory.rb @@ -27,7 +27,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :project do transient do no_types false @@ -48,7 +48,7 @@ FactoryGirl.define do callback(:before_create) do |project, evaluator| unless evaluator.no_types || ::Type.where(is_standard: true).count > 0 - project.types << FactoryGirl.build(:type_standard) + project.types << FactoryBot.build(:type_standard) end end @@ -61,10 +61,10 @@ FactoryGirl.define do # the project's initialize function looking for the default type # when we will be setting the type later on anyway initialize_with do - types = if instance_variable_get(:@build_strategy).is_a?(FactoryGirl::Strategy::Stub) - [FactoryGirl.build_stubbed(:type)] + types = if instance_variable_get(:@build_strategy).is_a?(FactoryBot::Strategy::Stub) + [FactoryBot.build_stubbed(:type)] else - [FactoryGirl.build(:type)] + [FactoryBot.build(:type)] end new(types: types) @@ -72,7 +72,7 @@ FactoryGirl.define do factory :valid_project do callback(:after_build) do |project| - project.types << FactoryGirl.build(:type_with_workflow) + project.types << FactoryBot.build(:type_with_workflow) end end end diff --git a/spec/factories/project_type_factory.rb b/spec/factories/project_type_factory.rb index 8c6408ec80..dfce95036f 100644 --- a/spec/factories/project_type_factory.rb +++ b/spec/factories/project_type_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory(:project_type, class: ProjectType) do sequence(:name) do |n| "Project Type No. #{n}" end sequence(:position) { |n| n } diff --git a/spec/factories/query_factory.rb b/spec/factories/query_factory.rb index e0145a6634..21ed91c187 100644 --- a/spec/factories/query_factory.rb +++ b/spec/factories/query_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :query do project user factory: :user diff --git a/spec/factories/relation_factory.rb b/spec/factories/relation_factory.rb index ef02b74b0a..80f30329e7 100644 --- a/spec/factories/relation_factory.rb +++ b/spec/factories/relation_factory.rb @@ -26,10 +26,10 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :relation do from factory: :work_package - to { FactoryGirl.build(:work_package, project: from.project) } + to { FactoryBot.build(:work_package, project: from.project) } relation_type 'relates' # "relates", "duplicates", "duplicated", "blocks", "blocked", "precedes", "follows" delay nil description nil diff --git a/spec/factories/repository_factory.rb b/spec/factories/repository_factory.rb index 0e083c8d60..f4869f95d4 100644 --- a/spec/factories/repository_factory.rb +++ b/spec/factories/repository_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :repository_subversion, class: Repository::Subversion do url 'file://tmp/svn_test_repo' scm_type 'existing' diff --git a/spec/factories/role_factory.rb b/spec/factories/role_factory.rb index e57f380bc3..7d2d1937ef 100644 --- a/spec/factories/role_factory.rb +++ b/spec/factories/role_factory.rb @@ -28,7 +28,7 @@ require 'digest' -FactoryGirl.define do +FactoryBot.define do factory :role do permissions [] sequence(:name) do |n| "role_#{n}" end diff --git a/spec/factories/status_factory.rb b/spec/factories/status_factory.rb index 4b4d2b4c19..a33847b1f3 100644 --- a/spec/factories/status_factory.rb +++ b/spec/factories/status_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :status do sequence(:name) do |n| "status #{n}" end is_closed false diff --git a/spec/factories/time_entry_activity_factory.rb b/spec/factories/time_entry_activity_factory.rb index a21f1fbf4b..2a66d12a17 100644 --- a/spec/factories/time_entry_activity_factory.rb +++ b/spec/factories/time_entry_activity_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :time_entry_activity do sequence(:name) { |n| "Time Entry Activity No. #{n}" } end diff --git a/spec/factories/time_entry_factory.rb b/spec/factories/time_entry_factory.rb index 8c5979107b..791b21fd3a 100644 --- a/spec/factories/time_entry_factory.rb +++ b/spec/factories/time_entry_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :time_entry do project user diff --git a/spec/factories/token_factory.rb b/spec/factories/token_factory.rb index 396a0a5ca2..8798be59a1 100644 --- a/spec/factories/token_factory.rb +++ b/spec/factories/token_factory.rb @@ -28,7 +28,7 @@ require 'securerandom' -FactoryGirl.define do +FactoryBot.define do factory :invitation_token, class: ::Token::Invitation do user end diff --git a/spec/factories/type_factory.rb b/spec/factories/type_factory.rb index 9c3bab1a4e..5ae4d05fb3 100644 --- a/spec/factories/type_factory.rb +++ b/spec/factories/type_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :type do sequence(:position) do |p| p end name do |a| "Type No. #{a.position}" end @@ -35,7 +35,7 @@ FactoryGirl.define do factory :type_with_workflow, class: Type do callback(:after_build) do |t| - t.workflows = [FactoryGirl.build(:workflow_with_default_status)] + t.workflows = [FactoryBot.build(:workflow_with_default_status)] end end end diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb index 66b0166106..a3fde8000f 100644 --- a/spec/factories/user_factory.rb +++ b/spec/factories/user_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :user, parent: :principal, class: User do firstname 'Bob' lastname 'Bobbit' diff --git a/spec/factories/user_password_factory.rb b/spec/factories/user_password_factory.rb index 339c3ef468..2b8018a7ef 100644 --- a/spec/factories/user_password_factory.rb +++ b/spec/factories/user_password_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :user_password, class: UserPassword.active_type do association :user plain_password 'adminADMIN!' diff --git a/spec/factories/user_preference_factory.rb b/spec/factories/user_preference_factory.rb index c9d032b278..6248750825 100644 --- a/spec/factories/user_preference_factory.rb +++ b/spec/factories/user_preference_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :user_preference do user hide_mail true diff --git a/spec/factories/user_session_factory.rb b/spec/factories/user_session_factory.rb index 9a09488d87..9c3fb5005d 100644 --- a/spec/factories/user_session_factory.rb +++ b/spec/factories/user_session_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :user_session do sequence(:session_id) do |n| "session_#{n}" end association :user diff --git a/spec/factories/version_factory.rb b/spec/factories/version_factory.rb index 0782ff8345..2dc38cb61b 100644 --- a/spec/factories/version_factory.rb +++ b/spec/factories/version_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :version do sequence(:name) do |i| "Version #{i}" end effective_date Date.today + 14.days diff --git a/spec/factories/watcher_factory.rb b/spec/factories/watcher_factory.rb index 6c7f574de3..e4188821b3 100644 --- a/spec/factories/watcher_factory.rb +++ b/spec/factories/watcher_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :watcher do association :watchable association :user diff --git a/spec/factories/wiki_content_factory.rb b/spec/factories/wiki_content_factory.rb index 0253f846d3..9390deaa68 100644 --- a/spec/factories/wiki_content_factory.rb +++ b/spec/factories/wiki_content_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :wiki_content do page factory: :wiki_page author factory: :user diff --git a/spec/factories/wiki_factory.rb b/spec/factories/wiki_factory.rb index 246490d9ed..4f2896a21e 100644 --- a/spec/factories/wiki_factory.rb +++ b/spec/factories/wiki_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :wiki do start_page 'Wiki' project diff --git a/spec/factories/wiki_page_factory.rb b/spec/factories/wiki_page_factory.rb index 3ee0cc1959..26d0c53ab1 100644 --- a/spec/factories/wiki_page_factory.rb +++ b/spec/factories/wiki_page_factory.rb @@ -26,14 +26,14 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :wiki_page do wiki sequence(:title) do |n| "Wiki Page No. #{n}" end factory :wiki_page_with_content do callback(:after_build) do |wiki_page| - wiki_page.content = FactoryGirl.build :wiki_content, page: wiki_page + wiki_page.content = FactoryBot.build :wiki_content, page: wiki_page end end end diff --git a/spec/factories/wiki_redirect_factory.rb b/spec/factories/wiki_redirect_factory.rb index a1ee4da709..ae279bc5ca 100644 --- a/spec/factories/wiki_redirect_factory.rb +++ b/spec/factories/wiki_redirect_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :wiki_redirect do wiki diff --git a/spec/factories/work_package_custom_field_factory.rb b/spec/factories/work_package_custom_field_factory.rb index 17aa5772c8..3f6411dd7a 100644 --- a/spec/factories/work_package_custom_field_factory.rb +++ b/spec/factories/work_package_custom_field_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :work_package_custom_field do transient do default_locales nil diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rb index 67c7ce8ada..3553eee01a 100644 --- a/spec/factories/work_package_factory.rb +++ b/spec/factories/work_package_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :work_package do transient do custom_values nil @@ -62,7 +62,7 @@ FactoryGirl.define do end priority - project { FactoryGirl.build_stubbed(:project_with_types) } + project { FactoryBot.build_stubbed(:project_with_types) } status sequence(:subject) { |n| "WorkPackage No. #{n}" } description { |i| "Description for '#{i.subject}'" } diff --git a/spec/factories/workflow_factory.rb b/spec/factories/workflow_factory.rb index e34af31a19..c9f3eb2e54 100644 --- a/spec/factories/workflow_factory.rb +++ b/spec/factories/workflow_factory.rb @@ -26,7 +26,7 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -FactoryGirl.define do +FactoryBot.define do factory :workflow do old_status factory: :status new_status factory: :status diff --git a/spec/features/accessibility/work_packages/calendar_toggable_fieldsets_spec.rb b/spec/features/accessibility/work_packages/calendar_toggable_fieldsets_spec.rb index ccaad8f8d6..2c5665d919 100644 --- a/spec/features/accessibility/work_packages/calendar_toggable_fieldsets_spec.rb +++ b/spec/features/accessibility/work_packages/calendar_toggable_fieldsets_spec.rb @@ -34,8 +34,8 @@ describe 'Work package calendar index', type: :feature do describe 'Toggable fieldset', js: true do include_context 'Toggable fieldset examples' - let(:project) { FactoryGirl.create(:project) } - let(:current_user) { FactoryGirl.create (:admin) } + let(:project) { FactoryBot.create(:project) } + let(:current_user) { FactoryBot.create (:admin) } let(:work_packages_page) { WorkPackagesPage.new(project) } before do diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb index 0445787642..ba924dcf0b 100644 --- a/spec/features/accessibility/work_packages/work_package_query_spec.rb +++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb @@ -30,9 +30,9 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' describe 'Work package index accessibility', type: :feature, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:sort_ascending_selector) { '.icon-sort-ascending' } let(:sort_descending_selector) { '.icon-sort-descending' } @@ -167,7 +167,7 @@ describe 'Work package index accessibility', type: :feature, selenium: true do describe 'hotkeys', js: true do let!(:another_work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) } before do diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rb index d05a658ace..4a17fcfa00 100644 --- a/spec/features/admin/attribute_help_texts_spec.rb +++ b/spec/features/admin/attribute_help_texts_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Attribute help texts' do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } let(:instance) { AttributeHelpText.last } let(:modal) { Components::AttributeHelpTextModal.new(instance) } diff --git a/spec/features/admin/custom_fields/multi_value_custom_fields_spec.rb b/spec/features/admin/custom_fields/multi_value_custom_fields_spec.rb index 261e9b1f90..f2873c9cdb 100644 --- a/spec/features/admin/custom_fields/multi_value_custom_fields_spec.rb +++ b/spec/features/admin/custom_fields/multi_value_custom_fields_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Multi-value custom fields creation', type: :feature, js: true do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } def drag_and_drop(handle, to) scroll_to_element(handle) diff --git a/spec/features/admin/enterprise_spec.rb b/spec/features/admin/enterprise_spec.rb index fc2f7c1a6c..cc521f2d5e 100644 --- a/spec/features/admin/enterprise_spec.rb +++ b/spec/features/admin/enterprise_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe 'Enterprise token', type: :feature do include Redmine::I18n - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } let(:token_object) do token = OpenProject::Token.new token.subscriber = 'Foobar' diff --git a/spec/features/admin/enumerations_spec.rb b/spec/features/admin/enumerations_spec.rb index e995cf3bdf..02aaeb4362 100644 --- a/spec/features/admin/enumerations_spec.rb +++ b/spec/features/admin/enumerations_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Enumerations', type: :feature do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } before do login_as(admin) diff --git a/spec/features/api/authentication_spec.rb b/spec/features/api/authentication_spec.rb index c1fe9888aa..665422d1d7 100644 --- a/spec/features/api/authentication_spec.rb +++ b/spec/features/api/authentication_spec.rb @@ -62,7 +62,7 @@ describe 'Login', type: :feature do let(:user_password) { 'bob1!' * 4 } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, force_password_change: false, first_login: false, login: 'bob', @@ -74,7 +74,7 @@ describe 'Login', type: :feature do ) end - let(:other_user) { FactoryGirl.create(:user) } + let(:other_user) { FactoryBot.create(:user) } it 'enforces the current user to be set correctly on each api request' do # login to set the session diff --git a/spec/features/attachments/attachments_spec.rb b/spec/features/attachments/attachments_spec.rb index ae8561651d..a908156854 100644 --- a/spec/features/attachments/attachments_spec.rb +++ b/spec/features/attachments/attachments_spec.rb @@ -29,16 +29,16 @@ require 'spec_helper' describe 'attachments', type: :feature do - let(:project) { FactoryGirl.create :valid_project } - let(:current_user) { FactoryGirl.create :admin } - let!(:priority) { FactoryGirl.create :priority_normal } + let(:project) { FactoryBot.create :valid_project } + let(:current_user) { FactoryBot.create :admin } + let!(:priority) { FactoryBot.create :priority_normal } before do allow(User).to receive(:current).and_return current_user end describe 'upload', js: true do - let(:file) { FactoryGirl.create :file, name: 'textfile.txt' } + let(:file) { FactoryBot.create :file, name: 'textfile.txt' } # FIXME rework this spec after implementing fullscreen create view xit 'uploading a short text file and viewing it inline' do diff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rb index e3bafa675a..872075c3c8 100644 --- a/spec/features/auth/auth_stages_spec.rb +++ b/spec/features/auth/auth_stages_spec.rb @@ -50,7 +50,7 @@ describe 'Authentication Stages', type: :feature do let(:user_password) { 'bob' * 4 } let(:user) do - FactoryGirl.create( + FactoryBot.create( :user, force_password_change: false, first_login: false, diff --git a/spec/features/auth/login_spec.rb b/spec/features/auth/login_spec.rb index 0fd363fdbd..37bcbbc473 100644 --- a/spec/features/auth/login_spec.rb +++ b/spec/features/auth/login_spec.rb @@ -44,7 +44,7 @@ describe 'Login', type: :feature do let(:user_password) { 'bob' * 4 } let(:new_user_password) { 'obb' * 4 } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, force_password_change: true, first_login: true, login: 'bob', diff --git a/spec/features/auth/lost_password_spec.rb b/spec/features/auth/lost_password_spec.rb index a2a1259c59..7fec4abecb 100644 --- a/spec/features/auth/lost_password_spec.rb +++ b/spec/features/auth/lost_password_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Lost password', type: :feature do - let!(:user) { FactoryGirl.create :user } + let!(:user) { FactoryBot.create :user } it 'shows same flash for invalid and existing users' do visit account_lost_password_path diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb index 75ebc2e765..354abe6e69 100644 --- a/spec/features/auth/omniauth_spec.rb +++ b/spec/features/auth/omniauth_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe 'Omniauth authentication', type: :feature do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, force_password_change: false, identity_url: 'developer:omnibob@example.com', login: 'omnibob', diff --git a/spec/features/boards/message_spec.rb b/spec/features/boards/message_spec.rb index 30624af88b..99b6192dbb 100644 --- a/spec/features/boards/message_spec.rb +++ b/spec/features/boards/message_spec.rb @@ -29,16 +29,16 @@ require 'spec_helper' describe 'messages', type: :feature do - let(:user) { FactoryGirl.create :admin, firstname: 'Hugo', lastname: 'Hungrig' } + let(:user) { FactoryBot.create :admin, firstname: 'Hugo', lastname: 'Hungrig' } before do allow(User).to receive(:current).and_return user end describe 'quoting' do - let(:topic) { FactoryGirl.create :message } + let(:topic) { FactoryBot.create :message } let!(:reply) do - FactoryGirl.create :message, + FactoryBot.create :message, board: topic.board, parent: topic, author: user, diff --git a/spec/features/categories/delete_spec.rb b/spec/features/categories/delete_spec.rb index 8294cfe617..ca9d390b40 100644 --- a/spec/features/categories/delete_spec.rb +++ b/spec/features/categories/delete_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' require 'features/categories/categories_page' describe 'Deletion', type: :feature do - let(:current_user) { FactoryGirl.create :admin } - let(:category) { FactoryGirl.create :category } + let(:current_user) { FactoryBot.create :admin } + let(:category) { FactoryBot.create :category } let(:categories_page) { CategoriesPage.new(category.project) } let(:delete_button) { 'div#tab-content-categories a.icon-delete' } let(:confirm_deletion_button) { 'input[type="submit"]' } @@ -62,7 +62,7 @@ describe 'Deletion', type: :feature do describe 'with work package' do let!(:work_package) { - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: category.project, category: category } diff --git a/spec/features/custom_fields/create_bool_spec.rb b/spec/features/custom_fields/create_bool_spec.rb index da51a682e6..87402dd631 100644 --- a/spec/features/custom_fields/create_bool_spec.rb +++ b/spec/features/custom_fields/create_bool_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'support/pages/custom_fields' describe 'custom fields', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:cf_page) { Pages::CustomFields.new } before do diff --git a/spec/features/custom_fields/create_date_spec.rb b/spec/features/custom_fields/create_date_spec.rb index f02f586213..da1b1453c3 100644 --- a/spec/features/custom_fields/create_date_spec.rb +++ b/spec/features/custom_fields/create_date_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'support/pages/custom_fields' describe 'custom fields', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:cf_page) { Pages::CustomFields.new } before do diff --git a/spec/features/custom_fields/create_float_spec.rb b/spec/features/custom_fields/create_float_spec.rb index 0c2f3a7e84..b49fbf2824 100644 --- a/spec/features/custom_fields/create_float_spec.rb +++ b/spec/features/custom_fields/create_float_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'support/pages/custom_fields' describe 'custom fields', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:cf_page) { Pages::CustomFields.new } before do diff --git a/spec/features/custom_fields/create_int_spec.rb b/spec/features/custom_fields/create_int_spec.rb index 31704cd47a..90996143fa 100644 --- a/spec/features/custom_fields/create_int_spec.rb +++ b/spec/features/custom_fields/create_int_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'support/pages/custom_fields' describe 'custom fields', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:cf_page) { Pages::CustomFields.new } before do diff --git a/spec/features/custom_fields/custom_fields_spec.rb b/spec/features/custom_fields/custom_fields_spec.rb index 36903bc061..59b6444139 100644 --- a/spec/features/custom_fields/custom_fields_spec.rb +++ b/spec/features/custom_fields/custom_fields_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'support/pages/custom_fields' describe 'custom fields', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:cf_page) { Pages::CustomFields.new } before do @@ -67,7 +67,7 @@ describe 'custom fields', js: true do context "with an existing list custom field" do let!(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, name: "Platform", possible_values: ["Playstation", "Xbox", "Nintendo", "PC"] @@ -158,7 +158,7 @@ describe 'custom fields', js: true do context "with work packages using the options" do before do - FactoryGirl.create_list( + FactoryBot.create_list( :work_package_custom_value, 3, custom_field: custom_field, diff --git a/spec/features/custom_fields/multi_user_custom_field_spec.rb b/spec/features/custom_fields/multi_user_custom_field_spec.rb index 8ff0ab927a..75e1c366ec 100644 --- a/spec/features/custom_fields/multi_user_custom_field_spec.rb +++ b/spec/features/custom_fields/multi_user_custom_field_spec.rb @@ -2,11 +2,11 @@ require "spec_helper" require "support/pages/abstract_work_package" describe "multi select custom values", js: true do - let(:type) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create :project, types: [type] } + let(:type) { FactoryBot.create :type } + let(:project) { FactoryBot.create :project, types: [type] } let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :user_wp_custom_field, name: "Reviewer", multi_value: true, @@ -27,14 +27,14 @@ describe "multi select custom values", js: true do member_names.zip(member_statuses).map do |name, status| first, last = name.split(" ") - FactoryGirl.create :user, firstname: first, lastname: last, status: status + FactoryBot.create :user, firstname: first, lastname: last, status: status end end - let(:role) { FactoryGirl.create :role } + let(:role) { FactoryBot.create :role } let(:wp_page) { Pages::FullWorkPackage.new work_package } - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } before do members.each do |user| @@ -46,7 +46,7 @@ describe "multi select custom values", js: true do context "with existing custom values" do let(:work_package) do - wp = FactoryGirl.build :work_package, project: project, type: type + wp = FactoryBot.build :work_package, project: project, type: type wp.custom_field_values = { custom_field.id => [members[0].id.to_s, members[2].id.to_s] diff --git a/spec/features/custom_fields/multi_value_custom_field_spec.rb b/spec/features/custom_fields/multi_value_custom_field_spec.rb index 2068a6b09d..de9b790567 100644 --- a/spec/features/custom_fields/multi_value_custom_field_spec.rb +++ b/spec/features/custom_fields/multi_value_custom_field_spec.rb @@ -2,11 +2,11 @@ require "spec_helper" require "support/pages/abstract_work_package" describe "multi select custom values", js: true do - let(:type) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create :project, types: [type] } + let(:type) { FactoryBot.create :type } + let(:project) { FactoryBot.create :project, types: [type] } let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, name: "Ingredients", multi_value: true, @@ -26,11 +26,11 @@ describe "multi select custom values", js: true do let(:columns) { ::Components::WorkPackages::Columns.new } let(:group_by) { ::Components::WorkPackages::GroupBy.new } - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } context "with existing custom values" do let(:work_package) do - wp = FactoryGirl.build :work_package, project: project, type: type + wp = FactoryBot.build :work_package, project: project, type: type wp.custom_field_values = { custom_field.id => ["ham", "pineapple", "onions"].map { |s| custom_value_for(s) } @@ -41,7 +41,7 @@ describe "multi select custom values", js: true do end let(:work_package2) do - wp = FactoryGirl.build :work_package, project: project, type: type + wp = FactoryBot.build :work_package, project: project, type: type wp.custom_field_values = { custom_field.id => ["ham"].map { |s| custom_value_for(s) } diff --git a/spec/features/groups/group_memberships_spec.rb b/spec/features/groups/group_memberships_spec.rb index cb48038147..e0c62229a2 100644 --- a/spec/features/groups/group_memberships_spec.rb +++ b/spec/features/groups/group_memberships_spec.rb @@ -29,15 +29,15 @@ require 'spec_helper' feature 'group memberships through groups page', type: :feature do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:peter) { FactoryGirl.create :user, firstname: 'Peter', lastname: 'Pan' } - let!(:hannibal) { FactoryGirl.create :user, firstname: 'Hannibal', lastname: 'Smith' } - let(:group) { FactoryGirl.create :group, lastname: 'A-Team' } + let(:admin) { FactoryBot.create :admin } + let!(:peter) { FactoryBot.create :user, firstname: 'Peter', lastname: 'Pan' } + let!(:hannibal) { FactoryBot.create :user, firstname: 'Hannibal', lastname: 'Smith' } + let(:group) { FactoryBot.create :group, lastname: 'A-Team' } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } let(:members_page) { Pages::Members.new project.identifier } let(:group_page) { Pages::Groups.new.group(group.id) } diff --git a/spec/features/groups/groups_spec.rb b/spec/features/groups/groups_spec.rb index 44ce998b34..5c7af8c5e4 100644 --- a/spec/features/groups/groups_spec.rb +++ b/spec/features/groups/groups_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' feature 'group memberships through groups page', type: :feature do - let(:admin) { FactoryGirl.create :admin } - let!(:group) { FactoryGirl.create :group, lastname: "Bob's Team" } + let(:admin) { FactoryBot.create :admin } + let!(:group) { FactoryBot.create :group, lastname: "Bob's Team" } let(:groups_page) { Pages::Groups.new } diff --git a/spec/features/groups/membership_spec.rb b/spec/features/groups/membership_spec.rb index 2b726ef055..68446c8224 100644 --- a/spec/features/groups/membership_spec.rb +++ b/spec/features/groups/membership_spec.rb @@ -29,21 +29,21 @@ require 'spec_helper' feature 'group memberships through project members page', type: :feature do - let(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let(:alice) { FactoryGirl.create :user, firstname: 'Alice', lastname: 'Wonderland' } - let(:bob) { FactoryGirl.create :user, firstname: 'Bob', lastname: 'Bobbit' } - let(:group) { FactoryGirl.create :group, lastname: 'group1' } + let(:admin) { FactoryBot.create :admin } + let(:alice) { FactoryBot.create :user, firstname: 'Alice', lastname: 'Wonderland' } + let(:bob) { FactoryBot.create :user, firstname: 'Bob', lastname: 'Bobbit' } + let(:group) { FactoryBot.create :group, lastname: 'group1' } - let!(:alpha) { FactoryGirl.create :role, name: 'alpha', permissions: [:manage_members] } - let!(:beta) { FactoryGirl.create :role, name: 'beta' } + let!(:alpha) { FactoryBot.create :role, name: 'alpha', permissions: [:manage_members] } + let!(:beta) { FactoryBot.create :role, name: 'beta' } let(:members_page) { Pages::Members.new project.identifier } let(:groups_page) { Pages::Groups.new } before do - FactoryGirl.create :member, user: bob, project: project, roles: [alpha] + FactoryBot.create :member, user: bob, project: project, roles: [alpha] end context 'given a group with members' do diff --git a/spec/features/homescreen/robots_spec.rb b/spec/features/homescreen/robots_spec.rb index 57bfeb4c68..e11d3394bb 100644 --- a/spec/features/homescreen/robots_spec.rb +++ b/spec/features/homescreen/robots_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'robots.txt', type: :feature do - let!(:project) { FactoryGirl.create(:public_project) } + let!(:project) { FactoryBot.create(:public_project) } before do visit '/robots.txt' diff --git a/spec/features/members/error_messages_spec.rb b/spec/features/members/error_messages_spec.rb index e404440ab6..5a69a5f9dc 100644 --- a/spec/features/members/error_messages_spec.rb +++ b/spec/features/members/error_messages_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' feature 'Group memberships through groups page', type: :feature do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:peter) { FactoryGirl.create :user, firstname: 'Peter', lastname: 'Pan' } + let(:admin) { FactoryBot.create :admin } + let!(:peter) { FactoryBot.create :user, firstname: 'Peter', lastname: 'Pan' } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } let(:members_page) { Pages::Members.new project.identifier } diff --git a/spec/features/members/invitation_spec.rb b/spec/features/members/invitation_spec.rb index b510a229e0..9bd1de97af 100644 --- a/spec/features/members/invitation_spec.rb +++ b/spec/features/members/invitation_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' feature 'invite user via email', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } + let(:admin) { FactoryBot.create :admin } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } let(:members_page) { Pages::Members.new project.identifier } @@ -64,7 +64,7 @@ feature 'invite user via email', type: :feature, js: true do context 'with a registered user' do let!(:user) do - FactoryGirl.create :user, mail: 'hugo@openproject.com', + FactoryBot.create :user, mail: 'hugo@openproject.com', login: 'hugo@openproject.com', firstname: 'Hugo', lastname: 'Hurried' diff --git a/spec/features/members/membership_filter_spec.rb b/spec/features/members/membership_filter_spec.rb index ae506c694f..74351135d6 100644 --- a/spec/features/members/membership_filter_spec.rb +++ b/spec/features/members/membership_filter_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' feature 'group memberships through groups page', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } + let(:admin) { FactoryBot.create :admin } let!(:peter) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Peter', lastname: 'Pan', mail: 'foo@example.org', @@ -43,7 +43,7 @@ feature 'group memberships through groups page', type: :feature, js: true do end let!(:hannibal) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Pan', lastname: 'Hannibal', mail: 'foo@example.com', @@ -51,7 +51,7 @@ feature 'group memberships through groups page', type: :feature, js: true do member_through_role: role end - let(:role) { FactoryGirl.create(:role, permissions: %i(add_work_packages)) } + let(:role) { FactoryBot.create(:role, permissions: %i(add_work_packages)) } let(:members_page) { Pages::Members.new project.identifier } before do diff --git a/spec/features/members/membership_spec.rb b/spec/features/members/membership_spec.rb index fba741205e..ffff80c56f 100644 --- a/spec/features/members/membership_spec.rb +++ b/spec/features/members/membership_spec.rb @@ -29,18 +29,18 @@ require 'spec_helper' feature 'group memberships through groups page', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:peter) { FactoryGirl.create :user, firstname: 'Peter', lastname: 'Pan', mail: 'foo@example.org' } - let!(:hannibal) { FactoryGirl.create :user, firstname: 'Hannibal', lastname: 'Smith', mail: 'foo@bar.org' } - let!(:crash) { FactoryGirl.create :user, firstname: "", + let(:admin) { FactoryBot.create :admin } + let!(:peter) { FactoryBot.create :user, firstname: 'Peter', lastname: 'Pan', mail: 'foo@example.org' } + let!(:hannibal) { FactoryBot.create :user, firstname: 'Hannibal', lastname: 'Smith', mail: 'foo@bar.org' } + let!(:crash) { FactoryBot.create :user, firstname: "", lastname: "" } - let(:group) { FactoryGirl.create :group, lastname: 'A-Team' } + let(:group) { FactoryBot.create :group, lastname: 'A-Team' } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } let(:members_page) { Pages::Members.new project.identifier } diff --git a/spec/features/members/pagination_spec.rb b/spec/features/members/pagination_spec.rb index 9a6b342a44..d18b3c4ad6 100644 --- a/spec/features/members/pagination_spec.rb +++ b/spec/features/members/pagination_spec.rb @@ -29,15 +29,15 @@ require 'spec_helper' feature 'members pagination', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:peter) { FactoryGirl.create :user, firstname: 'Peter', lastname: 'Pan' } - let!(:bob) { FactoryGirl.create :user, firstname: 'Bob', lastname: 'Bobbit' } - let!(:alice) { FactoryGirl.create :user, firstname: 'Alice', lastname: 'Alison' } + let(:admin) { FactoryBot.create :admin } + let!(:peter) { FactoryBot.create :user, firstname: 'Peter', lastname: 'Pan' } + let!(:bob) { FactoryBot.create :user, firstname: 'Bob', lastname: 'Bobbit' } + let!(:alice) { FactoryBot.create :user, firstname: 'Alice', lastname: 'Alison' } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } let(:members_page) { Pages::Members.new project.identifier } diff --git a/spec/features/members/roles_spec.rb b/spec/features/members/roles_spec.rb index e4f4adaac4..326958d550 100644 --- a/spec/features/members/roles_spec.rb +++ b/spec/features/members/roles_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' feature 'members pagination', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin } - let!(:bob) { FactoryGirl.create :user, firstname: 'Bob', lastname: 'Bobbit' } - let!(:alice) { FactoryGirl.create :user, firstname: 'Alice', lastname: 'Alison' } + let(:admin) { FactoryBot.create :admin } + let!(:bob) { FactoryBot.create :user, firstname: 'Bob', lastname: 'Bobbit' } + let!(:alice) { FactoryBot.create :user, firstname: 'Alice', lastname: 'Alison' } - let!(:alpha) { FactoryGirl.create :role, name: 'alpha' } - let!(:beta) { FactoryGirl.create :role, name: 'beta' } + let!(:alpha) { FactoryBot.create :role, name: 'alpha' } + let!(:beta) { FactoryBot.create :role, name: 'beta' } let(:members_page) { Pages::Members.new project.identifier } diff --git a/spec/features/menu_items/admin_menu_item_spec.rb b/spec/features/menu_items/admin_menu_item_spec.rb index c669baec54..667f2d5594 100644 --- a/spec/features/menu_items/admin_menu_item_spec.rb +++ b/spec/features/menu_items/admin_menu_item_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' feature 'Admin menu items' do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } before do allow(User).to receive(:current).and_return user diff --git a/spec/features/menu_items/help_menu_spec.rb b/spec/features/menu_items/help_menu_spec.rb index b8bc60ecd9..cbffe47f44 100644 --- a/spec/features/menu_items/help_menu_spec.rb +++ b/spec/features/menu_items/help_menu_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' feature 'Help menu items' do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:help_item) { find('.menu-item--help') } before do diff --git a/spec/features/menu_items/query_menu_item_spec.rb b/spec/features/menu_items/query_menu_item_spec.rb index 1fa585a53f..5ee54cfe12 100644 --- a/spec/features/menu_items/query_menu_item_spec.rb +++ b/spec/features/menu_items/query_menu_item_spec.rb @@ -32,11 +32,11 @@ require 'features/work_packages/shared_contexts' require 'features/work_packages/work_packages_page' feature 'Query menu items' do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:notification) { PageObjects::Notifications.new(page) } - let(:status) { FactoryGirl.create :status } + let(:status) { FactoryBot.create :status } def visit_index_page(query) work_packages_page.select_query(query) @@ -49,11 +49,11 @@ feature 'Query menu items' do end context 'with identical names' do - let(:query_a) { FactoryGirl.create :public_query, name: 'some query.', project: project } - let(:query_b) { FactoryGirl.create :public_query, name: query_a.name, project: project } + let(:query_a) { FactoryBot.create :public_query, name: 'some query.', project: project } + let(:query_b) { FactoryBot.create :public_query, name: query_a.name, project: project } - let!(:menu_item_a) { FactoryGirl.create :query_menu_item, query: query_a } - let!(:menu_item_b) { FactoryGirl.create :query_menu_item, query: query_b } + let!(:menu_item_a) { FactoryBot.create :query_menu_item, query: query_a } + let!(:menu_item_b) { FactoryBot.create :query_menu_item, query: query_b } it 'can be shown' do visit_index_page(query_a) @@ -63,7 +63,7 @@ feature 'Query menu items' do end context 'with dots in their name' do - let(:query) { FactoryGirl.create :public_query, name: 'OP 3.0', project: project } + let(:query) { FactoryBot.create :public_query, name: 'OP 3.0', project: project } it 'can be added', js: true, selenium: true do visit_index_page(query) @@ -83,11 +83,11 @@ feature 'Query menu items' do end describe 'renaming a menu item' do - let(:query_a) { FactoryGirl.create :query, name: 'bbbb', project: project, user: user } - let(:query_b) { FactoryGirl.create :query, name: 'zzzz', project: project, user: user } + let(:query_a) { FactoryBot.create :query, name: 'bbbb', project: project, user: user } + let(:query_b) { FactoryBot.create :query, name: 'zzzz', project: project, user: user } - let!(:menu_item_a) { FactoryGirl.create :query_menu_item, query: query_a } - let!(:menu_item_b) { FactoryGirl.create :query_menu_item, query: query_b } + let!(:menu_item_a) { FactoryBot.create :query_menu_item, query: query_a } + let!(:menu_item_b) { FactoryBot.create :query_menu_item, query: query_b } let(:new_name) { 'aaaaa' } before do diff --git a/spec/features/menu_items/top_menu_item_spec.rb b/spec/features/menu_items/top_menu_item_spec.rb index dfe0066a38..af8db347fa 100644 --- a/spec/features/menu_items/top_menu_item_spec.rb +++ b/spec/features/menu_items/top_menu_item_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' feature 'Top menu items', js: true, selenium: true do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } let(:open_menu) { true } def has_menu_items?(*labels) @@ -56,8 +56,8 @@ feature 'Top menu items', js: true, selenium: true do before do |ex| allow(User).to receive(:current).and_return user - FactoryGirl.create(:anonymous_role) - FactoryGirl.create(:non_member) + FactoryBot.create(:anonymous_role) + FactoryBot.create(:non_member) if ex.metadata.key?(:allowed_to) allow(user).to receive(:allowed_to?).and_return(ex.metadata[:allowed_to]) @@ -76,7 +76,7 @@ feature 'Top menu items', js: true, selenium: true do let(:all_items) { [news_item, time_entries_item] } context 'as an admin' do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } it 'displays all items' do has_menu_items?(time_entries_item, news_item) end @@ -113,7 +113,7 @@ feature 'Top menu items', js: true, selenium: true do end context 'as an anonymous user' do - let(:user) { FactoryGirl.create :anonymous } + let(:user) { FactoryBot.create :anonymous } it 'displays only news' do has_menu_items? news_item end @@ -128,7 +128,7 @@ feature 'Top menu items', js: true, selenium: true do let(:all_items) { [new_project, all_projects] } context 'as an admin' do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } it 'displays all items' do has_menu_items?(new_project, all_projects) end @@ -156,7 +156,7 @@ feature 'Top menu items', js: true, selenium: true do end context 'as an anonymous user' do - let(:user) { FactoryGirl.create :anonymous } + let(:user) { FactoryBot.create :anonymous } let(:open_menu) { false } it 'does not show the menu' do diff --git a/spec/features/menu_items/wiki_menu_item_spec.rb b/spec/features/menu_items/wiki_menu_item_spec.rb index 6efe8a2645..7da69c4692 100644 --- a/spec/features/menu_items/wiki_menu_item_spec.rb +++ b/spec/features/menu_items/wiki_menu_item_spec.rb @@ -32,8 +32,8 @@ require 'features/work_packages/shared_contexts' require 'features/work_packages/work_packages_page' feature 'Wiki menu items' do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project, enabled_module_names: %w[wiki] } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project, enabled_module_names: %w[wiki] } let(:wiki) { project.wiki } let(:parent_menu) { wiki.wiki_menu_items.find_by(name: 'wiki') } diff --git a/spec/features/my/blocks_spec.rb b/spec/features/my/blocks_spec.rb index 21916def8c..8ca2b061ac 100644 --- a/spec/features/my/blocks_spec.rb +++ b/spec/features/my/blocks_spec.rb @@ -29,22 +29,22 @@ require 'spec_helper' describe 'Blocks on the my page', type: :feature, js: true do - let(:project) { FactoryGirl.create :project } - let(:open_status) { FactoryGirl.create :default_status } - let(:closed_status) { FactoryGirl.create :closed_status } + let(:project) { FactoryBot.create :project } + let(:open_status) { FactoryBot.create :default_status } + let(:closed_status) { FactoryBot.create :closed_status } - let!(:open_wp) { FactoryGirl.create(:work_package, project: project, status: open_status) } - let!(:closed_wp) { FactoryGirl.create(:work_package, project: project, status: closed_status) } - let!(:unwatched_wp) { FactoryGirl.create(:work_package, project: project, status: open_status) } + let!(:open_wp) { FactoryBot.create(:work_package, project: project, status: open_status) } + let!(:closed_wp) { FactoryBot.create(:work_package, project: project, status: closed_status) } + let!(:unwatched_wp) { FactoryBot.create(:work_package, project: project, status: open_status) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:layout) do { 'top' => ['issueswatched'], 'left' => [], 'right' => [] } end let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role, firstname: 'Mahboobeh').tap do |u| diff --git a/spec/features/projects/copy_spec.rb b/spec/features/projects/copy_spec.rb index c77da34044..7a0787b8bd 100644 --- a/spec/features/projects/copy_spec.rb +++ b/spec/features/projects/copy_spec.rb @@ -32,12 +32,12 @@ describe 'Projects copy', type: :feature, js: true do let!(:project) do - project = FactoryGirl.create(:project, + project = FactoryBot.create(:project, parent: parent_project, types: active_types, custom_field_values: { project_custom_field.id => 'some text cf' }) - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, user: user, roles: [role]) @@ -48,52 +48,52 @@ describe 'Projects copy', project end let!(:parent_project) do - project = FactoryGirl.create(:project) + project = FactoryBot.create(:project) - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, user: user, roles: [role]) project end let!(:project_custom_field) do - FactoryGirl.create(:text_project_custom_field, is_required: true) + FactoryBot.create(:text_project_custom_field, is_required: true) end let!(:wp_custom_field) do - FactoryGirl.create(:text_wp_custom_field) + FactoryBot.create(:text_wp_custom_field) end let!(:inactive_wp_custom_field) do - FactoryGirl.create(:text_wp_custom_field) + FactoryBot.create(:text_wp_custom_field) end let(:active_types) do - [FactoryGirl.create(:type), FactoryGirl.create(:type)] + [FactoryBot.create(:type), FactoryBot.create(:type)] end let!(:inactive_type) do - FactoryGirl.create(:type) + FactoryBot.create(:type) end - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: permissions) end let(:permissions) { %i(copy_projects edit_project add_subprojects manage_types view_work_packages) } let(:wp_user) do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, user: user, roles: [role]) user end let(:category) do - FactoryGirl.create(:category, project: project) + FactoryBot.create(:category, project: project) end let(:version) do - FactoryGirl.create(:version, project: project) + FactoryBot.create(:version, project: project) end let!(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: project.types.first, author: wp_user, diff --git a/spec/features/projects/project_autocomplete_spec.rb b/spec/features/projects/project_autocomplete_spec.rb index 4ee893e8dd..bbc6fdd5fe 100644 --- a/spec/features/projects/project_autocomplete_spec.rb +++ b/spec/features/projects/project_autocomplete_spec.rb @@ -30,22 +30,22 @@ require 'spec_helper' require 'features/projects/projects_page' describe 'Projects autocomplete page', type: :feature, js: true do - let!(:admin) { FactoryGirl.create :admin } + let!(:admin) { FactoryBot.create :admin } let!(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Plain project', identifier: 'plain-project') end let!(:project2) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'foobar', identifier: 'foobar') end let!(:project3) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Plain other project', parent: project2, identifier: 'plain-project-2') @@ -62,7 +62,7 @@ describe 'Projects autocomplete page', type: :feature, js: true do names.map do |name| identifier = name.gsub(/[ \-]+/, "-").downcase - FactoryGirl.create :project, name: name, identifier: identifier + FactoryBot.create :project, name: name, identifier: identifier end end diff --git a/spec/features/projects/projects_custom_fields_spec.rb b/spec/features/projects/projects_custom_fields_spec.rb index 939d2a4cfa..6cede01774 100644 --- a/spec/features/projects/projects_custom_fields_spec.rb +++ b/spec/features/projects/projects_custom_fields_spec.rb @@ -30,10 +30,10 @@ require 'spec_helper' require 'features/projects/projects_page' describe 'Projects custom fields', type: :feature do - let(:current_user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project, name: 'Foo project', identifier: 'foo-project') } + let(:current_user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project, name: 'Foo project', identifier: 'foo-project') } let!(:custom_field) do - FactoryGirl.create(:bool_project_custom_field) + FactoryBot.create(:bool_project_custom_field) end let(:identifier) { "project_custom_field_values_#{custom_field.id}" } diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index c56149945d..fc6733c41d 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -34,21 +34,21 @@ describe 'Projects index page', js: true, with_settings: { login_required?: false } do - let!(:admin) { FactoryGirl.create :admin } + let!(:admin) { FactoryBot.create :admin } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } - let!(:custom_field) { FactoryGirl.create :project_custom_field } - let!(:invisible_custom_field) { FactoryGirl.create :project_custom_field, visible: false } + let!(:custom_field) { FactoryBot.create :project_custom_field } + let!(:invisible_custom_field) { FactoryBot.create :project_custom_field, visible: false } let!(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Plain project', identifier: 'plain-project') end let!(:public_project) do - project = FactoryGirl.create(:project, + project = FactoryBot.create(:project, name: 'Public project', identifier: 'public-project', is_public: true) @@ -57,11 +57,11 @@ describe 'Projects index page', project end let!(:development_project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Development project', identifier: 'development-project') end - let(:news) { FactoryGirl.create(:news, project: project) } + let(:news) { FactoryBot.create(:news, project: project) } def load_and_open_filters(user) login_as(user) @@ -148,7 +148,7 @@ describe 'Projects index page', feature 'for project members' do let!(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: development_project, member_through_role: developer, login: 'nerd', @@ -356,7 +356,7 @@ describe 'Projects index page', feature 'Active or archived' do let!(:archived_project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Archived project', identifier: 'archived-project', status: Project::STATUS_ARCHIVED) @@ -400,8 +400,8 @@ describe 'Projects index page', end feature 'other filter types' do - let!(:list_custom_field) { FactoryGirl.create :list_project_custom_field } - let!(:date_custom_field) { FactoryGirl.create :date_project_custom_field } + let!(:list_custom_field) { FactoryBot.create :list_project_custom_field } + let!(:date_custom_field) { FactoryBot.create :date_project_custom_field } let(:datetime_of_this_week) do today = Date.today # Ensure that the date is not today but still in the middle of the week to not run into week-start-issues here. @@ -411,7 +411,7 @@ describe 'Projects index page', let(:fixed_datetime) { DateTime.parse('2017-11-11T11:11:11+00:00') } let!(:project_created_on_today) do - project = FactoryGirl.create(:project, + project = FactoryBot.create(:project, name: 'Created today project', created_on: DateTime.now) project.custom_field_values = { list_custom_field.id => list_custom_field.possible_values[2], @@ -420,23 +420,23 @@ describe 'Projects index page', project end let!(:project_created_on_this_week) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Created on this week project', created_on: datetime_of_this_week) end let!(:project_created_on_six_days_ago) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Created on six days ago project', created_on: DateTime.now - 6.days) end let!(:project_created_on_fixed_date) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Created on fixed date project', created_on: fixed_datetime) end let!(:todays_wp) do # This WP should trigger a change to the project's 'latest activity at' DateTime - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, updated_at: DateTime.now, project: project_created_on_today) end @@ -612,30 +612,30 @@ describe 'Projects index page', feature 'Non-admins with role with permission' do let!(:can_copy_projects_role) do - FactoryGirl.create :role, name: 'Can Copy Projects Role', permissions: [:copy_projects] + FactoryBot.create :role, name: 'Can Copy Projects Role', permissions: [:copy_projects] end let!(:can_add_subprojects_role) do - FactoryGirl.create :role, name: 'Can Add Subprojects Role', permissions: [:add_subprojects] + FactoryBot.create :role, name: 'Can Add Subprojects Role', permissions: [:add_subprojects] end let!(:parent_project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, name: 'Parent project', identifier: 'parent-project') end let!(:can_copy_projects_manager) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: parent_project, member_through_role: can_copy_projects_role) end let!(:can_add_subprojects_manager) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: parent_project, member_through_role: can_add_subprojects_role) end let!(:simple_member) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: parent_project, member_through_role: developer) end @@ -718,16 +718,16 @@ describe 'Projects index page', end feature 'order' do - let!(:integer_custom_field) { FactoryGirl.create(:int_project_custom_field) } + let!(:integer_custom_field) { FactoryBot.create(:int_project_custom_field) } # order is important here as the implementation uses lft # first but then reorders in ruby let!(:child_project_z) do - FactoryGirl.create(:project, + FactoryBot.create(:project, parent: project, name: "Z Child") end let!(:child_project_a) do - FactoryGirl.create(:project, + FactoryBot.create(:project, parent: project, name: "A Child") end diff --git a/spec/features/projects/projects_spec.rb b/spec/features/projects/projects_spec.rb index 01a0e43aba..fe1970413e 100644 --- a/spec/features/projects/projects_spec.rb +++ b/spec/features/projects/projects_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' require 'features/projects/projects_page' describe 'Projects', type: :feature do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return current_user end describe 'creation', js: true do - let!(:project) { FactoryGirl.create(:project, name: 'Foo project', identifier: 'foo-project') } + let!(:project) { FactoryBot.create(:project, name: 'Foo project', identifier: 'foo-project') } before do visit projects_path @@ -98,9 +98,9 @@ describe 'Projects', type: :feature do end describe 'project types' do - let(:phase_type) { FactoryGirl.create(:type, name: 'Phase', is_default: true) } - let(:milestone_type) { FactoryGirl.create(:type, name: 'Milestone', is_default: false) } - let!(:project) { FactoryGirl.create(:project, name: 'Foo project', types: [phase_type, milestone_type]) } + let(:phase_type) { FactoryBot.create(:type, name: 'Phase', is_default: true) } + let(:milestone_type) { FactoryBot.create(:type, name: 'Milestone', is_default: false) } + let!(:project) { FactoryBot.create(:project, name: 'Foo project', types: [phase_type, milestone_type]) } it "have the correct types checked for the project's types" do visit projects_path @@ -116,7 +116,7 @@ describe 'Projects', type: :feature do end describe 'deletion', js: true do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:projects_page) { ProjectsPage.new(project) } before do @@ -145,7 +145,7 @@ describe 'Projects', type: :feature do end describe 'identifier edit', js: true do - let!(:project) { FactoryGirl.create(:project, identifier: 'foo') } + let!(:project) { FactoryBot.create(:project, identifier: 'foo') } it 'updates the project identifier' do visit projects_path @@ -176,14 +176,14 @@ describe 'Projects', type: :feature do end describe 'form', js: true do - let(:project) { FactoryGirl.build(:project, name: 'Foo project', identifier: 'foo-project') } + let(:project) { FactoryBot.build(:project, name: 'Foo project', identifier: 'foo-project') } let!(:optional_custom_field) do - FactoryGirl.create(:custom_field, name: 'Optional Foo', + FactoryBot.create(:custom_field, name: 'Optional Foo', type: ProjectCustomField, is_for_all: true) end let!(:required_custom_field) do - FactoryGirl.create(:custom_field, name: 'Required Foo', + FactoryBot.create(:custom_field, name: 'Required Foo', type: ProjectCustomField, is_for_all: true, is_required: true) diff --git a/spec/features/repositories/checkout_instructions_spec.rb b/spec/features/repositories/checkout_instructions_spec.rb index 481fe822ef..fe6b558a8c 100644 --- a/spec/features/repositories/checkout_instructions_spec.rb +++ b/spec/features/repositories/checkout_instructions_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'Create repository', type: :feature, js: true do - let(:current_user) { FactoryGirl.create (:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:current_user) { FactoryBot.create (:admin) } + let(:project) { FactoryBot.create(:project) } let(:enabled_scms) { %w[git] } before do @@ -54,7 +54,7 @@ describe 'Create repository', type: :feature, js: true do } let!(:repository) { - repo = FactoryGirl.build(:repository_git, scm_type: :managed) + repo = FactoryBot.build(:repository_git, scm_type: :managed) repo.project = project repo.configure(:managed, nil) repo.save! diff --git a/spec/features/repositories/create_repository_spec.rb b/spec/features/repositories/create_repository_spec.rb index a437cda084..42e6a71b68 100644 --- a/spec/features/repositories/create_repository_spec.rb +++ b/spec/features/repositories/create_repository_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' require 'features/repositories/repository_settings_page' describe 'Create repository', type: :feature, js: true, selenium: true do - let(:current_user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:current_user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } let(:settings_page) { RepositorySettingsPage.new(project) } # Allow to override configuration values to determine diff --git a/spec/features/repositories/repository_settings_spec.rb b/spec/features/repositories/repository_settings_spec.rb index 5f7873dbe3..cf8992114d 100644 --- a/spec/features/repositories/repository_settings_spec.rb +++ b/spec/features/repositories/repository_settings_spec.rb @@ -31,8 +31,8 @@ require 'features/repositories/repository_settings_page' require 'features/support/components/danger_zone' describe 'Repository Settings', type: :feature, js: true do - let(:current_user) { FactoryGirl.create (:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:current_user) { FactoryBot.create (:admin) } + let(:project) { FactoryBot.create(:project) } let(:settings_page) { RepositorySettingsPage.new(project) } let(:dangerzone) { DangerZone.new(page) } @@ -99,7 +99,7 @@ describe 'Repository Settings', type: :feature, js: true do shared_examples 'manages the repository with' do |name, type, repository_type, project_name| let(:repository) { - FactoryGirl.create("repository_#{name}".to_sym, + FactoryBot.create("repository_#{name}".to_sym, scm_type: type, project: project) } @@ -173,7 +173,7 @@ describe 'Repository Settings', type: :feature, js: true do describe 'update repositories' do let(:repository) { - FactoryGirl.create(:repository_subversion, + FactoryBot.create(:repository_subversion, scm_type: :existing, project: project) } diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 9f0ddb9911..8735193621 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -30,13 +30,13 @@ require 'spec_helper' describe 'Search', type: :feature do describe 'pagination' do - let(:project) { FactoryGirl.create :project } - let(:user) { FactoryGirl.create :admin } + let(:project) { FactoryBot.create :project } + let(:user) { FactoryBot.create :admin } let!(:work_packages) do (1..23).map do |n| subject = "Subject No. #{n}" - FactoryGirl.create :work_package, subject: subject, project: project, created_at: "2016-11-21 #{n}:00".to_datetime + FactoryBot.create :work_package, subject: subject, project: project, created_at: "2016-11-21 #{n}:00".to_datetime end end diff --git a/spec/features/security/angular_xss_spec.rb b/spec/features/security/angular_xss_spec.rb index 4b44e929df..73ec627319 100644 --- a/spec/features/security/angular_xss_spec.rb +++ b/spec/features/security/angular_xss_spec.rb @@ -74,18 +74,18 @@ describe 'Angular expression escaping', type: :feature do end describe '#WorkPackage description field', js: true do - let(:project) { FactoryGirl.create :project } + let(:project) { FactoryBot.create :project } let(:property_name) { :description } let(:property_title) { 'Description' } let(:description_text) { 'Expression {{ 3 + 5 }}' } let!(:work_package) { - FactoryGirl.create( + FactoryBot.create( :work_package, project: project, description: description_text ) } - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:field) { WorkPackageEditorField.new wp_page, 'description' } let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) } @@ -110,8 +110,8 @@ describe 'Angular expression escaping', type: :feature do end describe '#wiki edit previewing', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project, enabled_module_names: %w(wiki) } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project, enabled_module_names: %w(wiki) } let(:content) { find '#content_text' } let(:preview) { find '#preview' } diff --git a/spec/features/security/expire_sessions.rb b/spec/features/security/expire_sessions.rb index 3c3846b6a8..adfe389d27 100644 --- a/spec/features/security/expire_sessions.rb +++ b/spec/features/security/expire_sessions.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Expire old user sessions', type: :feature do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } before :all do @session_store = OpenProject::Application.config.session_store diff --git a/spec/features/security/session_ttl_spec.rb b/spec/features/security/session_ttl_spec.rb index 26873e0c92..914c02feed 100644 --- a/spec/features/security/session_ttl_spec.rb +++ b/spec/features/security/session_ttl_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe 'Session TTL', with_settings: {session_ttl_enabled?: true, session_ttl: '10'}, type: :feature do - let!(:user) {FactoryGirl.create :admin} - let!(:work_package) {FactoryGirl.create :work_package} + let!(:user) {FactoryBot.create :admin} + let!(:work_package) {FactoryBot.create :work_package} before do login_with(user.login, user.password) diff --git a/spec/features/time_entry/csv_export_spec.rb b/spec/features/time_entry/csv_export_spec.rb index 237814968c..4ceec8d030 100644 --- a/spec/features/time_entry/csv_export_spec.rb +++ b/spec/features/time_entry/csv_export_spec.rb @@ -31,25 +31,25 @@ require 'spec_helper' describe 'time entry csv export', type: :feature do # Force project to have only the required module activated # This may otherwise break for non-core configurations - let(:project) { FactoryGirl.create(:project, enabled_module_names: %w(time_tracking)) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_time_entries]) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project, enabled_module_names: %w(time_tracking)) } + let(:role) { FactoryBot.create(:role, permissions: [:view_time_entries]) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:project_time_entry) { - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, project: project, work_package: work_package, comments: 'la le lu') } - let(:project2) { FactoryGirl.create(:project) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project2) } + let(:project2) { FactoryBot.create(:project) } + let(:work_package2) { FactoryBot.create(:work_package, project: project2) } let(:project_time_entry2) { - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, project: project2, work_package: work_package2, comments: 'la le lu la le lu') } let(:current_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_projects: [project, project2], member_through_role: role) } diff --git a/spec/features/time_entry/root_time_entries_spec.rb b/spec/features/time_entry/root_time_entries_spec.rb index 15bc4c21bc..2d625a032c 100644 --- a/spec/features/time_entry/root_time_entries_spec.rb +++ b/spec/features/time_entry/root_time_entries_spec.rb @@ -29,19 +29,19 @@ require "spec_helper" describe "/time_entries", type: :feature do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } describe "sorting time entries", js: true do - let(:projects) { FactoryGirl.create_list :project, 3 } + let(:projects) { FactoryBot.create_list :project, 3 } let(:comments) { ["TE 2", "TE 1", "TE 3"] } let(:hours) { [2, 5, 1] } let!(:time_entries) do comments.zip(projects).zip(hours).map do |comment_and_project, hours| comment, project = comment_and_project - work_package = FactoryGirl.create :work_package, project: project + work_package = FactoryBot.create :work_package, project: project - FactoryGirl.create :time_entry, + FactoryBot.create :time_entry, comments: comment, work_package: work_package, project: project, diff --git a/spec/features/time_entry/time_entry_report_spec.rb b/spec/features/time_entry/time_entry_report_spec.rb index 342e930eb4..f2567f8144 100644 --- a/spec/features/time_entry/time_entry_report_spec.rb +++ b/spec/features/time_entry/time_entry_report_spec.rb @@ -29,26 +29,26 @@ require 'spec_helper' describe 'time entry report', type: :feature, js: true do - let(:project) { FactoryGirl.create(:project, enabled_module_names: %w(time_tracking)) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_time_entries]) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project, enabled_module_names: %w(time_tracking)) } + let(:role) { FactoryBot.create(:role, permissions: [:view_time_entries]) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let!(:project_time_entry) { - FactoryGirl.create_list(:time_entry, + FactoryBot.create_list(:time_entry, 2, project: project, work_package: work_package, hours: 2.5) } - let(:project2) { FactoryGirl.create(:project) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project2) } + let(:project2) { FactoryBot.create(:project) } + let(:work_package2) { FactoryBot.create(:work_package, project: project2) } let!(:project_time_entry2) { - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, project: project2, spent_on: 1.year.ago, work_package: work_package2, hours: 5.0) } - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } before do login_as(user) diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb index 9051b34936..46c1e45e15 100644 --- a/spec/features/types/form_configuration_query_spec.rb +++ b/spec/features/types/form_configuration_query_spec.rb @@ -30,24 +30,24 @@ require 'spec_helper' require 'features/projects/project_settings_page' describe 'form subelements configuration', type: :feature, js: true do - let(:admin) { FactoryGirl.create :admin } - let(:type_bug) { FactoryGirl.create :type_bug } - let(:type_task) { FactoryGirl.create :type_task } + let(:admin) { FactoryBot.create :admin } + let(:type_bug) { FactoryBot.create :type_bug } + let(:type_task) { FactoryBot.create :type_task } - let(:project) { FactoryGirl.create :project, types: [type_bug, type_task] } + let(:project) { FactoryBot.create :project, types: [type_bug, type_task] } let!(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: type_bug end let!(:subtask) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: work_package, project: project, type: type_task end let!(:subbug) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: work_package, project: project, type: type_bug diff --git a/spec/features/types/form_configuration_spec.rb b/spec/features/types/form_configuration_spec.rb index 7ead8661e2..55eba4a238 100644 --- a/spec/features/types/form_configuration_spec.rb +++ b/spec/features/types/form_configuration_spec.rb @@ -30,13 +30,13 @@ require 'spec_helper' require 'features/projects/project_settings_page' describe 'form configuration', type: :feature, js: true do - let(:admin) { FactoryGirl.create :admin } - let(:type) { FactoryGirl.create :type } + let(:admin) { FactoryBot.create :admin } + let(:type) { FactoryBot.create :type } - let(:project) { FactoryGirl.create :project, types: [type] } - let(:category) { FactoryGirl.create :category, project: project } + let(:project) { FactoryBot.create :project, types: [type] } + let(:category) { FactoryBot.create :category, project: project } let(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: type, done_ratio: 10, @@ -221,7 +221,7 @@ describe 'form configuration', type: :feature, js: true do describe 'required custom field' do let(:custom_fields) { [custom_field] } - let(:custom_field) { FactoryGirl.create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') } + let(:custom_field) { FactoryBot.create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') } let(:cf_identifier) { "custom_field_#{custom_field.id}" } let(:cf_identifier_api) { "customField#{custom_field.id}" } @@ -251,7 +251,7 @@ describe 'form configuration', type: :feature, js: true do let(:project_settings_page) { ProjectSettingsPage.new(project) } let(:custom_fields) { [custom_field] } - let(:custom_field) { FactoryGirl.create(:integer_issue_custom_field, name: 'MyNumber') } + let(:custom_field) { FactoryBot.create(:integer_issue_custom_field, name: 'MyNumber') } let(:cf_identifier) { "custom_field_#{custom_field.id}" } let(:cf_identifier_api) { "customField#{custom_field.id}" } @@ -310,7 +310,7 @@ describe 'form configuration', type: :feature, js: true do context 'active in project' do let(:project) do - FactoryGirl.create :project, + FactoryBot.create :project, types: [type], work_package_custom_fields: custom_fields end diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb index d1a03fda95..c30a9f4836 100644 --- a/spec/features/types/reset_form_configuration_spec.rb +++ b/spec/features/types/reset_form_configuration_spec.rb @@ -30,16 +30,16 @@ require 'spec_helper' require 'features/projects/project_settings_page' describe 'Reset form configuration', type: :feature, js: true do - let(:admin) { FactoryGirl.create :admin } - let(:type) { FactoryGirl.create :type } + let(:admin) { FactoryBot.create :admin } + let(:type) { FactoryBot.create :type } - let(:project) { FactoryGirl.create :project, types: [type] } + let(:project) { FactoryBot.create :project, types: [type] } let(:form) { ::Components::Admin::TypeConfigurationForm.new } let(:dialog) { ::Components::ConfirmationDialog.new } describe "with EE token and CFs" do let(:custom_fields) { [custom_field] } - let(:custom_field) { FactoryGirl.create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') } + let(:custom_field) { FactoryBot.create(:integer_issue_custom_field, is_required: true, name: 'MyNumber') } let(:cf_identifier) { "custom_field_#{custom_field.id}" } let(:cf_identifier_api) { "customField#{custom_field.id}" } diff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rb index f7fb67a6d4..febece00cf 100644 --- a/spec/features/users/create_spec.rb +++ b/spec/features/users/create_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'create users', type: :feature, selenium: true do - let(:current_user) { FactoryGirl.create :admin } - let(:auth_source) { FactoryGirl.build :dummy_auth_source } + let(:current_user) { FactoryBot.create :admin } + let(:auth_source) { FactoryBot.build :dummy_auth_source } let(:new_user_page) { Pages::NewUser.new } before do diff --git a/spec/features/users/delete_spec.rb b/spec/features/users/delete_spec.rb index e32514868c..08430a4d5b 100644 --- a/spec/features/users/delete_spec.rb +++ b/spec/features/users/delete_spec.rb @@ -39,7 +39,7 @@ describe 'user deletion: ', type: :feature, js: true do context 'regular user' do let(:user_password) {'bob!' * 4} let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, password: user_password, password_confirmation: user_password) end @@ -68,10 +68,10 @@ describe 'user deletion: ', type: :feature, js: true do end context 'admin user' do - let!(:user) { FactoryGirl.create :user } + let!(:user) { FactoryBot.create :user } let(:user_password) { 'admin! * 4' } let(:current_user) do - FactoryGirl.create(:admin, + FactoryBot.create(:admin, password: user_password, password_confirmation: user_password) end diff --git a/spec/features/users/edit_users_spec.rb b/spec/features/users/edit_users_spec.rb index 368cd483c8..20263746ab 100644 --- a/spec/features/users/edit_users_spec.rb +++ b/spec/features/users/edit_users_spec.rb @@ -30,10 +30,10 @@ require 'spec_helper' require 'features/projects/projects_page' describe 'edit users', type: :feature, js: true do - let(:current_user) { FactoryGirl.create :admin } - let(:user) { FactoryGirl.create :user } + let(:current_user) { FactoryBot.create :admin } + let(:user) { FactoryBot.create :user } - let!(:auth_source) { FactoryGirl.create :auth_source } + let!(:auth_source) { FactoryBot.create :auth_source } before do allow(User).to receive(:current).and_return current_user diff --git a/spec/features/users/my_spec.rb b/spec/features/users/my_spec.rb index 24596346b9..60faab56d3 100644 --- a/spec/features/users/my_spec.rb +++ b/spec/features/users/my_spec.rb @@ -32,7 +32,7 @@ require 'features/projects/projects_page' describe 'my', type: :feature, js: true do let(:user_password) { 'bob' * 4 } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, mail: 'old@mail.com', login: 'bob', password: user_password, @@ -89,7 +89,7 @@ describe 'my', type: :feature, js: true do context 'as admin' do let(:user) { - FactoryGirl.create :admin, + FactoryBot.create :admin, password: user_password, password_confirmation: user_password } diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb index 5ae7cbb295..bf71768a3e 100644 --- a/spec/features/users/password_change_spec.rb +++ b/spec/features/users/password_change_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe 'random password generation', type: :feature, js: true do - let(:admin) { FactoryGirl.create :admin } - let(:auth_source) { FactoryGirl.build :dummy_auth_source } + let(:admin) { FactoryBot.create :admin } + let(:auth_source) { FactoryBot.build :dummy_auth_source } let(:old_password) { 'old_Password!123' } let(:new_password) { 'new_Password!123' } - let(:user) { FactoryGirl.create :user, password: old_password, password_confirmation: old_password } + let(:user) { FactoryBot.create :user, password: old_password, password_confirmation: old_password } let(:user_page) { ::Pages::Admin::User.new(user.id) } describe 'as admin user' do diff --git a/spec/features/users/resend_invitation_spec.rb b/spec/features/users/resend_invitation_spec.rb index 6fcbdc0c9a..875222c531 100644 --- a/spec/features/users/resend_invitation_spec.rb +++ b/spec/features/users/resend_invitation_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' feature 'resend invitation', type: :feature do - let(:current_user) { FactoryGirl.create :admin } - let(:user) { FactoryGirl.create :invited_user, mail: 'holly@openproject.com' } + let(:current_user) { FactoryBot.create :admin } + let(:user) { FactoryBot.create :invited_user, mail: 'holly@openproject.com' } before do allow(User).to receive(:current).and_return current_user diff --git a/spec/features/users/self_registration_spec.rb b/spec/features/users/self_registration_spec.rb index 15033a02f9..129119254b 100644 --- a/spec/features/users/self_registration_spec.rb +++ b/spec/features/users/self_registration_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'user self registration', type: :feature, js: true do - let(:admin) { FactoryGirl.create :admin, password: 'Test123Test123', password_confirmation: 'Test123Test123' } + let(:admin) { FactoryBot.create :admin, password: 'Test123Test123', password_confirmation: 'Test123Test123' } let(:home_page) { Pages::Home.new } context 'with "manual account activation"' do diff --git a/spec/features/users/user_memberships_spec.rb b/spec/features/users/user_memberships_spec.rb index 53edf065e3..9db8d571f9 100644 --- a/spec/features/users/user_memberships_spec.rb +++ b/spec/features/users/user_memberships_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' feature 'user memberships through user page', type: :feature, js: true do - let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } - let(:admin) { FactoryGirl.create :admin, firstname: 'Foobar', lastname: 'Blabla' } + let!(:project) { FactoryBot.create :project, name: 'Project 1', identifier: 'project1' } + let(:admin) { FactoryBot.create :admin, firstname: 'Foobar', lastname: 'Blabla' } - let!(:manager) { FactoryGirl.create :role, name: 'Manager' } - let!(:developer) { FactoryGirl.create :role, name: 'Developer' } + let!(:manager) { FactoryBot.create :role, name: 'Manager' } + let!(:developer) { FactoryBot.create :role, name: 'Developer' } let(:user_page) { Pages::Admin::User.new(admin.id) } @@ -62,7 +62,7 @@ feature 'user memberships through user page', type: :feature, js: true do end context 'when user has an inherited role' do - let(:group) { FactoryGirl.create :group, lastname: 'A-Team' } + let(:group) { FactoryBot.create :group, lastname: 'A-Team' } let(:group_page) { Pages::Groups.new.group(group.id) } before do diff --git a/spec/features/watching/toggle_watching_spec.rb b/spec/features/watching/toggle_watching_spec.rb index 7041df67ce..e99f1f498f 100644 --- a/spec/features/watching/toggle_watching_spec.rb +++ b/spec/features/watching/toggle_watching_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe 'Toggle watching', type: :feature, js: true do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_messages, :view_wiki_pages]) } - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:news) { FactoryGirl.create(:news, project: project) } - let(:board) { FactoryGirl.create(:board, project: project) } - let(:message) { FactoryGirl.create(:message, board: board) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_messages, :view_wiki_pages]) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:news) { FactoryBot.create(:news, project: project) } + let(:board) { FactoryBot.create(:board, project: project) } + let(:message) { FactoryBot.create(:message, board: board) } let(:wiki) { project.wiki } - let(:wiki_page) { FactoryGirl.create(:wiki_page_with_content, wiki: wiki) } + let(:wiki_page) { FactoryBot.create(:wiki_page_with_content, wiki: wiki) } before do allow(User).to receive(:current).and_return user diff --git a/spec/features/wiki/wiki_textile_links_spec.rb b/spec/features/wiki/wiki_textile_links_spec.rb index 22a8f03b9a..cc74cd54e2 100644 --- a/spec/features/wiki/wiki_textile_links_spec.rb +++ b/spec/features/wiki/wiki_textile_links_spec.rb @@ -29,13 +29,13 @@ require 'spec_helper' describe 'Wiki unicode title spec', type: :feature, js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:wiki_page_1) { - FactoryGirl.build :wiki_page_with_content, title: 'Test' + FactoryBot.build :wiki_page_with_content, title: 'Test' } let(:work_package) { - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, start_date: Date.today, due_date: Date.today + 1.days, diff --git a/spec/features/wiki/wiki_unicode_spec.rb b/spec/features/wiki/wiki_unicode_spec.rb index 46ee0bc15a..0d91ad1434 100644 --- a/spec/features/wiki/wiki_unicode_spec.rb +++ b/spec/features/wiki/wiki_unicode_spec.rb @@ -29,18 +29,18 @@ require 'spec_helper' describe 'Wiki unicode title spec', type: :feature, js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:wiki_page_1) { - FactoryGirl.build :wiki_page_with_content, + FactoryBot.build :wiki_page_with_content, title: '' } let(:wiki_page_2) { - FactoryGirl.build :wiki_page_with_content, + FactoryBot.build :wiki_page_with_content, title: 'Base de données' } let(:wiki_page_3) { - FactoryGirl.build :wiki_page_with_content, + FactoryBot.build :wiki_page_with_content, title: 'Base_de_données' } diff --git a/spec/features/work_package_show_spec.rb b/spec/features/work_package_show_spec.rb index 2a3883ac2a..ee267b9019 100644 --- a/spec/features/work_package_show_spec.rb +++ b/spec/features/work_package_show_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' RSpec.feature 'Work package show page', selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } let(:work_package) { - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, project: project, assigned_to: user, responsible: user) diff --git a/spec/features/work_packages/attribute_help_texts_spec.rb b/spec/features/work_packages/attribute_help_texts_spec.rb index 4221055536..59b7d46af1 100644 --- a/spec/features/work_packages/attribute_help_texts_spec.rb +++ b/spec/features/work_packages/attribute_help_texts_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe 'Work package attribute help texts', type: :feature, js: true do - let(:project) { FactoryGirl.create :project } - let(:work_package) { FactoryGirl.create :work_package, project: project } + let(:project) { FactoryBot.create :project } + let(:work_package) { FactoryBot.create :work_package, project: project } let(:instance) do - FactoryGirl.create :work_package_help_text, + FactoryBot.create :work_package_help_text, attribute_name: :status, help_text: 'Some *help text* for status.' end @@ -64,16 +64,16 @@ describe 'Work package attribute help texts', type: :feature, js: true do end describe 'as admin' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } it_behaves_like 'allows to view help texts' end describe 'as regular user' do let(:view_wps_role) do - FactoryGirl.create :role, permissions: [:view_work_packages] + FactoryBot.create :role, permissions: [:view_work_packages] end let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: view_wps_role end diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb index 821981085d..c85c347c59 100644 --- a/spec/features/work_packages/bulk/copy_work_package_spec.rb +++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb @@ -3,51 +3,51 @@ require 'features/page_objects/notification' describe 'Copy work packages through Rails view', js: true do let(:dev_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages] end let(:mover_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks add_work_packages] end let(:dev) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Dev', lastname: 'Guy', member_in_project: project, member_through_role: dev_role end let(:mover) do - FactoryGirl.create :admin, + FactoryBot.create :admin, firstname: 'Manager', lastname: 'Guy', member_in_project: project, member_through_role: mover_role end - let(:type) { FactoryGirl.create :type, name: 'Bug' } - let(:type2) { FactoryGirl.create :type, name: 'Risk' } + let(:type) { FactoryBot.create :type, name: 'Bug' } + let(:type2) { FactoryBot.create :type, name: 'Risk' } - let!(:project) { FactoryGirl.create(:project, name: 'Source', types: [type, type2]) } - let!(:project2) { FactoryGirl.create(:project, name: 'Target', types: [type, type2]) } + let!(:project) { FactoryBot.create(:project, name: 'Source', types: [type, type2]) } + let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type, type2]) } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: dev, project: project, type: type) } let!(:work_package2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: dev, project: project, type: type) } let(:status) { work_package.status } - let!(:status2) { FactoryGirl.create :default_status } + let!(:status2) { FactoryBot.create :default_status } let!(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type2.id, old_status: work_package.status, new_status: status2, @@ -98,7 +98,7 @@ describe 'Copy work packages through Rails view', js: true do end context 'when the target project does not have the type' do - let!(:project2) { FactoryGirl.create(:project, name: 'Target', types: [type2]) } + let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type2]) } it 'does moves the work package and changes the type' do expect(page).to have_selector('.flash.error', text: "Failed to save 2 work package(s) on 2 selected:") diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb index 1844751d10..c042f9d276 100644 --- a/spec/features/work_packages/bulk/move_work_package_spec.rb +++ b/spec/features/work_packages/bulk/move_work_package_spec.rb @@ -3,42 +3,42 @@ require 'features/page_objects/notification' describe 'Moving a work package through Rails view', js: true do let(:dev_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages add_work_packages] end let(:mover_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages move_work_packages manage_subtasks add_work_packages] end let(:dev) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Dev', lastname: 'Guy', member_in_project: project, member_through_role: dev_role end let(:mover) do - FactoryGirl.create :admin, + FactoryBot.create :admin, firstname: 'Manager', lastname: 'Guy', member_in_project: project, member_through_role: mover_role end - let(:type) { FactoryGirl.create :type, name: 'Bug' } - let(:type2) { FactoryGirl.create :type, name: 'Risk' } + let(:type) { FactoryBot.create :type, name: 'Bug' } + let(:type2) { FactoryBot.create :type, name: 'Risk' } - let!(:project) { FactoryGirl.create(:project, name: 'Source', types: [type, type2]) } - let!(:project2) { FactoryGirl.create(:project, name: 'Target', types: [type, type2]) } + let!(:project) { FactoryBot.create(:project, name: 'Source', types: [type, type2]) } + let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type, type2]) } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: dev, project: project, type: type) } let!(:child_wp) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: dev, parent: work_package, project: project, @@ -46,9 +46,9 @@ describe 'Moving a work package through Rails view', js: true do } let(:status) { work_package.status } - let!(:status2) { FactoryGirl.create :default_status } + let!(:status2) { FactoryBot.create :default_status } let!(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type2.id, old_status: work_package.status, new_status: status2, @@ -93,7 +93,7 @@ describe 'Moving a work package through Rails view', js: true do end context 'when the target project does not have the type' do - let!(:project2) { FactoryGirl.create(:project, name: 'Target', types: [type2]) } + let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type2]) } it 'does moves the work package and changes the type' do expect_angular_frontend_initialized diff --git a/spec/features/work_packages/cancel_editing_spec.rb b/spec/features/work_packages/cancel_editing_spec.rb index b3aaec8c52..828c6af2d7 100644 --- a/spec/features/work_packages/cancel_editing_spec.rb +++ b/spec/features/work_packages/cancel_editing_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe 'Cancel editing work package', js: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } + let(:work_package2) { FactoryBot.create(:work_package, project: project) } let(:wp_page) { ::Pages::AbstractWorkPackage.new(work_package) } let(:wp_table) { ::Pages::WorkPackagesTable.new } let(:paths) { @@ -136,7 +136,7 @@ describe 'Cancel editing work package', js: true do context 'when user does not want to be warned' do before do - FactoryGirl.create(:user_preference, user: user, others: { warn_on_leaving_unsaved: false }) + FactoryBot.create(:user_preference, user: user, others: { warn_on_leaving_unsaved: false }) end it 'does not alert when moving anywhere' do diff --git a/spec/features/work_packages/copy_spec.rb b/spec/features/work_packages/copy_spec.rb index c470d85e00..e669fe5d02 100644 --- a/spec/features/work_packages/copy_spec.rb +++ b/spec/features/work_packages/copy_spec.rb @@ -30,28 +30,28 @@ require 'spec_helper' RSpec.feature 'Work package copy', js: true, selenium: true do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: create_role) end let(:work_flow) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, role: create_role, type_id: original_work_package.type_id, old_status: original_work_package.status, - new_status: FactoryGirl.create(:status)) + new_status: FactoryBot.create(:status)) end let(:create_role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages, :add_work_packages, :edit_work_packages]) end - let(:type) { FactoryGirl.create(:type) } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create(:type) } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:original_work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, project: project, assigned_to: assignee, responsible: responsible, @@ -59,30 +59,30 @@ RSpec.feature 'Work package copy', js: true, selenium: true do type: type, author: author) end - let(:role) { FactoryGirl.build(:role, permissions: [:view_work_packages]) } + let(:role) { FactoryBot.build(:role, permissions: [:view_work_packages]) } let(:assignee) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'An', lastname: 'assignee', member_in_project: project, member_through_role: role) end let(:responsible) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'The', lastname: 'responsible', member_in_project: project, member_through_role: role) end let(:author) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'The', lastname: 'author', member_in_project: project, member_through_role: role) end let(:version) do - FactoryGirl.build(:version, + FactoryBot.build(:version, project: project) end diff --git a/spec/features/work_packages/custom_actions_spec.rb b/spec/features/work_packages/custom_actions_spec.rb index 393c1d6f98..90cf6dbae6 100644 --- a/spec/features/work_packages/custom_actions_spec.rb +++ b/spec/features/work_packages/custom_actions_spec.rb @@ -30,36 +30,36 @@ require 'spec_helper' describe 'Custom actions', type: :feature, js: true do let(:permissions) { %i(view_work_packages edit_work_packages move_work_packages) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } - let!(:other_role) { FactoryGirl.create(:role, permissions: permissions) } - let(:admin) { FactoryGirl.create(:admin) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } + let!(:other_role) { FactoryBot.create(:role, permissions: permissions) } + let(:admin) { FactoryBot.create(:admin) } let(:user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, firstname: 'A', lastname: 'User') - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, roles: [role], user: user) - FactoryGirl.create(:member, + FactoryBot.create(:member, project: other_project, roles: [role], user: user) user end let!(:other_member_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, firstname: 'Other member', lastname: 'User', member_in_project: project, member_through_role: role) end - let(:project) { FactoryGirl.create(:project) } - let(:other_project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } + let(:other_project) { FactoryBot.create(:project) } let!(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, assigned_to: user, priority: default_priority, @@ -68,49 +68,49 @@ describe 'Custom actions', type: :feature, js: true do let(:wp_page) { Pages::FullWorkPackage.new(work_package) } let(:default_priority) do - FactoryGirl.create(:default_priority, name: 'Normal') + FactoryBot.create(:default_priority, name: 'Normal') end let!(:immediate_priority) do - FactoryGirl.create(:issue_priority, + FactoryBot.create(:issue_priority, name: 'At once', position: IssuePriority.maximum(:position) + 1) end let(:default_status) do - FactoryGirl.create(:default_status) + FactoryBot.create(:default_status) end let(:closed_status) do - FactoryGirl.create(:closed_status, name: 'Closed') + FactoryBot.create(:closed_status, name: 'Closed') end let(:rejected_status) do - FactoryGirl.create(:closed_status, name: 'Rejected') + FactoryBot.create(:closed_status, name: 'Rejected') end let(:other_type) do - type = FactoryGirl.create(:type) + type = FactoryBot.create(:type) other_project.types << type type end let!(:workflows) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: work_package.status, new_status: closed_status, role: role, type: work_package.type) - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, new_status: work_package.status, old_status: closed_status, role: role, type: work_package.type) - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: work_package.status, new_status: rejected_status, role: role, type: work_package.type) end let!(:list_custom_field) do - cf = FactoryGirl.create(:list_wp_custom_field, multi_value: true) + cf = FactoryBot.create(:list_wp_custom_field, multi_value: true) project.work_package_custom_fields = [cf] work_package.type.custom_fields = [cf] @@ -118,13 +118,13 @@ describe 'Custom actions', type: :feature, js: true do cf end let!(:int_custom_field) do - FactoryGirl.create(:int_wp_custom_field) + FactoryBot.create(:int_wp_custom_field) end let(:selected_list_custom_field_options) do [list_custom_field.custom_options.first, list_custom_field.custom_options.last] end let!(:date_custom_field) do - cf = FactoryGirl.create(:date_wp_custom_field) + cf = FactoryBot.create(:date_wp_custom_field) other_project.work_package_custom_fields = [cf] other_type.custom_fields = [cf] diff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb index f89a67845d..a7bb50f192 100644 --- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb +++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb @@ -3,16 +3,16 @@ require 'features/work_packages/work_packages_page' require 'features/work_packages/details/inplace_editor/shared_examples' describe 'custom field inplace editor', js: true do - let(:user) { FactoryGirl.create :admin } - let(:type) { FactoryGirl.create(:type_standard, custom_fields: custom_fields) } + let(:user) { FactoryBot.create :admin } + let(:type) { FactoryBot.create(:type_standard, custom_fields: custom_fields) } let(:project) do - FactoryGirl.create :project, + FactoryBot.create :project, types: [type], work_package_custom_fields: custom_fields end let(:custom_fields) { [custom_field] } let(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, type: type, project: project, custom_values: initial_custom_values @@ -40,7 +40,7 @@ describe 'custom field inplace editor', js: true do describe 'long text' do let(:custom_field) do - FactoryGirl.create(:text_issue_custom_field, name: 'LongText') + FactoryBot.create(:text_issue_custom_field, name: 'LongText') end let(:field) { WorkPackageEditorField.new wp_page, property_name } let(:initial_custom_values) { { custom_field.id => 'foo' } } @@ -64,12 +64,12 @@ describe 'custom field inplace editor', js: true do describe 'custom field lists' do let(:custom_field1) do - FactoryGirl.create(:list_wp_custom_field, + FactoryBot.create(:list_wp_custom_field, is_required: false, possible_values: %w(foo bar baz)) end let(:custom_field2) do - FactoryGirl.create(:list_wp_custom_field, + FactoryBot.create(:list_wp_custom_field, is_required: false, possible_values: %w(X Y Z)) end @@ -122,7 +122,7 @@ describe 'custom field inplace editor', js: true do describe 'integer type' do let(:custom_field) do - FactoryGirl.create(:integer_issue_custom_field, args.merge(name: 'MyNumber')) + FactoryBot.create(:integer_issue_custom_field, args.merge(name: 'MyNumber')) end let(:initial_custom_values) { { custom_field.id => 123 } } @@ -190,13 +190,13 @@ describe 'custom field inplace editor', js: true do describe 'float type' do let(:custom_field) do - FactoryGirl.create(:float_wp_custom_field, args.merge(name: 'MyFloat')) + FactoryBot.create(:float_wp_custom_field, args.merge(name: 'MyFloat')) end let(:args) { {} } let(:initial_custom_values) { { custom_field.id => 123.50 } } context 'with english locale' do - let(:user) { FactoryGirl.create :admin, language: 'en' } + let(:user) { FactoryBot.create :admin, language: 'en' } it 'displays the float with english locale and allows editing' do field.expect_state_text '123.5' @@ -210,7 +210,7 @@ describe 'custom field inplace editor', js: true do context 'with german locale', driver: :chrome_headless_de do - let(:user) { FactoryGirl.create :admin, language: 'de' } + let(:user) { FactoryBot.create :admin, language: 'de' } it 'displays the float with german locale and allows editing' do field.expect_state_text '123,5' diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rb index a9e530d127..e9d8fa32ed 100644 --- a/spec/features/work_packages/details/date_editor_spec.rb +++ b/spec/features/work_packages/details/date_editor_spec.rb @@ -8,9 +8,9 @@ require 'features/work_packages/work_packages_page' describe 'date inplace editor', with_settings: { date_format: '%Y-%m-%d' }, js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, is_public: true } - let(:work_package) { FactoryGirl.create :work_package, project: project, start_date: '2016-01-01' } - let(:user) { FactoryGirl.create :admin } + let(:project) { FactoryBot.create :project_with_types, is_public: true } + let(:work_package) { FactoryBot.create :work_package, project: project, start_date: '2016-01-01' } + let(:user) { FactoryBot.create :admin } let(:work_packages_page) { Pages::FullWorkPackage.new(work_package,project) } let(:due_date) { work_packages_page.edit_field(:dueDate) } diff --git a/spec/features/work_packages/details/details_toolbar_spec.rb b/spec/features/work_packages/details/details_toolbar_spec.rb index d8a7cdd705..870e4068f8 100644 --- a/spec/features/work_packages/details/details_toolbar_spec.rb +++ b/spec/features/work_packages/details/details_toolbar_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' describe 'Work package details toolbar', js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, is_public: true } - let!(:work_package) { FactoryGirl.create :work_package, project: project } + let(:project) { FactoryBot.create :project_with_types, is_public: true } + let!(:work_package) { FactoryBot.create :work_package, project: project } let(:work_packages_page) { WorkPackagesPage.new(project) } describe 'toggle watch state' do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } before do login_as(user) work_packages_page.visit_index(work_package) diff --git a/spec/features/work_packages/details/inplace_editor/shared_examples.rb b/spec/features/work_packages/details/inplace_editor/shared_examples.rb index c620c61c2d..267fbfa0f7 100644 --- a/spec/features/work_packages/details/inplace_editor/shared_examples.rb +++ b/spec/features/work_packages/details/inplace_editor/shared_examples.rb @@ -36,10 +36,10 @@ shared_examples 'an auth aware field' do context 'when user is not authorized' do let(:user) { - FactoryGirl.create( + FactoryBot.create( :user, member_in_project: project, - member_through_role: FactoryGirl.build( + member_through_role: FactoryBot.build( :role, permissions: [:view_work_packages] ) @@ -123,7 +123,7 @@ shared_examples 'a previewable field' do end shared_examples 'a workpackage autocomplete field' do - let!(:wp2) { FactoryGirl.create(:work_package, project: project, subject: 'AutoFoo') } + let!(:wp2) { FactoryBot.create(:work_package, project: project, subject: 'AutoFoo') } before do skip('Markdown mode does not provide autocompleting') if Setting.text_formatting == 'markdown' @@ -137,23 +137,23 @@ shared_examples 'a workpackage autocomplete field' do end shared_examples 'a principal autocomplete field' do - let(:role) { FactoryGirl.create(:role, permissions: %i[view_work_packages edit_work_packages]) } + let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages edit_work_packages]) } let!(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role, firstname: 'John' end let!(:mentioned_user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role, firstname: 'Laura', lastname: 'Foobar' end let!(:mentioned_group) do - FactoryGirl.create(:group, lastname: 'Laudators').tap do |group| - FactoryGirl.create :member, + FactoryBot.create(:group, lastname: 'Laudators').tap do |group| + FactoryBot.create :member, principal: group, project: project, roles: [role] diff --git a/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb b/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb index fce16e96d4..e15035d256 100644 --- a/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb +++ b/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb @@ -6,11 +6,11 @@ require 'support/work_packages/work_package_field' require 'features/work_packages/work_packages_page' describe 'subject inplace editor', js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, is_public: true } + let(:project) { FactoryBot.create :project_with_types, is_public: true } let(:property_name) { :subject } let(:property_title) { 'Subject' } - let(:work_package) { FactoryGirl.create :work_package, project: project } - let(:user) { FactoryGirl.create :admin } + let(:work_package) { FactoryBot.create :work_package, project: project } + let(:user) { FactoryBot.create :admin } let(:work_packages_page) { Pages::SplitWorkPackage.new(work_package,project) } let(:field) { work_packages_page.edit_field(property_name) } let(:notification) { ::PageObjects::Notifications.new(page) } diff --git a/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb b/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb index 3d5d25335c..f0fd8cdbd4 100644 --- a/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb +++ b/spec/features/work_packages/details/inplace_editor/version_editor_spec.rb @@ -5,32 +5,32 @@ require 'support/work_packages/work_package_field' require 'features/work_packages/work_packages_page' describe 'subject inplace editor', js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, name: 'Root', is_public: true } - let(:subproject1) { FactoryGirl.create :project_with_types, name: 'Child', parent: project } - let(:subproject2) { FactoryGirl.create :project_with_types, name: 'Aunt', parent: project } + let(:project) { FactoryBot.create :project_with_types, name: 'Root', is_public: true } + let(:subproject1) { FactoryBot.create :project_with_types, name: 'Child', parent: project } + let(:subproject2) { FactoryBot.create :project_with_types, name: 'Aunt', parent: project } let!(:version) { - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', sharing: 'tree', project: project) } let!(:version2) { - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', sharing: 'tree', project: subproject1) } let!(:version3) { - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', sharing: 'tree', project: subproject2) } let(:property_name) { :version } - let(:work_package) { FactoryGirl.create :work_package, project: project } - let(:user) { FactoryGirl.create :admin } + let(:work_package) { FactoryBot.create :work_package, project: project } + let(:user) { FactoryBot.create :admin } let(:work_package_page) { Pages::FullWorkPackage.new(work_package) } before do diff --git a/spec/features/work_packages/details/markdown/activity_comments_spec.rb b/spec/features/work_packages/details/markdown/activity_comments_spec.rb index 6ad9e389e6..7d06472e55 100644 --- a/spec/features/work_packages/details/markdown/activity_comments_spec.rb +++ b/spec/features/work_packages/details/markdown/activity_comments_spec.rb @@ -6,9 +6,9 @@ require 'features/work_packages/details/inplace_editor/shared_examples' describe 'activity comments', with_settings: { text_formatting: 'markdown' }, js: true do - let(:project) { FactoryGirl.create :project, is_public: true } + let(:project) { FactoryBot.create :project, is_public: true } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, journal_notes: initial_comment) } @@ -27,7 +27,7 @@ describe 'activity comments', end context 'with permission' do - let(:current_user) { FactoryGirl.create :admin } + let(:current_user) { FactoryBot.create :admin } before do wp_page.visit! @@ -99,7 +99,7 @@ describe 'activity comments', end describe 'work packages' do - let!(:wp2) { FactoryGirl.create(:work_package, project: project, subject: 'AutoFoo') } + let!(:wp2) { FactoryBot.create(:work_package, project: project, subject: 'AutoFoo') } it 'autocompletes the other work package' do comment_field.input_element.send_keys("##{wp2.id}") expect(page).to have_selector('.atwho-view-ul li', text: wp2.to_s.strip) @@ -191,8 +191,8 @@ describe 'activity comments', end context 'with no permission' do - let(:current_user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) } + let(:current_user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create :role, permissions: %i(view_work_packages) } before do wp_page.visit! diff --git a/spec/features/work_packages/details/markdown/description_editor_spec.rb b/spec/features/work_packages/details/markdown/description_editor_spec.rb index 26d7d022f9..d7ae314707 100644 --- a/spec/features/work_packages/details/markdown/description_editor_spec.rb +++ b/spec/features/work_packages/details/markdown/description_editor_spec.rb @@ -33,18 +33,18 @@ require 'support/work_packages/work_package_field' require 'features/work_packages/work_packages_page' describe 'description inplace editor', js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, is_public: true } + let(:project) { FactoryBot.create :project_with_types, is_public: true } let(:property_name) { :description } let(:property_title) { 'Description' } let(:description_text) { 'Ima description' } let!(:work_package) { - FactoryGirl.create( + FactoryBot.create( :work_package, project: project, description: description_text ) } - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:field) { WorkPackageEditorField.new wp_page, 'description' } let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) } @@ -106,8 +106,8 @@ describe 'description inplace editor', js: true, selenium: true do end context 'with no permission' do - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create :role, permissions: %i(view_work_packages) } it 'does not show the field' do expect(page).to have_no_selector('.wp-edit-field.description.-editable') diff --git a/spec/features/work_packages/details/relations/hierarchy_spec.rb b/spec/features/work_packages/details/relations/hierarchy_spec.rb index ec3c9a196e..87f1c318d8 100644 --- a/spec/features/work_packages/details/relations/hierarchy_spec.rb +++ b/spec/features/work_packages/details/relations/hierarchy_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' describe 'Work package relations tab', js: true, selenium: true do include_context 'ui-autocomplete helpers' - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create :project } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create :project } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:work_packages_page) { ::Pages::SplitWorkPackage.new(work_package) } let(:full_wp) { ::Pages::FullWorkPackage.new(work_package) } let(:relations) { ::Components::WorkPackages::Relations.new(work_package) } @@ -29,9 +29,9 @@ describe 'Work package relations tab', js: true, selenium: true do describe 'as admin' do - let!(:parent) { FactoryGirl.create(:work_package, project: project) } - let!(:child) { FactoryGirl.create(:work_package, project: project) } - let!(:child2) { FactoryGirl.create(:work_package, project: project, subject: 'Something new') } + let!(:parent) { FactoryBot.create(:work_package, project: project) } + let!(:child) { FactoryBot.create(:work_package, project: project) } + let!(:child2) { FactoryBot.create(:work_package, project: project, subject: 'Something new') } it 'allows to manage hierarchy' do # Shows link parent link @@ -59,21 +59,21 @@ describe 'Work package relations tab', js: true, selenium: true do end describe 'relation group-by toggler' do - let(:project) { FactoryGirl.create :project, types: [type_1, type_2] } - let(:type_1) { FactoryGirl.create :type } - let(:type_2) { FactoryGirl.create :type } + let(:project) { FactoryBot.create :project, types: [type_1, type_2] } + let(:type_1) { FactoryBot.create :type } + let(:type_2) { FactoryBot.create :type } - let(:to_1) { FactoryGirl.create(:work_package, type: type_1, project: project) } - let(:to_2) { FactoryGirl.create(:work_package, type: type_2, project: project) } + let(:to_1) { FactoryBot.create(:work_package, type: type_1, project: project) } + let(:to_2) { FactoryBot.create(:work_package, type: type_2, project: project) } let!(:relation_1) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: work_package, to: to_1, relation_type: Relation::TYPE_FOLLOWS end let!(:relation_2) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: work_package, to: to_2, relation_type: Relation::TYPE_RELATES @@ -93,18 +93,18 @@ describe 'Work package relations tab', js: true, selenium: true do describe 'with limited permissions' do let(:permissions) { %i(view_work_packages) } let(:user_role) do - FactoryGirl.create :role, permissions: permissions + FactoryBot.create :role, permissions: permissions end let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: user_role end context 'as view-only user, with parent set' do - let(:parent) { FactoryGirl.create(:work_package, project: project) } - let(:work_package) { FactoryGirl.create(:work_package, parent: parent, project: project) } + let(:parent) { FactoryBot.create(:work_package, project: project) } + let(:work_package) { FactoryBot.create(:work_package, parent: parent, project: project) } it 'shows no links to create relations' do # No create buttons should exist @@ -127,8 +127,8 @@ describe 'Work package relations tab', js: true, selenium: true do context 'with manage_subtasks permissions' do let(:permissions) { %i(view_work_packages manage_subtasks) } - let!(:parent) { FactoryGirl.create(:work_package, project: project) } - let!(:child) { FactoryGirl.create(:work_package, project: project) } + let!(:parent) { FactoryBot.create(:work_package, project: project) } + let!(:child) { FactoryBot.create(:work_package, project: project) } it 'should be able to link parent and children' do # Shows link parent link diff --git a/spec/features/work_packages/details/relations/relations_spec.rb b/spec/features/work_packages/details/relations/relations_spec.rb index 956aa381a5..5220f6f0f0 100644 --- a/spec/features/work_packages/details/relations/relations_spec.rb +++ b/spec/features/work_packages/details/relations/relations_spec.rb @@ -3,10 +3,10 @@ require 'spec_helper' describe 'Work package relations tab', js: true, selenium: true do include_context 'ui-autocomplete helpers' - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create :project } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create :project } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:work_packages_page) { ::Pages::SplitWorkPackage.new(work_package) } let(:full_wp) { ::Pages::FullWorkPackage.new(work_package) } let(:relations) { ::Components::WorkPackages::Relations.new(work_package) } @@ -28,21 +28,21 @@ describe 'Work package relations tab', js: true, selenium: true do end describe 'relation group-by toggler' do - let(:project) { FactoryGirl.create :project, types: [type_1, type_2] } - let(:type_1) { FactoryGirl.create :type } - let(:type_2) { FactoryGirl.create :type } + let(:project) { FactoryBot.create :project, types: [type_1, type_2] } + let(:type_1) { FactoryBot.create :type } + let(:type_2) { FactoryBot.create :type } - let(:to_1) { FactoryGirl.create(:work_package, type: type_1, project: project) } - let(:to_2) { FactoryGirl.create(:work_package, type: type_2, project: project) } + let(:to_1) { FactoryBot.create(:work_package, type: type_1, project: project) } + let(:to_2) { FactoryBot.create(:work_package, type: type_2, project: project) } let!(:relation_1) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: work_package, to: to_1, relation_type: Relation::TYPE_FOLLOWS end let!(:relation_2) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: work_package, to: to_2, relation_type: Relation::TYPE_RELATES @@ -117,17 +117,17 @@ describe 'Work package relations tab', js: true, selenium: true do describe 'with limited permissions' do let(:permissions) { %i(view_work_packages) } let(:user_role) do - FactoryGirl.create :role, permissions: permissions + FactoryBot.create :role, permissions: permissions end let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: user_role end context 'as view-only user, with parent set' do - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } it 'shows no links to create relations' do # No create buttons should exist @@ -143,7 +143,7 @@ describe 'Work package relations tab', js: true, selenium: true do %i(view_work_packages add_work_packages manage_subtasks manage_work_package_relations) end - let!(:relatable) { FactoryGirl.create(:work_package, project: project) } + let!(:relatable) { FactoryBot.create(:work_package, project: project) } it 'should allow to manage relations' do relations.add_relation(type: 'follows', to: relatable) diff --git a/spec/features/work_packages/details/textile/activity_comments_spec.rb b/spec/features/work_packages/details/textile/activity_comments_spec.rb index ee4fddca77..2ab644a3a8 100644 --- a/spec/features/work_packages/details/textile/activity_comments_spec.rb +++ b/spec/features/work_packages/details/textile/activity_comments_spec.rb @@ -6,9 +6,9 @@ require 'features/work_packages/details/inplace_editor/shared_examples' describe 'activity comments (textile)', with_settings: { text_formatting: 'textile' }, js: true do - let(:project) { FactoryGirl.create :project, is_public: true } + let(:project) { FactoryBot.create :project, is_public: true } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, journal_notes: initial_comment) } @@ -27,7 +27,7 @@ describe 'activity comments (textile)', end context 'with permission' do - let(:current_user) { FactoryGirl.create :admin } + let(:current_user) { FactoryBot.create :admin } before do wp_page.visit! @@ -119,7 +119,7 @@ describe 'activity comments (textile)', end describe 'autocomplete' do - let!(:wp2) { FactoryGirl.create(:work_package, project: project, subject: 'AutoFoo') } + let!(:wp2) { FactoryBot.create(:work_package, project: project, subject: 'AutoFoo') } it 'autocompletes the other work package' do comment_field.input_element.send_keys("##{wp2.id}") @@ -200,8 +200,8 @@ describe 'activity comments (textile)', end context 'with no permission' do - let(:current_user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) } + let(:current_user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create :role, permissions: %i(view_work_packages) } before do wp_page.visit! diff --git a/spec/features/work_packages/details/textile/description_editor_spec.rb b/spec/features/work_packages/details/textile/description_editor_spec.rb index 26d7d022f9..d7ae314707 100644 --- a/spec/features/work_packages/details/textile/description_editor_spec.rb +++ b/spec/features/work_packages/details/textile/description_editor_spec.rb @@ -33,18 +33,18 @@ require 'support/work_packages/work_package_field' require 'features/work_packages/work_packages_page' describe 'description inplace editor', js: true, selenium: true do - let(:project) { FactoryGirl.create :project_with_types, is_public: true } + let(:project) { FactoryBot.create :project_with_types, is_public: true } let(:property_name) { :description } let(:property_title) { 'Description' } let(:description_text) { 'Ima description' } let!(:work_package) { - FactoryGirl.create( + FactoryBot.create( :work_package, project: project, description: description_text ) } - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:field) { WorkPackageEditorField.new wp_page, 'description' } let(:wp_page) { Pages::SplitWorkPackage.new(work_package, project) } @@ -106,8 +106,8 @@ describe 'description inplace editor', js: true, selenium: true do end context 'with no permission' do - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create :role, permissions: %i(view_work_packages) } it 'does not show the field' do expect(page).to have_no_selector('.wp-edit-field.description.-editable') diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb index c4f5b319c8..111d6c782e 100644 --- a/spec/features/work_packages/edit_work_package_spec.rb +++ b/spec/features/work_packages/edit_work_package_spec.rb @@ -3,24 +3,24 @@ require 'features/page_objects/notification' describe 'edit work package', js: true do let(:dev_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :add_work_packages] end let(:dev) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Dev', lastname: 'Guy', member_in_project: project, member_through_role: dev_role end let(:manager_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :edit_work_packages] end let(:manager) do - FactoryGirl.create :admin, + FactoryBot.create :admin, firstname: 'Manager', lastname: 'Guy', member_in_project: project, @@ -28,22 +28,22 @@ describe 'edit work package', js: true do end let(:cf_all) do - FactoryGirl.create :work_package_custom_field, is_for_all: true, field_format: 'text' + FactoryBot.create :work_package_custom_field, is_for_all: true, field_format: 'text' end let(:cf_tp1) do - FactoryGirl.create :work_package_custom_field, is_for_all: true, field_format: 'text' + FactoryBot.create :work_package_custom_field, is_for_all: true, field_format: 'text' end let(:cf_tp2) do - FactoryGirl.create :work_package_custom_field, is_for_all: true, field_format: 'text' + FactoryBot.create :work_package_custom_field, is_for_all: true, field_format: 'text' end - let(:type) { FactoryGirl.create :type, custom_fields: [cf_all, cf_tp1] } - let(:type2) { FactoryGirl.create :type, custom_fields: [cf_all, cf_tp2] } - let(:project) { FactoryGirl.create(:project, types: [type, type2]) } + let(:type) { FactoryBot.create :type, custom_fields: [cf_all, cf_tp1] } + let(:type2) { FactoryBot.create :type, custom_fields: [cf_all, cf_tp2] } + let(:project) { FactoryBot.create(:project, types: [type, type2]) } let(:work_package) { - work_package = FactoryGirl.create(:work_package, + work_package = FactoryBot.create(:work_package, author: dev, project: project, type: type, @@ -58,17 +58,17 @@ describe 'edit work package', js: true do let(:new_subject) { 'Some other subject' } let(:wp_page) { Pages::FullWorkPackage.new(work_package) } - let(:priority2) { FactoryGirl.create :priority } - let(:status2) { FactoryGirl.create :status } + let(:priority2) { FactoryBot.create :priority } + let(:status2) { FactoryBot.create :status } let(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type2.id, old_status: work_package.status, new_status: status2, role: manager_role end - let(:version) { FactoryGirl.create :version, project: project } - let(:category) { FactoryGirl.create :category, project: project } + let(:version) { FactoryBot.create :version, project: project } + let(:category) { FactoryBot.create :category, project: project } let(:visit_before) { true } @@ -162,7 +162,7 @@ describe 'edit work package', js: true do context 'switching to custom field with required CF' do let(:custom_field) { - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', default_value: nil, @@ -170,7 +170,7 @@ describe 'edit work package', js: true do is_for_all: true ) } - let!(:type2) { FactoryGirl.create(:type, custom_fields: [custom_field]) } + let!(:type2) { FactoryBot.create(:type, custom_fields: [custom_field]) } it 'shows the required field when switching' do type_field = wp_page.edit_field(:type) diff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rb index ff0ab073c6..5930bf7806 100644 --- a/spec/features/work_packages/export_spec.rb +++ b/spec/features/work_packages/export_spec.rb @@ -30,16 +30,16 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' describe 'work package export', type: :feature do - let(:project) { FactoryGirl.create :project_with_types, types: [type_a, type_b] } - let(:current_user) { FactoryGirl.create :admin } + let(:project) { FactoryBot.create :project_with_types, types: [type_a, type_b] } + let(:current_user) { FactoryBot.create :admin } - let(:type_a) { FactoryGirl.create :type, name: "Type A" } - let(:type_b) { FactoryGirl.create :type, name: "Type B" } + let(:type_a) { FactoryBot.create :type, name: "Type A" } + let(:type_b) { FactoryBot.create :type, name: "Type B" } - let(:wp_1) { FactoryGirl.create :work_package, project: project, done_ratio: 25, type: type_a } - let(:wp_2) { FactoryGirl.create :work_package, project: project, done_ratio: 0, type: type_a } - let(:wp_3) { FactoryGirl.create :work_package, project: project, done_ratio: 0, type: type_b } - let(:wp_4) { FactoryGirl.create :work_package, project: project, done_ratio: 0, type: type_a } + let(:wp_1) { FactoryBot.create :work_package, project: project, done_ratio: 25, type: type_a } + let(:wp_2) { FactoryBot.create :work_package, project: project, done_ratio: 0, type: type_a } + let(:wp_3) { FactoryBot.create :work_package, project: project, done_ratio: 0, type: type_b } + let(:wp_4) { FactoryBot.create :work_package, project: project, done_ratio: 0, type: type_a } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } diff --git a/spec/features/work_packages/indem_sums_spec.rb b/spec/features/work_packages/indem_sums_spec.rb index eca8d1f7a4..b7645061db 100644 --- a/spec/features/work_packages/indem_sums_spec.rb +++ b/spec/features/work_packages/indem_sums_spec.rb @@ -30,16 +30,16 @@ require 'spec_helper' RSpec.feature 'Work package index sums', js: true do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } let(:project) { - FactoryGirl.create(:project, name: 'project1', identifier: 'project1') + FactoryBot.create(:project, name: 'project1', identifier: 'project1') } let!(:work_package_1) { - FactoryGirl.create(:work_package, project: project, estimated_hours: 10) + FactoryBot.create(:work_package, project: project, estimated_hours: 10) } let!(:work_package_2) { - FactoryGirl.create(:work_package, project: project, estimated_hours: 15) + FactoryBot.create(:work_package, project: project, estimated_hours: 15) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb index cc645a2324..d3d4037191 100644 --- a/spec/features/work_packages/navigation_spec.rb +++ b/spec/features/work_packages/navigation_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' RSpec.feature 'Work package navigation', js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.build(:work_package, project: project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.build(:work_package, project: project) } before do login_as(user) diff --git a/spec/features/work_packages/new/attributes_from_filter_spec.rb b/spec/features/work_packages/new/attributes_from_filter_spec.rb index 994a015464..e1c76e4701 100644 --- a/spec/features/work_packages/new/attributes_from_filter_spec.rb +++ b/spec/features/work_packages/new/attributes_from_filter_spec.rb @@ -29,23 +29,23 @@ require 'spec_helper' RSpec.feature 'Work package create uses attributes from filters', js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:type_bug) { FactoryGirl.create(:type_bug) } - let(:type_task) { FactoryGirl.create(:type_task) } - let(:project) { FactoryGirl.create(:project, types: [type_task, type_bug]) } - let(:status) { FactoryGirl.create(:default_status) } + let(:user) { FactoryBot.create(:admin) } + let(:type_bug) { FactoryBot.create(:type_bug) } + let(:type_task) { FactoryBot.create(:type_task) } + let(:project) { FactoryBot.create(:project, types: [type_task, type_bug]) } + let(:status) { FactoryBot.create(:default_status) } - let!(:status) { FactoryGirl.create(:default_status) } - let!(:priority) { FactoryGirl.create :priority, is_default: true } + let!(:status) { FactoryBot.create(:default_status) } + let!(:priority) { FactoryBot.create :priority, is_default: true } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } let(:split_view_create) { ::Pages::SplitWorkPackageCreate.new(project: project) } let(:filters) { ::Components::WorkPackages::Filters.new } - let(:role) { FactoryGirl.create :existing_role, permissions: [:view_work_packages] } + let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] } let!(:assignee) do - FactoryGirl.create(:user, + FactoryBot.create(:user, firstname: 'An', lastname: 'assignee', member_in_project: project, @@ -53,7 +53,7 @@ RSpec.feature 'Work package create uses attributes from filters', js: true, sele end let!(:query) do - FactoryGirl.build(:query, project: project, user: user).tap do |query| + FactoryBot.build(:query, project: project, user: user).tap do |query| query.filters.clear query.column_names = ['id', 'subject', 'type', 'assigned_to'] query.save! diff --git a/spec/features/work_packages/new/create_child_spec.rb b/spec/features/work_packages/new/create_child_spec.rb index 9e55f36415..fa67a6da77 100644 --- a/spec/features/work_packages/new/create_child_spec.rb +++ b/spec/features/work_packages/new/create_child_spec.rb @@ -30,28 +30,28 @@ require 'spec_helper' RSpec.feature 'Work package create children', js: true, selenium: true do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: create_role) end let(:work_flow) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, role: create_role, type_id: original_work_package.type_id, old_status: original_work_package.status, - new_status: FactoryGirl.create(:status)) + new_status: FactoryBot.create(:status)) end let(:create_role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages, :add_work_packages, :edit_work_packages, :manage_subtasks]) end - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:original_work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, project: project, assigned_to: assignee, responsible: responsible, @@ -61,35 +61,35 @@ RSpec.feature 'Work package create children', js: true, selenium: true do status: default_status) end let(:default_priority) do - FactoryGirl.build(:default_priority) + FactoryBot.build(:default_priority) end let(:default_status) do - FactoryGirl.build(:default_status) + FactoryBot.build(:default_status) end - let(:role) { FactoryGirl.build(:role, permissions: [:view_work_packages]) } + let(:role) { FactoryBot.build(:role, permissions: [:view_work_packages]) } let(:assignee) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'An', lastname: 'assignee', member_in_project: project, member_through_role: role) end let(:responsible) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'The', lastname: 'responsible', member_in_project: project, member_through_role: role) end let(:author) do - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'The', lastname: 'author', member_in_project: project, member_through_role: role) end let(:version) do - FactoryGirl.build(:version, + FactoryBot.build(:version, project: project) end diff --git a/spec/features/work_packages/new/new_work_package_spec.rb b/spec/features/work_packages/new/new_work_package_spec.rb index e93d372f00..a9889a77f9 100644 --- a/spec/features/work_packages/new/new_work_package_spec.rb +++ b/spec/features/work_packages/new/new_work_package_spec.rb @@ -4,16 +4,16 @@ require 'features/work_packages/work_packages_page' require 'features/page_objects/notification' describe 'new work package', js: true do - let(:type_task) { FactoryGirl.create(:type_task) } - let(:type_bug) { FactoryGirl.create(:type_bug) } + let(:type_task) { FactoryBot.create(:type_task) } + let(:type_bug) { FactoryBot.create(:type_bug) } let(:types) { [type_task, type_bug] } - let!(:status) { FactoryGirl.create(:status, is_default: true) } - let!(:priority) { FactoryGirl.create(:priority, is_default: true) } + let!(:status) { FactoryBot.create(:status, is_default: true) } + let!(:priority) { FactoryBot.create(:priority, is_default: true) } let!(:project) do - FactoryGirl.create(:project, types: types) + FactoryBot.create(:project, types: types) end - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:subject) { 'My subject' } @@ -26,7 +26,7 @@ describe 'new work package', js: true do let(:notification) { PageObjects::Notifications.new(page) } def disable_leaving_unsaved_warning - FactoryGirl.create(:user_preference, user: user, others: { warn_on_leaving_unsaved: false }) + FactoryBot.create(:user_preference, user: user, others: { warn_on_leaving_unsaved: false }) end def save_work_package!(expect_success = true) @@ -140,7 +140,7 @@ describe 'new work package', js: true do context 'custom fields' do let(:custom_field1) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', is_required: true, @@ -148,7 +148,7 @@ describe 'new work package', js: true do ) end let(:custom_field2) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'list', possible_values: %w(foo bar xyz), @@ -158,9 +158,9 @@ describe 'new work package', js: true do let(:custom_fields) do [custom_field1, custom_field2] end - let(:type_task) { FactoryGirl.create(:type_task, custom_fields: custom_fields) } + let(:type_task) { FactoryBot.create(:type_task, custom_fields: custom_fields) } let(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, types: types, work_package_custom_fields: custom_fields) end @@ -237,7 +237,7 @@ describe 'new work package', js: true do context 'full screen' do let(:safeguard_selector) { '.work-package--new-state' } - let(:existing_wp) { FactoryGirl.create :work_package, type: type_bug, project: project } + let(:existing_wp) { FactoryBot.create :work_package, type: type_bug, project: project } let(:wp_page) { Pages::FullWorkPackage.new(existing_wp) } before do @@ -265,8 +265,8 @@ describe 'new work package', js: true do end context 'as a user with no permissions' do - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create :role, permissions: %i(view_work_packages) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create :role, permissions: %i(view_work_packages) } let(:wp_page) { ::Pages::Page.new } let(:paths) do @@ -287,7 +287,7 @@ describe 'new work package', js: true do end context 'a anonymous user is prompted to login' do - let(:user) { FactoryGirl.create(:anonymous) } + let(:user) { FactoryBot.create(:anonymous) } let(:wp_page) { ::Pages::Page.new } let(:paths) do diff --git a/spec/features/work_packages/pagination_spec.rb b/spec/features/work_packages/pagination_spec.rb index f5a83f9c2c..b034856fa6 100644 --- a/spec/features/work_packages/pagination_spec.rb +++ b/spec/features/work_packages/pagination_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' RSpec.feature 'Work package pagination', js: true do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } let(:project) { - FactoryGirl.create(:project, name: 'project1', identifier: 'project1') + FactoryBot.create(:project, name: 'project1', identifier: 'project1') } shared_examples_for 'paginated work package list' do - let!(:work_package_1) { FactoryGirl.create(:work_package, project: project) } - let!(:work_package_2) { FactoryGirl.create(:work_package, project: project) } + let!(:work_package_1) { FactoryBot.create(:work_package, project: project) } + let!(:work_package_2) { FactoryBot.create(:work_package, project: project) } before do login_as(admin) diff --git a/spec/features/work_packages/project_context_switch_spec.rb b/spec/features/work_packages/project_context_switch_spec.rb index 4082b5433e..f06685f0a0 100644 --- a/spec/features/work_packages/project_context_switch_spec.rb +++ b/spec/features/work_packages/project_context_switch_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe 'Project context switching spec', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { Pages::WorkPackagesTable.new } let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) } diff --git a/spec/features/work_packages/select_query_spec.rb b/spec/features/work_packages/select_query_spec.rb index 88c6bf969f..9d4f515d94 100644 --- a/spec/features/work_packages/select_query_spec.rb +++ b/spec/features/work_packages/select_query_spec.rb @@ -30,10 +30,10 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' describe 'Query selection', type: :feature do - let(:project) { FactoryGirl.create :project, identifier: 'test_project', is_public: false } - let(:role) { FactoryGirl.create :role, permissions: [:view_work_packages] } + let(:project) { FactoryBot.create :project, identifier: 'test_project', is_public: false } + let(:role) { FactoryBot.create :role, permissions: [:view_work_packages] } let(:current_user) do - FactoryGirl.create :user, member_in_project: project, + FactoryBot.create :user, member_in_project: project, member_through_role: role end @@ -41,10 +41,10 @@ describe 'Query selection', type: :feature do let(:filter_2_name) { 'percentageDone' } let(:i18n_filter_1_name) { WorkPackage.human_attribute_name(:assigned_to) } let(:i18n_filter_2_name) { WorkPackage.human_attribute_name(:done_ratio) } - let(:default_status) { FactoryGirl.create(:default_status) } + let(:default_status) { FactoryBot.create(:default_status) } let(:query) do - FactoryGirl.build(:query, project: project, is_public: true).tap do |query| + FactoryBot.build(:query, project: project, is_public: true).tap do |query| query.filters.clear query.add_filter('assigned_to_id', '=', ['me']) query.add_filter('done_ratio', '>=', [10]) @@ -100,7 +100,7 @@ describe 'Query selection', type: :feature do context 'when the selected query is changed' do let(:query2) do - FactoryGirl.create(:query, project: project, is_public: true) + FactoryBot.create(:query, project: project, is_public: true) end before do diff --git a/spec/features/work_packages/select_work_package_row_spec.rb b/spec/features/work_packages/select_work_package_row_spec.rb index 86aae8fb9e..adf8117b5b 100644 --- a/spec/features/work_packages/select_work_package_row_spec.rb +++ b/spec/features/work_packages/select_work_package_row_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe 'Select work package row', type: :feature, js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } - let(:work_package_1) { FactoryGirl.create(:work_package, project: project) } - let(:work_package_2) { FactoryGirl.create(:work_package, project: project) } - let(:work_package_3) { FactoryGirl.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } + let(:work_package_1) { FactoryBot.create(:work_package, project: project) } + let(:work_package_2) { FactoryBot.create(:work_package, project: project) } + let(:work_package_3) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } include_context 'work package table helpers' diff --git a/spec/features/work_packages/table/configuration_modal/filter_spec.rb b/spec/features/work_packages/table/configuration_modal/filter_spec.rb index 1f6b702487..4279e01808 100644 --- a/spec/features/work_packages/table/configuration_modal/filter_spec.rb +++ b/spec/features/work_packages/table/configuration_modal/filter_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' describe 'Work Package table configuration modal filters spec', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create(:project) } - let!(:wp_1) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let!(:wp_1) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:modal) { ::Components::WorkPackages::TableConfigurationModal.new } let(:filters) { ::Components::WorkPackages::TableConfiguration::Filters.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'done_ratio'] query.save! @@ -23,9 +23,9 @@ describe 'Work Package table configuration modal filters spec', js: true do end context 'by version in project' do - let(:version) { FactoryGirl.create :version, project: project } - let(:work_package_with_version) { FactoryGirl.create :work_package, project: project, fixed_version: version } - let(:work_package_without_version) { FactoryGirl.create :work_package, project: project } + let(:version) { FactoryBot.create :version, project: project } + let(:work_package_with_version) { FactoryBot.create :work_package, project: project, fixed_version: version } + let(:work_package_without_version) { FactoryBot.create :work_package, project: project } before do work_package_with_version diff --git a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb index 21ec163f35..61a82766ce 100644 --- a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb +++ b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' describe 'Work Package table configuration modal', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create(:project) } - let!(:wp_1) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let!(:wp_1) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:modal) { ::Components::WorkPackages::TableConfigurationModal.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'done_ratio'] query.save! diff --git a/spec/features/work_packages/table/context_menu_spec.rb b/spec/features/work_packages/table/context_menu_spec.rb index 6985b81332..6657d5de69 100644 --- a/spec/features/work_packages/table/context_menu_spec.rb +++ b/spec/features/work_packages/table/context_menu_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe 'Work package table context menu', js: true do - let(:user) { FactoryGirl.create(:admin) } - let(:work_package) { FactoryGirl.create(:work_package) } + let(:user) { FactoryBot.create(:admin) } + let(:work_package) { FactoryBot.create(:work_package) } let(:wp_table) { Pages::WorkPackagesTable.new } let(:wp_timeline) { Pages::WorkPackagesTimeline.new(work_package.project) } @@ -87,7 +87,7 @@ describe 'Work package table context menu', js: true do end context 'multiple selected' do - let!(:work_package2) { FactoryGirl.create(:work_package) } + let!(:work_package2) { FactoryBot.create(:work_package) } before do # Go to table diff --git a/spec/features/work_packages/table/delete_work_packages.spec.rb b/spec/features/work_packages/table/delete_work_packages.spec.rb index a22f9190c9..c69381ba95 100644 --- a/spec/features/work_packages/table/delete_work_packages.spec.rb +++ b/spec/features/work_packages/table/delete_work_packages.spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'Delete work package', js: true do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } let(:context_menu) { Components::WorkPackages::ContextMenu.new } let(:destroy_modal) { Components::WorkPackages::DestroyModal.new } @@ -62,9 +62,9 @@ describe 'Delete work package', js: true do end describe 'deleting multiple work packages in the table' do - let!(:wp1) { FactoryGirl.create(:work_package) } - let!(:wp2) { FactoryGirl.create(:work_package) } - let!(:wp_child) { FactoryGirl.create(:work_package, parent: wp1) } + let!(:wp1) { FactoryBot.create(:work_package) } + let!(:wp2) { FactoryBot.create(:work_package) } + let!(:wp_child) { FactoryBot.create(:work_package, parent: wp1) } let(:wp_table) { Pages::WorkPackagesTable.new } @@ -91,7 +91,7 @@ describe 'Delete work package', js: true do end describe 'when deleting it outside a project context' do - let(:work_package) { FactoryGirl.create(:work_package) } + let(:work_package) { FactoryBot.create(:work_package) } let(:split_view) { Pages::SplitWorkPackage.new(work_package) } let(:wp_table) { Pages::WorkPackagesTable.new } @@ -99,8 +99,8 @@ describe 'Delete work package', js: true do end describe 'when deleting it within a project context' do - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project:project) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project:project) } let(:split_view) { Pages::SplitWorkPackage.new(work_package, project.identifier) } let(:wp_table) { Pages::WorkPackagesTable.new(project.identifier) } diff --git a/spec/features/work_packages/table/edit_work_packages_spec.rb b/spec/features/work_packages/table/edit_work_packages_spec.rb index 43cdbca61c..80a0c9896b 100644 --- a/spec/features/work_packages/table/edit_work_packages_spec.rb +++ b/spec/features/work_packages/table/edit_work_packages_spec.rb @@ -2,24 +2,24 @@ require 'spec_helper' describe 'Inline editing work packages', js: true do let(:manager_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :edit_work_packages] end let(:manager) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Manager', lastname: 'Guy', member_in_project: project, member_through_role: manager_role end - let(:type) { FactoryGirl.create :type } - let(:status1) { FactoryGirl.create :status } - let(:status2) { FactoryGirl.create :status } + let(:type) { FactoryBot.create :type } + let(:status1) { FactoryBot.create :status } + let(:status2) { FactoryBot.create :status } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type, status: status1, @@ -29,14 +29,14 @@ describe 'Inline editing work packages', js: true do let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status1, new_status: status2, role: manager_role end - let(:version) { FactoryGirl.create :version, project: project } - let(:category) { FactoryGirl.create :category, project: project } + let(:version) { FactoryBot.create :version, project: project } + let(:category) { FactoryBot.create :category, project: project } before do login_as(manager) @@ -118,14 +118,14 @@ describe 'Inline editing work packages', js: true do context 'custom field' do let(:custom_fields) { fields = [ - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'list', possible_values: %w(foo bar xyz), is_required: true, is_for_all: false ), - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', is_required: true, @@ -135,10 +135,10 @@ describe 'Inline editing work packages', js: true do fields } - let(:type) { FactoryGirl.create(:type_task, custom_fields: custom_fields) } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create(:type_task, custom_fields: custom_fields) } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: 'Foobar', status: status1, type: type, diff --git a/spec/features/work_packages/table/empty_filters_spec.rb b/spec/features/work_packages/table/empty_filters_spec.rb index 7ff76f7f1d..69e2002436 100644 --- a/spec/features/work_packages/table/empty_filters_spec.rb +++ b/spec/features/work_packages/table/empty_filters_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe 'Empty query filters', js: true do - let(:user) { FactoryGirl.create(:admin) } - let(:work_package) { FactoryGirl.create(:work_package) } + let(:user) { FactoryBot.create(:admin) } + let(:work_package) { FactoryBot.create(:work_package) } let(:wp_table) { ::Pages::WorkPackagesTable.new } let(:filters) { ::Components::WorkPackages::Filters.new } diff --git a/spec/features/work_packages/table/group_by/group_by_progress_spec.rb b/spec/features/work_packages/table/group_by/group_by_progress_spec.rb index a8a3910792..8b533c160b 100644 --- a/spec/features/work_packages/table/group_by/group_by_progress_spec.rb +++ b/spec/features/work_packages/table/group_by/group_by_progress_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' describe 'Work Package group by progress', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } - let!(:wp_1) { FactoryGirl.create(:work_package, project: project) } - let!(:wp_2) { FactoryGirl.create(:work_package, project: project, done_ratio: 10) } - let!(:wp_3) { FactoryGirl.create(:work_package, project: project, done_ratio: 10) } - let!(:wp_4) { FactoryGirl.create(:work_package, project: project, done_ratio: 50) } + let!(:wp_1) { FactoryBot.create(:work_package, project: project) } + let!(:wp_2) { FactoryBot.create(:work_package, project: project, done_ratio: 10) } + let!(:wp_3) { FactoryBot.create(:work_package, project: project, done_ratio: 10) } + let!(:wp_4) { FactoryBot.create(:work_package, project: project, done_ratio: 50) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:group_by) { ::Components::WorkPackages::GroupBy.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'done_ratio'] query.save! @@ -52,7 +52,7 @@ describe 'Work Package group by progress', js: true do context 'with grouped query' do let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'done_ratio'] query.group_by = 'done_ratio' diff --git a/spec/features/work_packages/table/group_by/group_headers_spec.rb b/spec/features/work_packages/table/group_by/group_headers_spec.rb index cd0a9451d5..9b00c4dd5c 100644 --- a/spec/features/work_packages/table/group_by/group_headers_spec.rb +++ b/spec/features/work_packages/table/group_by/group_headers_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' describe 'Work Package table group headers', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project) { FactoryGirl.create(:project) } - let(:category) { FactoryGirl.create :category, project: project, name: 'Foo' } - let(:category2) { FactoryGirl.create :category, project: project, name: 'Bar' } + let(:project) { FactoryBot.create(:project) } + let(:category) { FactoryBot.create :category, project: project, name: 'Foo' } + let(:category2) { FactoryBot.create :category, project: project, name: 'Bar' } - let!(:wp_cat1) { FactoryGirl.create(:work_package, project: project, category: category) } - let!(:wp_cat2) { FactoryGirl.create(:work_package, project: project, category: category2) } - let!(:wp_none) { FactoryGirl.create(:work_package, project: project) } + let!(:wp_cat1) { FactoryBot.create(:work_package, project: project, category: category) } + let!(:wp_cat2) { FactoryBot.create(:work_package, project: project, category: category2) } + let!(:wp_none) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:group_by) { ::Components::WorkPackages::GroupBy.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'category'] query.show_hierarchies = false diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb index be1173e1a1..739b0023dd 100644 --- a/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb +++ b/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe 'Work Package table hierarchy parent below', js: true do - let(:user) { FactoryGirl.create :admin } - let(:type_bug) { FactoryGirl.create(:type_bug) } - let(:type_task) { FactoryGirl.create(:type_task) } - let(:project) { FactoryGirl.create(:project, types: [type_task, type_bug]) } + let(:user) { FactoryBot.create :admin } + let(:type_bug) { FactoryBot.create(:type_bug) } + let(:type_task) { FactoryBot.create(:type_task) } + let(:project) { FactoryBot.create(:project, types: [type_task, type_bug]) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:hierarchy) { ::Components::WorkPackages::Hierarchies.new } @@ -34,12 +34,12 @@ describe 'Work Package table hierarchy parent below', js: true do # .... Child # V Grandparent describe 'grand-parent sorted below child, parent invisible' do - let(:child) { FactoryGirl.create(:work_package, project: project, type: type_task) } - let(:parent) { FactoryGirl.create(:work_package, project: project, type: type_bug) } - let(:grandparent) { FactoryGirl.create(:work_package, project: project, type: type_task) } + let(:child) { FactoryBot.create(:work_package, project: project, type: type_task) } + let(:parent) { FactoryBot.create(:work_package, project: project, type: type_bug) } + let(:grandparent) { FactoryBot.create(:work_package, project: project, type: type_task) } let(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['id', 'subject', 'type'] query.filters.clear query.add_filter('type_id', '=', [type_task.id]) diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb index 2e07da829b..04bd57aa37 100644 --- a/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb +++ b/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe 'Work Package table hierarchy', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create(:project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:hierarchy) { ::Components::WorkPackages::Hierarchies.new } @@ -12,15 +12,15 @@ describe 'Work Package table hierarchy', js: true do end describe 'hierarchies in same project' do - let(:category) { FactoryGirl.create :category, project: project, name: 'Foo' } + let(:category) { FactoryBot.create :category, project: project, name: 'Foo' } - let!(:wp_root) { FactoryGirl.create(:work_package, project: project) } - let!(:wp_inter) { FactoryGirl.create(:work_package, project: project, parent: wp_root) } - let!(:wp_leaf) { FactoryGirl.create(:work_package, project: project, category: category, parent: wp_inter) } - let!(:wp_other) { FactoryGirl.create(:work_package, project: project) } + let!(:wp_root) { FactoryBot.create(:work_package, project: project) } + let!(:wp_inter) { FactoryBot.create(:work_package, project: project, parent: wp_root) } + let!(:wp_leaf) { FactoryBot.create(:work_package, project: project, category: category, parent: wp_inter) } + let!(:wp_other) { FactoryBot.create(:work_package, project: project) } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'category'] query.filters.clear query.add_filter('category_id', '=', [category.id]) @@ -89,9 +89,9 @@ describe 'Work Package table hierarchy', js: true do end describe 'with a cross project hierarchy' do - let(:project2) { FactoryGirl.create(:project) } - let!(:wp_root) { FactoryGirl.create(:work_package, project: project) } - let!(:wp_inter) { FactoryGirl.create(:work_package, project: project2, parent: wp_root) } + let(:project2) { FactoryBot.create(:project) } + let!(:wp_root) { FactoryBot.create(:work_package, project: project) } + let!(:wp_inter) { FactoryBot.create(:work_package, project: project2, parent: wp_root) } let(:global_table) { Pages::WorkPackagesTable.new } it 'shows the hierarchy indicator only when the rows are both shown' do wp_table.visit! @@ -108,12 +108,12 @@ describe 'Work Package table hierarchy', js: true do end describe 'flat table such that the parent appears below the child' do - let!(:wp_root) { FactoryGirl.create(:work_package, project: project) } - let!(:wp_inter) { FactoryGirl.create(:work_package, project: project, parent: wp_root) } - let!(:wp_leaf) { FactoryGirl.create(:work_package, project: project, parent: wp_inter) } + let!(:wp_root) { FactoryBot.create(:work_package, project: project) } + let!(:wp_inter) { FactoryBot.create(:work_package, project: project, parent: wp_root) } + let!(:wp_leaf) { FactoryBot.create(:work_package, project: project, parent: wp_inter) } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'category'] query.filters.clear query.show_hierarchies = false @@ -155,35 +155,35 @@ describe 'Work Package table hierarchy', js: true do describe 'sorting by assignee' do include_context 'work package table helpers' let!(:root_assigned) do - FactoryGirl.create(:work_package, subject: 'root_assigned', project: project, assigned_to: user) + FactoryBot.create(:work_package, subject: 'root_assigned', project: project, assigned_to: user) end let!(:inter_assigned) do - FactoryGirl.create(:work_package, subject: 'inter_assigned', project: project, assigned_to: user, parent: root_assigned) + FactoryBot.create(:work_package, subject: 'inter_assigned', project: project, assigned_to: user, parent: root_assigned) end let!(:inter) do - FactoryGirl.create(:work_package, subject: 'inter', project: project, parent: root_assigned) + FactoryBot.create(:work_package, subject: 'inter', project: project, parent: root_assigned) end let!(:leaf_assigned) do - FactoryGirl.create(:work_package, subject: 'leaf_assigned', project: project, assigned_to: user, parent: inter) + FactoryBot.create(:work_package, subject: 'leaf_assigned', project: project, assigned_to: user, parent: inter) end let!(:leaf) do - FactoryGirl.create(:work_package, subject: 'leaf', project: project, parent: inter) + FactoryBot.create(:work_package, subject: 'leaf', project: project, parent: inter) end let!(:root) do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) end let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end let(:permissions) { %i(view_work_packages add_work_packages) } - let(:role) { FactoryGirl.create :role, permissions: permissions } + let(:role) { FactoryBot.create :role, permissions: permissions } let(:sort_by) { ::Components::WorkPackages::SortBy.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'assigned_to'] query.filters.clear query.sort_criteria = [['assigned_to', 'asc']] diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_vs_grouping_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_vs_grouping_spec.rb index 5a5f892a28..798c915159 100644 --- a/spec/features/work_packages/table/hierarchy/hierarchy_vs_grouping_spec.rb +++ b/spec/features/work_packages/table/hierarchy/hierarchy_vs_grouping_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'Work Package table hierarchy vs grouping', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create(:project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:hierarchy) { ::Components::WorkPackages::Hierarchies.new } diff --git a/spec/features/work_packages/table/hierarchy/parent_column_spec.rb b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb index fbff2e3427..40ccba32d4 100644 --- a/spec/features/work_packages/table/hierarchy/parent_column_spec.rb +++ b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe 'Work Package table parent column', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create(:project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } @@ -11,11 +11,11 @@ describe 'Work Package table parent column', js: true do end - let!(:parent) { FactoryGirl.create(:work_package, project: project) } - let!(:child) { FactoryGirl.create(:work_package, project: project, parent: parent) } + let!(:parent) { FactoryBot.create(:work_package, project: project) } + let!(:child) { FactoryBot.create(:work_package, project: project, parent: parent) } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'parent'] query.filters.clear query.show_hierarchies = false diff --git a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb index 4281b8fddd..554a12e522 100644 --- a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb +++ b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' describe 'inline create work package', js: true do - let(:type) { FactoryGirl.create(:type) } + let(:type) { FactoryBot.create(:type) } let(:types) { [type] } let(:permissions) { %i(view_work_packages add_work_packages)} - let(:role) { FactoryGirl.create :role, permissions: permissions } + let(:role) { FactoryBot.create :role, permissions: permissions } let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end - let(:status) { FactoryGirl.create(:default_status) } + let(:status) { FactoryBot.create(:default_status) } let(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status, - new_status: FactoryGirl.create(:status), + new_status: FactoryBot.create(:status), role: role end - let!(:project) { FactoryGirl.create(:project, is_public: true, types: types) } - let!(:existing_wp) { FactoryGirl.create(:work_package, project: project) } - let!(:priority) { FactoryGirl.create :priority, is_default: true } + let!(:project) { FactoryBot.create(:project, is_public: true, types: types) } + let!(:existing_wp) { FactoryBot.create(:work_package, project: project) } + let!(:priority) { FactoryBot.create :priority, is_default: true } before do workflow @@ -132,14 +132,14 @@ describe 'inline create work package', js: true do context 'user has permissions in other project' do let(:permissions) { [:view_work_packages] } - let(:project2) { FactoryGirl.create :project } + let(:project2) { FactoryBot.create :project } let(:role2) { - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :add_work_packages] } let!(:membership) { - FactoryGirl.create :member, + FactoryBot.create :member, user: user, project: project2, roles: [role2] diff --git a/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb b/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb index 720346a1d2..58efcf83b1 100644 --- a/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb +++ b/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' describe 'Refreshing in inline-create row', flaky: true, js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:columns) { ::Components::WorkPackages::Columns.new } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'category'] query.filters.clear diff --git a/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb b/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb index f31639654e..f524e05371 100644 --- a/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb +++ b/spec/features/work_packages/table/inline_create/parallel_creation_spec.rb @@ -4,23 +4,23 @@ describe 'Parallel work package creation spec', js: true do let(:type) { project.types.first } let(:permissions) { %i(view_work_packages add_work_packages) } - let(:role) { FactoryGirl.create :role, permissions: permissions } + let(:role) { FactoryBot.create :role, permissions: permissions } let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end - let(:status) { FactoryGirl.create(:default_status) } + let(:status) { FactoryBot.create(:default_status) } let(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status, - new_status: FactoryGirl.create(:status), + new_status: FactoryBot.create(:status), role: role end - let!(:project) { FactoryGirl.create(:project, is_public: true) } - let!(:priority) { FactoryGirl.create :priority, is_default: true } + let!(:project) { FactoryBot.create(:project, is_public: true) } + let!(:priority) { FactoryBot.create :priority, is_default: true } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } before do diff --git a/spec/features/work_packages/table/invalid_query_spec.rb b/spec/features/work_packages/table/invalid_query_spec.rb index afe7a66e1c..51c3cce7ce 100644 --- a/spec/features/work_packages/table/invalid_query_spec.rb +++ b/spec/features/work_packages/table/invalid_query_spec.rb @@ -1,28 +1,28 @@ require 'spec_helper' describe 'Invalid query spec', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } let(:filters) { ::Components::WorkPackages::Filters.new } let(:group_by) { ::Components::WorkPackages::GroupBy.new } let(:member) do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: project, - roles: [FactoryGirl.create(:role)]) + roles: [FactoryBot.create(:role)]) end let(:status) do - FactoryGirl.create(:status) + FactoryBot.create(:status) end let(:status2) do - FactoryGirl.create(:status) + FactoryBot.create(:status) end let(:invalid_query) do - query = FactoryGirl.create(:query, + query = FactoryBot.create(:query, project: project, user: user) @@ -36,13 +36,13 @@ describe 'Invalid query spec', js: true do end let(:valid_query) do - FactoryGirl.create(:query, + FactoryBot.create(:query, project: project, user: user) end let(:work_package_assigned) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, status: status2, assigned_to: user) diff --git a/spec/features/work_packages/table/milestones_spec.rb b/spec/features/work_packages/table/milestones_spec.rb index 9ccd72fa5e..e425445c20 100644 --- a/spec/features/work_packages/table/milestones_spec.rb +++ b/spec/features/work_packages/table/milestones_spec.rb @@ -1,12 +1,12 @@ require 'spec_helper' describe 'Inline editing milestones', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:type) { FactoryGirl.create :type, is_milestone: true } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create :type, is_milestone: true } + let(:project) { FactoryBot.create(:project, types: [type]) } let!(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type, subject: 'Foobar') @@ -14,7 +14,7 @@ describe 'Inline editing milestones', js: true do let!(:wp_table) { Pages::WorkPackagesTable.new(project) } let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject', 'start_date', 'due_date'] query.filters.clear query.show_hierarchies = false diff --git a/spec/features/work_packages/table/queries/filter_spec.rb b/spec/features/work_packages/table/queries/filter_spec.rb index 9b19d941c0..4a4eca2bad 100644 --- a/spec/features/work_packages/table/queries/filter_spec.rb +++ b/spec/features/work_packages/table/queries/filter_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe 'filter work packages', js: true do - let(:user) { FactoryGirl.create :admin } - let(:watcher) { FactoryGirl.create :user } - let(:project) { FactoryGirl.create :project } - let(:role) { FactoryGirl.create :existing_role, permissions: [:view_work_packages] } + let(:user) { FactoryBot.create :admin } + let(:watcher) { FactoryBot.create :user } + let(:project) { FactoryBot.create :project } + let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } let(:filters) { ::Components::WorkPackages::Filters.new } @@ -43,13 +43,13 @@ describe 'filter work packages', js: true do context 'by watchers' do let(:work_package_with_watcher) do - wp = FactoryGirl.build :work_package, project: project + wp = FactoryBot.build :work_package, project: project wp.add_watcher watcher wp.save! wp end - let(:work_package_without_watcher) { FactoryGirl.create :work_package, project: project } + let(:work_package_without_watcher) { FactoryBot.create :work_package, project: project } before do work_package_with_watcher @@ -72,9 +72,9 @@ describe 'filter work packages', js: true do end context 'by version in project' do - let(:version) { FactoryGirl.create :version, project: project } - let(:work_package_with_version) { FactoryGirl.create :work_package, project: project, subject: 'With version', fixed_version: version } - let(:work_package_without_version) { FactoryGirl.create :work_package, subject: 'Without version', project: project } + let(:version) { FactoryBot.create :version, project: project } + let(:work_package_with_version) { FactoryBot.create :work_package, project: project, subject: 'With version', fixed_version: version } + let(:work_package_without_version) { FactoryBot.create :work_package, subject: 'Without version', project: project } before do work_package_with_version @@ -120,8 +120,8 @@ describe 'filter work packages', js: true do end context 'by due date outside of a project' do - let(:work_package_with_due_date) { FactoryGirl.create :work_package, project: project, due_date: Date.today } - let(:work_package_without_due_date) { FactoryGirl.create :work_package, project: project, due_date: Date.today + 5.days } + let(:work_package_with_due_date) { FactoryBot.create :work_package, project: project, due_date: Date.today } + let(:work_package_without_due_date) { FactoryBot.create :work_package, project: project, due_date: Date.today + 5.days } let(:wp_table) { ::Pages::WorkPackagesTable.new } before do @@ -175,7 +175,7 @@ describe 'filter work packages', js: true do context 'by list cf inside a project' do let(:type) do - type = FactoryGirl.create(:type) + type = FactoryBot.create(:type) project.types << type @@ -183,21 +183,21 @@ describe 'filter work packages', js: true do end let(:work_package_with_list_value) do - wp = FactoryGirl.create :work_package, project: project, type: type + wp = FactoryBot.create :work_package, project: project, type: type wp.send("#{list_cf.accessor_name}=", list_cf.custom_options.first.id) wp.save! wp end let(:work_package_with_anti_list_value) do - wp = FactoryGirl.create :work_package, project: project, type: type + wp = FactoryBot.create :work_package, project: project, type: type wp.send("#{list_cf.accessor_name}=", list_cf.custom_options.last.id) wp.save! wp end let(:list_cf) do - cf = FactoryGirl.create :list_wp_custom_field + cf = FactoryBot.create :list_wp_custom_field project.work_package_custom_fields << cf type.custom_fields << cf @@ -252,11 +252,11 @@ describe 'filter work packages', js: true do end context 'by attachment content' do - let(:attachment_a) { FactoryGirl.create(:attachment, filename: 'attachment-first.pdf') } - let(:attachment_b) { FactoryGirl.create(:attachment, filename: 'attachment-second.pdf') } - let(:wp_with_attachment_a) { FactoryGirl.create :work_package, subject: 'WP attachment A', project: project, attachments: [attachment_a] } - let(:wp_with_attachment_b) { FactoryGirl.create :work_package, subject: 'WP attachment B', project: project, attachments: [attachment_b] } - let(:wp_without_attachment) { FactoryGirl.create :work_package, subject: 'WP no attachment', project: project} + let(:attachment_a) { FactoryBot.create(:attachment, filename: 'attachment-first.pdf') } + let(:attachment_b) { FactoryBot.create(:attachment, filename: 'attachment-second.pdf') } + let(:wp_with_attachment_a) { FactoryBot.create :work_package, subject: 'WP attachment A', project: project, attachments: [attachment_a] } + let(:wp_with_attachment_b) { FactoryBot.create :work_package, subject: 'WP attachment B', project: project, attachments: [attachment_b] } + let(:wp_without_attachment) { FactoryBot.create :work_package, subject: 'WP no attachment', project: project} let(:wp_table) { ::Pages::WorkPackagesTable.new } before do diff --git a/spec/features/work_packages/table/queries/me_filter_spec.rb b/spec/features/work_packages/table/queries/me_filter_spec.rb index 50ca60ddd1..91e18093a8 100644 --- a/spec/features/work_packages/table/queries/me_filter_spec.rb +++ b/spec/features/work_packages/table/queries/me_filter_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe 'filter me value', js: true do - let(:project) { FactoryGirl.create :project, is_public: true } - let(:role) { FactoryGirl.create :existing_role, permissions: [:view_work_packages] } - let(:admin) { FactoryGirl.create :admin } - let(:user) { FactoryGirl.create :user } + let(:project) { FactoryBot.create :project, is_public: true } + let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] } + let(:admin) { FactoryBot.create :admin } + let(:user) { FactoryBot.create :user } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } let(:filters) { ::Components::WorkPackages::Filters.new } @@ -43,12 +43,12 @@ describe 'filter me value', js: true do end describe 'assignee' do - let(:wp_admin) { FactoryGirl.create :work_package, project: project, assigned_to: admin } - let(:wp_user) { FactoryGirl.create :work_package, project: project, assigned_to: user } + let(:wp_admin) { FactoryBot.create :work_package, project: project, assigned_to: admin } + let(:wp_user) { FactoryBot.create :work_package, project: project, assigned_to: user } context 'as anonymous', with_settings: { login_required?: false } do let(:assignee_query) do - query = FactoryGirl.create(:query, + query = FactoryBot.create(:query, name: 'Assignee Query', project: project, user: user) @@ -108,16 +108,16 @@ describe 'filter me value', js: true do describe 'custom_field of type user' do let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, name: 'CF user', field_format: 'user', is_required: false ) end - let(:type_task) { FactoryGirl.create(:type_task, custom_fields: [custom_field]) } + let(:type_task) { FactoryBot.create(:type_task, custom_fields: [custom_field]) } let(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, types: [type_task], work_package_custom_fields: [custom_field]) end @@ -125,14 +125,14 @@ describe 'filter me value', js: true do let(:cf_accessor) { "cf_#{custom_field.id}" } let(:cf_accessor_frontend) { "customField#{custom_field.id}" } let(:wp_admin) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, type: type_task, project: project, custom_field_values: { custom_field.id => admin.id } end let(:wp_user) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, type: type_task, project: project, custom_field_values: { custom_field.id => user.id } @@ -140,7 +140,7 @@ describe 'filter me value', js: true do context 'as anonymous', with_settings: { login_required?: false } do let(:assignee_query) do - query = FactoryGirl.create(:query, + query = FactoryBot.create(:query, name: 'CF user Query', project: project, user: user) diff --git a/spec/features/work_packages/table/queries/query_history_spec.rb b/spec/features/work_packages/table/queries/query_history_spec.rb index 974e1c968d..dbba5edf40 100644 --- a/spec/features/work_packages/table/queries/query_history_spec.rb +++ b/spec/features/work_packages/table/queries/query_history_spec.rb @@ -30,41 +30,41 @@ require 'spec_helper' describe 'Going back and forth through the browser history', type: :feature, js: true do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:type) { project.types.first } let(:role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages, :save_queries]) end let(:work_package_1) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type) end let(:work_package_2) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type, assigned_to: user) end let(:version) do - FactoryGirl.create(:version, + FactoryBot.create(:version, project: project) end let(:work_package_3) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type, fixed_version: version) end let(:assignee_query) do - query = FactoryGirl.create(:query, + query = FactoryBot.create(:query, name: 'Assignee Query', project: project, user: user) @@ -75,7 +75,7 @@ describe 'Going back and forth through the browser history', type: :feature, js: query end let(:version_query) do - query = FactoryGirl.create(:query, + query = FactoryBot.create(:query, name: 'Version Query', project: project, user: user) diff --git a/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb b/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb index dea080fcee..cfeca76597 100644 --- a/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb +++ b/spec/features/work_packages/table/queries/query_menu_refresh_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe 'Refreshing query menu item', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } - let(:work_package) { FactoryGirl.create :work_package, project: project } - let(:other_work_package) { FactoryGirl.create :work_package, project: project } + let(:work_package) { FactoryBot.create :work_package, project: project } + let(:other_work_package) { FactoryBot.create :work_package, project: project } before do login_as(user) diff --git a/spec/features/work_packages/table/queries/query_menu_spec.rb b/spec/features/work_packages/table/queries/query_menu_spec.rb index db4ab2d62d..7f6241e4ca 100644 --- a/spec/features/work_packages/table/queries/query_menu_spec.rb +++ b/spec/features/work_packages/table/queries/query_menu_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'Query menu item', js: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:wp_table) { ::Pages::WorkPackagesTable.new(project) } let(:filters) { ::Components::WorkPackages::Filters.new } @@ -39,9 +39,9 @@ describe 'Query menu item', js: true do end context 'filtering by version in project' do - let(:version) { FactoryGirl.create :version, project: project } - let(:work_package_with_version) { FactoryGirl.create :work_package, project: project, fixed_version: version } - let(:work_package_without_version) { FactoryGirl.create :work_package, project: project } + let(:version) { FactoryBot.create :version, project: project } + let(:work_package_with_version) { FactoryBot.create :work_package, project: project, fixed_version: version } + let(:work_package_without_version) { FactoryBot.create :work_package, project: project } before do work_package_with_version diff --git a/spec/features/work_packages/table/relations_spec.rb b/spec/features/work_packages/table/relations_spec.rb index 6281d0744c..bc24a2ad57 100644 --- a/spec/features/work_packages/table/relations_spec.rb +++ b/spec/features/work_packages/table/relations_spec.rb @@ -1,35 +1,35 @@ require 'spec_helper' describe 'Work Package table relations', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:type) { FactoryGirl.create(:type) } - let(:type2) { FactoryGirl.create(:type) } - let(:project) { FactoryGirl.create(:project, types: [type, type2]) } + let(:type) { FactoryBot.create(:type) } + let(:type2) { FactoryBot.create(:type) } + let(:project) { FactoryBot.create(:project, types: [type, type2]) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:relations) { ::Components::WorkPackages::Relations.new(relations) } let(:columns) { ::Components::WorkPackages::Columns.new } let(:wp_timeline) { Pages::WorkPackagesTimeline.new(project) } - let!(:wp_from) { FactoryGirl.create(:work_package, project: project, type: type2) } - let!(:wp_to) { FactoryGirl.create(:work_package, project: project, type: type) } - let!(:wp_to2) { FactoryGirl.create(:work_package, project: project, type: type) } + let!(:wp_from) { FactoryBot.create(:work_package, project: project, type: type2) } + let!(:wp_to) { FactoryBot.create(:work_package, project: project, type: type) } + let!(:wp_to2) { FactoryBot.create(:work_package, project: project, type: type) } let!(:relation) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: wp_from, to: wp_to, relation_type: Relation::TYPE_FOLLOWS) end let!(:relation2) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: wp_from, to: wp_to2, relation_type: Relation::TYPE_FOLLOWS) end let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject'] query.filters.clear diff --git a/spec/features/work_packages/table/switch_types_spec.rb b/spec/features/work_packages/table/switch_types_spec.rb index cc727d9f1d..cd7c3c599b 100644 --- a/spec/features/work_packages/table/switch_types_spec.rb +++ b/spec/features/work_packages/table/switch_types_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe 'Switching types in work package table', js: true do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } describe 'switching to required CF' do let(:cf_req_text) { - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', is_required: true, @@ -13,7 +13,7 @@ describe 'Switching types in work package table', js: true do ) } let(:cf_text) { - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', is_required: false, @@ -21,18 +21,18 @@ describe 'Switching types in work package table', js: true do ) } - let(:type_task) { FactoryGirl.create(:type_task, custom_fields: [cf_text]) } - let(:type_bug) { FactoryGirl.create(:type_bug, custom_fields: [cf_req_text]) } + let(:type_task) { FactoryBot.create(:type_task, custom_fields: [cf_text]) } + let(:type_bug) { FactoryBot.create(:type_bug, custom_fields: [cf_req_text]) } let(:project) { - FactoryGirl.create( + FactoryBot.create( :project, types: [type_task, type_bug], work_package_custom_fields: [cf_text, cf_req_text] ) } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: 'Foobar', type: type_task, project: project) @@ -40,7 +40,7 @@ describe 'Switching types in work package table', js: true do let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['id', 'subject', 'type', "cf_#{cf_text.id}"] query.save! @@ -174,7 +174,7 @@ describe 'Switching types in work package table', js: true do describe 'switching to required bool CF with default value' do let(:cf_req_bool) { - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'bool', is_required: true, @@ -182,18 +182,18 @@ describe 'Switching types in work package table', js: true do ) } - let(:type_task) { FactoryGirl.create(:type_task) } - let(:type_bug) { FactoryGirl.create(:type_bug, custom_fields: [cf_req_bool]) } + let(:type_task) { FactoryBot.create(:type_task) } + let(:type_bug) { FactoryBot.create(:type_bug, custom_fields: [cf_req_bool]) } let(:project) { - FactoryGirl.create( + FactoryBot.create( :project, types: [type_task, type_bug], work_package_custom_fields: [cf_req_bool] ) } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: 'Foobar', type: type_task, project: project) @@ -226,12 +226,12 @@ describe 'Switching types in work package table', js: true do describe 'switching to list CF' do let!(:wp_page) { Pages::FullWorkPackageCreate.new } - let!(:type_with_cf) { FactoryGirl.create(:type_task, custom_fields: [custom_field]) } - let!(:type) { FactoryGirl.create(:type_bug) } + let!(:type_with_cf) { FactoryBot.create(:type_task, custom_fields: [custom_field]) } + let!(:type) { FactoryBot.create(:type_bug) } let(:permissions) { %i(view_work_packages add_work_packages) } - let(:role) { FactoryGirl.create :role, permissions: permissions } + let(:role) { FactoryBot.create :role, permissions: permissions } let(:user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end @@ -242,7 +242,7 @@ describe 'Switching types in work package table', js: true do end let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, name: "Ingredients", multi_value: true, @@ -251,22 +251,22 @@ describe 'Switching types in work package table', js: true do end let!(:project) do - FactoryGirl.create( + FactoryBot.create( :project, types: [type, type_with_cf], work_package_custom_fields: [custom_field] ) end - let!(:status) { FactoryGirl.create(:default_status) } + let!(:status) { FactoryBot.create(:default_status) } let!(:workflow) do - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status, - new_status: FactoryGirl.create(:status), + new_status: FactoryBot.create(:status), role: role end - let!(:priority) { FactoryGirl.create :priority, is_default: true } + let!(:priority) { FactoryBot.create :priority, is_default: true } let(:cf_edit_field) do field = wp_page.edit_field "customField#{custom_field.id}" diff --git a/spec/features/work_packages/table_sorting_spec.rb b/spec/features/work_packages/table_sorting_spec.rb index bb365f2406..151742d5a3 100644 --- a/spec/features/work_packages/table_sorting_spec.rb +++ b/spec/features/work_packages/table_sorting_spec.rb @@ -30,25 +30,25 @@ require 'spec_helper' require 'features/work_packages/work_packages_page' describe 'Select work package row', type: :feature, js: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } let(:work_packages_page) { WorkPackagesPage.new(project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } describe 'sorting by version' do let(:work_package_1) do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) end let(:work_package_2) do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) end let(:version_1) do - FactoryGirl.create(:version, project: project, + FactoryBot.create(:version, project: project, name: 'aaa_version') end let(:version_2) do - FactoryGirl.create(:version, project: project, + FactoryBot.create(:version, project: project, name: 'zzz_version') end let(:columns) { ::Components::WorkPackages::Columns.new } @@ -108,31 +108,31 @@ describe 'Select work package row', type: :feature, js: true do let(:sort_by) { ::Components::WorkPackages::SortBy.new } let(:parent) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project end let(:child1) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: parent end let(:child2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: parent end let(:grand_child1) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: child1 end let(:grand_child2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: child2 end let(:grand_child3) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: child1 end diff --git a/spec/features/work_packages/tabs/activity_revisions_spec.rb b/spec/features/work_packages/tabs/activity_revisions_spec.rb index b2039865eb..453a736929 100644 --- a/spec/features/work_packages/tabs/activity_revisions_spec.rb +++ b/spec/features/work_packages/tabs/activity_revisions_spec.rb @@ -11,9 +11,9 @@ describe 'Activity tab', js: true, selenium: true do note_journal.update_attributes(created_at: at, user: attributes[:user]) end - let(:project) { FactoryGirl.create :project_with_types, is_public: true } + let(:project) { FactoryBot.create :project_with_types, is_public: true } let!(:work_package) { - work_package = FactoryGirl.create(:work_package, + work_package = FactoryBot.create(:work_package, project: project, created_at: 5.days.ago.to_date.to_s(:db), subject: initial_subject, @@ -51,7 +51,7 @@ describe 'Activity tab', js: true, selenium: true do alter_work_package_at(work_package, attributes: attributes, at: 1.days.ago.to_date.to_s(:db), - user: FactoryGirl.create(:admin)) + user: FactoryBot.create(:admin)) work_package.journals.last } @@ -115,11 +115,11 @@ describe 'Activity tab', js: true, selenium: true do context 'with permission' do let(:role) { - FactoryGirl.create(:role, permissions: [:view_work_packages, + FactoryBot.create(:role, permissions: [:view_work_packages, :add_work_package_notes]) } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } @@ -174,10 +174,10 @@ describe 'Activity tab', js: true, selenium: true do context 'with no permission' do let(:role) { - FactoryGirl.create(:role, permissions: [:view_work_packages]) + FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } diff --git a/spec/features/work_packages/tabs/activity_tab_spec.rb b/spec/features/work_packages/tabs/activity_tab_spec.rb index b2039865eb..453a736929 100644 --- a/spec/features/work_packages/tabs/activity_tab_spec.rb +++ b/spec/features/work_packages/tabs/activity_tab_spec.rb @@ -11,9 +11,9 @@ describe 'Activity tab', js: true, selenium: true do note_journal.update_attributes(created_at: at, user: attributes[:user]) end - let(:project) { FactoryGirl.create :project_with_types, is_public: true } + let(:project) { FactoryBot.create :project_with_types, is_public: true } let!(:work_package) { - work_package = FactoryGirl.create(:work_package, + work_package = FactoryBot.create(:work_package, project: project, created_at: 5.days.ago.to_date.to_s(:db), subject: initial_subject, @@ -51,7 +51,7 @@ describe 'Activity tab', js: true, selenium: true do alter_work_package_at(work_package, attributes: attributes, at: 1.days.ago.to_date.to_s(:db), - user: FactoryGirl.create(:admin)) + user: FactoryBot.create(:admin)) work_package.journals.last } @@ -115,11 +115,11 @@ describe 'Activity tab', js: true, selenium: true do context 'with permission' do let(:role) { - FactoryGirl.create(:role, permissions: [:view_work_packages, + FactoryBot.create(:role, permissions: [:view_work_packages, :add_work_package_notes]) } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } @@ -174,10 +174,10 @@ describe 'Activity tab', js: true, selenium: true do context 'with no permission' do let(:role) { - FactoryGirl.create(:role, permissions: [:view_work_packages]) + FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } diff --git a/spec/features/work_packages/tabs/keep_tab_spec.rb b/spec/features/work_packages/tabs/keep_tab_spec.rb index c4bc4a0b48..d896927254 100644 --- a/spec/features/work_packages/tabs/keep_tab_spec.rb +++ b/spec/features/work_packages/tabs/keep_tab_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' RSpec.feature 'Keep current details tab', js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } - let!(:wp1) { FactoryGirl.create(:work_package, project: project) } - let!(:wp2) { FactoryGirl.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } + let!(:wp1) { FactoryBot.create(:work_package, project: project) } + let!(:wp2) { FactoryBot.create(:work_package, project: project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:split) { Pages::WorkPackagesTable.new(project) } diff --git a/spec/features/work_packages/tabs/watcher_tab_spec.rb b/spec/features/work_packages/tabs/watcher_tab_spec.rb index 251ce01758..e7bb158e2e 100644 --- a/spec/features/work_packages/tabs/watcher_tab_spec.rb +++ b/spec/features/work_packages/tabs/watcher_tab_spec.rb @@ -4,11 +4,11 @@ require 'features/work_packages/work_packages_page' require 'support/work_packages/work_package_field' describe 'Watcher tab', js: true, selenium: true do - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { %i(view_work_packages view_work_package_watchers @@ -77,7 +77,7 @@ describe 'Watcher tab', js: true, selenium: true do context 'with a user with arbitrary characters' do let!(:html_user) { - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'foo', member_in_project: project, member_through_role: role diff --git a/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb b/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb index 99063f7e5b..ecc002902b 100644 --- a/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb +++ b/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do - let(:user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create(:project) } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:hierarchy) { ::Components::WorkPackages::Hierarchies.new } @@ -42,12 +42,12 @@ RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do end let!(:wp_root) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project end let!(:wp_leaf) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: wp_root, start_date: Date.today, @@ -55,7 +55,7 @@ RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do end let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['subject'] query.filters.clear query.show_hierarchies = true @@ -90,13 +90,13 @@ RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do context 'with a relation being rendered to a hidden row' do let!(:wp_other) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, start_date: Date.today + 5.days, due_date: (Date.today + 10.days) end let!(:relation) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: wp_leaf, to: wp_other, relation_type: Relation::TYPE_FOLLOWS) diff --git a/spec/features/work_packages/timeline/timeline_labels_spec.rb b/spec/features/work_packages/timeline/timeline_labels_spec.rb index 7d479eff02..5b8d89b8f2 100644 --- a/spec/features/work_packages/timeline/timeline_labels_spec.rb +++ b/spec/features/work_packages/timeline/timeline_labels_spec.rb @@ -32,18 +32,18 @@ RSpec.feature 'Work package timeline labels', with_settings: { date_format: '%Y-%m-%d' }, js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:type) { FactoryGirl.create(:type_bug) } - let(:milestone_type) { FactoryGirl.create(:type, is_milestone: true) } + let(:user) { FactoryBot.create(:admin) } + let(:type) { FactoryBot.create(:type_bug) } + let(:milestone_type) { FactoryBot.create(:type, is_milestone: true) } - let(:project) { FactoryGirl.create(:project, types: [type, milestone_type]) } + let(:project) { FactoryBot.create(:project, types: [type, milestone_type]) } let(:query_menu) { Components::WorkPackages::QueryMenu.new } let(:settings_menu) { Components::WorkPackages::SettingsMenu.new } let(:config_modal) { Components::Timelines::ConfigurationModal.new } let(:wp_timeline) { Pages::WorkPackagesTimeline.new(project) } let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, name: "Ingredients", multi_value: true, @@ -62,7 +62,7 @@ RSpec.feature 'Work package timeline labels', let(:future) { (Date.today + 5).iso8601 } let(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: type, assigned_to: user, @@ -73,7 +73,7 @@ RSpec.feature 'Work package timeline labels', end let(:milestone_work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: milestone_type, start_date: future, diff --git a/spec/features/work_packages/timeline/timeline_navigation_spec.rb b/spec/features/work_packages/timeline/timeline_navigation_spec.rb index 19892c0c8a..d24e37170c 100644 --- a/spec/features/work_packages/timeline/timeline_navigation_spec.rb +++ b/spec/features/work_packages/timeline/timeline_navigation_spec.rb @@ -29,15 +29,15 @@ require 'spec_helper' RSpec.feature 'Work package timeline navigation', js: true, selenium: true do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } let(:query_menu) { Components::WorkPackages::QueryMenu.new } let(:wp_timeline) { Pages::WorkPackagesTimeline.new(project) } let(:settings_menu) { Components::WorkPackages::SettingsMenu.new } let(:group_by) { Components::WorkPackages::GroupBy.new } let(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, start_date: Date.today, due_date: (Date.today + 5.days) @@ -49,24 +49,24 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do end describe 'with multiple queries' do - let(:type) { FactoryGirl.create :type } - let(:type2) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create(:project, types: [type, type2]) } + let(:type) { FactoryBot.create :type } + let(:type2) { FactoryBot.create :type } + let(:project) { FactoryBot.create(:project, types: [type, type2]) } let!(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: type end let!(:work_package2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, type: type2 end let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['id', 'type', 'subject'] query.filters.clear query.timeline_visible = false @@ -78,7 +78,7 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do end let!(:query_tl) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['id', 'type', 'subject'] query.filters.clear query.add_filter('type_id', '=', [type2.id]) @@ -151,7 +151,7 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do describe 'with a hierarchy being shown' do let!(:child_work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, parent: work_package, start_date: Date.today, @@ -186,40 +186,40 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do end describe 'when table is grouped' do - let(:project) { FactoryGirl.create(:project) } - let(:category) { FactoryGirl.create :category, project: project, name: 'Foo' } - let(:category2) { FactoryGirl.create :category, project: project, name: 'Bar' } + let(:project) { FactoryBot.create(:project) } + let(:category) { FactoryBot.create :category, project: project, name: 'Foo' } + let(:category2) { FactoryBot.create :category, project: project, name: 'Bar' } let(:wp_table) { Pages::WorkPackagesTable.new(project) } let(:relations) { ::Components::WorkPackages::Relations.new(wp_cat1) } let!(:wp_cat1) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, category: category, start_date: Date.today, due_date: (Date.today + 5.days) end let!(:wp_cat2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, category: category2, start_date: Date.today + 5.days, due_date: (Date.today + 10.days) end let!(:wp_none) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project end let!(:relation) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: wp_cat1, to: wp_cat2, relation_type: Relation::TYPE_FOLLOWS) end let!(:query) do - query = FactoryGirl.build(:query, user: user, project: project) + query = FactoryBot.build(:query, user: user, project: project) query.column_names = ['id', 'subject', 'category'] query.show_hierarchies = false query.timeline_visible = true diff --git a/spec/features/work_packages/work_package_index_spec.rb b/spec/features/work_packages/work_package_index_spec.rb index 3f568cc0db..94b7993079 100644 --- a/spec/features/work_packages/work_package_index_spec.rb +++ b/spec/features/work_packages/work_package_index_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' RSpec.feature 'Work package index view' do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } before do login_as(user) diff --git a/spec/features/work_packages/work_package_workflow_form_spec.rb b/spec/features/work_packages/work_package_workflow_form_spec.rb index 18e7f370cd..25c8ec73b1 100644 --- a/spec/features/work_packages/work_package_workflow_form_spec.rb +++ b/spec/features/work_packages/work_package_workflow_form_spec.rb @@ -33,23 +33,23 @@ require 'features/page_objects/notification' describe 'Work package transitive status workflows', js: true do let(:dev_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :edit_work_packages] end let(:dev) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Dev', lastname: 'Guy', member_in_project: project, member_through_role: dev_role end - let(:type) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create :type } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) { - work_package = FactoryGirl.create :work_package, + work_package = FactoryBot.create :work_package, project: project, type: type, created_at: 5.days.ago.to_date.to_s(:db) @@ -62,17 +62,17 @@ describe 'Work package transitive status workflows', js: true do let(:wp_page) { Pages::FullWorkPackage.new(work_package) } let(:status_from) { work_package.status } - let(:status_intermediate) { FactoryGirl.create :status } - let(:status_to) { FactoryGirl.create :status } + let(:status_intermediate) { FactoryBot.create :status } + let(:status_to) { FactoryBot.create :status } let(:workflows) { - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status_from, new_status: status_intermediate, role: dev_role - FactoryGirl.create :workflow, + FactoryBot.create :workflow, type_id: type.id, old_status: status_intermediate, new_status: status_to, diff --git a/spec/features/work_packages/zen_mode.rb b/spec/features/work_packages/zen_mode.rb index d8dc3a9962..4233000e6e 100644 --- a/spec/features/work_packages/zen_mode.rb +++ b/spec/features/work_packages/zen_mode.rb @@ -2,29 +2,29 @@ require 'spec_helper' describe 'Zen mode', js: true do let(:dev_role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [:view_work_packages, :edit_work_packages] end let(:dev) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Dev', lastname: 'Guy', member_in_project: project, member_through_role: dev_role end - let(:type) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create :type } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) do - FactoryGirl.create :work_package, project: project, type: type + FactoryBot.create :work_package, project: project, type: type end let(:wp_page) { Pages::FullWorkPackage.new(work_package) } let(:status_from) { work_package.status } - let(:status_intermediate) { FactoryGirl.create :status } + let(:status_intermediate) { FactoryBot.create :status } before do login_as(dev) diff --git a/spec/features/workflows/copy_spec.rb b/spec/features/workflows/copy_spec.rb index 35ccde82aa..8b4d94d751 100644 --- a/spec/features/workflows/copy_spec.rb +++ b/spec/features/workflows/copy_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe 'Workflow copy', type: :feature do - let(:role) { FactoryGirl.create(:role) } - let(:type) { FactoryGirl.create(:type) } - let(:admin) { FactoryGirl.create(:admin) } - let(:statuses) { (1..2).map { |_i| FactoryGirl.create(:status) } } + let(:role) { FactoryBot.create(:role) } + let(:type) { FactoryBot.create(:type) } + let(:admin) { FactoryBot.create(:admin) } + let(:statuses) { (1..2).map { |_i| FactoryBot.create(:status) } } let(:workflow) { - FactoryGirl.create(:workflow, role_id: role.id, + FactoryBot.create(:workflow, role_id: role.id, type_id: type.id, old_status_id: statuses[0].id, new_status_id: statuses[1].id, diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 531f833ef3..35aaf5b91a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -90,16 +90,16 @@ describe ApplicationHelper, type: :helper do end describe '.link_to_if_authorized' do - let(:project) { FactoryGirl.create :valid_project } + let(:project) { FactoryBot.create :valid_project } let(:project_member) { - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, - member_through_role: FactoryGirl.create(:role, + member_through_role: FactoryBot.create(:role, permissions: [:view_work_packages, :edit_work_packages, :browse_repository, :view_changesets, :view_wiki_pages]) } let(:issue) { - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, author: project_member, type: project.types.first @@ -178,7 +178,7 @@ describe ApplicationHelper, type: :helper do context 'with project' do before do - @project = FactoryGirl.build(:project) + @project = FactoryBot.build(:project) end context 'right now' do diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 245576bb51..0b193e8746 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -41,10 +41,10 @@ describe ProjectsHelper, type: :helper do User.current = nil end - let(:test_project) { FactoryGirl.create :valid_project } + let(:test_project) { FactoryBot.create :valid_project } describe 'a version' do - let(:version) { FactoryGirl.create :version, project: test_project } + let(:version) { FactoryBot.create :version, project: test_project } it 'can be formatted' do expect(format_version_name(version)).to eq("#{test_project.name} - #{version.name}") @@ -60,7 +60,7 @@ describe ProjectsHelper, type: :helper do end describe 'with a valid user' do - let(:user) { FactoryGirl.create :user, member_in_project: test_project } + let(:user) { FactoryBot.create :user, member_in_project: test_project } before do login_as(user) end it 'generates a link' do @@ -85,7 +85,7 @@ describe ProjectsHelper, type: :helper do end describe 'a system version' do - let(:version) { FactoryGirl.create :version, project: test_project, sharing: 'system' } + let(:version) { FactoryBot.create :version, project: test_project, sharing: 'system' } it 'can be formatted' do expect(format_version_name(version)).to eq("#{test_project.name} - #{version.name}") @@ -106,7 +106,7 @@ describe ProjectsHelper, type: :helper do end def stub_descendant_of(*ancestors) - wp = FactoryGirl.build_stubbed(:project) + wp = FactoryBot.build_stubbed(:project) allow(wp) .to receive(:is_descendant_of?) diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index bbd12da258..ecfbaaa669 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'search/index', type: :helper do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:scope) { 'foobar' } before do diff --git a/spec/helpers/types_helper_spec.rb b/spec/helpers/types_helper_spec.rb index 2f86c186ae..130eddfdb4 100644 --- a/spec/helpers/types_helper_spec.rb +++ b/spec/helpers/types_helper_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe TypesHelper, type: :helper do - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } describe "#form_configuration_groups" do it "returns a Hash with the keys :actives and :inactives Arrays" do diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 927e07e7dd..929f0433ad 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -32,7 +32,7 @@ describe UsersHelper, type: :helper do include UsersHelper def build_user(status, blocked) - user = FactoryGirl.build(:user) + user = FactoryBot.build(:user) allow(user).to receive(:status).and_return(User::STATUSES[status]) allow(user).to receive(:failed_too_many_recent_login_attempts?).and_return(blocked) allow(user).to receive(:failed_login_count).and_return(3) diff --git a/spec/helpers/work_packages_filter_helper_spec.rb b/spec/helpers/work_packages_filter_helper_spec.rb index 85920793d6..727b0b5945 100644 --- a/spec/helpers/work_packages_filter_helper_spec.rb +++ b/spec/helpers/work_packages_filter_helper_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe WorkPackagesFilterHelper, type: :helper do - let(:project) { FactoryGirl.create(:project) } - let(:version) { FactoryGirl.create(:version, project: project) } + let(:project) { FactoryBot.create(:project) } + let(:version) { FactoryBot.create(:version, project: project) } let(:global) { false } shared_examples_for 'work package path with query_props' do diff --git a/spec/helpers/work_packages_helper_spec.rb b/spec/helpers/work_packages_helper_spec.rb index c8b09c25b8..47f224cce8 100644 --- a/spec/helpers/work_packages_helper_spec.rb +++ b/spec/helpers/work_packages_helper_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe WorkPackagesHelper, type: :helper do - let(:stub_work_package) { FactoryGirl.build_stubbed(:work_package) } - let(:stub_project) { FactoryGirl.build_stubbed(:project) } - let(:stub_type) { FactoryGirl.build_stubbed(:type) } - let(:stub_user) { FactoryGirl.build_stubbed(:user) } + let(:stub_work_package) { FactoryBot.build_stubbed(:work_package) } + let(:stub_project) { FactoryBot.build_stubbed(:project) } + let(:stub_type) { FactoryBot.build_stubbed(:type) } + let(:stub_user) { FactoryBot.build_stubbed(:user) } describe '#link_to_work_package' do - let(:open_status) { FactoryGirl.build_stubbed(:status, is_closed: false) } - let(:closed_status) { FactoryGirl.build_stubbed(:status, is_closed: true) } + let(:open_status) { FactoryBot.build_stubbed(:status, is_closed: false) } + let(:closed_status) { FactoryBot.build_stubbed(:status, is_closed: true) } before do stub_work_package.status = open_status @@ -154,11 +154,11 @@ describe WorkPackagesHelper, type: :helper do end describe '#work_package_css_classes' do - let(:statuses) { (1..5).map { |_i| FactoryGirl.build_stubbed(:status) } } - let(:priority) { FactoryGirl.build_stubbed :priority, is_default: true } + let(:statuses) { (1..5).map { |_i| FactoryBot.build_stubbed(:status) } } + let(:priority) { FactoryBot.build_stubbed :priority, is_default: true } let(:status) { statuses[0] } let(:stub_work_package) { - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, status: status, priority: priority) } diff --git a/spec/lib/acts_as_journalized/journaled_spec.rb b/spec/lib/acts_as_journalized/journaled_spec.rb index 634cf873dc..aba331aa25 100644 --- a/spec/lib/acts_as_journalized/journaled_spec.rb +++ b/spec/lib/acts_as_journalized/journaled_spec.rb @@ -30,15 +30,15 @@ require 'spec_helper' describe 'Journalized Objects' do before(:each) do - @project ||= FactoryGirl.create(:project_with_types) + @project ||= FactoryBot.create(:project_with_types) @type ||= @project.types.first - @current = FactoryGirl.create(:user, login: 'user1', mail: 'user1@users.com') + @current = FactoryBot.create(:user, login: 'user1', mail: 'user1@users.com') allow(User).to receive(:current).and_return(@current) end it 'should work with work packages' do - @status_open ||= FactoryGirl.create(:status, name: 'Open', is_default: true) - @work_package ||= FactoryGirl.create(:work_package, project: @project, status: @status_open, type: @type, author: @current) + @status_open ||= FactoryBot.create(:status, name: 'Open', is_default: true) + @work_package ||= FactoryBot.create(:work_package, project: @project, status: @status_open, type: @type, author: @current) initial_journal = @work_package.journals.first recreated_journal = @work_package.recreate_initial_journal! @@ -47,7 +47,7 @@ describe 'Journalized Objects' do end it 'should work with news' do - @news ||= FactoryGirl.create(:news, project: @project, author: @current, title: 'Test', summary: 'Test', description: 'Test') + @news ||= FactoryBot.create(:news, project: @project, author: @current, title: 'Test', summary: 'Test', description: 'Test') initial_journal = @news.journals.first recreated_journal = @news.recreate_initial_journal! @@ -56,7 +56,7 @@ describe 'Journalized Objects' do end it 'should work with wiki content' do - @wiki_content ||= FactoryGirl.create(:wiki_content, author: @current) + @wiki_content ||= FactoryBot.create(:wiki_content, author: @current) initial_journal = @wiki_content.journals.first recreated_journal = @wiki_content.recreate_initial_journal! @@ -65,7 +65,7 @@ describe 'Journalized Objects' do end it 'should work with messages' do - @message ||= FactoryGirl.create(:message, content: 'Test', subject: 'Test', author: @current) + @message ||= FactoryBot.create(:message, content: 'Test', subject: 'Test', author: @current) initial_journal = @message.journals.first recreated_journal = @message.recreate_initial_journal! @@ -74,10 +74,10 @@ describe 'Journalized Objects' do end it 'should work with time entries' do - @status_open ||= FactoryGirl.create(:status, name: 'Open', is_default: true) - @work_package ||= FactoryGirl.create(:work_package, project: @project, status: @status_open, type: @type, author: @current) + @status_open ||= FactoryBot.create(:status, name: 'Open', is_default: true) + @work_package ||= FactoryBot.create(:work_package, project: @project, status: @status_open, type: @type, author: @current) - @time_entry ||= FactoryGirl.create(:time_entry, work_package: @work_package, project: @project, spent_on: Time.now, hours: 5, user: @current, activity: FactoryGirl.create(:time_entry_activity)) + @time_entry ||= FactoryBot.create(:time_entry, work_package: @work_package, project: @project, spent_on: Time.now, hours: 5, user: @current, activity: FactoryBot.create(:time_entry_activity)) initial_journal = @time_entry.journals.first recreated_journal = @time_entry.recreate_initial_journal! @@ -86,7 +86,7 @@ describe 'Journalized Objects' do end it 'should work with attachments' do - @attachment ||= FactoryGirl.create(:attachment, container: FactoryGirl.create(:work_package), author: @current) + @attachment ||= FactoryBot.create(:attachment, container: FactoryBot.create(:work_package), author: @current) initial_journal = @attachment.journals.first recreated_journal = @attachment.recreate_initial_journal! @@ -96,8 +96,8 @@ describe 'Journalized Objects' do it 'should work with changesets' do Setting.enabled_scm = ['subversion'] - @repository ||= FactoryGirl.create(:repository_subversion, url: 'http://svn.test.com') - @changeset ||= FactoryGirl.create(:changeset, committer: @current.login, repository: @repository) + @repository ||= FactoryBot.create(:repository_subversion, url: 'http://svn.test.com') + @changeset ||= FactoryBot.create(:changeset, committer: @current.login, repository: @repository) initial_journal = @changeset.journals.first recreated_journal = @changeset.recreate_initial_journal! @@ -107,16 +107,16 @@ describe 'Journalized Objects' do describe 'journal_editable_by?' do context 'when the journable is a work package' do - let!(:user) { FactoryGirl.create(:user) } - let!(:project) { FactoryGirl.create(:project_with_types) } - let!(:role) { FactoryGirl.create(:role, permissions: [:edit_work_packages]) } + let!(:user) { FactoryBot.create(:user) } + let!(:project) { FactoryBot.create(:project_with_types) } + let!(:role) { FactoryBot.create(:role, permissions: [:edit_work_packages]) } let!(:member) { - FactoryGirl.create(:member, project: project, + FactoryBot.create(:member, project: project, roles: [role], principal: user) } let!(:work_package) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, author: user, project: project, description: '') diff --git a/spec/lib/api/decorators/aggregation_group_spec.rb b/spec/lib/api/decorators/aggregation_group_spec.rb index 8829b06de2..e5a4878710 100644 --- a/spec/lib/api/decorators/aggregation_group_spec.rb +++ b/spec/lib/api/decorators/aggregation_group_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe ::API::Decorators::AggregationGroup do let(:query) do - query = FactoryGirl.build_stubbed(:query) + query = FactoryBot.build_stubbed(:query) query.group_by = :assigned_to query diff --git a/spec/lib/api/decorators/formattable_spec.rb b/spec/lib/api/decorators/formattable_spec.rb index 3855c726f2..5a099c88ef 100644 --- a/spec/lib/api/decorators/formattable_spec.rb +++ b/spec/lib/api/decorators/formattable_spec.rb @@ -49,7 +49,7 @@ describe ::API::Decorators::Formattable do end context 'passing an object context' do - let(:object) { FactoryGirl.build_stubbed :work_package } + let(:object) { FactoryBot.build_stubbed :work_package } subject { described_class.new(represented, object: object) } it 'passes that to format_text' do diff --git a/spec/lib/api/utilities/property_name_converter_spec.rb b/spec/lib/api/utilities/property_name_converter_spec.rb index 4cbd7566e9..24fa817c24 100644 --- a/spec/lib/api/utilities/property_name_converter_spec.rb +++ b/spec/lib/api/utilities/property_name_converter_spec.rb @@ -79,7 +79,7 @@ describe ::API::Utilities::PropertyNameConverter do describe '#to_ar_name' do let(:attribute_name) { 'anAttribute' } - let(:context) { FactoryGirl.build_stubbed(:work_package) } + let(:context) { FactoryBot.build_stubbed(:work_package) } subject { described_class.to_ar_name(attribute_name, context: context) } @@ -164,7 +164,7 @@ describe ::API::Utilities::PropertyNameConverter do end context 'in an appropriate context' do - let(:context) { FactoryGirl.build_stubbed(:version) } + let(:context) { FactoryBot.build_stubbed(:version) } it 'should be performed' do is_expected.to eql('updated_on') diff --git a/spec/lib/api/v3/activities/activity_representer_spec.rb b/spec/lib/api/v3/activities/activity_representer_spec.rb index caf7b65177..93a6772ccd 100644 --- a/spec/lib/api/v3/activities/activity_representer_spec.rb +++ b/spec/lib/api/v3/activities/activity_representer_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe ::API::V3::Activities::ActivityRepresenter do - let(:current_user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:work_package) { FactoryGirl.build(:work_package) } + let(:current_user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:work_package) { FactoryBot.build(:work_package) } let(:journal) { Journal::AggregatedJournal.aggregated_journals.first } let(:project) { work_package.project } let(:permissions) { %i(edit_own_work_package_notes) } - let(:role) { FactoryGirl.create :role, permissions: permissions } + let(:role) { FactoryBot.create :role, permissions: permissions } let(:representer) { described_class.new(journal, current_user: current_user) } before do diff --git a/spec/lib/api/v3/attachments/attachment_representer_spec.rb b/spec/lib/api/v3/attachments/attachment_representer_spec.rb index f349ab95d0..bcc224e504 100644 --- a/spec/lib/api/v3/attachments/attachment_representer_spec.rb +++ b/spec/lib/api/v3/attachments/attachment_representer_spec.rb @@ -32,14 +32,14 @@ describe ::API::V3::Attachments::AttachmentRepresenter do include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:all_permissions) { %i[view_work_packages edit_work_packages] } let(:permissions) { all_permissions } - let(:container) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:container) { FactoryBot.build_stubbed(:stubbed_work_package) } let(:attachment) do - FactoryGirl.build_stubbed(:attachment, + FactoryBot.build_stubbed(:attachment, container: container, created_on: DateTime.now) do |attachment| allow(attachment) diff --git a/spec/lib/api/v3/categories/category_collection_representer_spec.rb b/spec/lib/api/v3/categories/category_collection_representer_spec.rb index ecf8ecb42e..a49d1dccdc 100644 --- a/spec/lib/api/v3/categories/category_collection_representer_spec.rb +++ b/spec/lib/api/v3/categories/category_collection_representer_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::API::V3::Categories::CategoryCollectionRepresenter do - let(:categories) { FactoryGirl.build_list(:category, 3) } + let(:categories) { FactoryBot.build_list(:category, 3) } let(:representer) { described_class.new(categories, '/api/v3/projects/1/categories', diff --git a/spec/lib/api/v3/categories/category_representer_spec.rb b/spec/lib/api/v3/categories/category_representer_spec.rb index 53263c83f7..24e2c2991b 100644 --- a/spec/lib/api/v3/categories/category_representer_spec.rb +++ b/spec/lib/api/v3/categories/category_representer_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe ::API::V3::Categories::CategoryRepresenter do - let(:category) { FactoryGirl.build_stubbed(:category) } - let(:user) { FactoryGirl.build(:user) } + let(:category) { FactoryBot.build_stubbed(:category) } + let(:user) { FactoryBot.build(:user) } let(:representer) { described_class.new(category, current_user: double('current_user')) } context 'generation' do @@ -67,7 +67,7 @@ describe ::API::V3::Categories::CategoryRepresenter do context 'default assignee set' do let(:category) { - FactoryGirl.build_stubbed(:category, assigned_to: user) + FactoryBot.build_stubbed(:category, assigned_to: user) } it_behaves_like 'category has core values' @@ -90,7 +90,7 @@ describe ::API::V3::Categories::CategoryRepresenter do end describe '#json_cache_key' do - let(:assigned_to) { FactoryGirl.build_stubbed(:user) } + let(:assigned_to) { FactoryBot.build_stubbed(:user) } before do category.assigned_to = assigned_to diff --git a/spec/lib/api/v3/configuration/configuration_representer_spec.rb b/spec/lib/api/v3/configuration/configuration_representer_spec.rb index f5216eb1fe..02336fb2f3 100644 --- a/spec/lib/api/v3/configuration/configuration_representer_spec.rb +++ b/spec/lib/api/v3/configuration/configuration_representer_spec.rb @@ -32,7 +32,7 @@ describe ::API::V3::Configuration::ConfigurationRepresenter do include ::API::V3::Utilities::PathHelper let(:represented) { Setting } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(represented, current_user: current_user) } context 'generation' do diff --git a/spec/lib/api/v3/custom_actions/custom_action_execute_representer_parsing_spec.rb b/spec/lib/api/v3/custom_actions/custom_action_execute_representer_parsing_spec.rb index 00a20a560a..b173aa22a4 100644 --- a/spec/lib/api/v3/custom_actions/custom_action_execute_representer_parsing_spec.rb +++ b/spec/lib/api/v3/custom_actions/custom_action_execute_representer_parsing_spec.rb @@ -32,8 +32,8 @@ describe ::API::V3::CustomActions::CustomActionExecuteRepresenter, 'parsing' do include ::API::V3::Utilities::PathHelper let(:struct) { OpenStruct.new } - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } let(:representer) do described_class.new(struct, current_user: user) diff --git a/spec/lib/api/v3/custom_actions/custom_action_representer_generation_spec.rb b/spec/lib/api/v3/custom_actions/custom_action_representer_generation_spec.rb index 61a98920b7..47f6d22e41 100644 --- a/spec/lib/api/v3/custom_actions/custom_action_representer_generation_spec.rb +++ b/spec/lib/api/v3/custom_actions/custom_action_representer_generation_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::CustomActions::CustomActionRepresenter do include ::API::V3::Utilities::PathHelper - let(:custom_action) { FactoryGirl.build_stubbed(:custom_action) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:custom_action) { FactoryBot.build_stubbed(:custom_action) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) do described_class.new(custom_action, current_user: user, embed_links: true) diff --git a/spec/lib/api/v3/custom_options/custom_option_representer_spec.rb b/spec/lib/api/v3/custom_options/custom_option_representer_spec.rb index 4ccfac6471..f64ac4d3d3 100644 --- a/spec/lib/api/v3/custom_options/custom_option_representer_spec.rb +++ b/spec/lib/api/v3/custom_options/custom_option_representer_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe ::API::V3::CustomOptions::CustomOptionRepresenter do include ::API::V3::Utilities::PathHelper - let(:custom_option) { FactoryGirl.build_stubbed(:custom_option, custom_field: custom_field) } - let(:custom_field) { FactoryGirl.build_stubbed(:list_wp_custom_field) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:custom_option) { FactoryBot.build_stubbed(:custom_option, custom_field: custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:list_wp_custom_field) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) do described_class.new(custom_option, current_user: user) end diff --git a/spec/lib/api/v3/groups/group_representer_spec.rb b/spec/lib/api/v3/groups/group_representer_spec.rb index 77900d15f2..aeefb65fdf 100644 --- a/spec/lib/api/v3/groups/group_representer_spec.rb +++ b/spec/lib/api/v3/groups/group_representer_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe ::API::V3::Groups::GroupRepresenter do - let(:group) { FactoryGirl.build_stubbed(:group) } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:group) { FactoryBot.build_stubbed(:group) } + let(:current_user) { FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(group, current_user: current_user) } context 'generation' do @@ -61,7 +61,7 @@ describe ::API::V3::Groups::GroupRepresenter do end context 'as admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } it 'has an id property' do is_expected diff --git a/spec/lib/api/v3/help_texts/help_text_collection_representer_spec.rb b/spec/lib/api/v3/help_texts/help_text_collection_representer_spec.rb index 841ff88212..372fc93fb6 100644 --- a/spec/lib/api/v3/help_texts/help_text_collection_representer_spec.rb +++ b/spec/lib/api/v3/help_texts/help_text_collection_representer_spec.rb @@ -31,12 +31,12 @@ require 'spec_helper' describe ::API::V3::HelpTexts::HelpTextCollectionRepresenter do let!(:help_texts) do [ - FactoryGirl.build_stubbed(:work_package_help_text, attribute_name: 'id'), - FactoryGirl.build_stubbed(:work_package_help_text, attribute_name: 'status') + FactoryBot.build_stubbed(:work_package_help_text, attribute_name: 'id'), + FactoryBot.build_stubbed(:work_package_help_text, attribute_name: 'status') ] end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } def self_link 'a link that is provided' diff --git a/spec/lib/api/v3/help_texts/help_text_representer_spec.rb b/spec/lib/api/v3/help_texts/help_text_representer_spec.rb index 580bfa6370..3aab28e7e2 100644 --- a/spec/lib/api/v3/help_texts/help_text_representer_spec.rb +++ b/spec/lib/api/v3/help_texts/help_text_representer_spec.rb @@ -31,10 +31,10 @@ require 'spec_helper' describe ::API::V3::HelpTexts::HelpTextRepresenter do include ::API::V3::Utilities::PathHelper - let(:user) { FactoryGirl.build_stubbed :admin } + let(:user) { FactoryBot.build_stubbed :admin } let(:help_text) do - FactoryGirl.build_stubbed :work_package_help_text, + FactoryBot.build_stubbed :work_package_help_text, attribute_name: 'status', help_text: 'This is a help text for *status* attribute.' end diff --git a/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb b/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb index 3743f95aae..9af13cbf12 100644 --- a/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb +++ b/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::API::V3::Priorities::PriorityCollectionRepresenter do - let(:priorities) { FactoryGirl.build_list(:priority, 3) } + let(:priorities) { FactoryBot.build_list(:priority, 3) } let(:representer) { described_class.new(priorities, '/api/v3/priorities', current_user: double('current_user')) } diff --git a/spec/lib/api/v3/priorities/priority_representer_spec.rb b/spec/lib/api/v3/priorities/priority_representer_spec.rb index 680262dd4b..cd62b35639 100644 --- a/spec/lib/api/v3/priorities/priority_representer_spec.rb +++ b/spec/lib/api/v3/priorities/priority_representer_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::API::V3::Priorities::PriorityRepresenter do - let(:priority) { FactoryGirl.build_stubbed(:priority) } + let(:priority) { FactoryBot.build_stubbed(:priority) } let(:representer) { described_class.new(priority, current_user: double('current_user')) } include API::V3::Utilities::PathHelper diff --git a/spec/lib/api/v3/projects/project_collection_representer_spec.rb b/spec/lib/api/v3/projects/project_collection_representer_spec.rb index 7cb2d462c6..97a1b34dad 100644 --- a/spec/lib/api/v3/projects/project_collection_representer_spec.rb +++ b/spec/lib/api/v3/projects/project_collection_representer_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe ::API::V3::Projects::ProjectCollectionRepresenter do let(:self_link) { '/api/v3/versions/1/projects' } - let(:projects) { FactoryGirl.build_list(:project, 3) } - let(:current_user) { FactoryGirl.build(:user) } + let(:projects) { FactoryBot.build_list(:project, 3) } + let(:current_user) { FactoryBot.build(:user) } let(:representer) { described_class.new(projects, self_link, current_user: current_user) } diff --git a/spec/lib/api/v3/projects/project_representer_spec.rb b/spec/lib/api/v3/projects/project_representer_spec.rb index 63053b04ab..82964822d8 100644 --- a/spec/lib/api/v3/projects/project_representer_spec.rb +++ b/spec/lib/api/v3/projects/project_representer_spec.rb @@ -31,10 +31,10 @@ require 'spec_helper' describe ::API::V3::Projects::ProjectRepresenter do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:representer) { described_class.new(project, current_user: user) } let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:permissions) { [:add_work_packages] } @@ -161,7 +161,7 @@ describe ::API::V3::Projects::ProjectRepresenter do end describe '#json_cache_key' do - let(:project_type) { FactoryGirl.build_stubbed(:project_type) } + let(:project_type) { FactoryBot.build_stubbed(:project_type) } before do project.project_type = project_type diff --git a/spec/lib/api/v3/queries/columns/query_relation_to_type_column_representer_spec.rb b/spec/lib/api/v3/queries/columns/query_relation_to_type_column_representer_spec.rb index ea0e7c2248..f93da44df9 100644 --- a/spec/lib/api/v3/queries/columns/query_relation_to_type_column_representer_spec.rb +++ b/spec/lib/api/v3/queries/columns/query_relation_to_type_column_representer_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe ::API::V3::Queries::Columns::QueryRelationToTypeColumnRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:column) { Queries::WorkPackages::Columns::RelationToTypeColumn.new(type) } let(:representer) { described_class.new(column) } diff --git a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb index b87ac5512c..5034495a96 100644 --- a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb +++ b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb @@ -34,7 +34,7 @@ describe ::API::V3::Queries::Filters::QueryFilterInstanceRepresenter do let(:operator) { '=' } let(:values) { [status.id.to_s] } - let(:status) { FactoryGirl.build_stubbed(:status) } + let(:status) { FactoryBot.build_stubbed(:status) } let(:filter) do f = Queries::WorkPackages::Filter::StatusFilter.create! @@ -166,7 +166,7 @@ describe ::API::V3::Queries::Filters::QueryFilterInstanceRepresenter do end context 'with a bool custom field filter' do - let(:bool_cf) { FactoryGirl.create(:bool_wp_custom_field) } + let(:bool_cf) { FactoryBot.create(:bool_wp_custom_field) } let(:filter) do Queries::WorkPackages::Filter::CustomFieldFilter.create!(name: "cf_#{bool_cf.id}", operator: operator, values: values) end diff --git a/spec/lib/api/v3/queries/filters/query_filter_representer_spec.rb b/spec/lib/api/v3/queries/filters/query_filter_representer_spec.rb index d8db5b145f..2ce121ef0f 100644 --- a/spec/lib/api/v3/queries/filters/query_filter_representer_spec.rb +++ b/spec/lib/api/v3/queries/filters/query_filter_representer_spec.rb @@ -76,7 +76,7 @@ describe ::API::V3::Queries::Filters::QueryFilterRepresenter do end context 'for a custom field filter' do - let(:custom_field) { FactoryGirl.build_stubbed(:list_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:list_wp_custom_field) } let(:filter) do Queries::WorkPackages::Filter::CustomFieldFilter.from_custom_field! custom_field: custom_field end diff --git a/spec/lib/api/v3/queries/query_representer_generation_spec.rb b/spec/lib/api/v3/queries/query_representer_generation_spec.rb index 76aeed46b2..f60342608d 100644 --- a/spec/lib/api/v3/queries/query_representer_generation_spec.rb +++ b/spec/lib/api/v3/queries/query_representer_generation_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::QueryRepresenter do include ::API::V3::Utilities::PathHelper - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:user) { double('current_user', allowed_to?: true, admin: true, admin?: true) } let(:embed_links) { true } let(:representer) do @@ -117,7 +117,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'has no project' do - let(:query) { FactoryGirl.build_stubbed(:query, project: nil) } + let(:query) { FactoryBot.build_stubbed(:query, project: nil) } it_behaves_like 'has an empty link' do let(:link) { 'project' } @@ -150,7 +150,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'without a project' do - let(:query) { FactoryGirl.build_stubbed(:query, project: nil) } + let(:query) { FactoryBot.build_stubbed(:query, project: nil) } it_behaves_like 'has an untitled link' do let(:link) { 'schema' } @@ -159,7 +159,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'when unpersisted' do - let(:query) { FactoryGirl.build(:query, project: project) } + let(:query) { FactoryBot.build(:query, project: project) } it_behaves_like 'has an untitled link' do let(:link) { 'update' } @@ -168,7 +168,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'when unpersisted outside a project' do - let(:query) { FactoryGirl.build(:query) } + let(:query) { FactoryBot.build(:query) } it_behaves_like 'has an untitled link' do let(:link) { 'update' } @@ -186,7 +186,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'when not persisted' do - let(:query) { FactoryGirl.build(:query, project: project) } + let(:query) { FactoryBot.build(:query, project: project) } it_behaves_like 'has no link' do let(:link) { 'delete' } @@ -220,7 +220,7 @@ describe ::API::V3::Queries::QueryRepresenter do end context 'when not persisted and lacking permission' do - let(:query) { FactoryGirl.build(:query, project: project) } + let(:query) { FactoryBot.build(:query, project: project) } it_behaves_like 'has no link' do let(:link) { 'updateImmediately' } @@ -230,7 +230,7 @@ describe ::API::V3::Queries::QueryRepresenter do context 'when not persisted and having permission' do let(:permissions) { [:create] } - let(:query) { FactoryGirl.build(:query, project: project) } + let(:query) { FactoryBot.build(:query, project: project) } it_behaves_like 'has an untitled link' do let(:link) { 'updateImmediately' } @@ -263,7 +263,7 @@ describe ::API::V3::Queries::QueryRepresenter do end let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) query.add_filter('subject', '~', ['bogus']) query.group_by = 'author' query.sort_criteria = [['assigned_to', 'asc'], ['type', 'desc']] @@ -318,7 +318,7 @@ describe ::API::V3::Queries::QueryRepresenter do context 'without columns' do let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) # need to write bogus here because the query # will otherwise sport the default columns @@ -336,7 +336,7 @@ describe ::API::V3::Queries::QueryRepresenter do context 'with columns' do let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) query.column_names = ['status', 'assigned_to', 'updated_at'] @@ -375,7 +375,7 @@ describe ::API::V3::Queries::QueryRepresenter do context 'with group_by' do let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) query.group_by = 'status' @@ -399,7 +399,7 @@ describe ::API::V3::Queries::QueryRepresenter do context 'with sort_by' do let(:query) do - FactoryGirl.build_stubbed(:query, + FactoryBot.build_stubbed(:query, sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']]) end @@ -523,7 +523,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'with filters' do let(:query) do - query = FactoryGirl.build_stubbed(:query) + query = FactoryBot.build_stubbed(:query) query.add_filter('status_id', '=', [filter_status.id.to_s]) allow(query.filters.last) .to receive(:value_objects) @@ -535,8 +535,8 @@ describe ::API::V3::Queries::QueryRepresenter do query end - let(:filter_status) { FactoryGirl.build_stubbed(:status) } - let(:filter_user) { FactoryGirl.build_stubbed(:user) } + let(:filter_status) { FactoryBot.build_stubbed(:status) } + let(:filter_user) { FactoryBot.build_stubbed(:user) } it 'should render the filters' do expected_status = { @@ -594,7 +594,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'with sort criteria' do let(:query) do - FactoryGirl.build_stubbed(:query, + FactoryBot.build_stubbed(:query, sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']]) end @@ -611,7 +611,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'with columns' do let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) query.column_names = ['status', 'assigned_to', 'updated_at'] @@ -638,7 +638,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'with group by' do let(:query) do - query = FactoryGirl.build_stubbed(:query, project: project) + query = FactoryBot.build_stubbed(:query, project: project) query.group_by = 'status' @@ -665,7 +665,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'when timeline is visible' do let(:query) do - FactoryGirl.build_stubbed(:query, project: project).tap do |query| + FactoryBot.build_stubbed(:query, project: project).tap do |query| query.timeline_visible = true end end @@ -676,7 +676,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'when labels are overridden' do let(:query) do - FactoryGirl.build_stubbed(:query, project: project).tap do |query| + FactoryBot.build_stubbed(:query, project: project).tap do |query| query.timeline_labels = expected end end @@ -691,7 +691,7 @@ describe ::API::V3::Queries::QueryRepresenter do describe 'when timeline zoom level is changed' do let(:query) do - FactoryGirl.build_stubbed(:query, project: project).tap do |query| + FactoryBot.build_stubbed(:query, project: project).tap do |query| query.timeline_zoom_level = :weeks end end @@ -702,7 +702,7 @@ describe ::API::V3::Queries::QueryRepresenter do end describe 'embedded results' do - let(:query) { FactoryGirl.build_stubbed(:query) } + let(:query) { FactoryBot.build_stubbed(:query) } let(:representer) do described_class.new(query, current_user: user, diff --git a/spec/lib/api/v3/queries/query_representer_parsing_spec.rb b/spec/lib/api/v3/queries/query_representer_parsing_spec.rb index a588a6b488..1eb9fbeb67 100644 --- a/spec/lib/api/v3/queries/query_representer_parsing_spec.rb +++ b/spec/lib/api/v3/queries/query_representer_parsing_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::QueryRepresenter do include ::API::V3::Utilities::PathHelper - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:user) { double('current_user') } let(:representer) do described_class.new(query, current_user: user, embed_links: true) diff --git a/spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb index cdf4c2f37b..69d16970d6 100644 --- a/spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/assigned_to_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::AssignedToFilter.create!(context: query) } let(:form_embedded) { false } let(:group_assignment_enabled) { false } @@ -158,7 +158,7 @@ describe ::API::V3::Queries::Schemas::AssignedToFilterDependencyRepresenter, cle describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb index 3f1d0e314a..1cda69fece 100644 --- a/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/boolean_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:bool_cf) { FactoryGirl.build_stubbed(:bool_wp_custom_field) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:bool_cf) { FactoryBot.build_stubbed(:bool_wp_custom_field) } let(:filter) do Queries::WorkPackages::Filter::CustomFieldFilter.from_custom_field! custom_field: bool_cf, context: project diff --git a/spec/lib/api/v3/queries/schemas/category_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/category_filter_dependency_representer_spec.rb index 16d318c4ec..e343a57956 100644 --- a/spec/lib/api/v3/queries/schemas/category_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/category_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::CategoryFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::CategoryFilter.create!(context: query) } let(:form_embedded) { false } @@ -79,7 +79,7 @@ describe ::API::V3::Queries::Schemas::CategoryFilterDependencyRepresenter, clear describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/custom_option_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/custom_option_filter_dependency_representer_spec.rb index 6f7c5f9b37..185f6af461 100644 --- a/spec/lib/api/v3/queries/schemas/custom_option_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/custom_option_filter_dependency_representer_spec.rb @@ -31,15 +31,15 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:custom_field) do - cf = FactoryGirl.build_stubbed(:list_wp_custom_field) + cf = FactoryBot.build_stubbed(:list_wp_custom_field) allow(cf) .to receive(:custom_options) - .and_return([FactoryGirl.build_stubbed(:custom_option), - FactoryGirl.build_stubbed(:custom_option)]) + .and_return([FactoryBot.build_stubbed(:custom_option), + FactoryBot.build_stubbed(:custom_option)]) cf end let(:filter) do diff --git a/spec/lib/api/v3/queries/schemas/date_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/date_filter_dependency_representer_spec.rb index 5253ab181e..6f7785e854 100644 --- a/spec/lib/api/v3/queries/schemas/date_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/date_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::DateFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::DueDateFilter.create!(context: query) } let(:form_embedded) { false } @@ -110,7 +110,7 @@ describe ::API::V3::Queries::Schemas::DateFilterDependencyRepresenter, clear_cac describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/date_time_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/date_time_filter_dependency_representer_spec.rb index f699c771bc..d0b3b431eb 100644 --- a/spec/lib/api/v3/queries/schemas/date_time_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/date_time_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::DateTimeFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::CreatedAtFilter.create!(context: query) } let(:form_embedded) { false } @@ -99,7 +99,7 @@ describe ::API::V3::Queries::Schemas::DateTimeFilterDependencyRepresenter, clear describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb b/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb index b2f2d6e0a3..040654e4e2 100644 --- a/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb +++ b/spec/lib/api/v3/queries/schemas/filter_dependency_representer_factory_spec.rb @@ -75,7 +75,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type int' do - let(:custom_field) { FactoryGirl.build_stubbed(:int_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:int_wp_custom_field) } it 'is the integer dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter) @@ -83,7 +83,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type float' do - let(:custom_field) { FactoryGirl.build_stubbed(:float_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:float_wp_custom_field) } it 'is the float dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter) @@ -91,7 +91,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type text' do - let(:custom_field) { FactoryGirl.build_stubbed(:text_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:text_wp_custom_field) } it 'is the text dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::TextFilterDependencyRepresenter) @@ -99,7 +99,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type list' do - let(:custom_field) { FactoryGirl.build_stubbed(:list_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:list_wp_custom_field) } it 'is the string object dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::CustomOptionFilterDependencyRepresenter) @@ -107,7 +107,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type user' do - let(:custom_field) { FactoryGirl.build_stubbed(:user_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:user_wp_custom_field) } it 'is the user dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::UserFilterDependencyRepresenter) @@ -115,7 +115,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type version' do - let(:custom_field) { FactoryGirl.build_stubbed(:version_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:version_wp_custom_field) } it 'is the version dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter) @@ -123,7 +123,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type date' do - let(:custom_field) { FactoryGirl.build_stubbed(:date_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:date_wp_custom_field) } it 'is the date dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::DateFilterDependencyRepresenter) @@ -131,7 +131,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type bool' do - let(:custom_field) { FactoryGirl.build_stubbed(:bool_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:bool_wp_custom_field) } it 'is the string object dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::BooleanFilterDependencyRepresenter) @@ -139,7 +139,7 @@ describe ::API::V3::Queries::Schemas::FilterDependencyRepresenterFactory do end context 'type string' do - let(:custom_field) { FactoryGirl.build_stubbed(:string_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:string_wp_custom_field) } it 'is the text dependency' do is_expected.to be_a(::API::V3::Queries::Schemas::TextFilterDependencyRepresenter) diff --git a/spec/lib/api/v3/queries/schemas/float_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/float_filter_dependency_representer_spec.rb index b599e83873..5d5aa020ea 100644 --- a/spec/lib/api/v3/queries/schemas/float_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/float_filter_dependency_representer_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } - let(:custom_field) { FactoryGirl.build_stubbed(:float_wp_custom_field) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } + let(:custom_field) { FactoryBot.build_stubbed(:float_wp_custom_field) } let(:filter) do Queries::WorkPackages::Filter::CustomFieldFilter.from_custom_field! custom_field: custom_field, context: query @@ -94,7 +94,7 @@ describe ::API::V3::Queries::Schemas::FloatFilterDependencyRepresenter, clear_ca describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/group_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/group_filter_dependency_representer_spec.rb index 9f7dcfd957..68cfbad694 100644 --- a/spec/lib/api/v3/queries/schemas/group_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/group_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::GroupFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::GroupFilter.create!(context: query) } let(:form_embedded) { false } @@ -109,7 +109,7 @@ describe ::API::V3::Queries::Schemas::GroupFilterDependencyRepresenter, clear_ca describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/id_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/id_filter_dependency_representer_spec.rb index 3b7462eb2e..dd0de47ba7 100644 --- a/spec/lib/api/v3/queries/schemas/id_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/id_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::IdFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::IdFilter.create!(context: query) } let(:form_embedded) { false } @@ -88,7 +88,7 @@ describe ::API::V3::Queries::Schemas::IdFilterDependencyRepresenter, clear_cache describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/integer_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/integer_filter_dependency_representer_spec.rb index e78c270248..6581d5269a 100644 --- a/spec/lib/api/v3/queries/schemas/integer_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/integer_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::IntegerFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::DoneRatioFilter.create!(context: query) } let(:form_embedded) { false } diff --git a/spec/lib/api/v3/queries/schemas/parent_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/parent_filter_dependency_representer_spec.rb index a93ee60c17..8a2a3d2ca7 100644 --- a/spec/lib/api/v3/queries/schemas/parent_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/parent_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::ParentFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::ParentFilter.create!(context: query) } let(:form_embedded) { false } @@ -88,7 +88,7 @@ describe ::API::V3::Queries::Schemas::ParentFilterDependencyRepresenter, clear_c describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/priority_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/priority_filter_dependency_representer_spec.rb index bb4b4e6efe..8d7e6a68ab 100644 --- a/spec/lib/api/v3/queries/schemas/priority_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/priority_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::PriorityFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::PriorityFilter.create!(context: query) } let(:form_embedded) { false } diff --git a/spec/lib/api/v3/queries/schemas/query_filter_instance_schema_representer_spec.rb b/spec/lib/api/v3/queries/schemas/query_filter_instance_schema_representer_spec.rb index d4bde055c6..bf5f6bb7fc 100644 --- a/spec/lib/api/v3/queries/schemas/query_filter_instance_schema_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/query_filter_instance_schema_representer_spec.rb @@ -43,7 +43,7 @@ describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter, clea filter end - let(:custom_field) { FactoryGirl.build_stubbed(:list_wp_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:list_wp_custom_field) } let(:instance) do described_class.new(filter, self_link, @@ -53,7 +53,7 @@ describe ::API::V3::Queries::Schemas::QueryFilterInstanceSchemaRepresenter, clea let(:form_embedded) { false } let(:self_link) { 'bogus_self_path' } let(:project) { nil } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:json_cacheable) { true } let(:json_cache_key) { 'some key' } let(:dependency) do diff --git a/spec/lib/api/v3/queries/schemas/query_schema_representer_spec.rb b/spec/lib/api/v3/queries/schemas/query_schema_representer_spec.rb index 97e6f54094..fb342ec7f2 100644 --- a/spec/lib/api/v3/queries/schemas/query_schema_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/query_schema_representer_spec.rb @@ -279,7 +279,7 @@ describe ::API::V3::Queries::Schemas::QuerySchemaRepresenter do context 'when embedding' do let(:form_embedded) { true } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:available_values) do [Queries::WorkPackages::Columns::PropertyColumn.new(:bogus1), Queries::WorkPackages::Columns::PropertyColumn.new(:bogus2), @@ -336,7 +336,7 @@ describe ::API::V3::Queries::Schemas::QuerySchemaRepresenter do end context 'when project query' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:href) { api_v3_paths.query_project_filter_instance_schemas(project.id) } it 'contains the link to the filter schemas' do @@ -453,7 +453,7 @@ describe ::API::V3::Queries::Schemas::QuerySchemaRepresenter do end context 'when project query' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:href) { api_v3_paths.query_project_filter_instance_schemas(project.id) } it 'contains a collection of filter schemas' do diff --git a/spec/lib/api/v3/queries/schemas/subproject_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/subproject_filter_dependency_representer_spec.rb index feaf57c284..be429a74d5 100644 --- a/spec/lib/api/v3/queries/schemas/subproject_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/subproject_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::SubprojectFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::SubprojectFilter.create!(context: query) } let(:form_embedded) { false } @@ -78,7 +78,7 @@ describe ::API::V3::Queries::Schemas::SubprojectFilterDependencyRepresenter, cle describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/text_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/text_filter_dependency_representer_spec.rb index b2bcddbc2a..a41e488703 100644 --- a/spec/lib/api/v3/queries/schemas/text_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/text_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::TextFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::SubjectFilter.create!(context: query) } let(:form_embedded) { false } diff --git a/spec/lib/api/v3/queries/schemas/type_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/type_filter_dependency_representer_spec.rb index 42b004cc94..d6dc8c5177 100644 --- a/spec/lib/api/v3/queries/schemas/type_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/type_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::TypeFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::TypeFilter.create!(context: query) } let(:form_embedded) { false } @@ -91,7 +91,7 @@ describe ::API::V3::Queries::Schemas::TypeFilterDependencyRepresenter, clear_cac describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb index 09f2b4372f..796b8b0131 100644 --- a/spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/user_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed :project } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed :project } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::AuthorFilter.create!(context: query) } let(:form_embedded) { false } @@ -94,7 +94,7 @@ describe ::API::V3::Queries::Schemas::UserFilterDependencyRepresenter, clear_cac describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/queries/schemas/version_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/version_filter_dependency_representer_spec.rb index 03bf501e73..c94cfd1216 100644 --- a/spec/lib/api/v3/queries/schemas/version_filter_dependency_representer_spec.rb +++ b/spec/lib/api/v3/queries/schemas/version_filter_dependency_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter, clear_cache: true do include ::API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:filter) { Queries::WorkPackages::Filter::VersionFilter.create!(context: query) } let(:form_embedded) { false } @@ -107,7 +107,7 @@ describe ::API::V3::Queries::Schemas::VersionFilterDependencyRepresenter, clear_ describe 'caching' do let(:operator) { Queries::Operators::Equals } - let(:other_project) { FactoryGirl.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } before do # fill the cache diff --git a/spec/lib/api/v3/relations/relation_collection_representer_spec.rb b/spec/lib/api/v3/relations/relation_collection_representer_spec.rb index 4a6560c7df..fcb0868ceb 100644 --- a/spec/lib/api/v3/relations/relation_collection_representer_spec.rb +++ b/spec/lib/api/v3/relations/relation_collection_representer_spec.rb @@ -30,19 +30,19 @@ require 'spec_helper' describe ::API::V3::Relations::RelationCollectionRepresenter do let(:work_package) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:relations) do (1..3).map do - FactoryGirl.build_stubbed(:relation, + FactoryBot.build_stubbed(:relation, from: work_package, - to: FactoryGirl.build_stubbed(:work_package)) + to: FactoryBot.build_stubbed(:work_package)) end end let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end def self_link diff --git a/spec/lib/api/v3/relations/relation_representer_spec.rb b/spec/lib/api/v3/relations/relation_representer_spec.rb index ac85d83af9..effcb1e159 100644 --- a/spec/lib/api/v3/relations/relation_representer_spec.rb +++ b/spec/lib/api/v3/relations/relation_representer_spec.rb @@ -29,17 +29,17 @@ require 'spec_helper' describe ::API::V3::Relations::RelationRepresenter do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:from) { FactoryGirl.create :work_package } - let(:to) { FactoryGirl.create :work_package } + let(:from) { FactoryBot.create :work_package } + let(:to) { FactoryBot.create :work_package } let(:type) { "follows" } let(:description) { "This first" } let(:delay) { 3 } let(:relation) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: from, to: to, relation_type: type, diff --git a/spec/lib/api/v3/repositories/revision_representer_spec.rb b/spec/lib/api/v3/repositories/revision_representer_spec.rb index 48ff824361..a9f1da8909 100644 --- a/spec/lib/api/v3/repositories/revision_representer_spec.rb +++ b/spec/lib/api/v3/repositories/revision_representer_spec.rb @@ -33,10 +33,10 @@ describe ::API::V3::Repositories::RevisionRepresenter do let(:representer) { described_class.new(revision, current_user: double('current_user')) } - let(:project) { FactoryGirl.build :project } - let(:repository) { FactoryGirl.build :repository_subversion, project: project } + let(:project) { FactoryBot.build :project } + let(:repository) { FactoryBot.build :repository_subversion, project: project } let(:revision) { - FactoryGirl.build(:changeset, + FactoryBot.build(:changeset, id: 42, revision: '1234', repository: repository, @@ -89,7 +89,7 @@ describe ::API::V3::Repositories::RevisionRepresenter do end context 'with referencing commit message' do - let(:work_package) { FactoryGirl.build_stubbed(:work_package, project: project) } + let(:work_package) { FactoryBot.build_stubbed(:work_package, project: project) } let(:commit_message) { "Totally references ##{work_package.id}" } let(:html_reference) { id = work_package.id @@ -102,7 +102,7 @@ describe ::API::V3::Repositories::RevisionRepresenter do } before do - allow(User).to receive(:current).and_return(FactoryGirl.build_stubbed(:admin)) + allow(User).to receive(:current).and_return(FactoryBot.build_stubbed(:admin)) allow(WorkPackage) .to receive_message_chain('visible.includes.references.find_by') .and_return(work_package) @@ -123,7 +123,7 @@ describe ::API::V3::Repositories::RevisionRepresenter do end context 'with linked user as author' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } before do allow(revision).to receive(:user).and_return(user) end diff --git a/spec/lib/api/v3/root_representer_spec.rb b/spec/lib/api/v3/root_representer_spec.rb index 471adffee2..f6c85b7bd5 100644 --- a/spec/lib/api/v3/root_representer_spec.rb +++ b/spec/lib/api/v3/root_representer_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe ::API::V3::RootRepresenter do include ::API::V3::Utilities::PathHelper - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } let(:representer) { described_class.new({}, current_user: user) } let(:app_title) { 'Foo Project' } let(:version) { 'The version is over 9000!' } diff --git a/spec/lib/api/v3/statuses/status_collection_representer_spec.rb b/spec/lib/api/v3/statuses/status_collection_representer_spec.rb index fd7d1931c6..4c2c1c6ddd 100644 --- a/spec/lib/api/v3/statuses/status_collection_representer_spec.rb +++ b/spec/lib/api/v3/statuses/status_collection_representer_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe ::API::V3::Statuses::StatusCollectionRepresenter do include API::V3::Utilities::PathHelper - let(:statuses) { FactoryGirl.build_list(:status, 3) } + let(:statuses) { FactoryBot.build_list(:status, 3) } let(:representer) { described_class.new(statuses, api_v3_paths.statuses, current_user: double('current_user')) } diff --git a/spec/lib/api/v3/statuses/status_representer_spec.rb b/spec/lib/api/v3/statuses/status_representer_spec.rb index d23cf45686..80384230bf 100644 --- a/spec/lib/api/v3/statuses/status_representer_spec.rb +++ b/spec/lib/api/v3/statuses/status_representer_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::API::V3::Statuses::StatusRepresenter do - let(:status) { FactoryGirl.build_stubbed(:status) } + let(:status) { FactoryBot.build_stubbed(:status) } let(:representer) { described_class.new(status, current_user: double('current_user')) } context 'generation' do diff --git a/spec/lib/api/v3/support/link_examples.rb b/spec/lib/api/v3/support/link_examples.rb index e4b1e12784..f7102a12ec 100644 --- a/spec/lib/api/v3/support/link_examples.rb +++ b/spec/lib/api/v3/support/link_examples.rb @@ -34,7 +34,7 @@ require 'spec_helper' shared_examples_for 'action link' do let(:permissions) { %i(view_work_packages edit_work_packages) } let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:href) { nil } diff --git a/spec/lib/api/v3/time_entries/time_entries_activity_representer_rendering_spec.rb b/spec/lib/api/v3/time_entries/time_entries_activity_representer_rendering_spec.rb index 97fba01d3c..347aa7fb48 100644 --- a/spec/lib/api/v3/time_entries/time_entries_activity_representer_rendering_spec.rb +++ b/spec/lib/api/v3/time_entries/time_entries_activity_representer_rendering_spec.rb @@ -32,9 +32,9 @@ describe ::API::V3::TimeEntries::TimeEntriesActivityRepresenter, 'rendering' do include ::API::V3::Utilities::PathHelper let(:activity) do - FactoryGirl.build_stubbed(:time_entry_activity) + FactoryBot.build_stubbed(:time_entry_activity) end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) do described_class.new(activity, current_user: user, embed_links: true) end @@ -50,8 +50,8 @@ describe ::API::V3::TimeEntries::TimeEntriesActivityRepresenter, 'rendering' do # returns the projects where it (and it's children) is active it_behaves_like 'has a link collection' do - let(:project1) { FactoryGirl.build_stubbed(:project) } - let(:project2) { FactoryGirl.build_stubbed(:project) } + let(:project1) { FactoryBot.build_stubbed(:project) } + let(:project2) { FactoryBot.build_stubbed(:project) } before do allow(activity) diff --git a/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb b/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb index da1dd42105..c792c80676 100644 --- a/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb +++ b/spec/lib/api/v3/time_entries/time_entry_representer_rendering_spec.rb @@ -32,7 +32,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do include ::API::V3::Utilities::PathHelper let(:time_entry) do - FactoryGirl.build_stubbed(:time_entry, + FactoryBot.build_stubbed(:time_entry, comments: 'blubs', spent_on: Date.today, created_on: DateTime.now - 6.hours, @@ -42,10 +42,10 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do project: project, user: user) end - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:work_package) { time_entry.work_package } - let(:activity) { FactoryGirl.build_stubbed(:time_entry_activity) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:activity) { FactoryBot.build_stubbed(:time_entry_activity) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) do described_class.create(time_entry, current_user: user, embed_links: true) end @@ -90,7 +90,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do context 'for a non shared (project specific) activity' do let(:activity) do - activity = FactoryGirl.build_stubbed(:time_entry_activity, + activity = FactoryBot.build_stubbed(:time_entry_activity, project: project, parent: parent_activity) allow(activity) @@ -100,7 +100,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do activity end let(:parent_activity) do - FactoryGirl.build_stubbed(:time_entry_activity) + FactoryBot.build_stubbed(:time_entry_activity) end it_behaves_like 'has a titled link' do @@ -112,7 +112,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do context 'custom value' do let(:custom_field) do - FactoryGirl.build_stubbed(:time_entry_custom_field, field_format: 'user') + FactoryBot.build_stubbed(:time_entry_custom_field, field_format: 'user') end let(:custom_value) do CustomValue.new(custom_field: custom_field, @@ -120,7 +120,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do customized: time_entry) end let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end before do @@ -160,7 +160,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do end context 'with an empty comment' do - let(:time_entry) { FactoryGirl.build_stubbed(:time_entry) } + let(:time_entry) { FactoryBot.build_stubbed(:time_entry) } it_behaves_like 'property', :comment do let(:value) { time_entry.comments } end @@ -183,7 +183,7 @@ describe ::API::V3::TimeEntries::TimeEntryRepresenter, 'rendering' do end context 'custom value' do - let(:custom_field) { FactoryGirl.build_stubbed(:time_entry_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:time_entry_custom_field) } let(:custom_value) do CustomValue.new(custom_field: custom_field, value: '1234', diff --git a/spec/lib/api/v3/types/type_representer_spec.rb b/spec/lib/api/v3/types/type_representer_spec.rb index b61d6e1e44..fd0cd43233 100644 --- a/spec/lib/api/v3/types/type_representer_spec.rb +++ b/spec/lib/api/v3/types/type_representer_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::API::V3::Types::TypeRepresenter do - let(:type) { FactoryGirl.build_stubbed(:type, color: FactoryGirl.build_stubbed(:color)) } + let(:type) { FactoryBot.build_stubbed(:type, color: FactoryBot.build_stubbed(:color)) } let(:representer) { described_class.new(type, current_user: double('current_user')) } include API::V3::Utilities::PathHelper @@ -58,7 +58,7 @@ describe ::API::V3::Types::TypeRepresenter do end context 'no color set' do - let(:type) { FactoryGirl.build_stubbed(:type, color: nil) } + let(:type) { FactoryBot.build_stubbed(:type, color: nil) } it 'indicates a missing color' do is_expected.to be_json_eql(nil.to_json).at_path('color') @@ -74,7 +74,7 @@ describe ::API::V3::Types::TypeRepresenter do end context 'as default type' do - let(:type) { FactoryGirl.build_stubbed(:type, is_default: true) } + let(:type) { FactoryBot.build_stubbed(:type, is_default: true) } it 'indicates that it is the default type' do is_expected.to be_json_eql(true.to_json).at_path('isDefault') @@ -86,7 +86,7 @@ describe ::API::V3::Types::TypeRepresenter do end context 'as milestone' do - let(:type) { FactoryGirl.build_stubbed(:type, is_milestone: true) } + let(:type) { FactoryBot.build_stubbed(:type, is_milestone: true) } it 'indicates that it is a milestone' do is_expected.to be_json_eql(true.to_json).at_path('isMilestone') diff --git a/spec/lib/api/v3/user_preferences/user_preferences_representer_spec.rb b/spec/lib/api/v3/user_preferences/user_preferences_representer_spec.rb index 9941c11420..f60093acda 100644 --- a/spec/lib/api/v3/user_preferences/user_preferences_representer_spec.rb +++ b/spec/lib/api/v3/user_preferences/user_preferences_representer_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::UserPreferences::UserPreferencesRepresenter do include ::API::V3::Utilities::PathHelper - let(:preference) { FactoryGirl.build(:user_preference) } - let(:user) { FactoryGirl.build_stubbed(:user, preference: preference) } + let(:preference) { FactoryBot.build(:user_preference) } + let(:user) { FactoryBot.build_stubbed(:user, preference: preference) } let(:representer) { described_class.new(preference, current_user: user) } before do @@ -52,7 +52,7 @@ describe ::API::V3::UserPreferences::UserPreferencesRepresenter do describe 'timeZone' do context 'no time zone set' do - let(:preference) { FactoryGirl.build(:user_preference, time_zone: '') } + let(:preference) { FactoryBot.build(:user_preference, time_zone: '') } it 'shows the timeZone as nil' do is_expected.to be_json_eql(nil.to_json).at_path('timeZone') @@ -60,7 +60,7 @@ describe ::API::V3::UserPreferences::UserPreferencesRepresenter do end context 'short timezone set' do - let(:preference) { FactoryGirl.build(:user_preference, time_zone: 'Berlin') } + let(:preference) { FactoryBot.build(:user_preference, time_zone: 'Berlin') } it 'shows the canonical time zone' do is_expected.to be_json_eql('Europe/Berlin'.to_json).at_path('timeZone') @@ -68,7 +68,7 @@ describe ::API::V3::UserPreferences::UserPreferencesRepresenter do end context 'canonical timezone set' do - let(:preference) { FactoryGirl.build(:user_preference, time_zone: 'Europe/Paris') } + let(:preference) { FactoryBot.build(:user_preference, time_zone: 'Europe/Paris') } it 'shows the canonical time zone' do is_expected.to be_json_eql('Europe/Paris'.to_json).at_path('timeZone') diff --git a/spec/lib/api/v3/users/paginated_user_collection_representer_spec.rb b/spec/lib/api/v3/users/paginated_user_collection_representer_spec.rb index 01a94b0e8c..24e3fd5f84 100644 --- a/spec/lib/api/v3/users/paginated_user_collection_representer_spec.rb +++ b/spec/lib/api/v3/users/paginated_user_collection_representer_spec.rb @@ -37,7 +37,7 @@ describe ::API::V3::Users::PaginatedUserCollectionRepresenter do let(:actual_count) { 3 } let(:users) { - users = FactoryGirl.build_stubbed_list(:user, + users = FactoryBot.build_stubbed_list(:user, actual_count, created_on: Time.now, updated_on: Time.now) diff --git a/spec/lib/api/v3/users/user_collection_representer_spec.rb b/spec/lib/api/v3/users/user_collection_representer_spec.rb index 1066d9542e..ec6eee1ea8 100644 --- a/spec/lib/api/v3/users/user_collection_representer_spec.rb +++ b/spec/lib/api/v3/users/user_collection_representer_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe ::API::V3::Users::UserCollectionRepresenter do let(:users) { - FactoryGirl.build_stubbed_list(:user, + FactoryBot.build_stubbed_list(:user, 3, created_on: Time.now, updated_on: Time.now) diff --git a/spec/lib/api/v3/users/user_representer_spec.rb b/spec/lib/api/v3/users/user_representer_spec.rb index 4f1e686358..8463bfe5f2 100644 --- a/spec/lib/api/v3/users/user_representer_spec.rb +++ b/spec/lib/api/v3/users/user_representer_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe ::API::V3::Users::UserRepresenter do - let(:user) { FactoryGirl.build_stubbed(:user, status: 1) } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user, status: 1) } + let(:current_user) { FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(user, current_user: current_user) } context 'generation' do @@ -69,7 +69,7 @@ describe ::API::V3::Users::UserRepresenter do end context 'as admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } it 'shows everything' do is_expected.to have_json_path('id') @@ -91,10 +91,10 @@ describe ::API::V3::Users::UserRepresenter do end describe 'email' do - let(:user) { FactoryGirl.build_stubbed(:user, status: 1, preference: preference) } + let(:user) { FactoryBot.build_stubbed(:user, status: 1, preference: preference) } context 'user shows his E-Mail address' do - let(:preference) { FactoryGirl.build(:user_preference, hide_mail: false) } + let(:preference) { FactoryBot.build(:user_preference, hide_mail: false) } it 'shows the users E-Mail address' do is_expected.to be_json_eql(user.mail.to_json).at_path('email') @@ -102,7 +102,7 @@ describe ::API::V3::Users::UserRepresenter do end context 'user hides his E-Mail address' do - let(:preference) { FactoryGirl.build(:user_preference, hide_mail: true) } + let(:preference) { FactoryBot.build(:user_preference, hide_mail: true) } it 'does not render the users E-Mail address' do is_expected.to be_json_eql(nil.to_json).at_path('email') @@ -135,7 +135,7 @@ describe ::API::V3::Users::UserRepresenter do end context 'when current_user is admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } it 'should link to lock and update' do expect(subject).to have_json_path('_links/lock/href') @@ -196,7 +196,7 @@ describe ::API::V3::Users::UserRepresenter do end describe '#json_cache_key' do - let(:auth_source) { FactoryGirl.build_stubbed(:auth_source) } + let(:auth_source) { FactoryBot.build_stubbed(:auth_source) } before do user.auth_source = auth_source diff --git a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb b/spec/lib/api/v3/utilities/custom_field_injector_spec.rb index 2f4b45a035..2e5569c032 100644 --- a/spec/lib/api/v3/utilities/custom_field_injector_spec.rb +++ b/spec/lib/api/v3/utilities/custom_field_injector_spec.rb @@ -34,7 +34,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do let(:cf_path) { "customField#{custom_field.id}" } let(:field_format) { 'bool' } let(:custom_field) do - FactoryGirl.build(:custom_field, + FactoryBot.build(:custom_field, id: 1, field_format: field_format, is_required: true) @@ -73,7 +73,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do context 'with default set' do let(:custom_field) do - FactoryGirl.build(:custom_field, + FactoryBot.build(:custom_field, id: 1, field_format: 'string', default_value: 'foo', @@ -97,7 +97,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do it_behaves_like 'indicates length requirements' context 'custom field is not required' do - let(:custom_field) { FactoryGirl.build(:custom_field, is_required: false) } + let(:custom_field) { FactoryBot.build(:custom_field, is_required: false) } it 'marks the field as not required' do is_expected.to be_json_eql(false.to_json).at_path("#{cf_path}/required") @@ -105,7 +105,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'custom field has regex' do - let(:custom_field) { FactoryGirl.build(:custom_field, regexp: 'Foo+bar') } + let(:custom_field) { FactoryBot.build(:custom_field, regexp: 'Foo+bar') } it 'renders the regular expression' do is_expected.to be_json_eql('Foo+bar'.to_json).at_path("#{cf_path}/regularExpression") @@ -113,7 +113,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'custom field has minimum length' do - let(:custom_field) { FactoryGirl.build(:custom_field, min_length: 5) } + let(:custom_field) { FactoryBot.build(:custom_field, min_length: 5) } it_behaves_like 'indicates length requirements' do let(:min_length) { 5 } @@ -121,7 +121,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'custom field has maximum length' do - let(:custom_field) { FactoryGirl.build(:custom_field, max_length: 5) } + let(:custom_field) { FactoryBot.build(:custom_field, max_length: 5) } it_behaves_like 'indicates length requirements' do let(:max_length) { 5 } @@ -131,11 +131,11 @@ describe ::API::V3::Utilities::CustomFieldInjector do describe 'version custom field' do let(:custom_field) do - FactoryGirl.build(:version_wp_custom_field, + FactoryBot.build(:version_wp_custom_field, is_required: true) end - let(:assignable_versions) { FactoryGirl.build_list(:version, 3) } + let(:assignable_versions) { FactoryBot.build_list(:version, 3) } before do allow(schema) @@ -177,7 +177,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, is_required: true, possible_values: values @@ -206,7 +206,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do describe 'user custom field' do let(:custom_field) do - FactoryGirl.build(:custom_field, + FactoryBot.build(:custom_field, field_format: 'user', is_required: true) end @@ -262,7 +262,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do let(:raw_value) { nil } let(:typed_value) { raw_value } let(:value) { '' } - let(:current_user) { FactoryGirl.build(:user) } + let(:current_user) { FactoryBot.build(:user) } subject { modified_class.new(represented, current_user: current_user, embed_links: true).to_json } before do @@ -271,7 +271,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'user custom field' do - let(:value) { FactoryGirl.build(:user, id: 2) } + let(:value) { FactoryBot.build(:user, id: 2) } let(:raw_value) { value.id.to_s } let(:typed_value) { value } let(:field_format) { 'user' } @@ -298,7 +298,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'version custom field' do - let(:value) { FactoryGirl.build_stubbed(:version, id: 2) } + let(:value) { FactoryBot.build_stubbed(:version, id: 2) } let(:raw_value) { value.id.to_s } let(:typed_value) { value } let(:field_format) { 'version' } @@ -325,7 +325,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end context 'list custom field' do - let(:value) { FactoryGirl.build_stubbed(:custom_option) } + let(:value) { FactoryBot.build_stubbed(:custom_option) } let(:typed_value) { value.value } let(:raw_value) { value.id.to_s } let(:field_format) { 'list' } @@ -437,7 +437,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do end let(:custom_value) { double('CustomValue', value: value, typed_value: typed_value) } let(:value) { '' } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:typed_value) { value } subject { modified_class.new(represented, current_user: user).to_json } @@ -448,7 +448,7 @@ describe ::API::V3::Utilities::CustomFieldInjector do context 'reading' do let(:value) { '2' } - let(:typed_value) { FactoryGirl.build_stubbed(:user) } + let(:typed_value) { FactoryBot.build_stubbed(:user) } let(:field_format) { 'user' } it_behaves_like 'has a titled link' do diff --git a/spec/lib/api/v3/utilities/resource_link_generator_spec.rb b/spec/lib/api/v3/utilities/resource_link_generator_spec.rb index 3113e6ba49..946c4fa113 100644 --- a/spec/lib/api/v3/utilities/resource_link_generator_spec.rb +++ b/spec/lib/api/v3/utilities/resource_link_generator_spec.rb @@ -35,27 +35,27 @@ describe API::V3::Utilities::ResourceLinkGenerator do subject { described_class } describe ':make_link' do it 'supports work packages' do - wp = FactoryGirl.build_stubbed(:work_package) + wp = FactoryBot.build_stubbed(:work_package) expect(subject.make_link wp).to eql api_v3_paths.work_package(wp.id) end it 'supports priorities' do - prio = FactoryGirl.build_stubbed(:priority) + prio = FactoryBot.build_stubbed(:priority) expect(subject.make_link prio).to eql api_v3_paths.priority(prio.id) end it 'supports statuses' do - status = FactoryGirl.build_stubbed(:status) + status = FactoryBot.build_stubbed(:status) expect(subject.make_link status).to eql api_v3_paths.status(status.id) end it 'supports the anonymous user' do - user = FactoryGirl.build_stubbed(:anonymous) + user = FactoryBot.build_stubbed(:anonymous) expect(subject.make_link user).to eql api_v3_paths.user(user.id) end it 'returns nil for unsupported records' do - record = FactoryGirl.create(:custom_field) + record = FactoryBot.create(:custom_field) expect(subject.make_link record).to be_nil end diff --git a/spec/lib/api/v3/versions/version_collection_representer_spec.rb b/spec/lib/api/v3/versions/version_collection_representer_spec.rb index 83ef4272d0..b9fee15279 100644 --- a/spec/lib/api/v3/versions/version_collection_representer_spec.rb +++ b/spec/lib/api/v3/versions/version_collection_representer_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe ::API::V3::Versions::VersionCollectionRepresenter do let(:self_link) { '/api/v3/projects/1/versions' } - let(:versions) { FactoryGirl.build_list(:version, 3) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:versions) { FactoryBot.build_list(:version, 3) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(versions, self_link, current_user: user) } context 'generation' do diff --git a/spec/lib/api/v3/versions/version_representer_spec.rb b/spec/lib/api/v3/versions/version_representer_spec.rb index 31e70ed2d5..91e971e8f8 100644 --- a/spec/lib/api/v3/versions/version_representer_spec.rb +++ b/spec/lib/api/v3/versions/version_representer_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe ::API::V3::Versions::VersionRepresenter do - let(:version) { FactoryGirl.build_stubbed(:version) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:version) { FactoryBot.build_stubbed(:version) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(version, current_user: user) } include API::V3::Utilities::PathHelper diff --git a/spec/lib/api/v3/work_packages/create_form_representer_spec.rb b/spec/lib/api/v3/work_packages/create_form_representer_spec.rb index 664b1632d3..2eba0973db 100644 --- a/spec/lib/api/v3/work_packages/create_form_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/create_form_representer_spec.rb @@ -35,15 +35,15 @@ describe ::API::V3::WorkPackages::CreateFormRepresenter do let(:errors) { [] } let(:project) { - FactoryGirl.build_stubbed(:project) + FactoryBot.build_stubbed(:project) } let(:work_package) do - wp = FactoryGirl.build_stubbed(:work_package, project: project) + wp = FactoryBot.build_stubbed(:work_package, project: project) allow(wp).to receive(:assignable_versions).and_return [] wp end let(:current_user) { - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) } let(:representer) { described_class.new(work_package, current_user: current_user, errors: errors) @@ -180,7 +180,7 @@ describe ::API::V3::WorkPackages::CreateFormRepresenter do end context 'with project and general admin priviliges' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } before do allow(current_user).to receive(:allowed_to?) @@ -208,12 +208,12 @@ describe ::API::V3::WorkPackages::CreateFormRepresenter do end context "as admin" do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } context 'with type' do - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now, diff --git a/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb b/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb index 54b13ba5ac..7f302da958 100644 --- a/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb @@ -34,13 +34,13 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do let(:errors) { [] } let(:work_package) { - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now) } let(:current_user) { - FactoryGirl.build(:user, member_in_project: work_package.project) + FactoryBot.build(:user, member_in_project: work_package.project) } let(:representer) { described_class.new(work_package, current_user: current_user, errors: errors) @@ -115,9 +115,9 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do end context 'user with insufficient permissions' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } let(:current_user) do - FactoryGirl.build(:user, + FactoryBot.build(:user, member_in_project: work_package.project, member_through_role: role) end @@ -158,7 +158,7 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do end context 'with project and general admin priviliges' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } before do allow(current_user).to receive(:allowed_to?) @@ -186,12 +186,12 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do end context "as admin" do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } context 'with type' do - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now, diff --git a/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_integration_spec.rb b/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_integration_spec.rb index b9764bcef9..047d683282 100644 --- a/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_integration_spec.rb +++ b/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_integration_spec.rb @@ -31,20 +31,20 @@ require 'spec_helper' describe ::API::V3::WorkPackages::CustomActions::CustomActionsWrapper do - let!(:work_package1) { FactoryGirl.create(:work_package) } - let!(:work_package2) { FactoryGirl.create(:work_package) } + let!(:work_package1) { FactoryBot.create(:work_package) } + let!(:work_package2) { FactoryBot.create(:work_package) } let!(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: work_package2.project, member_through_role: role) end - let!(:role) { FactoryGirl.create(:role) } + let!(:role) { FactoryBot.create(:role) } let!(:status_custom_action) do - FactoryGirl.create(:custom_action, + FactoryBot.create(:custom_action, conditions: [CustomActions::Conditions::Status.new(work_package1.status_id.to_s)]) end let!(:role_custom_action) do - FactoryGirl.create(:custom_action, + FactoryBot.create(:custom_action, conditions: [CustomActions::Conditions::Role.new(role.id)]) end diff --git a/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_spec.rb b/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_spec.rb index ef98038533..109b1c5595 100644 --- a/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_spec.rb +++ b/spec/lib/api/v3/work_packages/custom_actions/custom_actions_wrapper_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe ::API::V3::WorkPackages::CustomActions::CustomActionsWrapper do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:custom_action) { FactoryGirl.build_stubbed(:custom_action) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:custom_action) { FactoryBot.build_stubbed(:custom_action) } let(:instance) do described_class.send(:new, work_package, [custom_action]) diff --git a/spec/lib/api/v3/work_packages/form_representer_spec.rb b/spec/lib/api/v3/work_packages/form_representer_spec.rb index e244b3c584..577a45448c 100644 --- a/spec/lib/api/v3/work_packages/form_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/form_representer_spec.rb @@ -33,13 +33,13 @@ describe ::API::V3::WorkPackages::FormRepresenter do let(:errors) { [] } let(:work_package) { - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now) } let(:current_user) { - FactoryGirl.build(:user, member_in_project: work_package.project) + FactoryBot.build(:user, member_in_project: work_package.project) } let(:representer) { described_class.new(work_package, current_user: current_user, errors: errors) diff --git a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb index 8a0a1c7ad8..1dbc24e39e 100644 --- a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:work_package) { - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, project: project, type: type) } @@ -145,8 +145,8 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do end describe '#assignable_priorities' do - let(:active_priority) { FactoryGirl.build(:priority, active: true) } - let(:inactive_priority) { FactoryGirl.build(:priority, active: false) } + let(:active_priority) { FactoryBot.build(:priority, active: true) } + let(:inactive_priority) { FactoryBot.build(:priority, active: false) } before do active_priority.save! @@ -262,8 +262,8 @@ describe ::API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do end describe '#assignable_custom_field_values' do - let(:list_cf) { FactoryGirl.create(:list_wp_custom_field) } - let(:version_cf) { FactoryGirl.build_stubbed(:version_wp_custom_field) } + let(:list_cf) { FactoryBot.create(:list_wp_custom_field) } + let(:version_cf) { FactoryBot.build_stubbed(:version_wp_custom_field) } it "is a list custom fields' possible values" do expect(subject.assignable_custom_field_values(list_cf)) diff --git a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb index 8b820de92d..cf3ae2bbf4 100644 --- a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe ::API::V3::WorkPackages::Schema::TypedWorkPackageSchema do - let(:project) { FactoryGirl.build(:project) } - let(:type) { FactoryGirl.build(:type) } + let(:project) { FactoryBot.build(:project) } + let(:type) { FactoryBot.build(:type) } let(:current_user) { double } subject { described_class.new(project: project, type: type) } @@ -92,8 +92,8 @@ describe ::API::V3::WorkPackages::Schema::TypedWorkPackageSchema do end describe '#assignable_custom_field_values' do - let(:list_cf) { FactoryGirl.build_stubbed(:list_wp_custom_field) } - let(:version_cf) { FactoryGirl.build_stubbed(:version_wp_custom_field) } + let(:list_cf) { FactoryBot.build_stubbed(:list_wp_custom_field) } + let(:version_cf) { FactoryBot.build_stubbed(:version_wp_custom_field) } it 'is nil for a list cf' do expect(subject.assignable_custom_field_values(list_cf)).to be_nil diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb index 2d9ef75d7b..801d107f34 100644 --- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb @@ -31,14 +31,14 @@ require 'spec_helper' describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.build_stubbed(:project_with_types) } + let(:project) { FactoryBot.build_stubbed(:project_with_types) } let(:wp_type) { project.types.first } - let(:custom_field) { FactoryGirl.build_stubbed(:custom_field) } - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package, project: project, type: wp_type) } + let(:custom_field) { FactoryBot.build_stubbed(:custom_field) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package, project: project, type: wp_type) } let(:current_user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end - let(:attribute_query) { FactoryGirl.build_stubbed(:query) } + let(:attribute_query) { FactoryBot.build_stubbed(:query) } let(:attribute_groups) do [Type::AttributeGroup.new(wp_type, "People", %w(assignee responsible)), Type::AttributeGroup.new(wp_type, "Estimates and time", %w(estimated_time spent_time)), @@ -98,7 +98,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do end context 'when values are allowed' do - let(:values) { FactoryGirl.build_stubbed_list(factory, 3) } + let(:values) { FactoryBot.build_stubbed_list(factory, 3) } before do allow(schema).to receive(:assignable_values).with(factory, anything).and_return(values) @@ -763,7 +763,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do let(:original_cache_key) { joined_cache_key } it 'changes when the project changes' do - work_package.project = FactoryGirl.build_stubbed(:project) + work_package.project = FactoryBot.build_stubbed(:project) expect(joined_cache_key).to_not eql(original_cache_key) end @@ -781,14 +781,14 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do end it 'changes when the type changes' do - work_package.type = FactoryGirl.build_stubbed(:type) + work_package.type = FactoryBot.build_stubbed(:type) expect(joined_cache_key).to_not eql(original_cache_key) end it 'changes when the locale changes' do allow(I18n).to receive(:locale).and_return(:de) - work_package.type = FactoryGirl.build_stubbed(:type) + work_package.type = FactoryBot.build_stubbed(:type) expect(joined_cache_key).to_not eql(original_cache_key) end @@ -796,7 +796,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do it 'changes when the custom_fields changes' do allow(work_package.project) .to receive(:all_work_package_custom_fields) - .and_return [FactoryGirl.build_stubbed(:custom_field)] + .and_return [FactoryBot.build_stubbed(:custom_field)] expect(joined_cache_key).to_not eql(original_cache_key) end diff --git a/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb index daff464cfe..be0ab5f79b 100644 --- a/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/schema/work_package_sums_schema_representer_spec.rb @@ -81,7 +81,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSumsSchemaRepresenter do end context 'custom field x' do - let(:custom_field) { FactoryGirl.build_stubbed(:integer_issue_custom_field) } + let(:custom_field) { FactoryBot.build_stubbed(:integer_issue_custom_field) } let(:available_custom_fields) { [custom_field] } context 'with it being configured to be summable' do diff --git a/spec/lib/api/v3/work_packages/update_form_representer_spec.rb b/spec/lib/api/v3/work_packages/update_form_representer_spec.rb index 5e2042b408..389d34edfe 100644 --- a/spec/lib/api/v3/work_packages/update_form_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/update_form_representer_spec.rb @@ -33,13 +33,13 @@ describe ::API::V3::WorkPackages::UpdateFormRepresenter do let(:errors) { [] } let(:work_package) { - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now) } let(:current_user) { - FactoryGirl.build(:user, member_in_project: work_package.project) + FactoryBot.build(:user, member_in_project: work_package.project) } let(:representer) { described_class.new(work_package, current_user: current_user, errors: errors) @@ -88,9 +88,9 @@ describe ::API::V3::WorkPackages::UpdateFormRepresenter do end context 'user with insufficient permissions' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } let(:current_user) { - FactoryGirl.build(:user, + FactoryBot.build(:user, member_in_project: work_package.project, member_through_role: role) } diff --git a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb index dfb2b940a1..fd08f6a6b2 100644 --- a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb @@ -33,7 +33,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do let(:self_base_link) { '/api/v3/example' } let(:work_packages) { WorkPackage.all } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:query) { {} } let(:groups) { nil } @@ -66,7 +66,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do .to receive(:allowed_to?) .and_return(true) - FactoryGirl.create_list(:work_package, total) + FactoryBot.create_list(:work_package, total) end context 'generation' do @@ -116,7 +116,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do end context 'with project scope' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } it 'has a project scoped collection of export formats if inside a project' do expected_query = query.merge(pageSize: 30, offset: 1) @@ -243,7 +243,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do end context 'in project context' do - let(:project) { FactoryGirl.build_stubbed :project } + let(:project) { FactoryBot.build_stubbed :project } it 'has no link to create work_packages' do is_expected @@ -384,7 +384,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do context 'with project admin priviliges' do # In this spec a user responds to `allowed_to` with true per default. - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } it 'has a link to set the custom fields for that project' do expected = { @@ -401,7 +401,7 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do context 'without project admin priviliges' do # In this spec a user responds to `allowed_to` with true per default. - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } before do allow(user).to receive(:allowed_to?).with(:edit_project, project).and_return(false) @@ -414,8 +414,8 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do context 'with project and general admin priviliges' do # In this spec a user responds to `allowed_to` with true per default. - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user) { FactoryGirl.build_stubbed(:admin) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user) { FactoryBot.build_stubbed(:admin) } before do allow(user).to receive(:allowed_to?).with(:edit_project, project).and_return(false) diff --git a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb index 2046ad5d99..4e482beb36 100644 --- a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb @@ -32,16 +32,16 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do include API::V3::Utilities::PathHelper let(:work_package) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, start_date: Date.today.to_datetime, due_date: Date.today.to_datetime, created_at: DateTime.now, updated_at: DateTime.now, - type: FactoryGirl.build_stubbed(:type)) + type: FactoryBot.build_stubbed(:type)) end let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:representer) do @@ -105,7 +105,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end context 'set' do - let(:work_package) { FactoryGirl.build(:work_package, estimated_hours: 0) } + let(:work_package) { FactoryBot.build(:work_package, estimated_hours: 0) } it { is_expected.to have_json_type(String).at_path('estimatedTime') } end @@ -156,7 +156,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end context 'no start date' do - let(:work_package) { FactoryGirl.build(:work_package, start_date: nil) } + let(:work_package) { FactoryBot.build(:work_package, start_date: nil) } it 'renders as null' do is_expected.to be_json_eql(nil.to_json).at_path('startDate') @@ -193,7 +193,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end context 'no due date' do - let(:work_package) { FactoryGirl.build(:work_package, due_date: nil) } + let(:work_package) { FactoryBot.build(:work_package, due_date: nil) } it 'renders as null' do is_expected.to be_json_eql(nil.to_json).at_path('dueDate') @@ -231,8 +231,8 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do context 'no due date' do let(:work_package) do - FactoryGirl.build_stubbed(:work_package, - type: FactoryGirl.build_stubbed(:type), + FactoryBot.build_stubbed(:work_package, + type: FactoryBot.build_stubbed(:type), due_date: nil) end @@ -284,7 +284,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'status' do - let(:status) { FactoryGirl.build_stubbed(:status) } + let(:status) { FactoryBot.build_stubbed(:status) } before do work_package.status = status @@ -299,7 +299,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'assignee and responsible' do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:link) { "/api/v3/users/#{user.id}" } describe 'assignee' do @@ -328,7 +328,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'version' do - let(:version) { FactoryGirl.build_stubbed(:version) } + let(:version) { FactoryBot.build_stubbed(:version) } before do work_package.fixed_version = version @@ -343,7 +343,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'category' do - let(:category) { FactoryGirl.build_stubbed(:category) } + let(:category) { FactoryBot.build_stubbed(:category) } before do work_package.category = category @@ -358,7 +358,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'priority' do - let(:priority) { FactoryGirl.build_stubbed(:priority) } + let(:priority) { FactoryBot.build_stubbed(:priority) } before do work_package.priority = priority @@ -374,7 +374,7 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do describe 'parent' do context 'with a parent' do - let(:parent) { FactoryGirl.build_stubbed(:work_package) } + let(:parent) { FactoryBot.build_stubbed(:work_package) } before do work_package.parent = parent @@ -602,9 +602,9 @@ describe ::API::V3::WorkPackages::WorkPackagePayloadRepresenter do end describe 'parent' do - let(:parent) { FactoryGirl.build_stubbed :work_package } + let(:parent) { FactoryBot.build_stubbed :work_package } let(:new_parent) do - wp = FactoryGirl.build_stubbed :work_package + wp = FactoryBot.build_stubbed :work_package allow(WorkPackage) .to receive(:find_by) .with(id: wp.id.to_s) diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb index 6d9f7bcad1..65d57f6eb1 100644 --- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe ::API::V3::WorkPackages::WorkPackageRepresenter do include ::API::V3::Utilities::PathHelper - let(:member) { FactoryGirl.build_stubbed(:user) } + let(:member) { FactoryBot.build_stubbed(:user) } let(:current_user) { member } let(:embed_links) { true } let(:representer) do @@ -39,7 +39,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end let(:parent) { nil } let(:work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, id: 42, start_date: Date.today.to_datetime, due_date: Date.today.to_datetime, @@ -65,7 +65,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do ] end let(:permissions) { all_permissions } - let(:project) { FactoryGirl.build_stubbed(:project_with_types) } + let(:project) { FactoryBot.build_stubbed(:project_with_types) } let(:type) { project.types.first } before(:each) do @@ -98,7 +98,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'no start date' do - let(:work_package) { FactoryGirl.build(:work_package, id: 42, start_date: nil) } + let(:work_package) { FactoryBot.build(:work_package, id: 42, start_date: nil) } it 'renders as null' do is_expected.to be_json_eql(nil.to_json).at_path('startDate') @@ -107,7 +107,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do context 'when the work package has a milestone type' do let(:milestone_type) do - FactoryGirl.build_stubbed(:type, + FactoryBot.build_stubbed(:type, is_milestone: true) end @@ -128,7 +128,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'no due date' do - let(:work_package) { FactoryGirl.build(:work_package, id: 42, due_date: nil) } + let(:work_package) { FactoryBot.build(:work_package, id: 42, due_date: nil) } it 'renders as null' do is_expected.to be_json_eql(nil.to_json).at_path('dueDate') @@ -137,7 +137,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do context 'when the work package has a milestone type' do let(:milestone_type) do - FactoryGirl.build_stubbed(:type, + FactoryBot.build_stubbed(:type, is_milestone: true) end @@ -153,7 +153,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'date' do let(:milestone_type) do - FactoryGirl.build_stubbed(:type, + FactoryBot.build_stubbed(:type, is_milestone: true) end @@ -178,7 +178,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do context 'when the work package has a non milestone type' do let(:none_milestone_type) do - FactoryGirl.build_stubbed(:type, + FactoryBot.build_stubbed(:type, is_milestone: false) end @@ -219,7 +219,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'estimatedTime' do let(:work_package) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, id: 42, created_at: DateTime.now, updated_at: DateTime.now, @@ -359,7 +359,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'assignee' do context 'assignee is set' do let(:work_package) do - FactoryGirl.build(:work_package, id: 42, assigned_to: FactoryGirl.build_stubbed(:user)) + FactoryBot.build(:work_package, id: 42, assigned_to: FactoryBot.build_stubbed(:user)) end it_behaves_like 'has a titled link' do @@ -379,7 +379,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'responsible' do context 'responsible is set' do let(:work_package) do - FactoryGirl.build(:work_package, id: 42, responsible: FactoryGirl.build_stubbed(:user)) + FactoryBot.build(:work_package, id: 42, responsible: FactoryBot.build_stubbed(:user)) end it_behaves_like 'has a titled link' do @@ -416,7 +416,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'version set' do - let!(:version) { FactoryGirl.create :version, project: project } + let!(:version) { FactoryBot.create :version, project: project } before do work_package.fixed_version = version @@ -462,7 +462,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'category set' do - let!(:category) { FactoryGirl.build_stubbed :category } + let!(:category) { FactoryBot.build_stubbed :category } before do work_package.category = category @@ -703,9 +703,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end describe 'linked relations' do - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:forbidden_project) { FactoryGirl.create(:project, is_public: false) } - let(:user) { FactoryGirl.create(:user, member_in_project: project) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:forbidden_project) { FactoryBot.create(:project, is_public: false) } + let(:user) { FactoryBot.create(:user, member_in_project: project) } before do login_as(user) @@ -714,14 +714,14 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'parent' do let(:visible_parent) do - FactoryGirl.build_stubbed(:stubbed_work_package) do |wp| + FactoryBot.build_stubbed(:stubbed_work_package) do |wp| allow(wp) .to receive(:visible?) .and_return(true) end end let(:invisible_parent) do - FactoryGirl.build_stubbed(:stubbed_work_package) do |wp| + FactoryBot.build_stubbed(:stubbed_work_package) do |wp| allow(wp) .to receive(:visible?) .and_return(false) @@ -754,9 +754,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'ancestors' do - let(:root) { FactoryGirl.build_stubbed(:work_package, project: project) } + let(:root) { FactoryBot.build_stubbed(:work_package, project: project) } let(:intermediate) do - FactoryGirl.build_stubbed(:work_package, parent: root, project: project) + FactoryBot.build_stubbed(:work_package, parent: root, project: project) end context 'when ancestors are visible' do @@ -787,9 +787,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end context 'children' do - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let!(:forbidden_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: forbidden_project, parent: work_package) end @@ -798,7 +798,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'visible and invisible children' do let!(:child) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, parent: work_package) end @@ -894,7 +894,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end end context 'when admin' do - let(:current_user) { FactoryGirl.build_stubbed :admin } + let(:current_user) { FactoryBot.build_stubbed :admin } it_behaves_like 'has a titled link' do let(:link) { 'configureForm' } @@ -906,7 +906,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'customActions' do it 'has a collection of customActions' do - unassign_action = FactoryGirl.build_stubbed(:custom_action, + unassign_action = FactoryBot.build_stubbed(:custom_action, actions: [CustomActions::Actions::AssignedTo.new(value: nil)], name: 'Unassign') allow(work_package) @@ -952,7 +952,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'relations' do let(:relation) do - FactoryGirl.build_stubbed(:relation, + FactoryBot.build_stubbed(:relation, from: work_package) end @@ -987,7 +987,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do describe 'customActions' do it 'has an array of customActions' do - unassign_action = FactoryGirl.build_stubbed(:custom_action, + unassign_action = FactoryBot.build_stubbed(:custom_action, actions: [CustomActions::Actions::AssignedTo.new(value: nil)], name: 'Unassign') allow(work_package) @@ -1015,9 +1015,9 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do end describe '#json_cache_key' do - let(:category) { FactoryGirl.build_stubbed(:category) } - let(:assigned_to) { FactoryGirl.build_stubbed(:user) } - let(:responsible) { FactoryGirl.build_stubbed(:user) } + let(:category) { FactoryBot.build_stubbed(:category) } + let(:assigned_to) { FactoryBot.build_stubbed(:user) } + let(:responsible) { FactoryBot.build_stubbed(:user) } before do work_package.category = category diff --git a/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb index 06ca1fe89b..64450e8986 100644 --- a/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb +++ b/spec/lib/api/v3/work_packages/work_package_sums_representer_spec.rb @@ -63,7 +63,7 @@ describe ::API::V3::WorkPackages::WorkPackageSumsRepresenter do end context 'custom field x' do - let(:custom_field) { FactoryGirl.build_stubbed(:integer_issue_custom_field, id: 1) } + let(:custom_field) { FactoryBot.build_stubbed(:integer_issue_custom_field, id: 1) } let(:available_custom_fields) { [custom_field] } let(:sums) { double 'sums', custom_field_1: 5 } diff --git a/spec/lib/api/v3/work_packages/work_packages_shared_helpers_spec.rb b/spec/lib/api/v3/work_packages/work_packages_shared_helpers_spec.rb index da5e96461d..031f74580d 100644 --- a/spec/lib/api/v3/work_packages/work_packages_shared_helpers_spec.rb +++ b/spec/lib/api/v3/work_packages/work_packages_shared_helpers_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe ::API::V3::WorkPackages::WorkPackagesSharedHelpers do - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } - let(:user) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages, :add_work_packages] } let(:env) { { 'api.request.body' => { 'subject' => 'foo' } } } diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rb index d91f9a9c53..955c428cbe 100644 --- a/spec/lib/custom_field_form_builder_spec.rb +++ b/spec/lib/custom_field_form_builder_spec.rb @@ -39,10 +39,10 @@ describe CustomFieldFormBuilder do let(:options) { { class: 'custom-class' } } let(:custom_field) do - FactoryGirl.build_stubbed(:custom_field) + FactoryBot.build_stubbed(:custom_field) end let(:resource) do - FactoryGirl.build_stubbed(:custom_value, custom_field: custom_field) + FactoryBot.build_stubbed(:custom_value, custom_field: custom_field) end subject(:output) do @@ -172,11 +172,11 @@ describe CustomFieldFormBuilder do context 'for a list custom field' do let(:custom_field) do - FactoryGirl.build_stubbed(:list_wp_custom_field, + FactoryBot.build_stubbed(:list_wp_custom_field, custom_options: [custom_option]) end let(:custom_option) do - FactoryGirl.build_stubbed(:custom_option, value: 'my_option') + FactoryBot.build_stubbed(:custom_option, value: 'my_option') end it_behaves_like 'wrapped in container', 'select-container' do @@ -230,9 +230,9 @@ describe CustomFieldFormBuilder do end context 'for a user custom field' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } before do resource.custom_field.field_format = 'user' @@ -280,9 +280,9 @@ describe CustomFieldFormBuilder do end context 'for a version custom field' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:version1) { FactoryGirl.build_stubbed(:version) } - let(:version2) { FactoryGirl.build_stubbed(:version) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:version1) { FactoryBot.build_stubbed(:version) } + let(:version2) { FactoryBot.build_stubbed(:version) } before do resource.custom_field.field_format = 'version' diff --git a/spec/lib/journal_formatter/attachment_spec.rb b/spec/lib/journal_formatter/attachment_spec.rb index 552a53554d..05de98ceaa 100644 --- a/spec/lib/journal_formatter/attachment_spec.rb +++ b/spec/lib/journal_formatter/attachment_spec.rb @@ -46,9 +46,9 @@ describe OpenProject::JournalFormatter::Attachment do let(:journal) do OpenStruct.new(id: id) end - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:attachment) { - FactoryGirl.create(:attachment, + FactoryBot.create(:attachment, author: user) } let(:key) { "attachments_#{attachment.id}" } diff --git a/spec/lib/journal_formatter/custom_field_spec.rb b/spec/lib/journal_formatter/custom_field_spec.rb index 89231defbd..2513c9746d 100644 --- a/spec/lib/journal_formatter/custom_field_spec.rb +++ b/spec/lib/journal_formatter/custom_field_spec.rb @@ -38,8 +38,8 @@ describe OpenProject::JournalFormatter::CustomField do let(:journal) do OpenStruct.new(id: id) end - let(:user) { FactoryGirl.create(:user) } - let(:custom_field) { FactoryGirl.create(:issue_custom_field) } + let(:user) { FactoryBot.create(:user) } + let(:custom_field) { FactoryBot.create(:issue_custom_field) } let(:key) { "custom_fields_#{custom_field.id}" } describe '#render' do diff --git a/spec/lib/open_project/client_preference_extractor_spec.rb b/spec/lib/open_project/client_preference_extractor_spec.rb index a5eda8dd0a..e6f914b61e 100644 --- a/spec/lib/open_project/client_preference_extractor_spec.rb +++ b/spec/lib/open_project/client_preference_extractor_spec.rb @@ -32,7 +32,7 @@ describe OpenProject::ClientPreferenceExtractor do let(:extractor) { (Class.new { include OpenProject::ClientPreferenceExtractor }).new } describe 'user preferences' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } shared_examples_for 'preference with timezone' do before do diff --git a/spec/lib/open_project/macros/work_package_buttons_macro_spec.rb b/spec/lib/open_project/macros/work_package_buttons_macro_spec.rb index d0747af1db..a3123010f9 100644 --- a/spec/lib/open_project/macros/work_package_buttons_macro_spec.rb +++ b/spec/lib/open_project/macros/work_package_buttons_macro_spec.rb @@ -37,9 +37,9 @@ describe 'OpenProject work package button macros' do # no-op end - let(:type) { FactoryGirl.create :type, name: 'MyTaskName' } - let(:project) { FactoryGirl.create :valid_project, identifier: 'my-project', name: 'My project name', types: [type] } - let(:user) { FactoryGirl.create :admin } + let(:type) { FactoryBot.create :type, name: 'MyTaskName' } + let(:project) { FactoryBot.create :valid_project, identifier: 'my-project', name: 'My project name', types: [type] } + let(:user) { FactoryBot.create :admin } let(:input) { } subject { format_text(input, project: project) } diff --git a/spec/lib/open_project/omni_auth/authorization_spec.rb b/spec/lib/open_project/omni_auth/authorization_spec.rb index d759c33b2e..5234533463 100644 --- a/spec/lib/open_project/omni_auth/authorization_spec.rb +++ b/spec/lib/open_project/omni_auth/authorization_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe OpenProject::OmniAuth::Authorization do describe '.after_login!' do let(:auth_hash) { Struct.new(:uid).new 'bar' } - let(:user) { FactoryGirl.create :user, mail: 'foo@bar.de' } + let(:user) { FactoryBot.create :user, mail: 'foo@bar.de' } let(:state) { Struct.new(:number, :user_email, :uid).new 0, nil, nil } let(:collector) { [] } diff --git a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb index ea87bada89..4d8f36ced8 100644 --- a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb +++ b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb @@ -90,15 +90,15 @@ describe OpenProject::TextFormatting::Formatters::Markdown::Formatter do end context 'when visible user exists' do - let(:project) { FactoryGirl.create :project } - let(:role) { FactoryGirl.create(:role, permissions: %i(view_work_packages)) } + let(:project) { FactoryBot.create :project } + let(:role) { FactoryBot.create(:role, permissions: %i(view_work_packages)) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: 'foo@bar.com', firstname: 'Foo', lastname: 'Barrit', diff --git a/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb b/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb index 2c1cf1231e..6585726f71 100644 --- a/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb +++ b/spec/lib/open_project/text_formatting/markdown/markdown_spec.rb @@ -43,28 +43,28 @@ describe OpenProject::TextFormatting, end describe '.format_text' do - let(:project) { FactoryGirl.create :valid_project } + let(:project) { FactoryBot.create :valid_project } let(:identifier) { project.identifier } let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i(view_work_packages edit_work_packages browse_repository view_changesets view_wiki_pages) end let(:project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end let(:issue) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, author: project_member, type: project.types.first end let!(:non_member) do - FactoryGirl.create(:non_member) + FactoryBot.create(:non_member) end before do @@ -75,16 +75,16 @@ describe OpenProject::TextFormatting, context 'Changeset links' do let(:repository) do - FactoryGirl.build_stubbed :repository_subversion, + FactoryBot.build_stubbed :repository_subversion, project: project end let(:changeset1) do - FactoryGirl.build_stubbed :changeset, + FactoryBot.build_stubbed :changeset, repository: repository, comments: 'My very first commit' end let(:changeset2) do - FactoryGirl.build_stubbed :changeset, + FactoryBot.build_stubbed :changeset, repository: repository, comments: 'This commit fixes #1, #2 and references #1 & #3' end @@ -147,7 +147,7 @@ describe OpenProject::TextFormatting, context 'Version link' do let!(:version) { - FactoryGirl.create :version, + FactoryBot.create :version, name: '1.0', project: project } @@ -194,10 +194,10 @@ describe OpenProject::TextFormatting, end context 'Message links' do - let(:board) { FactoryGirl.create :board, project: project } - let(:message1) { FactoryGirl.create :message, board: board } + let(:board) { FactoryBot.create :board, project: project } + let(:message1) { FactoryBot.create :message, board: board } let(:message2) { - FactoryGirl.create :message, + FactoryBot.create :message, board: board, parent: message1 } @@ -252,7 +252,7 @@ describe OpenProject::TextFormatting, context 'Cyclic Description Links' do let(:issue2) { - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, author: project_member, type: project.types.first @@ -282,7 +282,7 @@ describe OpenProject::TextFormatting, end context 'Project links' do - let(:subproject) { FactoryGirl.create :valid_project, parent: project, is_public: true } + let(:subproject) { FactoryBot.create :valid_project, parent: project, is_public: true } let(:project_url) { { controller: 'projects', action: 'show', id: subproject.identifier } } context 'Plain project link' do @@ -306,13 +306,13 @@ describe OpenProject::TextFormatting, context 'User links' do let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages edit_work_packages browse_repository view_changesets view_wiki_pages] end let(:linked_project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end @@ -327,7 +327,7 @@ describe OpenProject::TextFormatting, end context 'when linked user not visible for reader' do - let(:role) { FactoryGirl.create(:non_member) } + let(:role) { FactoryBot.create(:non_member) } subject { format_text("user##{linked_project_member.id}") } @@ -347,7 +347,7 @@ describe OpenProject::TextFormatting, context "with an email address as login name" do let(:linked_project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role, login: "foo@bar.com" @@ -359,7 +359,7 @@ describe OpenProject::TextFormatting, end context 'when linked user not visible for reader' do - let(:role) { FactoryGirl.create(:non_member) } + let(:role) { FactoryBot.create(:non_member) } subject { format_text("user:\"#{linked_project_member.login}\"") } @@ -372,13 +372,13 @@ describe OpenProject::TextFormatting, context 'Group reference' do let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [] end let(:linked_project_member_group) do - FactoryGirl.create(:group).tap do |group| - FactoryGirl.create(:member, + FactoryBot.create(:group).tap do |group| + FactoryBot.create(:member, principal: group, project: project, roles: [role]) @@ -410,26 +410,26 @@ describe OpenProject::TextFormatting, context 'Wiki links' do let(:project_2) { - FactoryGirl.create :valid_project, + FactoryBot.create :valid_project, identifier: 'onlinestore' } let(:wiki_1) { - FactoryGirl.create :wiki, + FactoryBot.create :wiki, start_page: 'CookBook documentation', project: project } let(:wiki_page_1_1) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: 'CookBook documentation' } let(:wiki_page_1_2) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: 'Another page' } let(:wiki_page_1_3) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: '' } @@ -437,7 +437,7 @@ describe OpenProject::TextFormatting, before do project_2.reload - wiki_page_2_1 = FactoryGirl.create :wiki_page_with_content, + wiki_page_2_1 = FactoryBot.create :wiki_page_with_content, wiki: project_2.wiki, title: 'Start Page' @@ -558,7 +558,7 @@ describe OpenProject::TextFormatting, context 'Redmine links' do let(:repository) do - FactoryGirl.build_stubbed :repository_subversion, project: project + FactoryBot.build_stubbed :repository_subversion, project: project end def source_url(**args) @@ -607,12 +607,12 @@ describe OpenProject::TextFormatting, context 'Pre content should not parse wiki and redmine links' do let(:wiki) { - FactoryGirl.create :wiki, + FactoryBot.create :wiki, start_page: 'CookBook documentation', project: project } let(:wiki_page) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki, title: 'CookBook documentation' } diff --git a/spec/lib/open_project/text_formatting/textile/textile_spec.rb b/spec/lib/open_project/text_formatting/textile/textile_spec.rb index 517c755ccd..1914379533 100644 --- a/spec/lib/open_project/text_formatting/textile/textile_spec.rb +++ b/spec/lib/open_project/text_formatting/textile/textile_spec.rb @@ -41,28 +41,28 @@ describe OpenProject::TextFormatting do end describe '.format_text' do - let(:project) { FactoryGirl.create :valid_project } + let(:project) { FactoryBot.create :valid_project } let(:identifier) { project.identifier } let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i(view_work_packages edit_work_packages browse_repository view_changesets view_wiki_pages) end let(:project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end let(:issue) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, author: project_member, type: project.types.first end let!(:non_member) do - FactoryGirl.create(:non_member) + FactoryBot.create(:non_member) end before do @@ -73,16 +73,16 @@ describe OpenProject::TextFormatting do context 'Changeset links' do let(:repository) do - FactoryGirl.build_stubbed :repository_subversion, + FactoryBot.build_stubbed :repository_subversion, project: project end let(:changeset1) do - FactoryGirl.build_stubbed :changeset, + FactoryBot.build_stubbed :changeset, repository: repository, comments: 'My very first commit' end let(:changeset2) do - FactoryGirl.build_stubbed :changeset, + FactoryBot.build_stubbed :changeset, repository: repository, comments: 'This commit fixes #1, #2 and references #1 & #3' end @@ -145,7 +145,7 @@ describe OpenProject::TextFormatting do context 'Version link' do let!(:version) { - FactoryGirl.create :version, + FactoryBot.create :version, name: '1.0', project: project } @@ -192,10 +192,10 @@ describe OpenProject::TextFormatting do end context 'Message links' do - let(:board) { FactoryGirl.create :board, project: project } - let(:message1) { FactoryGirl.create :message, board: board } + let(:board) { FactoryBot.create :board, project: project } + let(:message1) { FactoryBot.create :message, board: board } let(:message2) { - FactoryGirl.create :message, + FactoryBot.create :message, board: board, parent: message1 } @@ -244,7 +244,7 @@ describe OpenProject::TextFormatting do context 'Cyclic Description Links' do let(:issue2) { - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project, author: project_member, type: project.types.first @@ -274,7 +274,7 @@ describe OpenProject::TextFormatting do end context 'Project links' do - let(:subproject) { FactoryGirl.create :valid_project, parent: project, is_public: true } + let(:subproject) { FactoryBot.create :valid_project, parent: project, is_public: true } let(:project_url) { { controller: 'projects', action: 'show', id: subproject.identifier } } context 'Plain project link' do @@ -298,13 +298,13 @@ describe OpenProject::TextFormatting do context 'User links' do let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: %i[view_work_packages edit_work_packages browse_repository view_changesets view_wiki_pages] end let(:linked_project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role end @@ -319,7 +319,7 @@ describe OpenProject::TextFormatting do end context 'when linked user not visible for reader' do - let(:role) { FactoryGirl.create(:non_member) } + let(:role) { FactoryBot.create(:non_member) } subject { format_text("user##{linked_project_member.id}") } @@ -339,7 +339,7 @@ describe OpenProject::TextFormatting do context "with an email address as login name" do let(:linked_project_member) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: role, login: "foo@bar.com" @@ -351,7 +351,7 @@ describe OpenProject::TextFormatting do end context 'when linked user not visible for reader' do - let(:role) { FactoryGirl.create(:non_member) } + let(:role) { FactoryBot.create(:non_member) } subject { format_text("user:\"#{linked_project_member.login}\"") } @@ -364,13 +364,13 @@ describe OpenProject::TextFormatting do context 'Group reference' do let(:role) do - FactoryGirl.create :role, + FactoryBot.create :role, permissions: [] end let(:linked_project_member_group) do - FactoryGirl.create(:group).tap do |group| - FactoryGirl.create(:member, + FactoryBot.create(:group).tap do |group| + FactoryBot.create(:member, principal: group, project: project, roles: [role]) @@ -402,26 +402,26 @@ describe OpenProject::TextFormatting do context 'Wiki links' do let(:project_2) { - FactoryGirl.create :valid_project, + FactoryBot.create :valid_project, identifier: 'onlinestore' } let(:wiki_1) { - FactoryGirl.create :wiki, + FactoryBot.create :wiki, start_page: 'CookBook documentation', project: project } let(:wiki_page_1_1) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: 'CookBook documentation' } let(:wiki_page_1_2) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: 'Another page' } let(:wiki_page_1_3) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki_1, title: '' } @@ -429,7 +429,7 @@ describe OpenProject::TextFormatting do before do project_2.reload - wiki_page_2_1 = FactoryGirl.create :wiki_page_with_content, + wiki_page_2_1 = FactoryBot.create :wiki_page_with_content, wiki: project_2.wiki, title: 'Start Page' @@ -550,7 +550,7 @@ describe OpenProject::TextFormatting do context 'Redmine links' do let(:repository) do - FactoryGirl.build_stubbed :repository_subversion, project: project + FactoryBot.build_stubbed :repository_subversion, project: project end let(:source_url) do { controller: 'repositories', @@ -603,12 +603,12 @@ describe OpenProject::TextFormatting do context 'Pre content should not parse wiki and redmine links' do let(:wiki) { - FactoryGirl.create :wiki, + FactoryBot.create :wiki, start_page: 'CookBook documentation', project: project } let(:wiki_page) { - FactoryGirl.create :wiki_page_with_content, + FactoryBot.create :wiki_page_with_content, wiki: wiki, title: 'CookBook documentation' } diff --git a/spec/lib/tabular_form_builder_spec.rb b/spec/lib/tabular_form_builder_spec.rb index 8fc81b6281..4f0ae4f7cb 100644 --- a/spec/lib/tabular_form_builder_spec.rb +++ b/spec/lib/tabular_form_builder_spec.rb @@ -34,7 +34,7 @@ describe TabularFormBuilder do let(:helper) { ActionView::Base.new } let(:resource) { - FactoryGirl.build(:user, + FactoryBot.build(:user, firstname: 'JJ', lastname: 'Abrams', login: 'lost', @@ -619,7 +619,7 @@ JJ Abrams context 'with ActiveModel and without specified label' do let(:resource) { - FactoryGirl.build_stubbed(:user, + FactoryBot.build_stubbed(:user, firstname: 'JJ', lastname: 'Abrams', login: 'lost', diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index a383ebd35e..842278bfe1 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -30,15 +30,15 @@ require 'spec_helper' describe UserMailer, type: :mailer do - let(:type_standard) { FactoryGirl.build_stubbed(:type_standard) } - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:journal) { FactoryGirl.build_stubbed(:work_package_journal) } + let(:type_standard) { FactoryBot.build_stubbed(:type_standard) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:journal) { FactoryBot.build_stubbed(:work_package_journal) } let(:work_package) { - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, type: type_standard) } - let(:recipient) { FactoryGirl.build_stubbed(:user) } + let(:recipient) { FactoryBot.build_stubbed(:user) } before do allow(work_package).to receive(:reload).and_return(work_package) @@ -74,9 +74,9 @@ describe UserMailer, type: :mailer do shared_examples_for 'does only send mails to author if permitted' do let(:user_preference) { - FactoryGirl.build(:user_preference, others: { no_self_notified: true }) + FactoryBot.build(:user_preference, others: { no_self_notified: true }) } - let(:user) { FactoryGirl.build_stubbed(:user, preference: user_preference) } + let(:user) { FactoryBot.build_stubbed(:user, preference: user_preference) } context 'mail is for another user' do it_behaves_like 'mail is sent' @@ -144,7 +144,7 @@ describe UserMailer, type: :mailer do end describe :wiki_content_added do - let(:wiki_content) { FactoryGirl.create(:wiki_content) } + let(:wiki_content) { FactoryBot.create(:wiki_content) } before do UserMailer.wiki_content_added(recipient, wiki_content, user).deliver_now @@ -156,7 +156,7 @@ describe UserMailer, type: :mailer do end describe '#wiki_content_updated' do - let(:wiki_content) { FactoryGirl.create(:wiki_content) } + let(:wiki_content) { FactoryBot.create(:wiki_content) } before do UserMailer.wiki_content_updated(recipient, wiki_content, user).deliver_now @@ -173,7 +173,7 @@ describe UserMailer, type: :mailer do describe '#message_id' do describe 'same user' do - let(:journal_2) { FactoryGirl.build_stubbed(:work_package_journal) } + let(:journal_2) { FactoryBot.build_stubbed(:work_package_journal) } before do allow(journal_2).to receive(:journable).and_return(work_package) @@ -193,7 +193,7 @@ describe UserMailer, type: :mailer do end describe 'same timestamp' do - let(:user_2) { FactoryGirl.build_stubbed(:user) } + let(:user_2) { FactoryBot.build_stubbed(:user) } before do allow(work_package).to receive(:recipients).and_return([user, user_2]) @@ -284,8 +284,8 @@ describe UserMailer, type: :mailer do end describe 'project attribute' do - let(:project_1) { FactoryGirl.create(:project) } - let(:project_2) { FactoryGirl.create(:project) } + let(:project_1) { FactoryBot.create(:project) } + let(:project_2) { FactoryBot.create(:project) } before do allow(journal).to receive(:details).and_return('project_id' => [project_1.id, project_2.id]) @@ -301,8 +301,8 @@ describe UserMailer, type: :mailer do end describe 'attribute issue status' do - let(:status_1) { FactoryGirl.create(:status) } - let(:status_2) { FactoryGirl.create(:status) } + let(:status_1) { FactoryBot.create(:status) } + let(:status_2) { FactoryBot.create(:status) } before do allow(journal).to receive(:details).and_return('status_id' => [status_1.id, status_2.id]) @@ -318,8 +318,8 @@ describe UserMailer, type: :mailer do end describe 'attribute type' do - let(:type_1) { FactoryGirl.create(:type_standard) } - let(:type_2) { FactoryGirl.create(:type_bug) } + let(:type_1) { FactoryBot.create(:type_standard) } + let(:type_2) { FactoryBot.create(:type_bug) } before do allow(journal).to receive(:details).and_return('type_id' => [type_1.id, type_2.id]) @@ -335,8 +335,8 @@ describe UserMailer, type: :mailer do end describe 'attribute assigned to' do - let(:assignee_1) { FactoryGirl.create(:user) } - let(:assignee_2) { FactoryGirl.create(:user) } + let(:assignee_1) { FactoryBot.create(:user) } + let(:assignee_2) { FactoryBot.create(:user) } before do allow(journal).to receive(:details).and_return('assigned_to_id' => [assignee_1.id, assignee_2.id]) @@ -352,8 +352,8 @@ describe UserMailer, type: :mailer do end describe 'attribute priority' do - let(:priority_1) { FactoryGirl.create(:priority) } - let(:priority_2) { FactoryGirl.create(:priority) } + let(:priority_1) { FactoryBot.create(:priority) } + let(:priority_2) { FactoryBot.create(:priority) } before do allow(journal).to receive(:details).and_return('priority_id' => [priority_1.id, priority_2.id]) @@ -369,8 +369,8 @@ describe UserMailer, type: :mailer do end describe 'attribute category' do - let(:category_1) { FactoryGirl.create(:category) } - let(:category_2) { FactoryGirl.create(:category) } + let(:category_1) { FactoryBot.create(:category) } + let(:category_2) { FactoryBot.create(:category) } before do allow(journal).to receive(:details).and_return('category_id' => [category_1.id, category_2.id]) @@ -386,8 +386,8 @@ describe UserMailer, type: :mailer do end describe 'attribute fixed version' do - let(:version_1) { FactoryGirl.create(:version) } - let(:version_2) { FactoryGirl.create(:version) } + let(:version_1) { FactoryBot.create(:version) } + let(:version_2) { FactoryBot.create(:version) } before do allow(journal).to receive(:details).and_return('fixed_version_id' => [version_1.id, version_2.id]) @@ -423,7 +423,7 @@ describe UserMailer, type: :mailer do let(:expected_text_1) { 'original, unchanged text' } let(:expected_text_2) { 'modified, new text' } let(:custom_field) { - FactoryGirl.create :work_package_custom_field, + FactoryBot.create :work_package_custom_field, field_format: 'text' } @@ -441,7 +441,7 @@ describe UserMailer, type: :mailer do end describe 'attachments' do - let(:attachment) { FactoryGirl.create :attachment } + let(:attachment) { FactoryBot.create :attachment } context 'added' do before do diff --git a/spec/models/activity/work_package_activity_provider_spec.rb b/spec/models/activity/work_package_activity_provider_spec.rb index 99161414c1..17591dd845 100644 --- a/spec/models/activity/work_package_activity_provider_spec.rb +++ b/spec/models/activity/work_package_activity_provider_spec.rb @@ -33,12 +33,12 @@ describe Activity::WorkPackageActivityProvider, type: :model do let(:work_package_edit_event) { 'work_package-edit' } let(:work_package_closed_event) { 'work_package-closed' } - let(:user) { FactoryGirl.create :admin } - let(:role) { FactoryGirl.create :role } - let(:status_closed) { FactoryGirl.create :closed_status } - let(:work_package) { FactoryGirl.build :work_package } + let(:user) { FactoryBot.create :admin } + let(:role) { FactoryBot.create :role } + let(:status_closed) { FactoryBot.create :closed_status } + let(:work_package) { FactoryBot.build :work_package } let!(:workflow) { - FactoryGirl.create :workflow, + FactoryBot.create :workflow, old_status: work_package.status, new_status: status_closed, type_id: work_package.type_id, @@ -59,7 +59,7 @@ describe Activity::WorkPackageActivityProvider, type: :model do end context 'should be selected and ordered correctly' do - let!(:work_packages) { (1..20).map { (FactoryGirl.create :work_package, author: user).id.to_s } } + let!(:work_packages) { (1..20).map { (FactoryBot.create :work_package, author: user).id.to_s } } let(:subject) { Activity::WorkPackageActivityProvider.find_events(event_scope, user, Date.yesterday, Date.tomorrow, limit: 10).map { |a| a.journable_id.to_s } } it { is_expected.to eq(work_packages.reverse.first(10)) } end diff --git a/spec/models/announcement_spec.rb b/spec/models/announcement_spec.rb index 8e571fc324..5e5d25f102 100644 --- a/spec/models/announcement_spec.rb +++ b/spec/models/announcement_spec.rb @@ -17,7 +17,7 @@ describe Announcement, type: :model do end context 'WHEN an announcement exists' do - let!(:announcement) { FactoryGirl.create :announcement } + let!(:announcement) { FactoryBot.create :announcement } it 'returns the true one announcement' do expect(Announcement.only_one).to eql announcement end @@ -26,7 +26,7 @@ describe Announcement, type: :model do describe '#active_and_current' do describe 'WHEN no announcement is active' do - let!(:announcement) { FactoryGirl.create(:inactive_announcement) } + let!(:announcement) { FactoryBot.create(:inactive_announcement) } it 'returns no announcement' do expect(Announcement.active_and_current).to be_nil @@ -35,7 +35,7 @@ describe Announcement, type: :model do describe 'WHEN the one announcement is active and today is before show_until' do let!(:announcement) { - FactoryGirl.create(:active_announcement, show_until: Date.today + 14.days) + FactoryBot.create(:active_announcement, show_until: Date.today + 14.days) } it 'returns that announcement' do @@ -45,7 +45,7 @@ describe Announcement, type: :model do describe 'WHEN the one announcement is active and today is after show_until' do let!(:announcement) { - FactoryGirl.create(:active_announcement, show_until: Date.today - 14.days) + FactoryBot.create(:active_announcement, show_until: Date.today - 14.days) } it 'returns no announcement' do @@ -55,7 +55,7 @@ describe Announcement, type: :model do describe 'WHEN the one announcement is active and today equals show_until' do let!(:announcement) { - FactoryGirl.create(:active_announcement, show_until: Date.today) + FactoryBot.create(:active_announcement, show_until: Date.today) } it 'returns that announcement' do expect(Announcement.active_and_current).to eql announcement @@ -66,14 +66,14 @@ describe Announcement, type: :model do describe 'instance methods' do describe '#active_and_current?' do describe 'WHEN the announcement is not active' do - let(:announcement) { FactoryGirl.build(:inactive_announcement) } + let(:announcement) { FactoryBot.build(:inactive_announcement) } it { expect(announcement.active_and_current?).to be_falsey } end describe 'WHEN the announcement is active and today is before show_until' do let(:announcement) { - FactoryGirl.build(:active_announcement, show_until: Date.today + 14.days) + FactoryBot.build(:active_announcement, show_until: Date.today + 14.days) } it { expect(announcement.active_and_current?).to be_truthy } @@ -81,7 +81,7 @@ describe Announcement, type: :model do describe 'WHEN the announcement is active and today is after show_until' do let!(:announcement) { - FactoryGirl.create(:active_announcement, show_until: Date.today - 14.days) + FactoryBot.create(:active_announcement, show_until: Date.today - 14.days) } it { expect(announcement.active_and_current?).to be_falsey } @@ -89,7 +89,7 @@ describe Announcement, type: :model do describe 'WHEN the announcement is active and today equals show_until' do let!(:announcement) { - FactoryGirl.build(:active_announcement, show_until: Date.today) + FactoryBot.build(:active_announcement, show_until: Date.today) } it { expect(announcement.active_and_current?).to be_truthy } diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index 1edac58ada..21ddf21d97 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -28,13 +28,13 @@ require 'spec_helper' describe Attachment, type: :model do - let(:author) { FactoryGirl.create :user } + let(:author) { FactoryBot.create :user } let(:long_description) { 'a' * 300 } - let(:work_package) { FactoryGirl.create :work_package, description: '' } - let(:file) { FactoryGirl.create :uploaded_jpg, name: 'test.jpg' } + let(:work_package) { FactoryBot.create :work_package, description: '' } + let(:file) { FactoryBot.create :uploaded_jpg, name: 'test.jpg' } let(:attachment) do - FactoryGirl.build( + FactoryBot.build( :attachment, author: author, container: work_package, @@ -42,7 +42,7 @@ describe Attachment, type: :model do file: file) end let(:stubbed_attachment) do - FactoryGirl.build_stubbed( + FactoryBot.build_stubbed( :attachment, author: author, container: work_package, @@ -75,7 +75,7 @@ describe Attachment, type: :model do end context 'with wrong content-type' do - let(:file) { FactoryGirl.create :uploaded_jpg, content_type: 'text/html' } + let(:file) { FactoryBot.create :uploaded_jpg, content_type: 'text/html' } it 'should detect the correct content-type' do expect(attachment.content_type).to eq 'image/jpeg' diff --git a/spec/models/attribute_help_text/work_package_spec.rb b/spec/models/attribute_help_text/work_package_spec.rb index 79bff56d08..5d9df827f5 100644 --- a/spec/models/attribute_help_text/work_package_spec.rb +++ b/spec/models/attribute_help_text/work_package_spec.rb @@ -37,7 +37,7 @@ describe AttributeHelpText::WorkPackage, type: :model do end describe '.used_attributes' do - let!(:instance) { FactoryGirl.create :work_package_help_text } + let!(:instance) { FactoryBot.create :work_package_help_text } subject { described_class.used_attributes instance.type } it 'returns used attributes' do @@ -46,21 +46,21 @@ describe AttributeHelpText::WorkPackage, type: :model do end describe '.visible' do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:permission) { [] } - let(:static_instance) { FactoryGirl.create :work_package_help_text, attribute_name: 'project' } + let(:static_instance) { FactoryBot.create :work_package_help_text, attribute_name: 'project' } let(:cf_instance) do - custom_field = FactoryGirl.create :text_wp_custom_field - FactoryGirl.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" + custom_field = FactoryBot.create :text_wp_custom_field + FactoryBot.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" end - subject { FactoryGirl.build :work_package_help_text } + subject { FactoryBot.build :work_package_help_text } before do # need to clear the cache to free the memoized @@ -75,7 +75,7 @@ describe AttributeHelpText::WorkPackage, type: :model do context 'user having no permission' do let(:user) do - FactoryGirl.create(:user) + FactoryBot.create(:user) end it 'returns the help text for the static attribute but not the one for the custom field' do @@ -96,33 +96,33 @@ describe AttributeHelpText::WorkPackage, type: :model do context 'user being member in a project with activated custom fields' do let(:permissions) { [] } let(:type) do - type = FactoryGirl.create(:type) + type = FactoryBot.create(:type) project.types << type type end let(:cf_instance_active) do - custom_field = FactoryGirl.create(:text_wp_custom_field) + custom_field = FactoryBot.create(:text_wp_custom_field) project.work_package_custom_fields << custom_field type.custom_fields << custom_field - FactoryGirl.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" + FactoryBot.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" end let(:cf_instance_inactive) do cf_instance end let(:cf_instance_inactive_no_type) do - custom_field = FactoryGirl.create(:text_wp_custom_field) + custom_field = FactoryBot.create(:text_wp_custom_field) project.work_package_custom_fields << custom_field - FactoryGirl.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" + FactoryBot.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" end let(:cf_instance_inactive_not_in_project) do - custom_field = FactoryGirl.create(:text_wp_custom_field) + custom_field = FactoryBot.create(:text_wp_custom_field) type.custom_fields << custom_field - FactoryGirl.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" + FactoryBot.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" end let(:cf_instance_for_all) do - custom_field = FactoryGirl.create(:text_wp_custom_field, is_for_all: true) - FactoryGirl.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" + custom_field = FactoryBot.create(:text_wp_custom_field, is_for_all: true) + FactoryBot.create :work_package_help_text, attribute_name: "custom_field_#{custom_field.id}" end before do @@ -185,7 +185,7 @@ describe AttributeHelpText::WorkPackage, type: :model do end describe 'instance' do - subject { FactoryGirl.build :work_package_help_text } + subject { FactoryBot.build :work_package_help_text } it 'provides a caption of its type' do expect(subject.attribute_scope).to eq 'WorkPackage' diff --git a/spec/models/board_spec.rb b/spec/models/board_spec.rb index 5e150e0204..e1d04105fc 100644 --- a/spec/models/board_spec.rb +++ b/spec/models/board_spec.rb @@ -32,7 +32,7 @@ require 'support/shared/acts_as_watchable' describe Board, type: :model do it_behaves_like 'acts_as_watchable included' do - let(:model_instance) { FactoryGirl.create(:board) } + let(:model_instance) { FactoryBot.create(:board) } let(:watch_permission) { :view_messages } # view_messages is a public permission let(:project) { model_instance.project } end diff --git a/spec/models/changeset_spec.rb b/spec/models/changeset_spec.rb index 606ce41882..9f38c9cddf 100644 --- a/spec/models/changeset_spec.rb +++ b/spec/models/changeset_spec.rb @@ -33,7 +33,7 @@ describe Changeset, type: :model do with_virtual_subversion_repository do let(:changeset) { - FactoryGirl.build(:changeset, + FactoryBot.build(:changeset, repository: repository, revision: '1', committer: email, @@ -67,7 +67,7 @@ describe Changeset, type: :model do end describe 'with user is committer' do - let!(:committer) { FactoryGirl.create(:user, login: email) } + let!(:committer) { FactoryBot.create(:user, login: email) } before do changeset.save! end @@ -77,8 +77,8 @@ describe Changeset, type: :model do end describe 'current user is not committer' do - let(:current_user) { FactoryGirl.create(:user) } - let!(:committer) { FactoryGirl.create(:user, login: email) } + let(:current_user) { FactoryBot.create(:user) } + let!(:committer) { FactoryBot.create(:user, login: email) } before do allow(User).to receive(:current).and_return current_user diff --git a/spec/models/copy_project_job_spec.rb b/spec/models/copy_project_job_spec.rb index 8d6301ed5d..7915e642df 100644 --- a/spec/models/copy_project_job_spec.rb +++ b/spec/models/copy_project_job_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe CopyProjectJob, type: :model do - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role, permissions: [:copy_projects]) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role, permissions: [:copy_projects]) } let(:params) { { name: 'Copy', identifier: 'copy' } } let(:maildouble) { double('Mail::Message', deliver: true) } @@ -40,9 +40,9 @@ describe CopyProjectJob, type: :model do end describe 'copy localizes error message' do - let(:user_de) { FactoryGirl.create(:admin, language: :de) } - let(:source_project) { FactoryGirl.create(:project) } - let(:target_project) { FactoryGirl.create(:project) } + let(:user_de) { FactoryBot.create(:admin, language: :de) } + let(:source_project) { FactoryBot.create(:project) } + let(:target_project) { FactoryBot.create(:project) } let(:copy_job) { CopyProjectJob.new user_id: user_de.id, @@ -70,12 +70,12 @@ describe CopyProjectJob, type: :model do end describe 'copy project succeeds with errors' do - let(:admin) { FactoryGirl.create(:admin) } - let(:source_project) { FactoryGirl.create(:project, types: [type]) } - let!(:work_package) { FactoryGirl.create(:work_package, project: source_project, type: type) } - let(:type) { FactoryGirl.create(:type_bug) } + let(:admin) { FactoryBot.create(:admin) } + let(:source_project) { FactoryBot.create(:project, types: [type]) } + let!(:work_package) { FactoryBot.create(:work_package, project: source_project, type: type) } + let(:type) { FactoryBot.create(:type_bug) } let (:custom_field) { - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, name: 'required_field', field_format: 'text', is_required: true, @@ -136,7 +136,7 @@ describe CopyProjectJob, type: :model do describe 'subproject' do let(:params) { { name: 'Copy', identifier: 'copy', parent_id: project.id } } - let(:subproject) { FactoryGirl.create(:project, parent: project) } + let(:subproject) { FactoryBot.create(:project, parent: project) } describe 'invalid parent' do before do expect(UserMailer).to receive(:copy_project_failed).and_return(maildouble) end @@ -149,9 +149,9 @@ describe CopyProjectJob, type: :model do end describe 'valid parent' do - let(:role_add_subproject) { FactoryGirl.create(:role, permissions: [:add_subprojects]) } + let(:role_add_subproject) { FactoryBot.create(:role, permissions: [:add_subprojects]) } let(:member_add_subproject) { - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: project, roles: [role_add_subproject]) diff --git a/spec/models/custom_action_spec.rb b/spec/models/custom_action_spec.rb index 20eab9d5a0..52ef3b515b 100644 --- a/spec/models/custom_action_spec.rb +++ b/spec/models/custom_action_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe CustomAction, type: :model do - let(:stubbed_instance) { FactoryGirl.build_stubbed :custom_action } - let(:instance) { FactoryGirl.create :custom_action, name: 'zzzzzzzzz' } - let(:other_instance) { FactoryGirl.create :custom_action, name: 'aaaaa' } + let(:stubbed_instance) { FactoryBot.build_stubbed :custom_action } + let(:instance) { FactoryBot.create :custom_action, name: 'zzzzzzzzz' } + let(:other_instance) { FactoryBot.create :custom_action, name: 'aaaaa' } describe '#name' do it 'can be set and read' do @@ -124,9 +124,9 @@ describe CustomAction, type: :model do end describe '.conditions' do - let(:status) { FactoryGirl.create(:status) } - let(:role) { FactoryGirl.create(:role) } - let(:project) { FactoryGirl.create(:project) } + let(:status) { FactoryBot.create(:status) } + let(:role) { FactoryBot.create(:role) } + let(:project) { FactoryBot.create(:project) } it 'is empty initially' do expect(stubbed_instance.conditions) diff --git a/spec/models/custom_actions/actions/assigned_to_spec.rb b/spec/models/custom_actions/actions/assigned_to_spec.rb index c94791fc6b..cca1bec8a8 100644 --- a/spec/models/custom_actions/actions/assigned_to_spec.rb +++ b/spec/models/custom_actions/actions/assigned_to_spec.rb @@ -35,14 +35,14 @@ describe CustomActions::Actions::AssignedTo, type: :model do users = [] if !Setting.work_package_group_assignment? - users = [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user)] + users = [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user)] allow(User) .to receive_message_chain(:active_or_registered, :select, :order_by_name) .and_return(users) else - users = [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:group)] + users = [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:group)] allow(Principal) .to receive_message_chain(:active_or_registered, :select, :order_by_name) .and_return(users) diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rb index 75dfc77706..e491c484d2 100644 --- a/spec/models/custom_actions/actions/custom_field_spec.rb +++ b/spec/models/custom_actions/actions/custom_field_spec.rb @@ -30,39 +30,39 @@ require_relative '../shared_expectations' describe CustomActions::Actions::CustomField, type: :model do let(:list_custom_field) do - FactoryGirl.build_stubbed(:list_wp_custom_field, - custom_options: [FactoryGirl.build_stubbed(:custom_option, value: 'A'), - FactoryGirl.build_stubbed(:custom_option, value: 'B')]) + FactoryBot.build_stubbed(:list_wp_custom_field, + custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'), + FactoryBot.build_stubbed(:custom_option, value: 'B')]) end let(:list_multi_custom_field) do - FactoryGirl.build_stubbed(:list_wp_custom_field, - custom_options: [FactoryGirl.build_stubbed(:custom_option, value: 'A'), - FactoryGirl.build_stubbed(:custom_option, value: 'B')], + FactoryBot.build_stubbed(:list_wp_custom_field, + custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'), + FactoryBot.build_stubbed(:custom_option, value: 'B')], multi_value: true) end let(:version_custom_field) do - FactoryGirl.build_stubbed(:version_wp_custom_field) + FactoryBot.build_stubbed(:version_wp_custom_field) end let(:bool_custom_field) do - FactoryGirl.build_stubbed(:bool_wp_custom_field) + FactoryBot.build_stubbed(:bool_wp_custom_field) end let(:user_custom_field) do - FactoryGirl.build_stubbed(:user_wp_custom_field) + FactoryBot.build_stubbed(:user_wp_custom_field) end let(:int_custom_field) do - FactoryGirl.build_stubbed(:int_wp_custom_field) + FactoryBot.build_stubbed(:int_wp_custom_field) end let(:float_custom_field) do - FactoryGirl.build_stubbed(:float_wp_custom_field) + FactoryBot.build_stubbed(:float_wp_custom_field) end let(:text_custom_field) do - FactoryGirl.build_stubbed(:text_wp_custom_field) + FactoryBot.build_stubbed(:text_wp_custom_field) end let(:string_custom_field) do - FactoryGirl.build_stubbed(:string_wp_custom_field) + FactoryBot.build_stubbed(:string_wp_custom_field) end let(:date_custom_field) do - FactoryGirl.build_stubbed(:date_wp_custom_field) + FactoryBot.build_stubbed(:date_wp_custom_field) end let(:custom_field) do @@ -320,10 +320,10 @@ describe CustomActions::Actions::CustomField, type: :model do context 'for a version custom field' do let(:custom_field) { version_custom_field } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:a_version) { FactoryGirl.build_stubbed(:version, name: 'aaaaa', project: project) } - let(:m_version) { FactoryGirl.build_stubbed(:version, name: 'mmmmm', project: project) } - let(:z_version) { FactoryGirl.build_stubbed(:version, name: 'zzzzz', project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:a_version) { FactoryBot.build_stubbed(:version, name: 'aaaaa', project: project) } + let(:m_version) { FactoryBot.build_stubbed(:version, name: 'mmmmm', project: project) } + let(:z_version) { FactoryBot.build_stubbed(:version, name: 'zzzzz', project: project) } let(:versions) { [z_version, a_version, m_version] } before do @@ -360,9 +360,9 @@ describe CustomActions::Actions::CustomField, type: :model do context 'for a user custom field' do let(:custom_field) { user_custom_field } let(:users) do - [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user)] + [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user)] end before do @@ -436,9 +436,9 @@ describe CustomActions::Actions::CustomField, type: :model do context 'for a user custom field' do let(:custom_field) { user_custom_field } let(:users) do - [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user)] + [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user)] end before do @@ -458,11 +458,11 @@ describe CustomActions::Actions::CustomField, type: :model do context 'for a version custom field' do let(:custom_field) { version_custom_field } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:versions) do - [FactoryGirl.build_stubbed(:version, project: project), - FactoryGirl.build_stubbed(:version, project: project), - FactoryGirl.build_stubbed(:version, project: project)] + [FactoryBot.build_stubbed(:version, project: project), + FactoryBot.build_stubbed(:version, project: project), + FactoryBot.build_stubbed(:version, project: project)] end before do diff --git a/spec/models/custom_actions/actions/date_spec.rb b/spec/models/custom_actions/actions/date_spec.rb index 276790bb48..44fd0355c2 100644 --- a/spec/models/custom_actions/actions/date_spec.rb +++ b/spec/models/custom_actions/actions/date_spec.rb @@ -36,7 +36,7 @@ describe CustomActions::Actions::Date, type: :model do it_behaves_like 'base custom action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets both start and due date to the action\'s value' do instance.values = [Date.today] diff --git a/spec/models/custom_actions/actions/done_ratio_spec.rb b/spec/models/custom_actions/actions/done_ratio_spec.rb index 5131209f59..a57a807a93 100644 --- a/spec/models/custom_actions/actions/done_ratio_spec.rb +++ b/spec/models/custom_actions/actions/done_ratio_spec.rb @@ -35,7 +35,7 @@ describe CustomActions::Actions::DoneRatio, type: :model do it_behaves_like 'base custom action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets the done_ratio to the action\'s value' do instance.values = [95] @@ -56,7 +56,7 @@ describe CustomActions::Actions::DoneRatio, type: :model do describe 'validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'is valid for values between 0 and 100' do diff --git a/spec/models/custom_actions/actions/due_date_spec.rb b/spec/models/custom_actions/actions/due_date_spec.rb index 35aaf01bf4..85e7cddcff 100644 --- a/spec/models/custom_actions/actions/due_date_spec.rb +++ b/spec/models/custom_actions/actions/due_date_spec.rb @@ -36,7 +36,7 @@ describe CustomActions::Actions::DueDate, type: :model do it_behaves_like 'base custom action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets the due_date to the action\'s value' do instance.values = [Date.today] diff --git a/spec/models/custom_actions/actions/estimated_hours_spec.rb b/spec/models/custom_actions/actions/estimated_hours_spec.rb index 71157a8198..4cbf33ec1c 100644 --- a/spec/models/custom_actions/actions/estimated_hours_spec.rb +++ b/spec/models/custom_actions/actions/estimated_hours_spec.rb @@ -36,7 +36,7 @@ describe CustomActions::Actions::EstimatedHours, type: :model do it_behaves_like 'base custom action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets the done_ratio to the action\'s value' do instance.values = [95.56] @@ -57,7 +57,7 @@ describe CustomActions::Actions::EstimatedHours, type: :model do describe 'validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'is valid for values equal to or greater than 0' do diff --git a/spec/models/custom_actions/actions/notify_spec.rb b/spec/models/custom_actions/actions/notify_spec.rb index bf616cb052..3705db8ec8 100644 --- a/spec/models/custom_actions/actions/notify_spec.rb +++ b/spec/models/custom_actions/actions/notify_spec.rb @@ -32,8 +32,8 @@ describe CustomActions::Actions::Notify, type: :model do let(:key) { :notify } let(:type) { :associated_property } let(:allowed_values) do - users = [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:group)] + users = [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:group)] allow(Principal) .to receive_message_chain(:active_or_registered, :select, :order_by_name) @@ -57,12 +57,12 @@ describe CustomActions::Actions::Notify, type: :model do it_behaves_like 'associated custom action validations' describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'adds a note with all values distinguised by type' do - principals = [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:group), - FactoryGirl.build_stubbed(:user)] + principals = [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:group), + FactoryBot.build_stubbed(:user)] allow(Principal) .to receive_message_chain(:active_or_registered, :select, :order_by_name, :where) diff --git a/spec/models/custom_actions/actions/priority_spec.rb b/spec/models/custom_actions/actions/priority_spec.rb index 878f321a18..4fc5c12a5e 100644 --- a/spec/models/custom_actions/actions/priority_spec.rb +++ b/spec/models/custom_actions/actions/priority_spec.rb @@ -32,8 +32,8 @@ describe CustomActions::Actions::Priority, type: :model do let(:key) { :priority } let(:type) { :associated_property } let(:allowed_values) do - priorities = [FactoryGirl.build_stubbed(:issue_priority), - FactoryGirl.build_stubbed(:issue_priority)] + priorities = [FactoryBot.build_stubbed(:issue_priority), + FactoryBot.build_stubbed(:issue_priority)] allow(IssuePriority) .to receive_message_chain(:select, :order) .and_return(priorities) diff --git a/spec/models/custom_actions/actions/project_spec.rb b/spec/models/custom_actions/actions/project_spec.rb index 92fd8e3659..ee416ebab3 100644 --- a/spec/models/custom_actions/actions/project_spec.rb +++ b/spec/models/custom_actions/actions/project_spec.rb @@ -34,8 +34,8 @@ describe CustomActions::Actions::Project, type: :model do let(:priority) { 10 } let(:allowed_values) do - projects = [FactoryGirl.build_stubbed(:project), - FactoryGirl.build_stubbed(:project)] + projects = [FactoryBot.build_stubbed(:project), + FactoryBot.build_stubbed(:project)] allow(Project) .to receive_message_chain(:select, :order) .and_return(projects) diff --git a/spec/models/custom_actions/actions/responsible_spec.rb b/spec/models/custom_actions/actions/responsible_spec.rb index d09a7c0aa4..6e785395c9 100644 --- a/spec/models/custom_actions/actions/responsible_spec.rb +++ b/spec/models/custom_actions/actions/responsible_spec.rb @@ -32,8 +32,8 @@ describe CustomActions::Actions::Responsible, type: :model do let(:key) { :responsible } let(:type) { :associated_property } let(:allowed_values) do - users = [FactoryGirl.build_stubbed(:user), - FactoryGirl.build_stubbed(:user)] + users = [FactoryBot.build_stubbed(:user), + FactoryBot.build_stubbed(:user)] allow(User) .to receive_message_chain(:active_or_registered, :select, :order_by_name) diff --git a/spec/models/custom_actions/actions/start_date_spec.rb b/spec/models/custom_actions/actions/start_date_spec.rb index 6644c05646..5df6d4a4d6 100644 --- a/spec/models/custom_actions/actions/start_date_spec.rb +++ b/spec/models/custom_actions/actions/start_date_spec.rb @@ -36,7 +36,7 @@ describe CustomActions::Actions::StartDate, type: :model do it_behaves_like 'base custom action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets the start_date to the action\'s value' do instance.values = [Date.today] diff --git a/spec/models/custom_actions/actions/status_spec.rb b/spec/models/custom_actions/actions/status_spec.rb index cc9c97147e..f2d317e588 100644 --- a/spec/models/custom_actions/actions/status_spec.rb +++ b/spec/models/custom_actions/actions/status_spec.rb @@ -32,8 +32,8 @@ describe CustomActions::Actions::Status, type: :model do let(:key) { :status } let(:type) { :associated_property } let(:allowed_values) do - statuses = [FactoryGirl.build_stubbed(:status), - FactoryGirl.build_stubbed(:status)] + statuses = [FactoryBot.build_stubbed(:status), + FactoryBot.build_stubbed(:status)] allow(Status) .to receive_message_chain(:select, :order) .and_return(statuses) diff --git a/spec/models/custom_actions/actions/type_spec.rb b/spec/models/custom_actions/actions/type_spec.rb index 6ac27c9569..0b1f552a8c 100644 --- a/spec/models/custom_actions/actions/type_spec.rb +++ b/spec/models/custom_actions/actions/type_spec.rb @@ -33,8 +33,8 @@ describe CustomActions::Actions::Type, type: :model do let(:priority) { 20 } let(:type) { :associated_property } let(:allowed_values) do - types = [FactoryGirl.build_stubbed(:type), - FactoryGirl.build_stubbed(:type)] + types = [FactoryBot.build_stubbed(:type), + FactoryBot.build_stubbed(:type)] allow(Type) .to receive_message_chain(:select, :order) .and_return(types) diff --git a/spec/models/custom_actions/conditions/project_spec.rb b/spec/models/custom_actions/conditions/project_spec.rb index 2964a67a5a..261b97929b 100644 --- a/spec/models/custom_actions/conditions/project_spec.rb +++ b/spec/models/custom_actions/conditions/project_spec.rb @@ -34,8 +34,8 @@ describe CustomActions::Conditions::Project, type: :model do describe '#allowed_values' do it 'is the list of all projects' do - projects = [FactoryGirl.build_stubbed(:project), - FactoryGirl.build_stubbed(:project)] + projects = [FactoryBot.build_stubbed(:project), + FactoryBot.build_stubbed(:project)] allow(Project) .to receive_message_chain(:select, :order) .and_return(projects) diff --git a/spec/models/custom_actions/conditions/role_spec.rb b/spec/models/custom_actions/conditions/role_spec.rb index ea831f7858..54fcae40a0 100644 --- a/spec/models/custom_actions/conditions/role_spec.rb +++ b/spec/models/custom_actions/conditions/role_spec.rb @@ -34,8 +34,8 @@ describe CustomActions::Conditions::Role, type: :model do describe '#allowed_values' do it 'is the list of all roles' do - roles = [FactoryGirl.build_stubbed(:role), - FactoryGirl.build_stubbed(:role)] + roles = [FactoryBot.build_stubbed(:role), + FactoryBot.build_stubbed(:role)] allow(Role) .to receive_message_chain(:givable, :select) diff --git a/spec/models/custom_actions/conditions/status_spec.rb b/spec/models/custom_actions/conditions/status_spec.rb index 093c5dddb0..77d4d5679f 100644 --- a/spec/models/custom_actions/conditions/status_spec.rb +++ b/spec/models/custom_actions/conditions/status_spec.rb @@ -34,8 +34,8 @@ describe CustomActions::Conditions::Status, type: :model do describe '#allowed_values' do it 'is the list of all status' do - statuses = [FactoryGirl.build_stubbed(:status), - FactoryGirl.build_stubbed(:status)] + statuses = [FactoryBot.build_stubbed(:status), + FactoryBot.build_stubbed(:status)] allow(Status) .to receive_message_chain(:select, :order) .and_return(statuses) diff --git a/spec/models/custom_actions/conditions/type_spec.rb b/spec/models/custom_actions/conditions/type_spec.rb index 9eaddee411..694cb1c4e1 100644 --- a/spec/models/custom_actions/conditions/type_spec.rb +++ b/spec/models/custom_actions/conditions/type_spec.rb @@ -34,8 +34,8 @@ describe CustomActions::Conditions::Type, type: :model do describe '#allowed_values' do it 'is the list of all types' do - types = [FactoryGirl.build_stubbed(:type), - FactoryGirl.build_stubbed(:type)] + types = [FactoryBot.build_stubbed(:type), + FactoryBot.build_stubbed(:type)] allow(Type) .to receive_message_chain(:select) .and_return(types) diff --git a/spec/models/custom_actions/shared_expectations.rb b/spec/models/custom_actions/shared_expectations.rb index 11dbcea9a3..23608684a1 100644 --- a/spec/models/custom_actions/shared_expectations.rb +++ b/spec/models/custom_actions/shared_expectations.rb @@ -125,7 +125,7 @@ end shared_examples_for 'associated custom action' do include_context 'custom actions action' do describe '#apply' do - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } it 'sets the associated_id in the work package to the action\'s value' do expect(work_package) @@ -145,7 +145,7 @@ end shared_examples_for 'associated custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -192,7 +192,7 @@ end shared_examples_for 'bool custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -237,7 +237,7 @@ end shared_examples_for 'int custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -273,7 +273,7 @@ end shared_examples_for 'float custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -309,7 +309,7 @@ end shared_examples_for 'string custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -349,7 +349,7 @@ end shared_examples_for 'date custom action validations' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on actions if values is blank (depending on required?)' do @@ -494,7 +494,7 @@ shared_examples_for 'associated custom condition' do describe '#validate' do let(:errors) do - FactoryGirl.build_stubbed(:custom_action).errors + FactoryBot.build_stubbed(:custom_action).errors end it 'adds an error on conditions if values not from list of allowed values' do diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb index ba4165d040..b169a7d80c 100644 --- a/spec/models/custom_field_spec.rb +++ b/spec/models/custom_field_spec.rb @@ -33,8 +33,8 @@ describe CustomField, type: :model do CustomField.destroy_all end - let(:field) { FactoryGirl.build :custom_field } - let(:field2) { FactoryGirl.build :custom_field } + let(:field) { FactoryBot.build :custom_field } + let(:field2) { FactoryBot.build :custom_field } describe '#name' do it { should validate_presence_of(:name) } @@ -178,7 +178,7 @@ describe CustomField, type: :model do end describe '#accessor_name' do - let(:field) { FactoryGirl.build_stubbed :custom_field } + let(:field) { FactoryBot.build_stubbed :custom_field } it 'is formatted as expected' do expect(field.accessor_name).to eql("custom_field_#{field.id}") @@ -186,9 +186,9 @@ describe CustomField, type: :model do end describe '#possible_values_options' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } context 'for a user custom field' do before do @@ -229,8 +229,8 @@ describe CustomField, type: :model do end context 'for a list custom field' do - let(:option1) { FactoryGirl.build_stubbed(:custom_option) } - let(:option2) { FactoryGirl.build_stubbed(:custom_option) } + let(:option1) { FactoryBot.build_stubbed(:custom_option) } + let(:option2) { FactoryBot.build_stubbed(:custom_option) } before do field.field_format = 'list' @@ -247,9 +247,9 @@ describe CustomField, type: :model do end describe 'nested attributes for custom options' do - let(:option) { FactoryGirl.build(:custom_option) } + let(:option) { FactoryBot.build(:custom_option) } let(:options) { [option] } - let(:field) { FactoryGirl.build :custom_field, field_format: 'list', custom_options: options } + let(:field) { FactoryBot.build :custom_field, field_format: 'list', custom_options: options } before do field.save! diff --git a/spec/models/custom_option_spec.rb b/spec/models/custom_option_spec.rb index 419e403cbb..05460ee29b 100644 --- a/spec/models/custom_option_spec.rb +++ b/spec/models/custom_option_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe CustomOption, type: :model do let(:custom_field) do - cf = FactoryGirl.build(:wp_custom_field, field_format: 'list') + cf = FactoryBot.build(:wp_custom_field, field_format: 'list') cf.custom_options.build(value: 'some value') cf @@ -54,7 +54,7 @@ describe CustomOption, type: :model do describe '.destroy' do context 'with more than one option for the cf' do before do - FactoryGirl.create(:custom_option, custom_field: custom_field) + FactoryBot.create(:custom_option, custom_field: custom_field) end it 'removes the option' do diff --git a/spec/models/custom_value/list_strategy_spec.rb b/spec/models/custom_value/list_strategy_spec.rb index 985d031682..5a3e8dc8df 100644 --- a/spec/models/custom_value/list_strategy_spec.rb +++ b/spec/models/custom_value/list_strategy_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe CustomValue::ListStrategy do let(:instance) { described_class.new(custom_value) } - let(:custom_field) { FactoryGirl.create :list_wp_custom_field } + let(:custom_field) { FactoryBot.create :list_wp_custom_field } let(:custom_value) do double("CustomField", value: value, custom_field: custom_field, customized: customized) end diff --git a/spec/models/custom_value/user_strategy_spec.rb b/spec/models/custom_value/user_strategy_spec.rb index cefadb311c..31bb18e469 100644 --- a/spec/models/custom_value/user_strategy_spec.rb +++ b/spec/models/custom_value/user_strategy_spec.rb @@ -37,8 +37,8 @@ describe CustomValue::UserStrategy do customized: customized) end let(:customized) { double('customized') } - let(:custom_field) { FactoryGirl.build(:custom_field) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:custom_field) { FactoryBot.build(:custom_field) } + let(:user) { FactoryBot.build_stubbed(:user) } describe '#parse_value/#typed_value' do subject { instance } diff --git a/spec/models/custom_value/version_strategy_spec.rb b/spec/models/custom_value/version_strategy_spec.rb index 29dc817416..07637ac582 100644 --- a/spec/models/custom_value/version_strategy_spec.rb +++ b/spec/models/custom_value/version_strategy_spec.rb @@ -37,8 +37,8 @@ describe CustomValue::VersionStrategy do customized: customized) end let(:customized) { double('customized') } - let(:custom_field) { FactoryGirl.build(:custom_field) } - let(:version) { FactoryGirl.build_stubbed(:version) } + let(:custom_field) { FactoryBot.build(:custom_field) } + let(:version) { FactoryBot.build_stubbed(:version) } describe '#parse_value/#typed_value' do subject { instance } diff --git a/spec/models/custom_value_spec.rb b/spec/models/custom_value_spec.rb index 4d74fdd2d0..b7221edf4e 100644 --- a/spec/models/custom_value_spec.rb +++ b/spec/models/custom_value_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe CustomValue do let(:format) { 'bool' } - let(:custom_field) { FactoryGirl.create(:custom_field, field_format: format) } - let(:custom_value) { FactoryGirl.create(:custom_value, custom_field: custom_field, value: value) } + let(:custom_field) { FactoryBot.create(:custom_field, field_format: format) } + let(:custom_value) { FactoryBot.create(:custom_value, custom_field: custom_field, value: value) } describe '#typed_value' do subject { custom_value } @@ -97,7 +97,7 @@ describe CustomValue do end describe 'value/value=' do - let(:custom_value) { FactoryGirl.build_stubbed(:custom_value) } + let(:custom_value) { FactoryBot.build_stubbed(:custom_value) } let(:strategy_double) { double('strategy_double') } it 'calls the strategy for parsing and uses that value' do diff --git a/spec/models/deleted_user_spec.rb b/spec/models/deleted_user_spec.rb index e8d23d4720..90657278da 100644 --- a/spec/models/deleted_user_spec.rb +++ b/spec/models/deleted_user_spec.rb @@ -65,7 +65,7 @@ describe DeletedUser, type: :model do describe '#available_custom_fields' do before do - FactoryGirl.create(:user_custom_field) + FactoryBot.create(:user_custom_field) end it { expect(user.available_custom_fields).to eq([]) } @@ -73,8 +73,8 @@ describe DeletedUser, type: :model do describe '#create' do describe 'WHEN creating a second deleted user' do - let(:u1) { FactoryGirl.build(:deleted_user) } - let(:u2) { FactoryGirl.build(:deleted_user) } + let(:u1) { FactoryBot.build(:deleted_user) } + let(:u2) { FactoryBot.build(:deleted_user) } before do u1.save! @@ -97,7 +97,7 @@ describe DeletedUser, type: :model do describe '#first' do describe 'WHEN a deleted user already exists' do - let(:user) { FactoryGirl.build(:deleted_user) } + let(:user) { FactoryBot.build(:deleted_user) } before do user.save! diff --git a/spec/models/design_color_spec.rb b/spec/models/design_color_spec.rb index 7345eaf115..4e4f1e6a5a 100644 --- a/spec/models/design_color_spec.rb +++ b/spec/models/design_color_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' RSpec.describe DesignColor, type: :model do let(:default_primary) { ::OpenProject::Design.variables['primary-color'] } - let(:primary_color) { FactoryGirl.create :"design_color_primary-color" } + let(:primary_color) { FactoryBot.create :"design_color_primary-color" } describe "#defaults" do it "returns a hash of default color variables with hex color codes" do diff --git a/spec/models/enabled_module_spec.rb b/spec/models/enabled_module_spec.rb index 981fb9ee80..83c14b59c3 100644 --- a/spec/models/enabled_module_spec.rb +++ b/spec/models/enabled_module_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe EnabledModule, type: :model do # Force reload, as association is not always(?) showing - let(:project) { FactoryGirl.create(:project, enabled_module_names: modules).reload } + let(:project) { FactoryBot.create(:project, enabled_module_names: modules).reload } describe '#wiki' do let(:modules) { %w[wiki] } @@ -81,7 +81,7 @@ describe EnabledModule, type: :model do end shared_examples 'does not create a repository when one exists' do - let!(:repository) { FactoryGirl.create(:repository_git, project: project) } + let!(:repository) { FactoryBot.create(:repository_git, project: project) } it 'should not create a separate repository when one exists already' do project.reload diff --git a/spec/models/group_performance_spec.rb b/spec/models/group_performance_spec.rb index 6e2195f3af..81db060185 100644 --- a/spec/models/group_performance_spec.rb +++ b/spec/models/group_performance_spec.rb @@ -32,13 +32,13 @@ require_relative '../support/shared/become_member' describe Group, type: :model do include BecomeMember - let(:group) { FactoryGirl.build(:group) } - let(:user) { FactoryGirl.build(:user) } - let(:status) { FactoryGirl.create(:status) } - let(:role) { FactoryGirl.create :role, permissions: [:view_work_packages] } + let(:group) { FactoryBot.build(:group) } + let(:user) { FactoryBot.build(:user) } + let(:status) { FactoryBot.create(:status) } + let(:role) { FactoryBot.create :role, permissions: [:view_work_packages] } let(:projects) do - projects = FactoryGirl.create_list :project_with_types, 20 + projects = FactoryBot.create_list :project_with_types, 20 projects.each do |project| add_user_to_project! user: group, project: project, role: role @@ -49,7 +49,7 @@ describe Group, type: :model do let!(:work_packages) do projects.flat_map do |project| - work_packages = FactoryGirl.create_list( + work_packages = FactoryBot.create_list( :work_package, 1, type: project.types.first, @@ -64,7 +64,7 @@ describe Group, type: :model do end end - let(:users) { FactoryGirl.create_list :user, 100 } + let(:users) { FactoryBot.create_list :user, 100 } before do users.each do |user| diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index bf8f678bb7..c946092ca9 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -32,13 +32,13 @@ require_relative '../support/shared/become_member' describe Group, type: :model do include BecomeMember - let(:group) { FactoryGirl.build(:group) } - let(:user) { FactoryGirl.build(:user) } - let(:watcher) { FactoryGirl.create :user } - let(:project) { FactoryGirl.create(:project_with_types) } - let(:status) { FactoryGirl.create(:status) } + let(:group) { FactoryBot.build(:group) } + let(:user) { FactoryBot.build(:user) } + let(:watcher) { FactoryBot.create :user } + let(:project) { FactoryBot.create(:project_with_types) } + let(:status) { FactoryBot.create(:status) } let(:package) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, author: user, project: project, status: status) @@ -92,7 +92,7 @@ describe Group, type: :model do describe '#create' do describe 'group with empty group name' do - let(:group) { FactoryGirl.build(:group, lastname: '') } + let(:group) { FactoryBot.build(:group, lastname: '') } it { expect(group.valid?).to be_falsey } diff --git a/spec/models/issue_priority_spec.rb b/spec/models/issue_priority_spec.rb index a0115bd73f..ddf35a6845 100644 --- a/spec/models/issue_priority_spec.rb +++ b/spec/models/issue_priority_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe IssuePriority, type: :model do - let(:stubbed_priority) { FactoryGirl.build_stubbed(:priority) } - let(:priority) { FactoryGirl.create(:priority) } + let(:stubbed_priority) { FactoryBot.build_stubbed(:priority) } + let(:priority) { FactoryBot.create(:priority) } describe '.ancestors' do it 'is an enumeration' do @@ -40,8 +40,8 @@ describe IssuePriority, type: :model do end describe '#objects_count' do - let(:work_package1) { FactoryGirl.create(:work_package, priority: priority) } - let(:work_package2) { FactoryGirl.create(:work_package) } + let(:work_package1) { FactoryBot.create(:work_package, priority: priority) } + let(:work_package2) { FactoryBot.create(:work_package) } it 'counts the work packages having the priority' do expect(priority.objects_count) @@ -75,10 +75,10 @@ describe IssuePriority, type: :model do end describe '#transer_to' do - let(:new_priority) { FactoryGirl.create(:priority) } - let(:work_package1) { FactoryGirl.create(:work_package, priority: priority) } - let(:work_package2) { FactoryGirl.create(:work_package) } - let(:work_package3) { FactoryGirl.create(:work_package, priority: new_priority) } + let(:new_priority) { FactoryBot.create(:priority) } + let(:work_package1) { FactoryBot.create(:work_package, priority: priority) } + let(:work_package2) { FactoryBot.create(:work_package) } + let(:work_package3) { FactoryBot.create(:work_package, priority: new_priority) } it 'moves all work_packages to the designated priority' do work_package1 diff --git a/spec/models/journal/aggregated_journal_spec.rb b/spec/models/journal/aggregated_journal_spec.rb index c1aaaaec14..b735e36648 100644 --- a/spec/models/journal/aggregated_journal_spec.rb +++ b/spec/models/journal/aggregated_journal_spec.rb @@ -64,10 +64,10 @@ end describe Journal::AggregatedJournal, type: :model do let(:work_package) { - FactoryGirl.build(:work_package) + FactoryBot.build(:work_package) } - let(:user1) { FactoryGirl.create(:user) } - let(:user2) { FactoryGirl.create(:user) } + let(:user1) { FactoryBot.create(:user) } + let(:user2) { FactoryBot.create(:user) } let(:initial_author) { user1 } subject { described_class.aggregated_journals } @@ -100,7 +100,7 @@ describe Journal::AggregatedJournal, type: :model do let(:notes) { nil } before do - changes = { status: FactoryGirl.build(:status) } + changes = { status: FactoryBot.build(:status) } changes[:journal_notes] = notes if notes allow(User).to receive(:current).and_return(new_author) @@ -243,7 +243,7 @@ describe Journal::AggregatedJournal, type: :model do let(:delay) { (Setting.journal_aggregation_time_minutes.to_i + 1).minutes } before do - work_package.status = FactoryGirl.build(:status) + work_package.status = FactoryBot.build(:status) work_package.save! work_package.journals.second.created_at += delay work_package.journals.second.save! @@ -265,7 +265,7 @@ describe Journal::AggregatedJournal, type: :model do let(:delay) { 0.001.seconds } before do - work_package.status = FactoryGirl.build(:status) + work_package.status = FactoryBot.build(:status) work_package.save! work_package.journals.second.created_at = work_package.journals.first.created_at + delay work_package.journals.second.save! @@ -280,7 +280,7 @@ describe Journal::AggregatedJournal, type: :model do end context 'different WP updated immediately after change' do - let(:other_wp) { FactoryGirl.build(:work_package) } + let(:other_wp) { FactoryBot.build(:work_package) } before do other_wp.save! end @@ -294,7 +294,7 @@ describe Journal::AggregatedJournal, type: :model do context 'passing a journable as parameter' do subject { described_class.aggregated_journals(journable: work_package) } - let(:other_wp) { FactoryGirl.build(:work_package) } + let(:other_wp) { FactoryBot.build(:work_package) } let(:new_author) { initial_author } before do diff --git a/spec/models/journal_manager_spec.rb b/spec/models/journal_manager_spec.rb index 4f29217fa1..1478aa3701 100644 --- a/spec/models/journal_manager_spec.rb +++ b/spec/models/journal_manager_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe JournalManager, type: :model do describe '#self.changed?' do let(:journable) do - FactoryGirl.create(:work_package, description: old).tap do |journable| + FactoryBot.create(:work_package, description: old).tap do |journable| # replace newline character and apply another change journable.assign_attributes description: changed end @@ -102,10 +102,10 @@ describe JournalManager, type: :model do end describe 'self.#update_user_references' do - let!(:work_package) { FactoryGirl.create :work_package } + let!(:work_package) { FactoryBot.create :work_package } let!(:doomed_user) { work_package.author } let!(:data1) { - FactoryGirl.build(:journal_work_package_journal, + FactoryBot.build(:journal_work_package_journal, subject: work_package.subject, status_id: work_package.status_id, type_id: work_package.type_id, @@ -113,7 +113,7 @@ describe JournalManager, type: :model do project_id: work_package.project_id) } let!(:data2) { - FactoryGirl.build(:journal_work_package_journal, + FactoryBot.build(:journal_work_package_journal, subject: work_package.subject, status_id: work_package.status_id, type_id: work_package.type_id, @@ -121,14 +121,14 @@ describe JournalManager, type: :model do project_id: work_package.project_id) } let!(:doomed_user_journal) { - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, notes: '1', user: doomed_user, journable_id: work_package.id, data: data1 } let!(:some_other_journal) { - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, notes: '2', journable_id: work_package.id, data: data2 diff --git a/spec/models/journal_notification_mailer_spec.rb b/spec/models/journal_notification_mailer_spec.rb index 13f31710ff..8413708e1c 100644 --- a/spec/models/journal_notification_mailer_spec.rb +++ b/spec/models/journal_notification_mailer_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe JournalNotificationMailer do - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:user) do - FactoryGirl.build(:user, + FactoryBot.build(:user, mail_notification: 'all', member_in_project: project) end let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: user, type: project.types.first) @@ -82,7 +82,7 @@ describe JournalNotificationMailer do context 'insufficient work package changes' do let(:journal) { another_work_package.journals.last } let(:another_work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: user, type: project.types.first) @@ -109,7 +109,7 @@ describe JournalNotificationMailer do describe 'journal creation' do context 'work_package_created' do before do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) end it_behaves_like 'handles deliveries', 'work_package_added' @@ -128,7 +128,7 @@ describe JournalNotificationMailer do it_behaves_like 'enqueues a regular notification' context 'WP creation' do - let(:journal) { FactoryGirl.create(:work_package).journals.first } + let(:journal) { FactoryBot.create(:work_package).journals.first } it 'sends no notification' do expect(Delayed::Job).not_to receive(:enqueue) @@ -155,7 +155,7 @@ describe JournalNotificationMailer do context 'status_updated' do before do work_package.add_journal(user) - work_package.status = FactoryGirl.build(:status) + work_package.status = FactoryBot.build(:status) work_package.save!(validate: false) end @@ -165,7 +165,7 @@ describe JournalNotificationMailer do context 'work_package_priority_updated' do before do work_package.add_journal(user) - work_package.priority = FactoryGirl.create(:issue_priority) + work_package.priority = FactoryBot.create(:issue_priority) work_package.save!(validate: false) end @@ -325,6 +325,6 @@ end describe 'initialization' do it 'subscribes the listener' do expect(JournalNotificationMailer).to receive(:distinguish_journals) - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end end diff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rb index 9ee3b3caa4..3567a66227 100644 --- a/spec/models/mail_handler_spec.rb +++ b/spec/models/mail_handler_spec.rb @@ -32,8 +32,8 @@ DEVELOPER_PERMISSIONS = [:view_messages, :delete_own_messages, :edit_own_message describe MailHandler, type: :model do let(:anno_user) { User.anonymous } - let(:project) { FactoryGirl.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', is_public: false) } - let(:priority_low) { FactoryGirl.create(:priority_low, is_default: true) } + let(:project) { FactoryBot.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', is_public: false) } + let(:priority_low) { FactoryBot.create(:priority_low, is_default: true) } before do allow(Setting).to receive(:notified_events).and_return(Redmine::Notifiable.all.map(&:name)) diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb index 30c0d50cad..97186d6c23 100644 --- a/spec/models/member_spec.rb +++ b/spec/models/member_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe Member, type: :model do - let(:user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role) } - let(:second_role) { FactoryGirl.create(:role) } - let(:member) { FactoryGirl.create(:member, user: user, roles: [role]) } + let(:user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role) } + let(:second_role) { FactoryBot.create(:role) } + let(:member) { FactoryBot.create(:member, user: user, roles: [role]) } describe '#add_role' do before do diff --git a/spec/models/menu_item_spec.rb b/spec/models/menu_item_spec.rb index ed6e1d7cb6..d1c8b59c2d 100644 --- a/spec/models/menu_item_spec.rb +++ b/spec/models/menu_item_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe MenuItem, type: :model do describe 'validations' do - let(:item) { FactoryGirl.build :menu_item } + let(:item) { FactoryBot.build :menu_item } it 'requires a title' do item.title = nil @@ -45,9 +45,9 @@ describe MenuItem, type: :model do end describe 'scoped uniqueness of title' do - let!(:item) { FactoryGirl.create :menu_item } - let(:another_item) { FactoryGirl.build :menu_item, title: item.title } - let(:wiki_menu_item) { FactoryGirl.build :wiki_menu_item, title: item.title } + let!(:item) { FactoryBot.create :menu_item } + let(:another_item) { FactoryBot.build :menu_item, title: item.title } + let(:wiki_menu_item) { FactoryBot.build :wiki_menu_item, title: item.title } it 'does not allow for duplicate titles' do expect(another_item).not_to be_valid @@ -61,8 +61,8 @@ describe MenuItem, type: :model do end context 'it should destroy' do - let!(:menu_item) { FactoryGirl.create(:menu_item) } - let!(:child_item) { FactoryGirl.create(:menu_item, parent_id: menu_item.id) } + let!(:menu_item) { FactoryBot.create(:menu_item) } + let!(:child_item) { FactoryBot.create(:menu_item, parent_id: menu_item.id) } example 'all children when deleting the parent' do menu_item.destroy diff --git a/spec/models/menu_items/query_menu_item_spec.rb b/spec/models/menu_items/query_menu_item_spec.rb index 88c076bffd..6b0c57a51a 100644 --- a/spec/models/menu_items/query_menu_item_spec.rb +++ b/spec/models/menu_items/query_menu_item_spec.rb @@ -29,17 +29,17 @@ require 'spec_helper' describe MenuItems::QueryMenuItem, type: :model do - let(:project) { FactoryGirl.create :project, enabled_module_names: %w[activity] } - let(:query) { FactoryGirl.create :query, project: project } - let(:another_query) { FactoryGirl.create :query, project: project } + let(:project) { FactoryBot.create :project, enabled_module_names: %w[activity] } + let(:query) { FactoryBot.create :query, project: project } + let(:another_query) { FactoryBot.create :query, project: project } describe 'it should destroy all items when destroying' do before(:each) do - query_item = FactoryGirl.create(:query_menu_item, + query_item = FactoryBot.create(:query_menu_item, query: query, name: 'Query Item', title: 'Query Item') - another_query_item = FactoryGirl.create(:query_menu_item, + another_query_item = FactoryBot.create(:query_menu_item, query: another_query, name: 'Another Query Item', title: 'Another Query Item') diff --git a/spec/models/menu_items/wiki_menu_item_spec.rb b/spec/models/menu_items/wiki_menu_item_spec.rb index f74d13fa0d..f628d953f8 100644 --- a/spec/models/menu_items/wiki_menu_item_spec.rb +++ b/spec/models/menu_items/wiki_menu_item_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe MenuItems::WikiMenuItem, type: :model do before(:each) do - @project = FactoryGirl.create(:project, enabled_module_names: %w[activity]) - @current = FactoryGirl.create(:user, login: 'user1', mail: 'user1@users.com') + @project = FactoryBot.create(:project, enabled_module_names: %w[activity]) + @current = FactoryBot.create(:user, login: 'user1', mail: 'user1@users.com') allow(User).to receive(:current).and_return(@current) end @@ -51,9 +51,9 @@ describe MenuItems::WikiMenuItem, type: :model do end it 'should change title when a wikipage is renamed' do - wikipage = FactoryGirl.create(:wiki_page, title: 'Oldtitle') + wikipage = FactoryBot.create(:wiki_page, title: 'Oldtitle') - menu_item_1 = FactoryGirl.create(:wiki_menu_item, navigatable_id: wikipage.wiki.id, + menu_item_1 = FactoryBot.create(:wiki_menu_item, navigatable_id: wikipage.wiki.id, title: 'Item 1', name: wikipage.slug) @@ -65,9 +65,9 @@ describe MenuItems::WikiMenuItem, type: :model do end it 'should not allow duplicate sibling entries' do - wikipage = FactoryGirl.create(:wiki_page, title: 'Parent Page') + wikipage = FactoryBot.create(:wiki_page, title: 'Parent Page') - parent = FactoryGirl.create( + parent = FactoryBot.create( :wiki_menu_item, navigatable_id: wikipage.wiki.id, title: 'Item 1', name: wikipage.slug) child_1 = parent.children.create name: "child-1", title: "Child 1" @@ -81,11 +81,11 @@ describe MenuItems::WikiMenuItem, type: :model do @project.enabled_modules << EnabledModule.new(name: 'wiki') @project.reload - @menu_item_1 = FactoryGirl.create(:wiki_menu_item, wiki: @project.wiki, + @menu_item_1 = FactoryBot.create(:wiki_menu_item, wiki: @project.wiki, name: 'Item 1', title: 'Item 1') - @menu_item_2 = FactoryGirl.create(:wiki_menu_item, wiki: @project.wiki, + @menu_item_2 = FactoryBot.create(:wiki_menu_item, wiki: @project.wiki, name: 'Item 2', parent_id: @menu_item_1.id, title: 'Item 2') diff --git a/spec/models/messages_spec.rb b/spec/models/messages_spec.rb index 6b5273ae7a..49215ba09e 100644 --- a/spec/models/messages_spec.rb +++ b/spec/models/messages_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' require 'support/shared/acts_as_watchable' describe Message, type: :model do - let(:message) { FactoryGirl.create(:message) } + let(:message) { FactoryBot.create(:message) } it_behaves_like 'acts_as_watchable included' do let(:model_instance) { message } diff --git a/spec/models/news_spec.rb b/spec/models/news_spec.rb index b2f2402ecd..ed9b5526de 100644 --- a/spec/models/news_spec.rb +++ b/spec/models/news_spec.rb @@ -35,17 +35,17 @@ describe News, type: :model do include BecomeMember let(:project) { - project = FactoryGirl.create(:public_project) + project = FactoryBot.create(:public_project) project.enabled_modules << EnabledModule.new(name: 'news') project.reload } - let!(:news) { FactoryGirl.create(:news, project: project) } + let!(:news) { FactoryBot.create(:news, project: project) } let(:permissions) { [] } - let(:role) { FactoryGirl.build(:role, permissions: permissions) } + let(:role) { FactoryBot.build(:role, permissions: permissions) } it_behaves_like 'acts_as_watchable included' do - let(:model_instance) { FactoryGirl.create(:news) } + let(:model_instance) { FactoryBot.create(:news) } let(:watch_permission) { :view_news } let(:project) { model_instance.project } end @@ -66,8 +66,8 @@ describe News, type: :model do end it 'only includes news elements from projects that are visible to the user' do - private_project = FactoryGirl.create(:project, is_public: false) - FactoryGirl.create(:news, project: private_project) + private_project = FactoryBot.create(:project, is_public: false) + FactoryBot.create(:news, project: private_project) latest_news = News.latest(user: User.anonymous) expect(latest_news).to match_array [news] @@ -77,7 +77,7 @@ describe News, type: :model do News.delete_all 10.times do - FactoryGirl.create(:news, project: project) + FactoryBot.create(:news, project: project) end expect(News.latest(user: User.current, count: 2).size).to eq(2) @@ -89,17 +89,17 @@ describe News, type: :model do News.delete_all 2.times do - FactoryGirl.create(:news, project: project) + FactoryBot.create(:news, project: project) end expect(News.latest.size).to eq(2) 3.times do - FactoryGirl.create(:news, project: project) + FactoryBot.create(:news, project: project) end expect(News.latest.size).to eq(5) 2.times do - FactoryGirl.create(:news, project: project) + FactoryBot.create(:news, project: project) end expect(News.latest.size).to eq(5) end @@ -108,12 +108,12 @@ describe News, type: :model do describe '#save', with_settings: { notified_events: %w(news_added) } do it 'sends email notifications when created' do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) project.members.reload - FactoryGirl.create(:news, project: project) + FactoryBot.create(:news, project: project) expect(ActionMailer::Base.deliveries.size).to eq(1) end end @@ -121,7 +121,7 @@ describe News, type: :model do describe '#to_param' do it 'includes includes id and title for a nicer url' do title = 'OpenProject now has a Twitter Account' - news = FactoryGirl.create(:news, title: title) + news = FactoryBot.create(:news, title: title) slug = "#{news.id}-openproject-now-has-a-twitter-account" expect(news.to_param).to eq slug diff --git a/spec/models/permitted_params_spec.rb b/spec/models/permitted_params_spec.rb index 6defcac336..fff61eddd5 100644 --- a/spec/models/permitted_params_spec.rb +++ b/spec/models/permitted_params_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe PermittedParams, type: :model do - let(:user) { FactoryGirl.build(:user) } - let(:admin) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:user) } + let(:admin) { FactoryBot.build(:admin) } shared_context 'prepare params comparison' do let(:params_key) { defined?(hash_key) ? hash_key : attribute } diff --git a/spec/models/planning_element_type_color_spec.rb b/spec/models/planning_element_type_color_spec.rb index 6e03f569cf..3fc341f8a6 100644 --- a/spec/models/planning_element_type_color_spec.rb +++ b/spec/models/planning_element_type_color_spec.rb @@ -32,8 +32,8 @@ describe PlanningElementTypeColor, type: :model do describe '- Relations ' do describe '#planning_element_types' do it 'can read planning_element_types w/ the help of the has_many association' do - color = FactoryGirl.create(:color) - planning_element_type = FactoryGirl.create(:type, + color = FactoryBot.create(:color) + planning_element_type = FactoryBot.create(:type, color_id: color.id) color.reload @@ -43,8 +43,8 @@ describe PlanningElementTypeColor, type: :model do end it 'nullifies dependent planning_element_types' do - color = FactoryGirl.create(:color) - planning_element_type = FactoryGirl.create(:type, + color = FactoryBot.create(:color) + planning_element_type = FactoryBot.create(:type, color_id: color.id) color.reload diff --git a/spec/models/principal_spec.rb b/spec/models/principal_spec.rb index 348b53bdca..0141fd2899 100644 --- a/spec/models/principal_spec.rb +++ b/spec/models/principal_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Principal, type: :model do - let(:user) { FactoryGirl.build(:user) } - let(:group) { FactoryGirl.build(:group) } + let(:user) { FactoryBot.build(:user) } + let(:group) { FactoryBot.build(:group) } def self.should_return_groups_and_users_if_active(method, *params) it 'should return a user' do diff --git a/spec/models/project/activity_spec.rb b/spec/models/project/activity_spec.rb index d53b2cff49..eaaa76dbea 100644 --- a/spec/models/project/activity_spec.rb +++ b/spec/models/project/activity_spec.rb @@ -30,89 +30,89 @@ require 'spec_helper' describe Project::Activity, type: :model do let(:project) { - FactoryGirl.create(:project) + FactoryBot.create(:project) } let(:initial_time) { Time.now } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) } let(:work_package2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) } let(:wiki_content) { project.reload - page = FactoryGirl.create(:wiki_page, + page = FactoryBot.create(:wiki_page, wiki: project.wiki) - FactoryGirl.create(:wiki_content, + FactoryBot.create(:wiki_content, page: page) } let(:wiki_content2) { project.reload - page = FactoryGirl.create(:wiki_page, + page = FactoryBot.create(:wiki_page, wiki: project.wiki) - FactoryGirl.create(:wiki_content, + FactoryBot.create(:wiki_content, page: page) } let(:news) { - FactoryGirl.create(:news, + FactoryBot.create(:news, project: project) } let(:news2) { - FactoryGirl.create(:news, + FactoryBot.create(:news, project: project) } let(:repository) { - FactoryGirl.create(:repository_git, + FactoryBot.create(:repository_git, project: project) } let(:changeset) { - FactoryGirl.create(:changeset, + FactoryBot.create(:changeset, repository: repository) } let(:changeset2) { - FactoryGirl.create(:changeset, + FactoryBot.create(:changeset, repository: repository) } let(:board) { - FactoryGirl.create(:board, + FactoryBot.create(:board, project: project) } let(:message) { - FactoryGirl.create(:message, + FactoryBot.create(:message, board: board) } let(:message2) { - FactoryGirl.create(:message, + FactoryBot.create(:message, board: board) } let(:time_entry) { - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, work_package: work_package, project: project) } let(:time_entry2) { - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, work_package: work_package, project: project) } diff --git a/spec/models/project/allowed_to_scope_spec.rb b/spec/models/project/allowed_to_scope_spec.rb index b7956dee78..bc186eec45 100644 --- a/spec/models/project/allowed_to_scope_spec.rb +++ b/spec/models/project/allowed_to_scope_spec.rb @@ -30,32 +30,32 @@ require 'spec_helper' describe Project, 'allowed to', type: :model do - let(:user) { FactoryGirl.build(:user) } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:admin) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:user) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:admin) { FactoryBot.build(:admin) } let(:private_project) do - FactoryGirl.build(:project, + FactoryBot.build(:project, is_public: false, status: project_status) end let(:public_project) do - FactoryGirl.build(:project, + FactoryBot.build(:project, is_public: true, status: project_status) end let(:project_status) { Project::STATUS_ACTIVE } let(:role) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: permissions) end let(:anonymous_role) do - FactoryGirl.build(:anonymous_role, + FactoryBot.build(:anonymous_role, permissions: anonymous_permissions) end let(:non_member_role) do - FactoryGirl.build(:non_member, + FactoryBot.build(:non_member, permissions: non_member_permissions) end let(:permissions) { [action] } @@ -65,7 +65,7 @@ describe Project, 'allowed to', type: :model do let(:public_action) { :view_news } let(:public_non_module_action) { :view_project } let(:member) do - FactoryGirl.build(:member, + FactoryBot.build(:member, user: user, roles: [role], project: project) diff --git a/spec/models/project/copy_spec.rb b/spec/models/project/copy_spec.rb index baa956681a..9458e483cb 100644 --- a/spec/models/project/copy_spec.rb +++ b/spec/models/project/copy_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe Project::Copy, type: :model do describe '#copy' do - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:copy) { Project.new } before do @@ -48,7 +48,7 @@ describe Project::Copy, type: :model do end describe '#copy_attributes' do - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:copy) do copy = Project.new @@ -70,8 +70,8 @@ describe Project::Copy, type: :model do describe '#work_package_custom_fields' do let(:project) do - project = FactoryGirl.create(:project_with_types) - work_package_custom_field = FactoryGirl.create(:work_package_custom_field) + project = FactoryBot.create(:project_with_types) + work_package_custom_field = FactoryBot.create(:work_package_custom_field) project.work_package_custom_fields << work_package_custom_field project.save project @@ -85,7 +85,7 @@ describe Project::Copy, type: :model do describe '#is_public' do describe '#non_public' do let(:project) do - project = FactoryGirl.create(:project_with_types) + project = FactoryBot.create(:project_with_types) project.is_public = false project.save project @@ -98,7 +98,7 @@ describe Project::Copy, type: :model do describe '#public' do let(:project) do - project = FactoryGirl.create(:project_with_types) + project = FactoryBot.create(:project_with_types) project.is_public = true project.save project @@ -112,7 +112,7 @@ describe Project::Copy, type: :model do end describe '#copy_associations' do - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:copy) do copy = Project.new copy.name = 'foo' @@ -123,18 +123,18 @@ describe Project::Copy, type: :model do end describe '#copy_work_packages' do - let(:work_package) { FactoryGirl.create(:work_package, project: project) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project) } - let(:work_package3) { FactoryGirl.create(:work_package, project: project) } - let(:version) { FactoryGirl.create(:version, project: project) } - let(:user) { FactoryGirl.create(:admin) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } + let(:work_package2) { FactoryBot.create(:work_package, project: project) } + let(:work_package3) { FactoryBot.create(:work_package, project: project) } + let(:version) { FactoryBot.create(:version, project: project) } + let(:user) { FactoryBot.create(:admin) } before do login_as(user) end describe '#attachments' do - let!(:attachment) { FactoryGirl.create(:attachment, container: work_package) } + let!(:attachment) { FactoryBot.create(:attachment, container: work_package) } before do copy.send :copy_work_packages, project, only @@ -163,7 +163,7 @@ describe Project::Copy, type: :model do describe '#relation' do before do - FactoryGirl.create(:relation, from: work_package, to: work_package2) + FactoryBot.create(:relation, from: work_package, to: work_package2) [work_package, work_package2].each { |wp| project.work_packages << wp } copy.send :copy_work_packages, project @@ -206,7 +206,7 @@ describe Project::Copy, type: :model do describe '#category' do before do wp = work_package - wp.category = FactoryGirl.create(:category, project: project) + wp.category = FactoryBot.create(:category, project: project) wp.save project.work_packages << wp.reload @@ -223,8 +223,8 @@ describe Project::Copy, type: :model do end describe '#watchers' do - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:watcher) { FactoryGirl.create(:user, member_in_project: project, member_through_role: role) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:watcher) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) } describe '#active_watcher' do before do @@ -268,7 +268,7 @@ describe Project::Copy, type: :model do end describe '#copy_queries' do - let(:query) { FactoryGirl.create(:query, project: project) } + let(:query) { FactoryBot.create(:query, project: project) } before do query @@ -283,7 +283,7 @@ describe Project::Copy, type: :model do context 'with a filter' do let(:query) { - query = FactoryGirl.build(:query, project: project) + query = FactoryBot.build(:query, project: project) query.add_filter('subject', '~', ['bogus']) query.save! } @@ -298,7 +298,7 @@ describe Project::Copy, type: :model do context 'with a query menu item' do let(:query) { - query = FactoryGirl.build(:query, project: project) + query = FactoryBot.build(:query, project: project) query.add_filter('subject', '~', ['bogus']) query.save! @@ -322,8 +322,8 @@ describe Project::Copy, type: :model do describe '#copy_members' do describe '#with_user' do before do - role = FactoryGirl.create(:role) - user = FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + role = FactoryBot.create(:role) + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role) copy.send(:copy_members, project) copy.save @@ -336,7 +336,7 @@ describe Project::Copy, type: :model do describe '#with_group' do before do - project.add_member! FactoryGirl.create(:group), FactoryGirl.create(:role) + project.add_member! FactoryBot.create(:group), FactoryBot.create(:role) copy.send(:copy_members, project) copy.save @@ -350,7 +350,7 @@ describe Project::Copy, type: :model do describe '#copy_wiki' do before do - project.wiki = FactoryGirl.create(:wiki, project: project) + project.wiki = FactoryBot.create(:wiki, project: project) project.save copy.send(:copy_wiki, project) @@ -365,7 +365,7 @@ describe Project::Copy, type: :model do describe '#copy_wiki_pages' do describe '#dont_copy_wiki_page_without_content' do before do - project.wiki.pages << FactoryGirl.create(:wiki_page) + project.wiki.pages << FactoryBot.create(:wiki_page) copy.send(:copy_wiki_pages, project) copy.save @@ -378,7 +378,7 @@ describe Project::Copy, type: :model do describe '#copy_wiki_page_with_content' do before do - project.wiki.pages << FactoryGirl.create(:wiki_page_with_content) + project.wiki.pages << FactoryBot.create(:wiki_page_with_content) copy.send(:copy_wiki_pages, project) copy.save @@ -391,7 +391,7 @@ describe Project::Copy, type: :model do end describe '#copy_wiki_menu_items' do before do - project.wiki.wiki_menu_items << FactoryGirl.create(:wiki_menu_item_with_parent, wiki: project.wiki) + project.wiki.wiki_menu_items << FactoryBot.create(:wiki_menu_item_with_parent, wiki: project.wiki) copy.send(:copy_wiki_menu_items, project) copy.save end @@ -403,7 +403,7 @@ describe Project::Copy, type: :model do end describe '#copy_boards' do - let(:board) { FactoryGirl.create(:board, project: project) } + let(:board) { FactoryBot.create(:board, project: project) } context 'boards are copied' do before do @@ -418,8 +418,8 @@ describe Project::Copy, type: :model do context 'board topics are copied' do before do - topic = FactoryGirl.create(:message, board: board) - message = FactoryGirl.create(:message, board: board, parent_id: topic.id) + topic = FactoryBot.create(:message, board: board) + message = FactoryBot.create(:message, board: board, parent_id: topic.id) copy.send(:copy_boards, project) copy.save @@ -434,7 +434,7 @@ describe Project::Copy, type: :model do describe '#copy_versions' do before do - FactoryGirl.create(:version, project: project) + FactoryBot.create(:version, project: project) copy.send(:copy_versions, project) copy.save @@ -447,7 +447,7 @@ describe Project::Copy, type: :model do describe '#copy_categories' do before do - FactoryGirl.create(:category, project: project) + FactoryBot.create(:category, project: project) copy.send(:copy_categories, project) copy.save diff --git a/spec/models/project/customizable_spec.rb b/spec/models/project/customizable_spec.rb index 6cc7624459..133f7dd42c 100644 --- a/spec/models/project/customizable_spec.rb +++ b/spec/models/project/customizable_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe Project, 'customizable', type: :model do let(:project) do - FactoryGirl.build_stubbed(:project, + FactoryBot.build_stubbed(:project, custom_values: custom_values) end let(:stub_available_custom_fields) do @@ -46,9 +46,9 @@ describe Project, 'customizable', type: :model do .and_return(available_custom_fields) end let(:custom_values) { [] } - let(:bool_custom_field) { FactoryGirl.build_stubbed(:bool_project_custom_field) } - let(:text_custom_field) { FactoryGirl.build_stubbed(:text_project_custom_field) } - let(:list_custom_field) { FactoryGirl.build_stubbed(:list_project_custom_field) } + let(:bool_custom_field) { FactoryBot.build_stubbed(:bool_project_custom_field) } + let(:text_custom_field) { FactoryBot.build_stubbed(:text_project_custom_field) } + let(:list_custom_field) { FactoryBot.build_stubbed(:list_project_custom_field) } before do stub_available_custom_fields @@ -80,7 +80,7 @@ describe Project, 'customizable', type: :model do context 'with a value set' do let(:custom_value) do - FactoryGirl.build_stubbed(:custom_value, + FactoryBot.build_stubbed(:custom_value, custom_field: custom_field, value: true) end @@ -97,12 +97,12 @@ describe Project, 'customizable', type: :model do describe '#custom_value_attributes' do let(:available_custom_fields) { [bool_custom_field, list_custom_field, text_custom_field] } let(:text_custom_value) do - FactoryGirl.build_stubbed(:custom_value, + FactoryBot.build_stubbed(:custom_value, custom_field: text_custom_field, value: 'blubs') end let(:bool_custom_value) do - FactoryGirl.build_stubbed(:custom_value, + FactoryBot.build_stubbed(:custom_value, custom_field: bool_custom_field, value: true) end diff --git a/spec/models/project/storage_spec.rb b/spec/models/project/storage_spec.rb index 2affbd06f6..75564d1a0e 100644 --- a/spec/models/project/storage_spec.rb +++ b/spec/models/project/storage_spec.rb @@ -31,22 +31,22 @@ require 'spec_helper' describe Project::Storage, type: :model do let(:project1) { - FactoryGirl.create(:project) + FactoryBot.create(:project) .reload # Reload required for wiki association to be available } - let(:project2) { FactoryGirl.create(:project) } + let(:project2) { FactoryBot.create(:project) } before do allow(Setting).to receive(:enabled_scm).and_return(['git']) - wp = FactoryGirl.create(:work_package, project: project1) - FactoryGirl.create(:work_package, project: project1) - FactoryGirl.create_list(:attachment, 10, filesize: 250, container: wp) + wp = FactoryBot.create(:work_package, project: project1) + FactoryBot.create(:work_package, project: project1) + FactoryBot.create_list(:attachment, 10, filesize: 250, container: wp) - wikipage = FactoryGirl.create(:wiki_page, wiki: project1.wiki) - FactoryGirl.create(:attachment, filesize: 10000, container: wikipage) + wikipage = FactoryBot.create(:wiki_page, wiki: project1.wiki) + FactoryBot.create(:attachment, filesize: 10000, container: wikipage) - repo = FactoryGirl.create(:repository_git, project: project2) + repo = FactoryBot.create(:repository_git, project: project2) repo.update_attributes(required_storage_bytes: 1234) end @@ -78,7 +78,7 @@ describe Project::Storage, type: :model do end context 'with a project with all modules' do - let(:repository1) { FactoryGirl.create(:repository_git, project: project1) } + let(:repository1) { FactoryBot.create(:repository_git, project: project1) } before do repository1.update_attributes(required_storage_bytes: 543211234) end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6e94062f8f..18d081404c 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -32,9 +32,9 @@ require File.expand_path('../../support/shared/become_member', __FILE__) describe Project, type: :model do include BecomeMember - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:admin) { FactoryGirl.create(:admin) } - let(:user) { FactoryGirl.create(:user) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:admin) { FactoryBot.create(:admin) } + let(:user) { FactoryBot.create(:user) } describe Project::STATUS_ACTIVE do it 'equals 1' do @@ -50,18 +50,18 @@ describe Project, type: :model do end it 'is active when :status equals STATUS_ACTIVE' do - project = FactoryGirl.build :project, status: 42 + project = FactoryBot.build :project, status: 42 expect(project).to be_active end it "is not active when :status doesn't equal STATUS_ACTIVE" do - project = FactoryGirl.build :project, status: 99 + project = FactoryBot.build :project, status: 99 expect(project).not_to be_active end end context 'when the wiki module is enabled' do - let(:project) { FactoryGirl.create(:project, disable_modules: 'wiki') } + let(:project) { FactoryBot.create(:project, disable_modules: 'wiki') } before :each do project.enabled_module_names = project.enabled_module_names | ['wiki'] @@ -80,13 +80,13 @@ describe Project, type: :model do end describe 'copy_allowed?' do - let(:user) { FactoryGirl.create(:user) } - let(:role_add_subproject) { FactoryGirl.create(:role, permissions: [:add_subprojects]) } - let(:role_copy_projects) { FactoryGirl.create(:role, permissions: [:edit_project, :copy_projects, :add_project]) } - let(:parent_project) { FactoryGirl.create(:project) } - let(:project) { FactoryGirl.create(:project, parent: parent_project) } + let(:user) { FactoryBot.create(:user) } + let(:role_add_subproject) { FactoryBot.create(:role, permissions: [:add_subprojects]) } + let(:role_copy_projects) { FactoryBot.create(:role, permissions: [:edit_project, :copy_projects, :add_project]) } + let(:parent_project) { FactoryBot.create(:project) } + let(:project) { FactoryBot.create(:project, parent: parent_project) } let!(:subproject_member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: project, roles: [role_copy_projects]) @@ -97,7 +97,7 @@ describe Project, type: :model do context 'with permission to add subprojects' do let!(:member_add_subproject) { - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: parent_project, roles: [role_add_subproject]) @@ -116,17 +116,17 @@ describe Project, type: :model do end describe 'available principles' do - let(:user) { FactoryGirl.create(:user) } - let(:group) { FactoryGirl.create(:group) } - let(:role) { FactoryGirl.create(:role) } + let(:user) { FactoryBot.create(:user) } + let(:group) { FactoryBot.create(:group) } + let(:role) { FactoryBot.create(:role) } let!(:user_member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, principal: user, project: project, roles: [role]) } let!(:group_member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, principal: group, project: project, roles: [role]) @@ -160,12 +160,12 @@ describe Project, type: :model do end describe '#types_used_by_work_packages' do - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:type) { project.types.first } let(:other_type) { project.types.second } - let(:project_work_package) { FactoryGirl.create(:work_package, type: type, project: project) } - let(:other_project) { FactoryGirl.create(:project, no_types: true, types: [other_type, type]) } - let(:other_project_work_package) { FactoryGirl.create(:work_package, type: other_type, project: other_project) } + let(:project_work_package) { FactoryBot.create(:work_package, type: type, project: project) } + let(:other_project) { FactoryBot.create(:project, no_types: true, types: [other_type, type]) } + let(:other_project_work_package) { FactoryBot.create(:work_package, type: other_type, project: other_project) } it 'returns the type used by a work package of the project' do project_work_package @@ -176,9 +176,9 @@ describe Project, type: :model do end describe '#allowed_parent?' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:other_project) { FactoryGirl.build_stubbed(:project) } - let(:another_project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } + let(:another_project) { FactoryBot.build_stubbed(:project) } it 'is false for nil on a persisted project with no allowed parents' do allow(project) @@ -197,7 +197,7 @@ describe Project, type: :model do end it 'is true for nil on an unpersisted project with no allowed parents' do - project = FactoryGirl.build(:project) + project = FactoryBot.build(:project) allow(project) .to receive(:allowed_parents) @@ -223,7 +223,7 @@ describe Project, type: :model do end it 'is true for blank on an unpersisted project with no allowed parents' do - project = FactoryGirl.build(:project) + project = FactoryBot.build(:project) allow(project) .to receive(:allowed_parents) diff --git a/spec/models/project_type_spec.rb b/spec/models/project_type_spec.rb index eda7474f90..c269dfd86f 100644 --- a/spec/models/project_type_spec.rb +++ b/spec/models/project_type_spec.rb @@ -32,8 +32,8 @@ describe ProjectType, type: :model do describe '- Relations ' do describe '#projects' do it 'can read projects w/ the help of the has_many association' do - project_type = FactoryGirl.create(:project_type) - project = FactoryGirl.create(:project, project_type_id: project_type.id) + project_type = FactoryBot.create(:project_type) + project = FactoryBot.create(:project, project_type_id: project_type.id) project_type.reload diff --git a/spec/models/queries/available_filters_spec.rb b/spec/models/queries/available_filters_spec.rb index 126cc8f476..b2a85766f9 100644 --- a/spec/models/queries/available_filters_spec.rb +++ b/spec/models/queries/available_filters_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::AvailableFilters, type: :model do - let(:context) { FactoryGirl.build_stubbed(:project) } + let(:context) { FactoryBot.build_stubbed(:project) } let(:register) { Queries::FilterRegister } class HelperClass diff --git a/spec/models/queries/members/filters/group_filter_spec.rb b/spec/models/queries/members/filters/group_filter_spec.rb index c63aa70160..0ade91d5bf 100644 --- a/spec/models/queries/members/filters/group_filter_spec.rb +++ b/spec/models/queries/members/filters/group_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::Members::Filters::GroupFilter, type: :model do - let(:group1) { FactoryGirl.build_stubbed(:group) } - let(:group2) { FactoryGirl.build_stubbed(:group) } + let(:group1) { FactoryBot.build_stubbed(:group) } + let(:group2) { FactoryBot.build_stubbed(:group) } before do allow(Group) diff --git a/spec/models/queries/members/filters/role_filter_spec.rb b/spec/models/queries/members/filters/role_filter_spec.rb index 28d7a5bb7c..2c07ee7d1e 100644 --- a/spec/models/queries/members/filters/role_filter_spec.rb +++ b/spec/models/queries/members/filters/role_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::Members::Filters::RoleFilter, type: :model do - let(:role1) { FactoryGirl.build_stubbed(:role) } - let(:role2) { FactoryGirl.build_stubbed(:role) } + let(:role1) { FactoryBot.build_stubbed(:role) } + let(:role2) { FactoryBot.build_stubbed(:role) } before do allow(Role) diff --git a/spec/models/queries/projects/filters/created_on_filter_spec.rb b/spec/models/queries/projects/filters/created_on_filter_spec.rb index 11f97da39f..c97de8a676 100644 --- a/spec/models/queries/projects/filters/created_on_filter_spec.rb +++ b/spec/models/queries/projects/filters/created_on_filter_spec.rb @@ -37,8 +37,8 @@ describe Queries::Projects::Filters::CreatedOnFilter, type: :model do let(:model) { Project } let(:attribute) { :created_on } let(:values) { ['3'] } - let(:admin) { FactoryGirl.build_stubbed(:admin) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:admin) { FactoryBot.build_stubbed(:admin) } + let(:user) { FactoryBot.build_stubbed(:user) } describe '#available?' do context 'for an admin' do diff --git a/spec/models/queries/projects/filters/custom_field_filter_spec.rb b/spec/models/queries/projects/filters/custom_field_filter_spec.rb index 1ee482464c..2ad3097d6c 100644 --- a/spec/models/queries/projects/filters/custom_field_filter_spec.rb +++ b/spec/models/queries/projects/filters/custom_field_filter_spec.rb @@ -37,15 +37,15 @@ describe Queries::Projects::Filters::CustomFieldFilter, type: :model do let(:instance_key) { nil } let(:name) { field.name } - let(:list_project_custom_field) { FactoryGirl.create(:list_project_custom_field) } - let(:bool_project_custom_field) { FactoryGirl.build_stubbed(:bool_project_custom_field) } - let(:int_project_custom_field) { FactoryGirl.build_stubbed(:int_project_custom_field) } - let(:float_project_custom_field) { FactoryGirl.build_stubbed(:float_project_custom_field) } - let(:text_project_custom_field) { FactoryGirl.build_stubbed(:text_project_custom_field) } - let(:user_project_custom_field) { FactoryGirl.build_stubbed(:user_project_custom_field) } - let(:version_project_custom_field) { FactoryGirl.build_stubbed(:version_project_custom_field) } - let(:date_project_custom_field) { FactoryGirl.build_stubbed(:date_project_custom_field) } - let(:string_project_custom_field) { FactoryGirl.build_stubbed(:string_project_custom_field) } + let(:list_project_custom_field) { FactoryBot.create(:list_project_custom_field) } + let(:bool_project_custom_field) { FactoryBot.build_stubbed(:bool_project_custom_field) } + let(:int_project_custom_field) { FactoryBot.build_stubbed(:int_project_custom_field) } + let(:float_project_custom_field) { FactoryBot.build_stubbed(:float_project_custom_field) } + let(:text_project_custom_field) { FactoryBot.build_stubbed(:text_project_custom_field) } + let(:user_project_custom_field) { FactoryBot.build_stubbed(:user_project_custom_field) } + let(:version_project_custom_field) { FactoryBot.build_stubbed(:version_project_custom_field) } + let(:date_project_custom_field) { FactoryBot.build_stubbed(:date_project_custom_field) } + let(:string_project_custom_field) { FactoryBot.build_stubbed(:string_project_custom_field) } let(:custom_field) { list_project_custom_field } let(:all_custom_fields) do @@ -418,8 +418,8 @@ describe Queries::Projects::Filters::CustomFieldFilter, type: :model do end describe '#value_objects' do - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } before do allow(Principal) @@ -447,8 +447,8 @@ describe Queries::Projects::Filters::CustomFieldFilter, type: :model do end describe '#value_objects' do - let(:version1) { FactoryGirl.build_stubbed(:version) } - let(:version2) { FactoryGirl.build_stubbed(:version) } + let(:version1) { FactoryBot.build_stubbed(:version) } + let(:version2) { FactoryBot.build_stubbed(:version) } before do allow(Version) diff --git a/spec/models/queries/projects/filters/latest_activity_at_filter_spec.rb b/spec/models/queries/projects/filters/latest_activity_at_filter_spec.rb index 62ef680488..249f5ab358 100644 --- a/spec/models/queries/projects/filters/latest_activity_at_filter_spec.rb +++ b/spec/models/queries/projects/filters/latest_activity_at_filter_spec.rb @@ -37,8 +37,8 @@ describe Queries::Projects::Filters::LatestActivityAtFilter, type: :model do let(:model) { Project.with_latest_activity } let(:attribute) { :activity } let(:values) { ['3'] } - let(:admin) { FactoryGirl.build_stubbed(:admin) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:admin) { FactoryBot.build_stubbed(:admin) } + let(:user) { FactoryBot.build_stubbed(:user) } describe '#available?' do context 'for an admin' do diff --git a/spec/models/queries/queries/query_query_spec.rb b/spec/models/queries/queries/query_query_spec.rb index a50b6fc5d7..4033b70337 100644 --- a/spec/models/queries/queries/query_query_spec.rb +++ b/spec/models/queries/queries/query_query_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::Queries::QueryQuery, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user: user) } let(:base_scope) { Query.visible(to: user) } diff --git a/spec/models/queries/relations/filters/from_filter_spec.rb b/spec/models/queries/relations/filters/from_filter_spec.rb index 94195d03d1..a7f4a3bddb 100644 --- a/spec/models/queries/relations/filters/from_filter_spec.rb +++ b/spec/models/queries/relations/filters/from_filter_spec.rb @@ -34,7 +34,7 @@ describe Queries::Relations::Filters::FromFilter, type: :model do include_context 'filter tests' let(:values) { ['1'] } let(:model) { Relation } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } it_behaves_like 'basic query filter' do let(:class_key) { :from_id } diff --git a/spec/models/queries/relations/filters/involved_filter_spec.rb b/spec/models/queries/relations/filters/involved_filter_spec.rb index 291e32c36d..fc4d17099f 100644 --- a/spec/models/queries/relations/filters/involved_filter_spec.rb +++ b/spec/models/queries/relations/filters/involved_filter_spec.rb @@ -34,7 +34,7 @@ describe Queries::Relations::Filters::InvolvedFilter, type: :model do include_context 'filter tests' let(:values) { ['1'] } let(:model) { Relation } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } it_behaves_like 'basic query filter' do let(:class_key) { :involved } diff --git a/spec/models/queries/relations/filters/to_filter_spec.rb b/spec/models/queries/relations/filters/to_filter_spec.rb index 877d95619b..439ff38277 100644 --- a/spec/models/queries/relations/filters/to_filter_spec.rb +++ b/spec/models/queries/relations/filters/to_filter_spec.rb @@ -34,7 +34,7 @@ describe Queries::Relations::Filters::ToFilter, type: :model do include_context 'filter tests' let(:values) { ['1'] } let(:model) { Relation } - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } it_behaves_like 'basic query filter' do let(:class_key) { :to_id } diff --git a/spec/models/queries/relations/relation_query_spec.rb b/spec/models/queries/relations/relation_query_spec.rb index 5b5ebc53c7..439c0ec2ad 100644 --- a/spec/models/queries/relations/relation_query_spec.rb +++ b/spec/models/queries/relations/relation_query_spec.rb @@ -76,7 +76,7 @@ describe Queries::Relations::RelationQuery, type: :model do end context 'with a from filter' do - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } before do login_as(current_user) instance.where('from_id', '=', ['1']) diff --git a/spec/models/queries/time_entries/filters/project_filter_spec.rb b/spec/models/queries/time_entries/filters/project_filter_spec.rb index 59cbc47b33..6022220d88 100644 --- a/spec/models/queries/time_entries/filters/project_filter_spec.rb +++ b/spec/models/queries/time_entries/filters/project_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::TimeEntries::Filters::ProjectFilter, type: :model do - let(:project1) { FactoryGirl.build_stubbed(:project) } - let(:project2) { FactoryGirl.build_stubbed(:project) } + let(:project1) { FactoryBot.build_stubbed(:project) } + let(:project2) { FactoryBot.build_stubbed(:project) } before do allow(Project) diff --git a/spec/models/queries/time_entries/filters/user_filter_spec.rb b/spec/models/queries/time_entries/filters/user_filter_spec.rb index b5d8e0196a..5fa270f2c7 100644 --- a/spec/models/queries/time_entries/filters/user_filter_spec.rb +++ b/spec/models/queries/time_entries/filters/user_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::TimeEntries::Filters::UserFilter, type: :model do - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } before do allow(Principal) diff --git a/spec/models/queries/time_entries/filters/work_package_filter_spec.rb b/spec/models/queries/time_entries/filters/work_package_filter_spec.rb index d866246e36..6f5c982c51 100644 --- a/spec/models/queries/time_entries/filters/work_package_filter_spec.rb +++ b/spec/models/queries/time_entries/filters/work_package_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::TimeEntries::Filters::WorkPackageFilter, type: :model do - let(:work_package1) { FactoryGirl.build_stubbed(:work_package) } - let(:work_package2) { FactoryGirl.build_stubbed(:work_package) } + let(:work_package1) { FactoryBot.build_stubbed(:work_package) } + let(:work_package2) { FactoryBot.build_stubbed(:work_package) } before do allow(WorkPackage) diff --git a/spec/models/queries/time_entries/time_entry_query_spec.rb b/spec/models/queries/time_entries/time_entry_query_spec.rb index 0ec60e9c23..b891999e95 100644 --- a/spec/models/queries/time_entries/time_entry_query_spec.rb +++ b/spec/models/queries/time_entries/time_entry_query_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::TimeEntries::TimeEntryQuery, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:base_scope) { TimeEntry.visible(user) } let(:instance) { described_class.new } diff --git a/spec/models/queries/users/filters/group_filter_spec.rb b/spec/models/queries/users/filters/group_filter_spec.rb index 21358f330f..4f78e268e2 100644 --- a/spec/models/queries/users/filters/group_filter_spec.rb +++ b/spec/models/queries/users/filters/group_filter_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe Queries::Users::Filters::GroupFilter, type: :model do - let(:group1) { FactoryGirl.build_stubbed(:group) } - let(:group2) { FactoryGirl.build_stubbed(:group) } + let(:group1) { FactoryBot.build_stubbed(:group) } + let(:group2) { FactoryBot.build_stubbed(:group) } before do allow(Group) diff --git a/spec/models/queries/users/user_query_spec.rb b/spec/models/queries/users/user_query_spec.rb index 0e84f6773e..93d5c7168f 100644 --- a/spec/models/queries/users/user_query_spec.rb +++ b/spec/models/queries/users/user_query_spec.rb @@ -97,7 +97,7 @@ describe Queries::Users::UserQuery, type: :model do end context 'with a group filter' do - let(:group_1) { FactoryGirl.build_stubbed(:group) } + let(:group_1) { FactoryBot.build_stubbed(:group) } before do allow(Group) diff --git a/spec/models/queries/work_packages/columns/custom_field_column_spec.rb b/spec/models/queries/work_packages/columns/custom_field_column_spec.rb index b616475a2f..cd3e4f1774 100644 --- a/spec/models/queries/work_packages/columns/custom_field_column_spec.rb +++ b/spec/models/queries/work_packages/columns/custom_field_column_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' require_relative 'shared_query_column_specs' describe Queries::WorkPackages::Columns::CustomFieldColumn, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:custom_field) do mock_model(CustomField, field_format: 'string', order_statements: nil) @@ -41,11 +41,11 @@ describe Queries::WorkPackages::Columns::CustomFieldColumn, type: :model do describe 'instances' do let(:text_custom_field) do - FactoryGirl.create(:text_wp_custom_field) + FactoryBot.create(:text_wp_custom_field) end let(:list_custom_field) do - FactoryGirl.create(:list_wp_custom_field) + FactoryBot.create(:list_wp_custom_field) end context 'within project' do diff --git a/spec/models/queries/work_packages/columns/relation_of_type_column_spec.rb b/spec/models/queries/work_packages/columns/relation_of_type_column_spec.rb index 76c17de551..46c11938e3 100644 --- a/spec/models/queries/work_packages/columns/relation_of_type_column_spec.rb +++ b/spec/models/queries/work_packages/columns/relation_of_type_column_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' require_relative 'shared_query_column_specs' describe Queries::WorkPackages::Columns::RelationOfTypeColumn, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:instance) { described_class.new(type) } let(:enterprise_token_allows) { true } diff --git a/spec/models/queries/work_packages/columns/relation_to_type_column_spec.rb b/spec/models/queries/work_packages/columns/relation_to_type_column_spec.rb index d912310cee..f1fbc481fb 100644 --- a/spec/models/queries/work_packages/columns/relation_to_type_column_spec.rb +++ b/spec/models/queries/work_packages/columns/relation_to_type_column_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' require_relative 'shared_query_column_specs' describe Queries::WorkPackages::Columns::RelationToTypeColumn, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:type) { FactoryBot.build_stubbed(:type) } let(:instance) { described_class.new(type) } let(:enterprise_token_allows) { true } diff --git a/spec/models/queries/work_packages/filter/assigned_to_filter_spec.rb b/spec/models/queries/work_packages/filter/assigned_to_filter_spec.rb index 55e6c652e4..b3d964edbc 100644 --- a/spec/models/queries/work_packages/filter/assigned_to_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/assigned_to_filter_spec.rb @@ -40,9 +40,9 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do let(:values) { [] } describe 'where filter results' do - let(:work_package) { FactoryGirl.create(:work_package, assigned_to: assignee) } - let(:assignee) { FactoryGirl.create(:user) } - let(:group) { FactoryGirl.create(:group) } + let(:work_package) { FactoryBot.create(:work_package, assigned_to: assignee) } + let(:assignee) { FactoryBot.create(:user) } + let(:group) { FactoryBot.create(:group) } subject { WorkPackage.where(instance.where) } @@ -84,7 +84,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do before do allow(User) .to receive(:current) - .and_return(FactoryGirl.create(:user)) + .and_return(FactoryBot.create(:user)) end it 'does not return the work package' do @@ -94,8 +94,8 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do end context 'for me and user values' do - let(:user) { FactoryGirl.create :user } - let(:assignee2) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } + let(:assignee2) { FactoryBot.create :user } let(:values) { [assignee.id, user.id, 'me', assignee2.id] } before do @@ -153,7 +153,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do context "for a user value with the user's group being assignee" do let(:values) { [user.id.to_s] } let(:assignee) { group } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do group.users << user @@ -168,7 +168,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do context "for a user value with the user not being member of the assigned group" do let(:values) { [user.id.to_s] } let(:assignee) { group } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } it 'does not return the work package' do is_expected @@ -192,7 +192,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do let(:class_key) { :assigned_to_id } describe '#valid_values!' do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:loader) do loader = double('loader') diff --git a/spec/models/queries/work_packages/filter/assigned_to_spec.rb b/spec/models/queries/work_packages/filter/assigned_to_spec.rb index d03a5fca4e..b8d7bbf299 100644 --- a/spec/models/queries/work_packages/filter/assigned_to_spec.rb +++ b/spec/models/queries/work_packages/filter/assigned_to_spec.rb @@ -34,8 +34,8 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do let(:type) { :list_optional } let(:class_key) { :assigned_to_id } - let(:user_1) { FactoryGirl.build_stubbed(:user) } - let(:group_1) { FactoryGirl.build_stubbed(:group) } + let(:user_1) { FactoryBot.build_stubbed(:user) } + let(:group_1) { FactoryBot.build_stubbed(:group) } let(:principal_loader) do loader = double('principal_loader') diff --git a/spec/models/queries/work_packages/filter/assignee_or_group_filter_spec.rb b/spec/models/queries/work_packages/filter/assignee_or_group_filter_spec.rb index 21f28d94c7..4fff50cda8 100644 --- a/spec/models/queries/work_packages/filter/assignee_or_group_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/assignee_or_group_filter_spec.rb @@ -40,9 +40,9 @@ describe Queries::WorkPackages::Filter::AssigneeOrGroupFilter, type: :model do let(:values) { [] } describe 'where filter results' do - let(:work_package) { FactoryGirl.create(:work_package, assigned_to: assignee) } - let(:assignee) { FactoryGirl.create(:user) } - let(:group) { FactoryGirl.create(:group) } + let(:work_package) { FactoryBot.create(:work_package, assigned_to: assignee) } + let(:assignee) { FactoryBot.create(:user) } + let(:group) { FactoryBot.create(:group) } subject { WorkPackage.where(instance.where) } @@ -76,7 +76,7 @@ describe Queries::WorkPackages::Filter::AssigneeOrGroupFilter, type: :model do before do allow(User) .to receive(:current) - .and_return(FactoryGirl.create(:user)) + .and_return(FactoryBot.create(:user)) end it 'does not return the work package' do @@ -120,7 +120,7 @@ describe Queries::WorkPackages::Filter::AssigneeOrGroupFilter, type: :model do context "for a user value with the user's group being assignee" do let(:values) { [user.id.to_s] } let(:assignee) { group } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do group.users << user @@ -135,7 +135,7 @@ describe Queries::WorkPackages::Filter::AssigneeOrGroupFilter, type: :model do context "for a user value with the user not being member of the assigned group" do let(:values) { [user.id.to_s] } let(:assignee) { group } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } it 'does not return the work package' do is_expected @@ -160,7 +160,7 @@ describe Queries::WorkPackages::Filter::AssigneeOrGroupFilter, type: :model do let(:human_name) { I18n.t('query_fields.assignee_or_group') } describe '#valid_values!' do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:loader) do loader = double('loader') diff --git a/spec/models/queries/work_packages/filter/author_filter_spec.rb b/spec/models/queries/work_packages/filter/author_filter_spec.rb index 4d4e8c4516..89dc055517 100644 --- a/spec/models/queries/work_packages/filter/author_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/author_filter_spec.rb @@ -34,7 +34,7 @@ describe Queries::WorkPackages::Filter::AuthorFilter, type: :model do let(:type) { :list } let(:class_key) { :author_id } - let(:user_1) { FactoryGirl.build_stubbed(:user) } + let(:user_1) { FactoryBot.build_stubbed(:user) } let(:principal_loader) do loader = double('principal_loader') diff --git a/spec/models/queries/work_packages/filter/category_filter_spec.rb b/spec/models/queries/work_packages/filter/category_filter_spec.rb index 53ae9a317a..731cd84e82 100644 --- a/spec/models/queries/work_packages/filter/category_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/category_filter_spec.rb @@ -65,7 +65,7 @@ describe Queries::WorkPackages::Filter::CategoryFilter, type: :model do end describe '#allowed_values' do - let(:category) { FactoryGirl.build_stubbed(:category) } + let(:category) { FactoryBot.build_stubbed(:category) } before do allow(project) @@ -80,8 +80,8 @@ describe Queries::WorkPackages::Filter::CategoryFilter, type: :model do end describe '#value_objects' do - let(:category1) { FactoryGirl.build_stubbed(:category) } - let(:category2) { FactoryGirl.build_stubbed(:category) } + let(:category1) { FactoryBot.build_stubbed(:category) } + let(:category2) { FactoryBot.build_stubbed(:category) } before do allow(project) diff --git a/spec/models/queries/work_packages/filter/custom_field_filter_spec.rb b/spec/models/queries/work_packages/filter/custom_field_filter_spec.rb index 2d7acc2c8e..d17145f7b7 100644 --- a/spec/models/queries/work_packages/filter/custom_field_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/custom_field_filter_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::CustomFieldFilter, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } let(:cf_accessor) { "cf_#{custom_field.id}" } let(:instance) do described_class.create!(name: cf_accessor, operator: '=', context: query) @@ -38,15 +38,15 @@ describe Queries::WorkPackages::Filter::CustomFieldFilter, type: :model do let(:instance_key) { nil } let(:name) { field.name } - let(:list_wp_custom_field) { FactoryGirl.create(:list_wp_custom_field) } - let(:bool_wp_custom_field) { FactoryGirl.build_stubbed(:bool_wp_custom_field) } - let(:int_wp_custom_field) { FactoryGirl.build_stubbed(:int_wp_custom_field) } - let(:float_wp_custom_field) { FactoryGirl.build_stubbed(:float_wp_custom_field) } - let(:text_wp_custom_field) { FactoryGirl.build_stubbed(:text_wp_custom_field) } - let(:user_wp_custom_field) { FactoryGirl.build_stubbed(:user_wp_custom_field) } - let(:version_wp_custom_field) { FactoryGirl.build_stubbed(:version_wp_custom_field) } - let(:date_wp_custom_field) { FactoryGirl.build_stubbed(:date_wp_custom_field) } - let(:string_wp_custom_field) { FactoryGirl.build_stubbed(:string_wp_custom_field) } + let(:list_wp_custom_field) { FactoryBot.create(:list_wp_custom_field) } + let(:bool_wp_custom_field) { FactoryBot.build_stubbed(:bool_wp_custom_field) } + let(:int_wp_custom_field) { FactoryBot.build_stubbed(:int_wp_custom_field) } + let(:float_wp_custom_field) { FactoryBot.build_stubbed(:float_wp_custom_field) } + let(:text_wp_custom_field) { FactoryBot.build_stubbed(:text_wp_custom_field) } + let(:user_wp_custom_field) { FactoryBot.build_stubbed(:user_wp_custom_field) } + let(:version_wp_custom_field) { FactoryBot.build_stubbed(:version_wp_custom_field) } + let(:date_wp_custom_field) { FactoryBot.build_stubbed(:date_wp_custom_field) } + let(:string_wp_custom_field) { FactoryBot.build_stubbed(:string_wp_custom_field) } let(:custom_field) { list_wp_custom_field } let(:all_custom_fields) do @@ -499,8 +499,8 @@ describe Queries::WorkPackages::Filter::CustomFieldFilter, type: :model do end describe '#value_objects' do - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } before do allow(Principal) @@ -529,8 +529,8 @@ describe Queries::WorkPackages::Filter::CustomFieldFilter, type: :model do end describe '#value_objects' do - let(:version1) { FactoryGirl.build_stubbed(:version) } - let(:version2) { FactoryGirl.build_stubbed(:version) } + let(:version1) { FactoryBot.build_stubbed(:version) } + let(:version2) { FactoryBot.build_stubbed(:version) } before do allow(Version) diff --git a/spec/models/queries/work_packages/filter/group_filter_spec.rb b/spec/models/queries/work_packages/filter/group_filter_spec.rb index 174cc2ed3b..7570214c23 100644 --- a/spec/models/queries/work_packages/filter/group_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/group_filter_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::GroupFilter, type: :model do - let(:group) { FactoryGirl.build_stubbed(:group) } + let(:group) { FactoryBot.build_stubbed(:group) } it_behaves_like 'basic query filter' do let(:order) { 6 } @@ -76,7 +76,7 @@ describe Queries::WorkPackages::Filter::GroupFilter, type: :model do end describe '#value_objects' do - let(:group2) { FactoryGirl.build_stubbed(:group) } + let(:group2) { FactoryBot.build_stubbed(:group) } before do allow(Group) diff --git a/spec/models/queries/work_packages/filter/id_filter_spec.rb b/spec/models/queries/work_packages/filter/id_filter_spec.rb index 322c051082..38cc315556 100644 --- a/spec/models/queries/work_packages/filter/id_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/id_filter_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::IdFilter, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:query) do - FactoryGirl.build_stubbed(:query, project: project) + FactoryBot.build_stubbed(:query, project: project) end it_behaves_like 'basic query filter' do @@ -105,7 +105,7 @@ describe Queries::WorkPackages::Filter::IdFilter, type: :model do end describe '#value_object' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } it 'returns the work package for the values' do allow(WorkPackage) @@ -127,8 +127,8 @@ describe Queries::WorkPackages::Filter::IdFilter, type: :model do end describe '#valid_values!' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } - let(:invisible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } + let(:invisible_wp) { FactoryBot.build_stubbed(:work_package) } context 'within a project' do it 'removes all non existing/non visible ids' do @@ -171,8 +171,8 @@ describe Queries::WorkPackages::Filter::IdFilter, type: :model do end describe '#validate' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } - let(:invisible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } + let(:invisible_wp) { FactoryBot.build_stubbed(:work_package) } context 'within a project' do it 'is valid if only visible wps are values' do @@ -236,8 +236,8 @@ describe Queries::WorkPackages::Filter::IdFilter, type: :model do end describe '#where' do - let(:visible_wp) { FactoryGirl.create(:work_package) } - let(:other_wp) { FactoryGirl.create(:work_package) } + let(:visible_wp) { FactoryBot.create(:work_package) } + let(:other_wp) { FactoryBot.create(:work_package) } before do visible_wp diff --git a/spec/models/queries/work_packages/filter/parent_filter_spec.rb b/spec/models/queries/work_packages/filter/parent_filter_spec.rb index 425e4ef086..5ffc40a6e4 100644 --- a/spec/models/queries/work_packages/filter/parent_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/parent_filter_spec.rb @@ -31,9 +31,9 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::ParentFilter, type: :model do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:query) do - FactoryGirl.build_stubbed(:query, project: project) + FactoryBot.build_stubbed(:query, project: project) end it_behaves_like 'basic query filter' do @@ -105,7 +105,7 @@ describe Queries::WorkPackages::Filter::ParentFilter, type: :model do end describe '#value_object' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } it 'returns the work package for the values' do allow(WorkPackage) @@ -145,8 +145,8 @@ describe Queries::WorkPackages::Filter::ParentFilter, type: :model do end describe '#valid_values!' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } - let(:invisible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } + let(:invisible_wp) { FactoryBot.build_stubbed(:work_package) } context 'within a project' do it 'removes all non existing/non visible ids' do @@ -189,8 +189,8 @@ describe Queries::WorkPackages::Filter::ParentFilter, type: :model do end describe '#validate' do - let(:visible_wp) { FactoryGirl.build_stubbed(:work_package) } - let(:invisible_wp) { FactoryGirl.build_stubbed(:work_package) } + let(:visible_wp) { FactoryBot.build_stubbed(:work_package) } + let(:invisible_wp) { FactoryBot.build_stubbed(:work_package) } context 'within a project' do it 'is valid if only visible wps are values' do @@ -254,8 +254,8 @@ describe Queries::WorkPackages::Filter::ParentFilter, type: :model do end describe '#where and #includes' do - let(:parent) { FactoryGirl.create(:work_package) } - let(:visible_wp) { FactoryGirl.create(:work_package, parent: parent) } + let(:parent) { FactoryBot.create(:work_package) } + let(:visible_wp) { FactoryBot.create(:work_package, parent: parent) } before do visible_wp diff --git a/spec/models/queries/work_packages/filter/principal_loader_spec.rb b/spec/models/queries/work_packages/filter/principal_loader_spec.rb index f81177e34c..45b815a6b7 100644 --- a/spec/models/queries/work_packages/filter/principal_loader_spec.rb +++ b/spec/models/queries/work_packages/filter/principal_loader_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::PrincipalLoader, type: :model do - let(:user_1) { FactoryGirl.build_stubbed(:user) } - let(:group_1) { FactoryGirl.build_stubbed(:group) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:user_1) { FactoryBot.build_stubbed(:user) } + let(:group_1) { FactoryBot.build_stubbed(:group) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:instance) { described_class.new(project) } context 'with a project' do @@ -72,7 +72,7 @@ describe Queries::WorkPackages::Filter::PrincipalLoader, type: :model do context 'without a project' do let(:project) { nil } - let(:visible_projects) { [FactoryGirl.build_stubbed(:project)] } + let(:visible_projects) { [FactoryBot.build_stubbed(:project)] } let(:matching_principals) { [user_1, group_1] } before do diff --git a/spec/models/queries/work_packages/filter/priority_filter_spec.rb b/spec/models/queries/work_packages/filter/priority_filter_spec.rb index 6fda60ac5f..b6da825441 100644 --- a/spec/models/queries/work_packages/filter/priority_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/priority_filter_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::PriorityFilter, type: :model do - let(:priority) { FactoryGirl.build_stubbed(:priority) } + let(:priority) { FactoryBot.build_stubbed(:priority) } it_behaves_like 'basic query filter' do let(:order) { 3 } @@ -75,7 +75,7 @@ describe Queries::WorkPackages::Filter::PriorityFilter, type: :model do end describe '#value_objects' do - let(:priority2) { FactoryGirl.build_stubbed(:priority) } + let(:priority2) { FactoryBot.build_stubbed(:priority) } before do allow(IssuePriority) diff --git a/spec/models/queries/work_packages/filter/project_filter_spec.rb b/spec/models/queries/work_packages/filter/project_filter_spec.rb index 4b81fc75a8..f3bb66ca0a 100644 --- a/spec/models/queries/work_packages/filter/project_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/project_filter_spec.rb @@ -66,8 +66,8 @@ describe Queries::WorkPackages::Filter::ProjectFilter, type: :model do let(:project) { nil } it 'is an array of group values' do - parent = FactoryGirl.build_stubbed(:project, id: 1) - child = FactoryGirl.build_stubbed(:project, parent: parent, id: 2) + parent = FactoryBot.build_stubbed(:project, id: 1) + child = FactoryBot.build_stubbed(:project, parent: parent, id: 2) visible_projects = [parent, child] @@ -95,8 +95,8 @@ describe Queries::WorkPackages::Filter::ProjectFilter, type: :model do end describe '#value_objects' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:project2) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:project2) { FactoryBot.build_stubbed(:project) } before do allow(Project) diff --git a/spec/models/queries/work_packages/filter/responsible_filter_spec.rb b/spec/models/queries/work_packages/filter/responsible_filter_spec.rb index 1474b1407f..32d9e8bb93 100644 --- a/spec/models/queries/work_packages/filter/responsible_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/responsible_filter_spec.rb @@ -34,7 +34,7 @@ describe Queries::WorkPackages::Filter::ResponsibleFilter, type: :model do let(:type) { :list_optional } let(:class_key) { :responsible_id } - let(:user_1) { FactoryGirl.build_stubbed(:user) } + let(:user_1) { FactoryBot.build_stubbed(:user) } let(:principal_loader) do loader = double('principal_loader') @@ -141,8 +141,8 @@ describe Queries::WorkPackages::Filter::ResponsibleFilter, type: :model do end describe '#value_objects' do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } before do allow(Principal) diff --git a/spec/models/queries/work_packages/filter/role_filter_spec.rb b/spec/models/queries/work_packages/filter/role_filter_spec.rb index 68979b0f98..0d6e460ad9 100644 --- a/spec/models/queries/work_packages/filter/role_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/role_filter_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::RoleFilter, type: :model do - let(:role) { FactoryGirl.build_stubbed(:role) } + let(:role) { FactoryBot.build_stubbed(:role) } it_behaves_like 'basic query filter' do let(:order) { 7 } @@ -76,7 +76,7 @@ describe Queries::WorkPackages::Filter::RoleFilter, type: :model do end describe '#value_objects' do - let(:role2) { FactoryGirl.build_stubbed(:role) } + let(:role2) { FactoryBot.build_stubbed(:role) } before do allow(Role) diff --git a/spec/models/queries/work_packages/filter/status_filter_spec.rb b/spec/models/queries/work_packages/filter/status_filter_spec.rb index 6c039f88f0..d7f4e57cbe 100644 --- a/spec/models/queries/work_packages/filter/status_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/status_filter_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::StatusFilter, type: :model do - let(:status) { FactoryGirl.build_stubbed(:status) } - let(:status2) { FactoryGirl.build_stubbed(:status) } + let(:status) { FactoryBot.build_stubbed(:status) } + let(:status2) { FactoryBot.build_stubbed(:status) } it_behaves_like 'basic query filter' do let(:order) { 1 } diff --git a/spec/models/queries/work_packages/filter/subproject_filter_spec.rb b/spec/models/queries/work_packages/filter/subproject_filter_spec.rb index 0997bd49ef..581c7aa3dd 100644 --- a/spec/models/queries/work_packages/filter/subproject_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/subproject_filter_spec.rb @@ -90,8 +90,8 @@ describe Queries::WorkPackages::Filter::SubprojectFilter, type: :model do end describe '#allowed_values' do - let(:subproject1) { FactoryGirl.build_stubbed(:project) } - let(:subproject2) { FactoryGirl.build_stubbed(:project) } + let(:subproject1) { FactoryBot.build_stubbed(:project) } + let(:subproject2) { FactoryBot.build_stubbed(:project) } before do allow(project) @@ -113,8 +113,8 @@ describe Queries::WorkPackages::Filter::SubprojectFilter, type: :model do end describe '#value_objects' do - let(:subproject1) { FactoryGirl.build_stubbed(:project) } - let(:subproject2) { FactoryGirl.build_stubbed(:project) } + let(:subproject1) { FactoryBot.build_stubbed(:project) } + let(:subproject2) { FactoryBot.build_stubbed(:project) } before do allow(project) diff --git a/spec/models/queries/work_packages/filter/type_filter_spec.rb b/spec/models/queries/work_packages/filter/type_filter_spec.rb index 7217a5bde5..f96931c314 100644 --- a/spec/models/queries/work_packages/filter/type_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/type_filter_spec.rb @@ -79,7 +79,7 @@ describe Queries::WorkPackages::Filter::TypeFilter, type: :model do end describe '#allowed_values' do - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:type) { FactoryBot.build_stubbed(:type) } context 'within a project' do before do allow(project) @@ -117,8 +117,8 @@ describe Queries::WorkPackages::Filter::TypeFilter, type: :model do end describe '#value_objects' do - let(:type1) { FactoryGirl.build_stubbed(:type) } - let(:type2) { FactoryGirl.build_stubbed(:type) } + let(:type1) { FactoryBot.build_stubbed(:type) } + let(:type2) { FactoryBot.build_stubbed(:type) } before do allow(project) diff --git a/spec/models/queries/work_packages/filter/version_filter_spec.rb b/spec/models/queries/work_packages/filter/version_filter_spec.rb index 393ff3bf35..5dfa21952f 100644 --- a/spec/models/queries/work_packages/filter/version_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/version_filter_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::VersionFilter, type: :model do - let(:version) { FactoryGirl.build_stubbed(:version) } + let(:version) { FactoryBot.build_stubbed(:version) } it_behaves_like 'basic query filter' do let(:order) { 7 } @@ -108,8 +108,8 @@ describe Queries::WorkPackages::Filter::VersionFilter, type: :model do end describe '#value_objects' do - let(:version1) { FactoryGirl.build_stubbed(:version) } - let(:version2) { FactoryGirl.build_stubbed(:version) } + let(:version1) { FactoryBot.build_stubbed(:version) } + let(:version2) { FactoryBot.build_stubbed(:version) } before do allow(project) diff --git a/spec/models/queries/work_packages/filter/watcher_filter_spec.rb b/spec/models/queries/work_packages/filter/watcher_filter_spec.rb index 872b819a42..ef0b359c4a 100644 --- a/spec/models/queries/work_packages/filter/watcher_filter_spec.rb +++ b/spec/models/queries/work_packages/filter/watcher_filter_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Queries::WorkPackages::Filter::WatcherFilter, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } it_behaves_like 'basic query filter' do let(:order) { 15 } @@ -151,7 +151,7 @@ describe Queries::WorkPackages::Filter::WatcherFilter, type: :model do end describe '#value_objects' do - let(:user1) { FactoryGirl.build_stubbed(:user) } + let(:user1) { FactoryBot.build_stubbed(:user) } before do allow(Principal) diff --git a/spec/models/query/results_spec.rb b/spec/models/query/results_spec.rb index 1e5e8acdb3..d3351b3cf6 100644 --- a/spec/models/query/results_spec.rb +++ b/spec/models/query/results_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe ::Query::Results, type: :model do let(:query) do - FactoryGirl.build :query, + FactoryBot.build :query, show_hierarchies: false end let(:query_results) do @@ -44,9 +44,9 @@ describe ::Query::Results, type: :model do ), order: 'work_packages.root_id DESC, work_packages.lft ASC' end - let(:project_1) { FactoryGirl.create :project } + let(:project_1) { FactoryBot.create :project } let(:role_pm) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: %i( view_work_packages edit_work_packages @@ -55,11 +55,11 @@ describe ::Query::Results, type: :model do )) end let(:role_dev) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_work_packages]) end let(:user_1) do - FactoryGirl.create(:user, + FactoryBot.create(:user, firstname: 'user', lastname: '1', member_in_project: project_1, @@ -67,7 +67,7 @@ describe ::Query::Results, type: :model do end let(:wp_p1) do (1..3).map do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_1, assigned_to_id: user_1.id) end @@ -75,7 +75,7 @@ describe ::Query::Results, type: :model do describe '#work_package_count_by_group' do let(:query) do - FactoryGirl.build :query, + FactoryBot.build :query, show_hierarchies: false, group_by: group_by end @@ -90,16 +90,16 @@ describe ::Query::Results, type: :model do end describe '#work_packages' do - let!(:project_1) { FactoryGirl.create :project } - let!(:project_2) { FactoryGirl.create :project } + let!(:project_1) { FactoryBot.create :project } + let!(:project_2) { FactoryBot.create :project } let!(:member) do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project_2, principal: user_1, roles: [role_pm]) end let!(:user_2) do - FactoryGirl.create(:user, + FactoryBot.create(:user, firstname: 'user', lastname: '2', member_in_project: project_2, @@ -107,12 +107,12 @@ describe ::Query::Results, type: :model do end let!(:wp_p2) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_2, assigned_to_id: user_2.id) end let!(:wp2_p2) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_2, assigned_to_id: user_1.id) end @@ -130,7 +130,7 @@ describe ::Query::Results, type: :model do end context 'when a project is set' do - let(:query) { FactoryGirl.build :query, project: project_2 } + let(:query) { FactoryBot.build :query, project: project_2 } it 'should display only wp for selected project and selected role' do expect(query_results.work_packages).to match_array([wp_p2]) @@ -138,7 +138,7 @@ describe ::Query::Results, type: :model do end context 'when no project is set' do - let(:query) { FactoryGirl.build :query, project: nil } + let(:query) { FactoryBot.build :query, project: nil } it 'should display all wp from projects where User.current has access' do expect(query_results.work_packages).to match_array([wp_p2, wp2_p2]) @@ -151,13 +151,13 @@ describe ::Query::Results, type: :model do context 'with a custom field being returned and paginating' do let(:group_by) { nil } let(:query) do - FactoryGirl.build_stubbed :query, + FactoryBot.build_stubbed :query, show_hierarchies: false, group_by: group_by, project: project_2 end - let!(:custom_field) { FactoryGirl.create(:work_package_custom_field, is_for_all: true) } + let!(:custom_field) { FactoryBot.create(:work_package_custom_field, is_for_all: true) } before do allow(User).to receive(:current).and_return(user_2) @@ -205,7 +205,7 @@ describe ::Query::Results, type: :model do context 'when grouping by responsible' do let(:query) do - FactoryGirl.build :query, + FactoryBot.build :query, show_hierarchies: false, group_by: group_by, project: project_1 @@ -227,15 +227,15 @@ describe ::Query::Results, type: :model do end describe '#sorted_work_packages' do - let(:work_package1) { FactoryGirl.create(:work_package, project: project_1) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project_1) } - let(:work_package3) { FactoryGirl.create(:work_package, project: project_1) } + let(:work_package1) { FactoryBot.create(:work_package, project: project_1) } + let(:work_package2) { FactoryBot.create(:work_package, project: project_1) } + let(:work_package3) { FactoryBot.create(:work_package, project: project_1) } let(:sort_by) { [['parent', 'asc']] } let(:columns) { %i(id subject) } let(:group_by) { '' } let(:query) do - FactoryGirl.build_stubbed :query, + FactoryBot.build_stubbed :query, show_hierarchies: false, group_by: group_by, sort_criteria: sort_by, @@ -247,9 +247,9 @@ describe ::Query::Results, type: :model do ::Query::Results.new query end - let(:user_a) { FactoryGirl.create(:user, firstname: 'AAA', lastname: 'AAA') } - let(:user_m) { FactoryGirl.create(:user, firstname: 'MMM', lastname: 'MMM') } - let(:user_z) { FactoryGirl.create(:user, firstname: 'ZZZ', lastname: 'ZZZ') } + let(:user_a) { FactoryBot.create(:user, firstname: 'AAA', lastname: 'AAA') } + let(:user_m) { FactoryBot.create(:user, firstname: 'MMM', lastname: 'MMM') } + let(:user_z) { FactoryBot.create(:user, firstname: 'ZZZ', lastname: 'ZZZ') } context 'grouping by assigned_to, having the author column selected' do let(:group_by) { 'assigned_to' } @@ -387,15 +387,15 @@ describe ::Query::Results, type: :model do end context 'sorting by parent' do - let(:work_package1) { FactoryGirl.create(:work_package, project: project_1, subject: '1') } - let(:work_package2) { FactoryGirl.create(:work_package, project: project_1, parent: work_package1, subject: '2') } - let(:work_package3) { FactoryGirl.create(:work_package, project: project_1, parent: work_package2, subject: '3') } - let(:work_package4) { FactoryGirl.create(:work_package, project: project_1, parent: work_package1, subject: '4') } - let(:work_package5) { FactoryGirl.create(:work_package, project: project_1, parent: work_package4, subject: '5') } - let(:work_package6) { FactoryGirl.create(:work_package, project: project_1, parent: work_package4, subject: '6') } - let(:work_package7) { FactoryGirl.create(:work_package, project: project_1, subject: '7') } - let(:work_package8) { FactoryGirl.create(:work_package, project: project_1, subject: '8') } - let(:work_package9) { FactoryGirl.create(:work_package, project: project_1, parent: work_package8, subject: '9') } + let(:work_package1) { FactoryBot.create(:work_package, project: project_1, subject: '1') } + let(:work_package2) { FactoryBot.create(:work_package, project: project_1, parent: work_package1, subject: '2') } + let(:work_package3) { FactoryBot.create(:work_package, project: project_1, parent: work_package2, subject: '3') } + let(:work_package4) { FactoryBot.create(:work_package, project: project_1, parent: work_package1, subject: '4') } + let(:work_package5) { FactoryBot.create(:work_package, project: project_1, parent: work_package4, subject: '5') } + let(:work_package6) { FactoryBot.create(:work_package, project: project_1, parent: work_package4, subject: '6') } + let(:work_package7) { FactoryBot.create(:work_package, project: project_1, subject: '7') } + let(:work_package8) { FactoryBot.create(:work_package, project: project_1, subject: '8') } + let(:work_package9) { FactoryBot.create(:work_package, project: project_1, parent: work_package8, subject: '9') } let(:work_packages) do [work_package1, work_package2, work_package3, work_package4, work_package5, work_package6, work_package7, work_package8, work_package9] @@ -431,9 +431,9 @@ describe ::Query::Results, type: :model do end context 'filtering by bool cf' do - let(:bool_cf) { FactoryGirl.create(:bool_wp_custom_field, is_filter: true) } + let(:bool_cf) { FactoryBot.create(:bool_wp_custom_field, is_filter: true) } let(:custom_value) do - FactoryGirl.create(:custom_value, + FactoryBot.create(:custom_value, custom_field: bool_cf, customized: work_package1, value: value) @@ -553,7 +553,7 @@ describe ::Query::Results, type: :model do let(:custom_value) { nil } let(:filter_value) { 'f' } let(:bool_cf) do - FactoryGirl.create(:bool_wp_custom_field, + FactoryBot.create(:bool_wp_custom_field, is_filter: true, is_for_all: true) end @@ -580,7 +580,7 @@ describe ::Query::Results, type: :model do # dependent on columns in GROUP BY clause" context 'when grouping by custom field' do let!(:custom_field) do - FactoryGirl.create(:int_wp_custom_field, is_for_all: true, is_filter: true) + FactoryBot.create(:int_wp_custom_field, is_for_all: true, is_filter: true) end before do diff --git a/spec/models/query_spec.rb b/spec/models/query_spec.rb index a1b82066dd..0df025cf5e 100644 --- a/spec/models/query_spec.rb +++ b/spec/models/query_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Query, type: :model do - let(:query) { FactoryGirl.build(:query) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:query) { FactoryBot.build(:query) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:relation_columns_allowed) { true } before do @@ -113,7 +113,7 @@ describe Query, type: :model do end context 'results caching' do - let(:project2) { FactoryGirl.build_stubbed(:project) } + let(:project2) { FactoryBot.build_stubbed(:project) } it 'does not call the db twice' do query.project = project @@ -168,14 +168,14 @@ describe Query, type: :model do context 'relation_to_type columns' do let(:type_in_project) do - type = FactoryGirl.create(:type) + type = FactoryBot.create(:type) project.types << type type end let(:type_not_in_project) do - FactoryGirl.create(:type) + FactoryBot.create(:type) end before do @@ -250,8 +250,8 @@ describe Query, type: :model do end describe '.available_columns' do - let(:custom_field) { FactoryGirl.create(:list_wp_custom_field) } - let(:type) { FactoryGirl.create(:type) } + let(:custom_field) { FactoryBot.create(:list_wp_custom_field) } + let(:type) { FactoryBot.create(:type) } before do stub_const('Relation::TYPES', @@ -313,8 +313,8 @@ describe Query, type: :model do end context 'when filters are blank' do - let(:status) { FactoryGirl.create :status } - let(:query) { FactoryGirl.build(:query).tap { |q| q.filters = [] } } + let(:status) { FactoryBot.create :status } + let(:query) { FactoryBot.build(:query).tap { |q| q.filters = [] } } it 'is valid' do expect(query.valid?).to be_truthy @@ -323,7 +323,7 @@ describe Query, type: :model do context 'with a missing value for a custom field' do let(:custom_field) do - FactoryGirl.create :text_issue_custom_field, is_filter: true, is_for_all: true + FactoryBot.create :text_issue_custom_field, is_filter: true, is_for_all: true end before do @@ -348,7 +348,7 @@ describe Query, type: :model do end describe '#valid_subset!' do - let(:valid_status) { FactoryGirl.build_stubbed(:status) } + let(:valid_status) { FactoryBot.build_stubbed(:status) } context 'filters' do before do diff --git a/spec/models/relation/hierarchy_paths_spec.rb b/spec/models/relation/hierarchy_paths_spec.rb index 32411c64d2..a42559a73c 100644 --- a/spec/models/relation/hierarchy_paths_spec.rb +++ b/spec/models/relation/hierarchy_paths_spec.rb @@ -30,15 +30,15 @@ require 'spec_helper' describe Relation, 'hierarchy_paths', type: :model do - let(:parent) { FactoryGirl.create(:work_package) } - let(:child) { FactoryGirl.create(:work_package) } + let(:parent) { FactoryBot.create(:work_package) } + let(:child) { FactoryBot.create(:work_package) } let(:grand_parent) do - wp = FactoryGirl.create(:work_package) + wp = FactoryBot.create(:work_package) parent.parent = wp parent.save! wp end - let(:grand_child) { FactoryGirl.create(:work_package, parent: child) } + let(:grand_child) { FactoryBot.create(:work_package, parent: child) } def record_for(id) ActiveRecord::Base.connection.select_rows <<-SQL @@ -164,7 +164,7 @@ describe Relation, 'hierarchy_paths', type: :model do context 'on update' do let(:parent_child_relation) { Relation.create relation_type: 'hierarchy', from: parent, to: child } let(:follows_relation) { Relation.create relation_type: 'follows', from: parent, to: child } - let(:other_wp) { FactoryGirl.create :work_package } + let(:other_wp) { FactoryBot.create :work_package } context 'on switching the type to non hierarchy' do before do diff --git a/spec/models/relation_spec.rb b/spec/models/relation_spec.rb index c353912d88..f1362f3e4f 100644 --- a/spec/models/relation_spec.rb +++ b/spec/models/relation_spec.rb @@ -30,10 +30,10 @@ require 'spec_helper' describe Relation, type: :model do - let(:from) { FactoryGirl.create(:work_package) } - let(:to) { FactoryGirl.create(:work_package) } + let(:from) { FactoryBot.create(:work_package) } + let(:to) { FactoryBot.create(:work_package) } let(:type) { 'relates' } - let(:relation) { FactoryGirl.build(:relation, from: from, to: to, relation_type: type) } + let(:relation) { FactoryBot.build(:relation, from: from, to: to, relation_type: type) } describe 'all relation types' do Relation::TYPES.each do |key, type_hash| @@ -66,7 +66,7 @@ describe Relation, type: :model do let(:type) { key } let(:reversed) { type_hash[:reverse] } let(:relation) do - FactoryGirl.build_stubbed(:relation, + FactoryBot.build_stubbed(:relation, relation_type: nil, column_name => column_count) end @@ -105,7 +105,7 @@ describe Relation, type: :model do end end let(:relation) do - FactoryGirl.build_stubbed(:relation, + FactoryBot.build_stubbed(:relation, relation_type: nil, column_name => 1, other_column => 1) @@ -123,7 +123,7 @@ describe Relation, type: :model do let(:column_name) { 'relates' } let(:type) { :relates } let(:relation) do - FactoryGirl.build(:relation, + FactoryBot.build(:relation, relation_type: 'relates') end @@ -179,17 +179,17 @@ describe Relation, type: :model do end describe '.visible' do - let(:user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member_project_to) do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: to.project, user: user, roles: [role]) end let(:member_project_from) do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: from.project, user: user, roles: [role]) @@ -235,20 +235,20 @@ describe Relation, type: :model do end describe 'it should validate circular dependency' do - let(:otherwp) { FactoryGirl.create(:work_package) } + let(:otherwp) { FactoryBot.create(:work_package) } let(:relation) do - FactoryGirl.build(:relation, from: from, to: to, relation_type: Relation::TYPE_PRECEDES) + FactoryBot.build(:relation, from: from, to: to, relation_type: Relation::TYPE_PRECEDES) end let(:relation2) do - FactoryGirl.build(:relation, from: to, to: otherwp, relation_type: Relation::TYPE_PRECEDES) + FactoryBot.build(:relation, from: to, to: otherwp, relation_type: Relation::TYPE_PRECEDES) end let(:invalid_precedes_relation) do - FactoryGirl.build(:relation, from: otherwp, to: from, relation_type: Relation::TYPE_PRECEDES) + FactoryBot.build(:relation, from: otherwp, to: from, relation_type: Relation::TYPE_PRECEDES) end let(:invalid_follows_relation) do - FactoryGirl.build(:relation, from: from, to: otherwp, relation_type: Relation::TYPE_FOLLOWS) + FactoryBot.build(:relation, from: from, to: otherwp, relation_type: Relation::TYPE_FOLLOWS) end it 'prevents invalid precedes relations' do diff --git a/spec/models/reports_services_spec.rb b/spec/models/reports_services_spec.rb index 32da5e36d7..402b96fc53 100644 --- a/spec/models/reports_services_spec.rb +++ b/spec/models/reports_services_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Reports::ReportsService, type: :model do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } it 'should be initializable with a project' do expect { Reports::ReportsService.new(project) }.not_to raise_error diff --git a/spec/models/repository/git_spec.rb b/spec/models/repository/git_spec.rb index 053f6e7071..6ca524ba13 100644 --- a/spec/models/repository/git_spec.rb +++ b/spec/models/repository/git_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe Repository::Git, type: :model do let(:encoding) { 'UTF-8' } - let(:instance) { FactoryGirl.build(:repository_git, path_encoding: encoding) } + let(:instance) { FactoryBot.build(:repository_git, path_encoding: encoding) } let(:adapter) { instance.scm } let(:config) { {} } let(:enabled_scm) { %w[git] } @@ -79,7 +79,7 @@ describe Repository::Git, type: :model do context 'with managed config' do let(:config) { { manages: managed_path } } - let(:project) { FactoryGirl.build :project } + let(:project) { FactoryBot.build :project } let(:identifier) { project.identifier + '.git' } it 'is manageable' do @@ -126,8 +126,8 @@ describe Repository::Git, type: :model do end context 'and associated project with parent' do - let(:parent) { FactoryGirl.build :project } - let(:project) { FactoryGirl.build :project, parent: parent } + let(:parent) { FactoryBot.build :project } + let(:project) { FactoryBot.build :project, parent: parent } before do instance.project = project @@ -142,7 +142,7 @@ describe Repository::Git, type: :model do end describe 'URL validation' do - let(:instance) { FactoryGirl.build(:repository_git, url: url) } + let(:instance) { FactoryBot.build(:repository_git, url: url) } shared_examples 'repository url is valid' do it 'is valid' do @@ -179,7 +179,7 @@ describe Repository::Git, type: :model do with_git_repository do |repo_dir| let(:url) { repo_dir } let(:instance) { - FactoryGirl.create(:repository_git, + FactoryBot.create(:repository_git, path_encoding: encoding, url: url, root_url: url) @@ -405,8 +405,8 @@ describe Repository::Git, type: :model do end context 'with an admin browsing activity' do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } def find_events(user, options = {}) fetcher = Redmine::Activity::Fetcher.new(user, options) diff --git a/spec/models/repository/subversion_spec.rb b/spec/models/repository/subversion_spec.rb index 0e613788d5..6e3b268076 100644 --- a/spec/models/repository/subversion_spec.rb +++ b/spec/models/repository/subversion_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Repository::Subversion, type: :model do - let(:instance) { FactoryGirl.build(:repository_subversion) } + let(:instance) { FactoryBot.build(:repository_subversion) } let(:adapter) { instance.scm } let(:config) { {} } let(:enabled_scm) { %w[subversion] } @@ -98,7 +98,7 @@ describe Repository::Subversion, type: :model do context 'with managed config' do let(:config) { { manages: managed_path } } - let(:project) { FactoryGirl.build :project } + let(:project) { FactoryBot.build :project } it 'is manageable' do expect(instance.manageable?).to be true @@ -127,8 +127,8 @@ describe Repository::Subversion, type: :model do end context 'and associated project with parent' do - let(:parent) { FactoryGirl.build :project } - let(:project) { FactoryGirl.build :project, parent: parent } + let(:parent) { FactoryBot.build :project } + let(:project) { FactoryBot.build :project, parent: parent } before do instance.project = project @@ -144,7 +144,7 @@ describe Repository::Subversion, type: :model do describe 'with a remote repository' do let(:instance) { - FactoryGirl.build(:repository_subversion, + FactoryBot.build(:repository_subversion, url: 'https://somewhere.example.org/svn/foo' ) } @@ -157,7 +157,7 @@ describe Repository::Subversion, type: :model do describe 'with an actual repository' do with_subversion_repository do |repo_dir| let(:url) { "file://#{repo_dir}" } - let(:instance) { FactoryGirl.create(:repository_subversion, url: url, root_url: url) } + let(:instance) { FactoryBot.create(:repository_subversion, url: url, root_url: url) } it 'should be available' do expect(instance.scm).to be_available @@ -301,8 +301,8 @@ describe Repository::Subversion, type: :model do end context 'with an admin browsing activity' do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.create(:project) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.create(:project) } def find_events(user, options = {}) fetcher = Redmine::Activity::Fetcher.new(user, options) diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index a83307cf5d..62d80d0540 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe Role, type: :model do let(:permissions) { [:permission1, :permission2] } - let(:build_role) { FactoryGirl.build(:role, permissions: permissions) } - let(:created_role) { FactoryGirl.create(:role, permissions: permissions) } + let(:build_role) { FactoryBot.build(:role, permissions: permissions) } + let(:created_role) { FactoryBot.create(:role, permissions: permissions) } describe '#by_permission' do it 'returns roles with given permission' do diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index a0128aeb76..4c87ce48c2 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -29,15 +29,15 @@ require 'spec_helper' describe Status, type: :model do - let(:stubbed_status) { FactoryGirl.build_stubbed(:status) } + let(:stubbed_status) { FactoryBot.build_stubbed(:status) } describe '.new_statuses_allowed' do - let(:role) { FactoryGirl.create(:role) } - let(:type) { FactoryGirl.create(:type) } - let(:statuses) { (1..4).map { |_i| FactoryGirl.create(:status) } } + let(:role) { FactoryBot.create(:role) } + let(:type) { FactoryBot.create(:type) } + let(:statuses) { (1..4).map { |_i| FactoryBot.create(:status) } } let(:status) { statuses[0] } let(:workflow_a) do - FactoryGirl.create(:workflow, role_id: role.id, + FactoryBot.create(:workflow, role_id: role.id, type_id: type.id, old_status_id: statuses[0].id, new_status_id: statuses[1].id, @@ -45,7 +45,7 @@ describe Status, type: :model do assignee: false) end let(:workflow_b) do - FactoryGirl.create(:workflow, role_id: role.id, + FactoryBot.create(:workflow, role_id: role.id, type_id: type.id, old_status_id: statuses[0].id, new_status_id: statuses[2].id, @@ -53,7 +53,7 @@ describe Status, type: :model do assignee: false) end let(:workflow_c) do - FactoryGirl.create(:workflow, role_id: role.id, + FactoryBot.create(:workflow, role_id: role.id, type_id: type.id, old_status_id: statuses[0].id, new_status_id: statuses[3].id, diff --git a/spec/models/system_user_spec.rb b/spec/models/system_user_spec.rb index 33ff91e822..56fb770cbc 100644 --- a/spec/models/system_user_spec.rb +++ b/spec/models/system_user_spec.rb @@ -65,17 +65,17 @@ describe SystemUser, type: :model do end describe '#run_given' do - let(:project) { FactoryGirl.create(:project_with_types, is_public: false) } - let(:user) { FactoryGirl.build(:user) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project_with_types, is_public: false) } + let(:user) { FactoryBot.build(:user) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } - let(:status) { FactoryGirl.create(:status) } + let(:status) { FactoryBot.create(:status) } let(:issue) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, author: user, project: project, status: status) diff --git a/spec/models/time_entry_spec.rb b/spec/models/time_entry_spec.rb index 489f4f5448..2eb4fb1305 100644 --- a/spec/models/time_entry_spec.rb +++ b/spec/models/time_entry_spec.rb @@ -32,11 +32,11 @@ require 'spec_helper' describe TimeEntry, type: :model do let(:activity) do - FactoryGirl.build(:time_entry_activity) + FactoryBot.build(:time_entry_activity) end describe '#activated_projects' do - let(:project1) { FactoryGirl.create(:project) } + let(:project1) { FactoryBot.create(:project) } context 'project specific activity' do before do @@ -64,16 +64,16 @@ describe TimeEntry, type: :model do end context 'system activity' do - let(:project2) { FactoryGirl.create(:project) } - let(:project3) { FactoryGirl.create(:project) } + let(:project2) { FactoryBot.create(:project) } + let(:project3) { FactoryBot.create(:project) } let(:child_activity_active) do - FactoryGirl.create(:time_entry_activity, + FactoryBot.create(:time_entry_activity, parent: activity, project: project1) end let(:child_activity_inactive) do - FactoryGirl.create(:time_entry_activity, + FactoryBot.create(:time_entry_activity, parent: activity, project: project2, active: false) diff --git a/spec/models/token/base_token_spec.rb b/spec/models/token/base_token_spec.rb index fea67b444c..20acf58a2b 100644 --- a/spec/models/token/base_token_spec.rb +++ b/spec/models/token/base_token_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::Token::Base, type: :model do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } subject { described_class.new user: user } diff --git a/spec/models/token/hashed_token_spec.rb b/spec/models/token/hashed_token_spec.rb index 2459587da6..61446b23e4 100644 --- a/spec/models/token/hashed_token_spec.rb +++ b/spec/models/token/hashed_token_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe ::Token::HashedToken, type: :model do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } subject { described_class.new user: user } diff --git a/spec/models/type/attribute_groups_spec.rb b/spec/models/type/attribute_groups_spec.rb index 82cf312dcf..8c11b9e794 100644 --- a/spec/models/type/attribute_groups_spec.rb +++ b/spec/models/type/attribute_groups_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::Type, type: :model do - let(:type) { FactoryGirl.build(:type) } - let(:admin) { FactoryGirl.create(:admin) } + let(:type) { FactoryBot.build(:type) } + let(:admin) { FactoryBot.create(:admin) } before do # Clear up the request store cache for all_work_package_attributes @@ -91,8 +91,8 @@ describe ::Type, type: :model do end context 'with a query group' do - let(:type) { FactoryGirl.create(:type) } - let(:query) { FactoryGirl.build(:global_query, user_id: 0) } + let(:type) { FactoryBot.create(:type) } + let(:query) { FactoryBot.build(:global_query, user_id: 0) } before do login_as(admin) @@ -111,7 +111,7 @@ describe ::Type, type: :model do end it 'removes the former query if a new one is assigned' do - new_query = FactoryGirl.build(:global_query, user_id: 0) + new_query = FactoryBot.build(:global_query, user_id: 0) type.attribute_groups[0].attributes = new_query type.save! type.reload @@ -189,7 +189,7 @@ describe ::Type, type: :model do end context 'with an invalid query' do - let(:query) { FactoryGirl.build(:global_query, name: '') } + let(:query) { FactoryBot.build(:global_query, name: '') } before do type.attribute_groups = [['some name', [query]]] @@ -203,7 +203,7 @@ describe ::Type, type: :model do describe 'custom fields' do let!(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string' ) @@ -225,13 +225,13 @@ describe ::Type, type: :model do describe 'custom field added implicitly to type' do let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'string', is_for_all: true ) end - let!(:type) { FactoryGirl.create(:type, custom_fields: [custom_field]) } + let!(:type) { FactoryBot.create(:type, custom_fields: [custom_field]) } it 'has the custom field in the default group' do OpenProject::Cache.clear @@ -253,7 +253,7 @@ describe ::Type, type: :model do end describe '#destroy' do - let(:query) { FactoryGirl.build(:global_query, user_id: 0) } + let(:query) { FactoryBot.build(:global_query, user_id: 0) } before do login_as(admin) diff --git a/spec/models/type_spec.rb b/spec/models/type_spec.rb index eecabf3693..4176531755 100644 --- a/spec/models/type_spec.rb +++ b/spec/models/type_spec.rb @@ -30,9 +30,9 @@ require 'spec_helper' describe ::Type, type: :model do - let(:type) { FactoryGirl.build(:type) } - let(:type2) { FactoryGirl.build(:type) } - let(:project) { FactoryGirl.build(:project) } + let(:type) { FactoryBot.build(:type) } + let(:type2) { FactoryBot.build(:type) } + let(:project) { FactoryBot.build(:project) } describe '.enabled_in(project)' do before do diff --git a/spec/models/user_deletion_spec.rb b/spec/models/user_deletion_spec.rb index 2be46dc767..4ecfcc3b69 100644 --- a/spec/models/user_deletion_spec.rb +++ b/spec/models/user_deletion_spec.rb @@ -29,21 +29,21 @@ require 'spec_helper' describe User, 'deletion', type: :model do - let(:project) { FactoryGirl.create(:project_with_types) } - let(:user) { FactoryGirl.build(:user, member_in_project: project) } - let(:user2) { FactoryGirl.build(:user) } + let(:project) { FactoryBot.create(:project_with_types) } + let(:user) { FactoryBot.build(:user, member_in_project: project) } + let(:user2) { FactoryBot.build(:user) } let(:member) { project.members.first } let(:role) { member.roles.first } - let(:status) { FactoryGirl.create(:status) } + let(:status) { FactoryBot.create(:status) } let(:issue) { - FactoryGirl.create(:work_package, type: project.types.first, + FactoryBot.create(:work_package, type: project.types.first, author: user, project: project, status: status, assigned_to: user) } let(:issue2) { - FactoryGirl.create(:work_package, type: project.types.first, + FactoryBot.create(:work_package, type: project.types.first, author: user2, project: project, status: status, @@ -170,7 +170,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created one attachment' do - let(:associated_instance) { FactoryGirl.build(:attachment) } + let(:associated_instance) { FactoryBot.build(:attachment) } let(:associated_class) { Attachment } let(:associations) { [:author] } @@ -178,7 +178,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has updated one attachment' do - let(:associated_instance) { FactoryGirl.build(:attachment) } + let(:associated_instance) { FactoryBot.build(:attachment) } let(:associated_class) { Attachment } let(:associations) { [:author] } @@ -187,7 +187,7 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has an issue created and assigned' do let(:associated_instance) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, project: project, status: status) } @@ -199,7 +199,7 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has an issue updated and assigned' do let(:associated_instance) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, project: project, status: status) } @@ -245,7 +245,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has updated a wiki content' do - let(:associated_instance) { FactoryGirl.build(:wiki_content) } + let(:associated_instance) { FactoryBot.build(:wiki_content) } let(:associated_class) { WikiContent } let(:associations) { [:author] } @@ -253,7 +253,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created a wiki content' do - let(:associated_instance) { FactoryGirl.build(:wiki_content) } + let(:associated_instance) { FactoryBot.build(:wiki_content) } let(:associated_class) { WikiContent } let(:associations) { [:author] } @@ -261,7 +261,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created a news' do - let(:associated_instance) { FactoryGirl.build(:news) } + let(:associated_instance) { FactoryBot.build(:news) } let(:associated_class) { News } let(:associations) { [:author] } @@ -269,7 +269,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has worked on news' do - let(:associated_instance) { FactoryGirl.build(:news) } + let(:associated_instance) { FactoryBot.build(:news) } let(:associated_class) { News } let(:associations) { [:author] } @@ -277,7 +277,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created a message' do - let(:associated_instance) { FactoryGirl.build(:message) } + let(:associated_instance) { FactoryBot.build(:message) } let(:associated_class) { Message } let(:associations) { [:author] } @@ -285,7 +285,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has worked on message' do - let(:associated_instance) { FactoryGirl.build(:message) } + let(:associated_instance) { FactoryBot.build(:message) } let(:associated_class) { Message } let(:associations) { [:author] } @@ -294,10 +294,10 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has created a time entry' do let(:associated_instance) { - FactoryGirl.build(:time_entry, project: project, + FactoryBot.build(:time_entry, project: project, work_package: issue, hours: 2, - activity: FactoryGirl.create(:time_entry_activity)) + activity: FactoryBot.create(:time_entry_activity)) } let(:associated_class) { TimeEntry } let(:associations) { [:user] } @@ -307,10 +307,10 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has worked on time_entry' do let(:associated_instance) { - FactoryGirl.build(:time_entry, project: project, + FactoryBot.build(:time_entry, project: project, work_package: issue, hours: 2, - activity: FactoryGirl.create(:time_entry_activity)) + activity: FactoryBot.create(:time_entry_activity)) } let(:associated_class) { TimeEntry } let(:associations) { [:user] } @@ -319,7 +319,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has commented' do - let(:news) { FactoryGirl.create(:news, author: user) } + let(:news) { FactoryBot.create(:news, author: user) } let(:associated_instance) { Comment.new(commented: news, @@ -344,7 +344,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user is watching something' do - let(:watched) { FactoryGirl.create(:work_package, project: project) } + let(:watched) { FactoryBot.create(:work_package, project: project) } let(:watch) { Watcher.new(user: user, watchable: watched) @@ -374,7 +374,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created a private query' do - let(:query) { FactoryGirl.build(:private_query, user: user) } + let(:query) { FactoryBot.build(:private_query, user: user) } before do query.save! @@ -386,7 +386,7 @@ describe User, 'deletion', type: :model do end describe 'WHEN the user has created a public query' do - let(:associated_instance) { FactoryGirl.build(:public_query) } + let(:associated_instance) { FactoryBot.build(:public_query) } let(:associated_class) { Query } let(:associations) { [:user] } @@ -397,7 +397,7 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has created a changeset' do with_virtual_subversion_repository do let(:associated_instance) do - FactoryGirl.build(:changeset, + FactoryBot.build(:changeset, repository_id: repository.id, committer: user.login) end @@ -412,7 +412,7 @@ describe User, 'deletion', type: :model do describe 'WHEN the user has updated a changeset' do with_virtual_subversion_repository do let(:associated_instance) do - FactoryGirl.build(:changeset, + FactoryBot.build(:changeset, repository_id: repository.id, committer: user2.login) end @@ -463,7 +463,7 @@ describe User, 'deletion', type: :model do describe 'WHEN the user is assigned an issue category' do let(:category) { - FactoryGirl.build(:category, assigned_to: user, + FactoryBot.build(:category, assigned_to: user, project: project) } diff --git a/spec/models/user_password_spec.rb b/spec/models/user_password_spec.rb index e8175e47b0..ea97bd2d2c 100644 --- a/spec/models/user_password_spec.rb +++ b/spec/models/user_password_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe UserPassword, type: :model do - let(:old_password) { FactoryGirl.create(:old_user_password) } - let(:user) { FactoryGirl.create(:user) } - let(:password) { FactoryGirl.create(:user_password, user: user, plain_password: 'adminAdmin!') } + let(:old_password) { FactoryBot.create(:old_user_password) } + let(:user) { FactoryBot.create(:user) } + let(:password) { FactoryBot.create(:user_password, user: user, plain_password: 'adminAdmin!') } describe '#expired?' do context 'with expiry value set', @@ -62,7 +62,7 @@ describe UserPassword, type: :model do describe '#rehash_as_active' do let(:password) { - pass = FactoryGirl.build(:legacy_sha1_password, user: user, plain_password: 'adminAdmin!') + pass = FactoryBot.build(:legacy_sha1_password, user: user, plain_password: 'adminAdmin!') expect(pass).to receive(:salt_and_hash_password!).and_return nil pass.save! @@ -96,7 +96,7 @@ describe UserPassword, type: :model do end describe '#save' do - let(:password) { FactoryGirl.build(:user_password) } + let(:password) { FactoryBot.build(:user_password) } it 'saves correctly' do expect(password).to receive(:salt_and_hash_password!).and_call_original diff --git a/spec/models/user_passwords/sha1_spec.rb b/spec/models/user_passwords/sha1_spec.rb index 2f61e2a23f..cd7d13c353 100644 --- a/spec/models/user_passwords/sha1_spec.rb +++ b/spec/models/user_passwords/sha1_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe UserPassword::SHA1, type: :model do let(:legacy_password) { - pass = FactoryGirl.build(:legacy_sha1_password, plain_password: 'adminAdmin!') + pass = FactoryBot.build(:legacy_sha1_password, plain_password: 'adminAdmin!') expect(pass).to receive(:salt_and_hash_password!).and_return nil pass.save! @@ -45,7 +45,7 @@ describe UserPassword::SHA1, type: :model do end describe '#create' do - let(:legacy_password) { FactoryGirl.build(:legacy_sha1_password) } + let(:legacy_password) { FactoryBot.build(:legacy_sha1_password) } it 'raises an exception trying to save it' do expect { legacy_password.save! }.to raise_error(ArgumentError) diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb index 2fd7a60d54..775a818d8b 100644 --- a/spec/models/user_preference_spec.rb +++ b/spec/models/user_preference_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe UserPreference do - let(:user) { FactoryGirl.build_stubbed(:user) } - subject { FactoryGirl.build(:user_preference, user: user) } + let(:user) { FactoryBot.build_stubbed(:user) } + subject { FactoryBot.build(:user_preference, user: user) } describe 'default settings' do it 'hides the email address' do @@ -136,7 +136,7 @@ describe UserPreference do end describe '[]=' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } context 'for attributes stored in "others"' do it 'will save the values on sending "save"' do diff --git a/spec/models/user_session_spec.rb b/spec/models/user_session_spec.rb index e1da729866..c8c9bce161 100644 --- a/spec/models/user_session_spec.rb +++ b/spec/models/user_session_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe UserSession do - subject { FactoryGirl.build(:user_session, user: user) } + subject { FactoryBot.build(:user_session, user: user) } shared_examples 'augments the user_id attribute' do it do @@ -39,7 +39,7 @@ describe UserSession do end describe 'when user_id is present' do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:user_id) { user.id } it_behaves_like 'augments the user_id attribute' end @@ -51,8 +51,8 @@ describe UserSession do end describe 'delete other sessions on destroy' do - let(:user) { FactoryGirl.build_stubbed(:user) } - let!(:sessions) { FactoryGirl.create_list(:user_session, 2, user: user) } + let(:user) { FactoryBot.build_stubbed(:user) } + let!(:sessions) { FactoryBot.create_list(:user_session, 2, user: user) } context 'when config is enabled', with_config: { drop_old_sessions_on_logout: true } do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index cf4d288678..2ca2be922a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -29,17 +29,17 @@ require 'spec_helper' describe User, type: :model do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.create(:project_with_types) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.create(:project_with_types) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } - let(:status) { FactoryGirl.create(:status) } + let(:status) { FactoryBot.create(:status) } let(:issue) { - FactoryGirl.build(:work_package, type: project.types.first, + FactoryBot.build(:work_package, type: project.types.first, author: user, project: project, status: status) @@ -208,7 +208,7 @@ describe User, type: :model do describe '#blocked' do let!(:blocked_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, failed_login_count: 3, last_failed_login_on: Time.now) end @@ -226,7 +226,7 @@ describe User, type: :model do end describe '#change_password_allowed?' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } context 'for user without auth source' do before do @@ -239,7 +239,7 @@ describe User, type: :model do end context 'for user with an auth source' do - let(:allowed_auth_source) { FactoryGirl.create :auth_source } + let(:allowed_auth_source) { FactoryBot.create :auth_source } context 'that allows password changes' do before do @@ -253,7 +253,7 @@ describe User, type: :model do end context 'that does not allow password changes' do - let(:denied_auth_source) { FactoryGirl.create :auth_source } + let(:denied_auth_source) { FactoryBot.create :auth_source } before do def denied_auth_source.allow_password_changes?; false; end @@ -310,7 +310,7 @@ describe User, type: :model do describe '#uses_external_authentication?' do context 'with identity_url' do - let(:user) { FactoryGirl.build(:user, identity_url: 'test_provider:veryuniqueid') } + let(:user) { FactoryBot.build(:user, identity_url: 'test_provider:veryuniqueid') } it 'should return true' do expect(user.uses_external_authentication?).to be_truthy @@ -318,7 +318,7 @@ describe User, type: :model do end context 'without identity_url' do - let(:user) { FactoryGirl.build(:user, identity_url: nil) } + let(:user) { FactoryBot.build(:user, identity_url: nil) } it 'should return false' do expect(user.uses_external_authentication?).to be_falsey @@ -382,9 +382,9 @@ describe User, type: :model do end context 'with an external auth source' do - let(:auth_source) { FactoryGirl.build(:auth_source) } + let(:auth_source) { FactoryBot.build(:auth_source) } let(:user_with_external_auth_source) do - user = FactoryGirl.build(:user, login: 'user') + user = FactoryBot.build(:user, login: 'user') allow(user).to receive(:auth_source).and_return(auth_source) user end @@ -444,7 +444,7 @@ describe User, type: :model do end describe '.default_admin_account_deleted_or_changed?' do - let(:default_admin) { FactoryGirl.build(:user, login: 'admin', password: 'admin', password_confirmation: 'admin', admin: true) } + let(:default_admin) { FactoryBot.build(:user, login: 'admin', password: 'admin', password_confirmation: 'admin', admin: true) } before do Setting.password_min_length = 5 @@ -509,8 +509,8 @@ describe User, type: :model do end describe '#impaired?' do - let(:anonymous) { FactoryGirl.create(:anonymous) } - let(:user) { FactoryGirl.create(:user) } + let(:anonymous) { FactoryBot.create(:anonymous) } + let(:user) { FactoryBot.create(:user) } context 'anonymous user with accessibility mode disabled for anonymous users' do before do @@ -543,25 +543,25 @@ describe User, type: :model do describe '#notify_about?' do let(:work_package) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, assigned_to: assignee, responsible: responsible, author: author) end let(:author) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:assignee) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:responsible) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:project) do work_package.project end let(:role) do - FactoryGirl.build_stubbed(:role) + FactoryBot.build_stubbed(:role) end it 'is false for an inactive user' do @@ -582,7 +582,7 @@ describe User, type: :model do end it "is false for a user with :only_my_events who has no relation to the work package" do - user = FactoryGirl.build_stubbed(:user, mail_notification: 'only_my_events') + user = FactoryBot.build_stubbed(:user, mail_notification: 'only_my_events') (Member.new.tap do |m| m.attributes = { user: user, project: project, role_ids: [role.id] } end) @@ -640,7 +640,7 @@ describe User, type: :model do end it "is false for a user with :only_my_events who has no relation to the work package" do - user = FactoryGirl.build(:user, mail_notification: 'selected') + user = FactoryBot.build(:user, mail_notification: 'selected') (Member.new.tap do |m| m.attributes = { user: user, project: project, role_ids: [role.id] } end) @@ -650,9 +650,9 @@ describe User, type: :model do end describe 'scope.newest' do - let!(:anonymous) { FactoryGirl.create(:anonymous) } - let!(:user1) { FactoryGirl.create(:user) } - let!(:user2) { FactoryGirl.create(:user) } + let!(:anonymous) { FactoryBot.create(:anonymous) } + let!(:user1) { FactoryBot.create(:user) } + let!(:user2) { FactoryBot.create(:user) } it 'without anonymous user' do expect(User.newest).to match_array([user1, user2]) diff --git a/spec/models/users/allowed_scope_spec.rb b/spec/models/users/allowed_scope_spec.rb index 379128d2f5..7e8ff3d15a 100644 --- a/spec/models/users/allowed_scope_spec.rb +++ b/spec/models/users/allowed_scope_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' describe User, 'allowed scope' do let(:user) { member.principal } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:project) { FactoryGirl.build(:project, is_public: false) } - let(:project2) { FactoryGirl.build(:project, is_public: false) } - let(:role) { FactoryGirl.build(:role) } - let(:role2) { FactoryGirl.build(:role) } - let(:anonymous_role) { FactoryGirl.build(:anonymous_role) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:project) { FactoryBot.build(:project, is_public: false) } + let(:project2) { FactoryBot.build(:project, is_public: false) } + let(:role) { FactoryBot.build(:role) } + let(:role2) { FactoryBot.build(:role) } + let(:anonymous_role) { FactoryBot.build(:anonymous_role) } let(:member) do - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role]) end diff --git a/spec/models/users/allowed_to_spec.rb b/spec/models/users/allowed_to_spec.rb index ebf7e4d039..e694043d11 100644 --- a/spec/models/users/allowed_to_spec.rb +++ b/spec/models/users/allowed_to_spec.rb @@ -29,20 +29,20 @@ require 'spec_helper' describe User, 'allowed_to?' do - let(:user) { FactoryGirl.build(:user) } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:project) { FactoryGirl.build(:project, is_public: false) } - let(:project2) { FactoryGirl.build(:project, is_public: false) } - let(:role) { FactoryGirl.build(:role) } - let(:role2) { FactoryGirl.build(:role) } - let(:anonymous_role) { FactoryGirl.build(:anonymous_role) } + let(:user) { FactoryBot.build(:user) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:project) { FactoryBot.build(:project, is_public: false) } + let(:project2) { FactoryBot.build(:project, is_public: false) } + let(:role) { FactoryBot.build(:role) } + let(:role2) { FactoryBot.build(:role) } + let(:anonymous_role) { FactoryBot.build(:anonymous_role) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } let(:member2) { - FactoryGirl.build(:member, project: project2, + FactoryBot.build(:member, project: project2, roles: [role2], principal: user) } diff --git a/spec/models/users/default_timezone_spec.rb b/spec/models/users/default_timezone_spec.rb index 204f25f93d..ccbe5f7699 100644 --- a/spec/models/users/default_timezone_spec.rb +++ b/spec/models/users/default_timezone_spec.rb @@ -29,7 +29,7 @@ require "spec_helper" describe User, "default time zone" do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } context "with no system default set" do it "is not set" do diff --git a/spec/models/version_spec.rb b/spec/models/version_spec.rb index 9745ba4e27..9b9a7d48f1 100644 --- a/spec/models/version_spec.rb +++ b/spec/models/version_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe Version, type: :model do - subject(:version) { FactoryGirl.build(:version, name: 'Test Version') } + subject(:version) { FactoryBot.build(:version, name: 'Test Version') } it { is_expected.to be_valid } @@ -42,7 +42,7 @@ describe Version, type: :model do end context '#to_s_for_project' do - let(:other_project) { FactoryGirl.build(:project) } + let(:other_project) { FactoryBot.build(:project) } it 'returns only the version for the same project' do expect(version.to_s_for_project(version.project)).to eq("#{version.name}") @@ -82,8 +82,8 @@ describe Version, type: :model do end context '#<=>' do - let(:version1) { FactoryGirl.build_stubbed(:version) } - let(:version2) { FactoryGirl.build_stubbed(:version) } + let(:version1) { FactoryBot.build_stubbed(:version) } + let(:version2) { FactoryBot.build_stubbed(:version) } it 'is 0 if name and project are equal' do version1.project = version2.project @@ -174,38 +174,38 @@ describe Version, type: :model do context '#projects' do let(:grand_parent_project) do - FactoryGirl.build(:project, name: 'grand_parent_project') + FactoryBot.build(:project, name: 'grand_parent_project') end let(:parent_project) do - FactoryGirl.build(:project, parent: grand_parent_project, name: 'parent_project') + FactoryBot.build(:project, parent: grand_parent_project, name: 'parent_project') end let(:sibling_parent_project) do - FactoryGirl.build(:project, parent: grand_parent_project, name: 'sibling_parent_project') + FactoryBot.build(:project, parent: grand_parent_project, name: 'sibling_parent_project') end let(:child_project) do - FactoryGirl.build(:project, parent: parent_project, name: 'child_project') + FactoryBot.build(:project, parent: parent_project, name: 'child_project') end let(:sibling_project) do - FactoryGirl.build(:project, parent: parent_project, name: 'sibling_project') + FactoryBot.build(:project, parent: parent_project, name: 'sibling_project') end let(:unrelated_project) do - FactoryGirl.build(:project, name: 'unrelated_project') + FactoryBot.build(:project, name: 'unrelated_project') end let(:unshared_version) do - FactoryGirl.build(:version, project: parent_project, sharing: 'none') + FactoryBot.build(:version, project: parent_project, sharing: 'none') end let(:hierarchy_shared_version) do - FactoryGirl.build(:version, project: parent_project, sharing: 'hierarchy') + FactoryBot.build(:version, project: parent_project, sharing: 'hierarchy') end let(:descendants_shared_version) do - FactoryGirl.build(:version, project: parent_project, sharing: 'descendants') + FactoryBot.build(:version, project: parent_project, sharing: 'descendants') end let(:system_shared_version) do - FactoryGirl.build(:version, project: parent_project, sharing: 'system') + FactoryBot.build(:version, project: parent_project, sharing: 'system') end let(:tree_shared_version) do - FactoryGirl.build(:version, project: parent_project, sharing: 'tree') + FactoryBot.build(:version, project: parent_project, sharing: 'tree') end def save_all_projects diff --git a/spec/models/watcher_notification_mailer_spec.rb b/spec/models/watcher_notification_mailer_spec.rb index 73b700aed2..89f0a1ef58 100644 --- a/spec/models/watcher_notification_mailer_spec.rb +++ b/spec/models/watcher_notification_mailer_spec.rb @@ -42,15 +42,15 @@ describe WatcherNotificationMailer do describe 'watcher setup' do let(:work_package) { - work_package = FactoryGirl.build_stubbed(:work_package) - journal = FactoryGirl.build_stubbed(:work_package_journal) + work_package = FactoryBot.build_stubbed(:work_package) + journal = FactoryBot.build_stubbed(:work_package_journal) allow(work_package).to receive(:journals).and_return([journal]) work_package } let(:watcher_setter) do - FactoryGirl.build_stubbed(:user, + FactoryBot.build_stubbed(:user, mail_notification: watching_setting, preference: user_pref) end @@ -58,12 +58,12 @@ describe WatcherNotificationMailer do let(:watching_setting) { 'all' } let(:self_notified) { true } let(:watching_user) { - FactoryGirl.build_stubbed(:user, + FactoryBot.build_stubbed(:user, mail_notification: watching_setting, preference: user_pref) } let(:user_pref) { - pref = FactoryGirl.build_stubbed(:user_preference) + pref = FactoryBot.build_stubbed(:user_preference) allow(pref).to receive(:self_notified?).and_return(self_notified) @@ -71,7 +71,7 @@ describe WatcherNotificationMailer do } let(:watcher) do - FactoryGirl.build_stubbed(:watcher, user: watching_user, + FactoryBot.build_stubbed(:watcher, user: watching_user, watchable: work_package) end @@ -171,21 +171,21 @@ describe WatcherNotificationMailer do end it_behaves_like 'notifies the added watcher for', 'selected' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } before do work_package.project = project allow(watching_user).to receive(:notified_projects_ids).and_return([project.id]) end end it_behaves_like 'does not notify the added watcher for', 'selected' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } before do work_package.project = project allow(watching_user).to receive(:notified_projects_ids).and_return([]) end end it_behaves_like 'does not notify the added watcher for', 'selected' do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } before do allow(watching_user).to receive(:notified_projects_ids).and_return([project.id]) end diff --git a/spec/models/watcher_spec.rb b/spec/models/watcher_spec.rb index 44d1a15be6..9fc99fdbdd 100644 --- a/spec/models/watcher_spec.rb +++ b/spec/models/watcher_spec.rb @@ -30,20 +30,20 @@ require 'spec_helper' describe Watcher, type: :model do let(:project) { watchable.project } - let(:user) { FactoryGirl.build :user, admin: true } + let(:user) { FactoryBot.build :user, admin: true } let(:watcher) do - FactoryGirl.build :watcher, + FactoryBot.build :watcher, watchable: watchable, user: user end - let(:watchable) { FactoryGirl.build :work_package } + let(:watchable) { FactoryBot.build :work_package } let(:other_watcher) do - FactoryGirl.build :watcher, + FactoryBot.build :watcher, watchable: watchable, user: other_user end - let(:other_project) { FactoryGirl.create(:project) } - let(:other_user) { FactoryGirl.create(:user, admin: true) } + let(:other_project) { FactoryBot.create(:project) } + let(:other_user) { FactoryBot.create(:user, admin: true) } describe '#valid' do it 'is valid for an active user' do @@ -99,7 +99,7 @@ describe Watcher, type: :model do end context 'with a non matching user scope' do - let(:other_other_user) { FactoryGirl.create(:user) } + let(:other_other_user) { FactoryBot.create(:user) } it 'leaves the watcher' do Watcher.prune(user: other_other_user) @@ -173,10 +173,10 @@ describe Watcher, type: :model do end context 'for a message' do - let(:board) { FactoryGirl.build(:board) } + let(:board) { FactoryBot.build(:board) } let(:watchable) do board.save! - FactoryGirl.build(:message, board: board) + FactoryBot.build(:message, board: board) end let(:project) { board.project } diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb index dd6c99bf70..32258ada2c 100644 --- a/spec/models/wiki_page_spec.rb +++ b/spec/models/wiki_page_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe WikiPage, type: :model do - let(:project) { FactoryGirl.create(:project).reload } # a wiki is created for project, but the object doesn't know of it (FIXME?) + let(:project) { FactoryBot.create(:project).reload } # a wiki is created for project, but the object doesn't know of it (FIXME?) let(:wiki) { project.wiki } - let(:wiki_page) { FactoryGirl.create(:wiki_page, wiki: wiki, title: wiki.wiki_menu_items.first.title) } + let(:wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki, title: wiki.wiki_menu_items.first.title) } it_behaves_like 'acts_as_watchable included' do - let(:model_instance) { FactoryGirl.create(:wiki_page) } + let(:model_instance) { FactoryBot.create(:wiki_page) } let(:watch_permission) { :view_wiki_pages } let(:project) { model_instance.wiki.project } end @@ -42,10 +42,10 @@ describe WikiPage, type: :model do describe '#create' do context 'when another project with same title exists' do - let(:project2) { FactoryGirl.create(:project) } + let(:project2) { FactoryBot.create(:project) } let(:wiki2) { project2.wiki } - let!(:wiki_page1) { FactoryGirl.create(:wiki_page, wiki: wiki, title: 'asdf') } - let!(:wiki_page2) { FactoryGirl.create(:wiki_page, wiki: wiki2, title: 'asdf') } + let!(:wiki_page1) { FactoryBot.create(:wiki_page, wiki: wiki, title: 'asdf') } + let!(:wiki_page2) { FactoryBot.create(:wiki_page, wiki: wiki2, title: 'asdf') } it 'scopes the slug correctly' do pages = WikiPage.where(title: 'asdf') @@ -57,10 +57,10 @@ describe WikiPage, type: :model do end describe '#nearest_parent_menu_item' do - let(:child_page) { FactoryGirl.create(:wiki_page, parent: wiki_page, wiki: wiki) } - let!(:child_page_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: child_page.slug, parent: wiki_page.menu_item) } - let(:grand_child_page) { FactoryGirl.create(:wiki_page, parent: child_page, wiki: wiki) } - let!(:grand_child_page_wiki_menu_item) { FactoryGirl.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) } + let(:child_page) { FactoryBot.create(:wiki_page, parent: wiki_page, wiki: wiki) } + let!(:child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: child_page.slug, parent: wiki_page.menu_item) } + let(:grand_child_page) { FactoryBot.create(:wiki_page, parent: child_page, wiki: wiki) } + let!(:grand_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) } context 'when called without options' do it 'returns the menu item of the parent page' do @@ -89,7 +89,7 @@ describe WikiPage, type: :model do context 'when one of two wiki pages is destroyed' do before :each do - another_wiki_page = FactoryGirl.create(:wiki_page, wiki: wiki) + another_wiki_page = FactoryBot.create(:wiki_page, wiki: wiki) wiki_page.destroy end diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb index 5a0abee2a6..91f653cacc 100644 --- a/spec/models/wiki_spec.rb +++ b/spec/models/wiki_spec.rb @@ -31,11 +31,11 @@ require 'spec_helper' describe Wiki, type: :model do describe 'creation' do - let(:project) { FactoryGirl.create(:project, disable_modules: 'wiki') } + let(:project) { FactoryBot.create(:project, disable_modules: 'wiki') } let(:start_page) { 'The wiki start page' } it_behaves_like 'acts_as_watchable included' do - let(:model_instance) { FactoryGirl.create(:wiki) } + let(:model_instance) { FactoryBot.create(:wiki) } let(:watch_permission) { :view_wiki_pages } let(:project) { model_instance.project } end diff --git a/spec/models/work_package/aggregate_ancestors_spec.rb b/spec/models/work_package/aggregate_ancestors_spec.rb index c26754d191..bf168b7dc0 100644 --- a/spec/models/work_package/aggregate_ancestors_spec.rb +++ b/spec/models/work_package/aggregate_ancestors_spec.rb @@ -29,43 +29,43 @@ require 'spec_helper' describe WorkPackage::Ancestors, type: :model do - let(:user) { FactoryGirl.create(:user) } - let(:project) { FactoryGirl.create :project } - let(:project2) { FactoryGirl.create :project } + let(:user) { FactoryBot.create(:user) } + let(:project) { FactoryBot.create :project } + let(:project2) { FactoryBot.create :project } let!(:root_work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, project: project end let!(:intermediate) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: root_work_package, project: project end let!(:intermediate_project2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: root_work_package, project: project2 end let!(:leaf) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: intermediate, project: project end let!(:leaf_project2) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: intermediate_project2, project: project end let(:view_role) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: [:view_work_packages]) end let(:none_role) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: []) end @@ -81,7 +81,7 @@ describe WorkPackage::Ancestors, type: :model do context 'with permission in the first project' do before do - FactoryGirl.create :member, + FactoryBot.create :member, user: user, project: project, roles: [view_role] @@ -119,7 +119,7 @@ describe WorkPackage::Ancestors, type: :model do context 'and permission in second project' do before do - FactoryGirl.create :member, + FactoryBot.create :member, user: user, project: project2, roles: [view_role] @@ -141,7 +141,7 @@ describe WorkPackage::Ancestors, type: :model do context 'no permissions' do before do - FactoryGirl.create :member, + FactoryBot.create :member, user: user, project: project, roles: [none_role] diff --git a/spec/models/work_package/ask_before_destruction_spec.rb b/spec/models/work_package/ask_before_destruction_spec.rb index 090e90194f..3f116e57e2 100644 --- a/spec/models/work_package/ask_before_destruction_spec.rb +++ b/spec/models/work_package/ask_before_destruction_spec.rb @@ -30,37 +30,37 @@ require 'spec_helper' describe WorkPackage, type: :model do let(:work_package) do - FactoryGirl.create(:work_package, project: project, + FactoryBot.create(:work_package, project: project, status: status) end let(:work_package2) do - FactoryGirl.create(:work_package, project: project2, + FactoryBot.create(:work_package, project: project2, status: status) end - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } - let(:type) { FactoryGirl.create(:type_standard) } - let(:project) { FactoryGirl.create(:project, types: [type]) } - let(:project2) { FactoryGirl.create(:project, types: [type]) } - let(:role) { FactoryGirl.create(:role) } - let(:role2) { FactoryGirl.create(:role) } + let(:type) { FactoryBot.create(:type_standard) } + let(:project) { FactoryBot.create(:project, types: [type]) } + let(:project2) { FactoryBot.create(:project, types: [type]) } + let(:role) { FactoryBot.create(:role) } + let(:role2) { FactoryBot.create(:role) } let(:member) do - FactoryGirl.create(:member, principal: user, + FactoryBot.create(:member, principal: user, roles: [role]) end let(:member2) do - FactoryGirl.create(:member, principal: user, + FactoryBot.create(:member, principal: user, roles: [role2], project: work_package2.project) end - let(:status) { FactoryGirl.create(:status) } - let(:priority) { FactoryGirl.create(:priority) } + let(:status) { FactoryBot.create(:status) } + let(:priority) { FactoryBot.create(:priority) } let(:time_entry) do - FactoryGirl.build(:time_entry, work_package: work_package, + FactoryBot.build(:time_entry, work_package: work_package, project: work_package.project) end let(:time_entry2) do - FactoryGirl.build(:time_entry, work_package: work_package2, + FactoryBot.build(:time_entry, work_package: work_package2, project: work_package2.project) end diff --git a/spec/models/work_package/openproject_notifications_spec.rb b/spec/models/work_package/openproject_notifications_spec.rb index 0cebbdd887..b8924739cd 100644 --- a/spec/models/work_package/openproject_notifications_spec.rb +++ b/spec/models/work_package/openproject_notifications_spec.rb @@ -33,11 +33,11 @@ require 'spec_helper' # Tests that email notifications will be sent upon creating or changing a work package. describe WorkPackage, type: :model do describe 'OpenProject notifications' do - let(:user) { FactoryGirl.create :admin } - let(:current_user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:current_user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, author: user, subject: 'I can see you', project: project diff --git a/spec/models/work_package/planning_comparison_spec.rb b/spec/models/work_package/planning_comparison_spec.rb index bd70d33e40..5a6825401e 100644 --- a/spec/models/work_package/planning_comparison_spec.rb +++ b/spec/models/work_package/planning_comparison_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'Planning Comparison', type: :model do - let (:project) { FactoryGirl.create(:project) } - let (:admin) { FactoryGirl.create(:admin) } + let (:project) { FactoryBot.create(:project) } + let (:admin) { FactoryBot.create(:admin) } before do # query implicitly uses the logged in user to check for allowed work_packages/projects @@ -43,7 +43,7 @@ describe 'Planning Comparison', type: :model do wp = nil # create 2 journal-entries, to make sure, that the comparison actually picks up the latest one Timecop.travel(2.weeks.ago) do - wp = FactoryGirl.create(:work_package, project: project, start_date: '01/01/2020', due_date: '01/03/2020') + wp = FactoryBot.create(:work_package, project: project, start_date: '01/01/2020', due_date: '01/03/2020') wp.save # triggers the journaling and saves the old due_date, creating the baseline for the comparison end @@ -93,9 +93,9 @@ describe 'Planning Comparison', type: :model do describe 'filtering work_packages also applies to the history' do let(:assigned_to_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, - member_through_role: FactoryGirl.build(:role)) + member_through_role: FactoryBot.build(:role)) end let (:filter) do { f: ['assigned_to_id'], @@ -107,7 +107,7 @@ describe 'Planning Comparison', type: :model do wp = nil # create 2 journal-entries, to make sure, that the comparison actually picks up the latest one Timecop.travel(1.week.ago) do - wp = FactoryGirl.create(:work_package, project: project, due_date: '01/03/2020', assigned_to_id: assigned_to_user.id) + wp = FactoryBot.create(:work_package, project: project, due_date: '01/03/2020', assigned_to_id: assigned_to_user.id) wp.save # triggers the journaling and saves the old due_date, creating the baseline for the comparison end @@ -118,11 +118,11 @@ describe 'Planning Comparison', type: :model do end let (:filtered_work_package) do - other_user = FactoryGirl.create(:user) + other_user = FactoryBot.create(:user) wp = nil # create 2 journal-entries, to make sure, that the comparison actually picks up the latest one Timecop.travel(1.week.ago) do - wp = FactoryGirl.create(:work_package, project: project, due_date: '01/03/2020', assigned_to_id: other_user.id) + wp = FactoryBot.create(:work_package, project: project, due_date: '01/03/2020', assigned_to_id: other_user.id) wp.save # triggers the journaling and saves the old due_date, creating the baseline for the comparison end diff --git a/spec/models/work_package/spent_time_spec.rb b/spec/models/work_package/spent_time_spec.rb index 437062910d..5364a789a4 100644 --- a/spec/models/work_package/spent_time_spec.rb +++ b/spec/models/work_package/spent_time_spec.rb @@ -36,51 +36,51 @@ describe WorkPackage::SpentTime, type: :model do child_work_package_in_other_project.project end let(:work_package) do - FactoryGirl.build(:work_package) + FactoryBot.build(:work_package) end let(:child_work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, project: project, parent: work_package) end let(:child_work_package_in_other_project) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, parent: work_package) end let(:time_entry) do - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, work_package: work_package, project: project) end let(:time_entry2) do - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, work_package: work_package, project: project) end let(:child_time_entry) do - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, work_package: child_work_package, project: project) end let(:child_time_entry_in_other_project) do - FactoryGirl.build(:time_entry, + FactoryBot.build(:time_entry, work_package: child_work_package_in_other_project, project: other_project) end let(:role) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: [:view_time_entries, :view_work_packages]) end let(:role_without_view_time_entries) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: [:view_work_packages]) end let(:role_without_view_work_packages) do - FactoryGirl.build(:role, + FactoryBot.build(:role, permissions: [:view_time_entries]) end let(:user) do - FactoryGirl.build(:user, + FactoryBot.build(:user, member_in_project: project, member_through_role: role) end @@ -116,7 +116,7 @@ describe WorkPackage::SpentTime, type: :model do context 'permissions' do it 'counts the child if that child is in a project in which the user ' + 'has the necessary permissions' do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: other_project, roles: [role]) @@ -129,7 +129,7 @@ describe WorkPackage::SpentTime, type: :model do it 'does not count the child if that child is in a project in which the user ' + 'lacks the view_time_entries permission' do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: other_project, roles: [role_without_view_time_entries]) @@ -142,7 +142,7 @@ describe WorkPackage::SpentTime, type: :model do it 'does not count the child if that child is in a project in which the user ' + 'lacks the view_work_packages permission' do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: other_project, roles: [role_without_view_work_packages]) diff --git a/spec/models/work_package/work_package_action_mailer_spec.rb b/spec/models/work_package/work_package_action_mailer_spec.rb index 2b871aada4..4e25427f9e 100644 --- a/spec/models/work_package/work_package_action_mailer_spec.rb +++ b/spec/models/work_package/work_package_action_mailer_spec.rb @@ -31,17 +31,17 @@ require 'spec_helper' describe WorkPackage, type: :model do describe ActionMailer::Base do let(:user_1) { - FactoryGirl.build(:user, + FactoryBot.build(:user, mail: 'dlopper@somenet.foo', member_in_project: project) } let(:user_2) { - FactoryGirl.build(:user, + FactoryBot.build(:user, mail: 'jsmith@somenet.foo', member_in_project: project) } - let(:project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.build(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.build(:work_package, project: project) } before do allow(work_package).to receive(:recipients).and_return([user_1]) @@ -83,7 +83,7 @@ describe WorkPackage, type: :model do end context 'group_assigned_work_package' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } before do group.users << user_1 diff --git a/spec/models/work_package/work_package_acts_as_event_spec.rb b/spec/models/work_package/work_package_acts_as_event_spec.rb index a4095c01c4..f1dbf39a38 100644 --- a/spec/models/work_package/work_package_acts_as_event_spec.rb +++ b/spec/models/work_package/work_package_acts_as_event_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe WorkPackage, type: :model do describe 'acts_as_event' do - let(:stub_work_package) { FactoryGirl.build_stubbed(:work_package) } + let(:stub_work_package) { FactoryBot.build_stubbed(:work_package) } describe '#event_url' do let(:expected_url) { { controller: :work_packages, action: :show, id: stub_work_package.id } } diff --git a/spec/models/work_package/work_package_acts_as_journalized_spec.rb b/spec/models/work_package/work_package_acts_as_journalized_spec.rb index 99a2ecf76a..89c156946e 100644 --- a/spec/models/work_package/work_package_acts_as_journalized_spec.rb +++ b/spec/models/work_package/work_package_acts_as_journalized_spec.rb @@ -30,21 +30,21 @@ require 'spec_helper' describe WorkPackage, type: :model do describe '#journal' do - let(:type) { FactoryGirl.create :type } + let(:type) { FactoryBot.create :type } let(:project) do - FactoryGirl.create :project, + FactoryBot.create :project, types: [type] end - let(:status) { FactoryGirl.create :default_status } - let(:priority) { FactoryGirl.create :priority } + let(:status) { FactoryBot.create :default_status } + let(:priority) { FactoryBot.create :priority } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project_id: project.id, type: type, description: 'Description', priority: priority) end - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do allow(User).to receive(:current).and_return current_user @@ -98,7 +98,7 @@ describe WorkPackage, type: :model do let(:description) { "Description\n\nwith newlines\n\nembedded" } let(:changed_description) { description.gsub("\n", "\r\n") } let!(:work_package_1) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project_id: project.id, type: type, description: description, @@ -131,17 +131,17 @@ describe WorkPackage, type: :model do context 'when there is a legacy journal containing non-escaped newlines' do let!(:work_package_journal_1) do - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, journable_id: work_package_1.id, version: 2, - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, description: description)) end let!(:work_package_journal_2) do - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, journable_id: work_package_1.id, version: 3, - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, description: changed_description)) end @@ -153,14 +153,14 @@ describe WorkPackage, type: :model do context 'on work package change' do let(:parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project_id: project.id, type: type, priority: priority) end - let(:type_2) { FactoryGirl.create :type } - let(:status_2) { FactoryGirl.create :status } - let(:priority_2) { FactoryGirl.create :priority } + let(:type_2) { FactoryBot.create :type } + let(:status_2) { FactoryBot.create :status } + let(:priority_2) { FactoryBot.create :priority } before do project.types << type_2 @@ -244,7 +244,7 @@ describe WorkPackage, type: :model do end context 'attachments' do - let(:attachment) { FactoryGirl.build :attachment } + let(:attachment) { FactoryBot.build :attachment } let(:attachment_id) { "attachments_#{attachment.id}" } before do @@ -286,9 +286,9 @@ describe WorkPackage, type: :model do end context 'custom values' do - let(:custom_field) { FactoryGirl.create :work_package_custom_field } + let(:custom_field) { FactoryBot.create :work_package_custom_field } let(:custom_value) do - FactoryGirl.build :custom_value, + FactoryBot.build :custom_value, value: 'false', custom_field: custom_field end @@ -319,7 +319,7 @@ describe WorkPackage, type: :model do include_context 'work package with custom value' let(:modified_custom_value) do - FactoryGirl.create :custom_value, + FactoryBot.create :custom_value, value: 'true', custom_field: custom_field end @@ -339,7 +339,7 @@ describe WorkPackage, type: :model do include_context 'work package with custom value' let(:unmodified_custom_value) do - FactoryGirl.create :custom_value, + FactoryBot.create :custom_value, value: 'false', custom_field: custom_field end @@ -373,13 +373,13 @@ describe WorkPackage, type: :model do context 'custom value did not exist before' do let(:custom_field) do - FactoryGirl.create :work_package_custom_field, + FactoryBot.create :work_package_custom_field, is_required: false, field_format: 'list', possible_values: ['', '1', '2', '3', '4', '5', '6', '7'] end let(:custom_value) do - FactoryGirl.create :custom_value, + FactoryBot.create :custom_value, value: '', customized: work_package, custom_field: custom_field @@ -407,35 +407,35 @@ describe WorkPackage, type: :model do Status.delete_all IssuePriority.delete_all - @type ||= FactoryGirl.create(:type_feature) + @type ||= FactoryBot.create(:type_feature) - @status_resolved ||= FactoryGirl.create(:status, name: 'Resolved', is_default: false) - @status_open ||= FactoryGirl.create(:status, name: 'Open', is_default: true) - @status_rejected ||= FactoryGirl.create(:status, name: 'Rejected', is_default: false) + @status_resolved ||= FactoryBot.create(:status, name: 'Resolved', is_default: false) + @status_open ||= FactoryBot.create(:status, name: 'Open', is_default: true) + @status_rejected ||= FactoryBot.create(:status, name: 'Rejected', is_default: false) - role = FactoryGirl.create(:role) - FactoryGirl.create(:workflow, + role = FactoryBot.create(:role) + FactoryBot.create(:workflow, old_status: @status_open, new_status: @status_resolved, role: role, type_id: @type.id) - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: @status_resolved, new_status: @status_rejected, role: role, type_id: @type.id) - @priority_low ||= FactoryGirl.create(:priority_low, is_default: true) - @priority_high ||= FactoryGirl.create(:priority_high) - @project ||= FactoryGirl.create(:project, no_types: true, types: [@type]) + @priority_low ||= FactoryBot.create(:priority_low, is_default: true) + @priority_high ||= FactoryBot.create(:priority_high) + @project ||= FactoryBot.create(:project, no_types: true, types: [@type]) - @current = FactoryGirl.create(:user, login: 'user1', mail: 'user1@users.com') + @current = FactoryBot.create(:user, login: 'user1', mail: 'user1@users.com') allow(User).to receive(:current).and_return(@current) @project.add_member!(@current, role) - @user2 = FactoryGirl.create(:user, login: 'user2', mail: 'user2@users.com') + @user2 = FactoryBot.create(:user, login: 'user2', mail: 'user2@users.com') - @issue ||= FactoryGirl.create(:work_package, + @issue ||= FactoryBot.create(:work_package, project: @project, status: @status_open, type: @type, diff --git a/spec/models/work_package/work_package_acts_as_searchable_spec.rb b/spec/models/work_package/work_package_acts_as_searchable_spec.rb index caf4743106..4e627219e9 100644 --- a/spec/models/work_package/work_package_acts_as_searchable_spec.rb +++ b/spec/models/work_package/work_package_acts_as_searchable_spec.rb @@ -33,15 +33,15 @@ describe WorkPackage, 'acts_as_searchable', type: :model do let(:wp_subject) { 'the quick brown fox jumps over the lazy dog' } let(:project) { - FactoryGirl.create(:project, + FactoryBot.create(:project, is_public: false) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, subject: wp_subject, project: project) } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } describe '#search' do describe "w/ the user being logged in diff --git a/spec/models/work_package/work_package_acts_as_watchable_spec.rb b/spec/models/work_package/work_package_acts_as_watchable_spec.rb index eb0f95fd73..3c44e26c50 100644 --- a/spec/models/work_package/work_package_acts_as_watchable_spec.rb +++ b/spec/models/work_package/work_package_acts_as_watchable_spec.rb @@ -31,14 +31,14 @@ require 'spec_helper' require 'support/shared/acts_as_watchable' describe WorkPackage, type: :model do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project) } it_behaves_like 'acts_as_watchable included' do - let(:model_instance) { FactoryGirl.create(:work_package) } + let(:model_instance) { FactoryBot.create(:work_package) } let(:watch_permission) { :view_work_packages } let(:project) { model_instance.project } end @@ -47,7 +47,7 @@ describe WorkPackage, type: :model do # the work package observer + journal observer context 'notifications' do let(:number_of_recipients) { (work_package.recipients | work_package.watcher_recipients).length } - let(:current_user) { FactoryGirl.create :user } + let(:current_user) { FactoryBot.create :user } before do allow(UserMailer).to receive_message_chain :work_package_updated, :deliver diff --git a/spec/models/work_package/work_package_custom_actions_spec.rb b/spec/models/work_package/work_package_custom_actions_spec.rb index a109fd038d..63526aa0b6 100644 --- a/spec/models/work_package/work_package_custom_actions_spec.rb +++ b/spec/models/work_package/work_package_custom_actions_spec.rb @@ -32,26 +32,26 @@ require 'spec_helper' describe WorkPackage, 'custom_actions', type: :model do let(:work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, project: project) end - let(:project) { FactoryGirl.create(:project) } - let(:status) { FactoryGirl.create(:status) } - let(:other_status) { FactoryGirl.create(:status) } + let(:project) { FactoryBot.create(:project) } + let(:status) { FactoryBot.create(:status) } + let(:other_status) { FactoryBot.create(:status) } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: work_package.project, member_through_role: role) end let(:role) do - FactoryGirl.create(:role) + FactoryBot.create(:role) end let(:conditions) do [CustomActions::Conditions::Status.new([status.id])] end let!(:custom_action) do - action = FactoryGirl.build(:custom_action) + action = FactoryBot.build(:custom_action) action.conditions = conditions action.save! @@ -111,7 +111,7 @@ describe WorkPackage, 'custom_actions', type: :model do end context 'with the condition requiring a different role' do - let(:other_role) { FactoryGirl.create(:role) } + let(:other_role) { FactoryBot.create(:role) } let(:conditions) do [CustomActions::Conditions::Role.new(other_role.id)] diff --git a/spec/models/work_package/work_package_custom_fields_spec.rb b/spec/models/work_package/work_package_custom_fields_spec.rb index 5114f3f607..40a0d7212e 100644 --- a/spec/models/work_package/work_package_custom_fields_spec.rb +++ b/spec/models/work_package/work_package_custom_fields_spec.rb @@ -30,15 +30,15 @@ require 'spec_helper' describe WorkPackage, type: :model do describe '#custom_fields' do - let(:type) { FactoryGirl.create(:type_standard) } - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:type) { FactoryBot.create(:type_standard) } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) do - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, project: project, type: type) end let (:custom_field) do - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, name: 'Database', field_format: 'list', possible_values: %w(MySQL PostgreSQL Oracle), @@ -183,9 +183,9 @@ describe WorkPackage, type: :model do end describe 'work package type change' do - let (:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } + let (:custom_field_2) { FactoryBot.create(:work_package_custom_field) } let(:type_feature) do - FactoryGirl.create(:type_feature, + FactoryBot.create(:type_feature, custom_fields: [custom_field_2]) end @@ -216,7 +216,7 @@ describe WorkPackage, type: :model do context 'w/o initial type' do let(:work_package_without_type) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, project: project, type: type) end @@ -260,7 +260,7 @@ describe WorkPackage, type: :model do describe "custom field type 'text'" do let(:value) { 'text' * 1024 } let(:custom_field) do - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, name: 'Test Text', field_format: 'text', is_required: true) @@ -286,7 +286,7 @@ describe WorkPackage, type: :model do describe 'validation error interpolation' do let :custom_field do - FactoryGirl.create :work_package_custom_field, + FactoryBot.create :work_package_custom_field, name: 'PIN', field_format: 'text', max_length: 4, diff --git a/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb b/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb index 5ecd8ff6e4..5366612d7e 100644 --- a/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb +++ b/spec/models/work_package/work_package_multi_value_custom_fields_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe WorkPackage, type: :model do - let(:type) { FactoryGirl.create :type } - let(:project) { FactoryGirl.create :project, types: [type] } + let(:type) { FactoryBot.create :type } + let(:project) { FactoryBot.create :project, types: [type] } let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :list_wp_custom_field, name: "Ingredients", multi_value: true, @@ -50,7 +50,7 @@ describe WorkPackage, type: :model do end let(:work_package) do - wp = FactoryGirl.create :work_package, project: project, type: type + wp = FactoryBot.create :work_package, project: project, type: type wp.reload wp.custom_field_values = { custom_field.id => custom_values @@ -68,7 +68,7 @@ describe WorkPackage, type: :model do end context 'when value not present' do - let(:work_package) { FactoryGirl.create :work_package, project: project, type: type } + let(:work_package) { FactoryBot.create :work_package, project: project, type: type } it 'returns nil properly' do expect(values).to eq(nil) diff --git a/spec/models/work_package/work_package_notifications_spec.rb b/spec/models/work_package/work_package_notifications_spec.rb index 631f653b32..af9afa7d7f 100644 --- a/spec/models/work_package/work_package_notifications_spec.rb +++ b/spec/models/work_package/work_package_notifications_spec.rb @@ -34,11 +34,11 @@ require 'spec_helper' # Tests that email notifications will be sent upon creating or changing a work package. describe WorkPackage, type: :model do describe 'email notifications' do - let(:user) { FactoryGirl.create :admin } - let(:current_user) { FactoryGirl.create :admin } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:current_user) { FactoryBot.create :admin } + let(:project) { FactoryBot.create :project } let!(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, author: user, subject: 'I can see you', project: project @@ -52,11 +52,11 @@ describe WorkPackage, type: :model do end context 'with email notifications disabled' do - let(:user) { FactoryGirl.create :admin, mail_notification: "none" } + let(:user) { FactoryBot.create :admin, mail_notification: "none" } let(:project) do - project = FactoryGirl.create :project - role = FactoryGirl.create :role + project = FactoryBot.create :project + role = FactoryBot.create :role project.members.create principal: user, roles: [role], mail_notification: true @@ -85,7 +85,7 @@ describe WorkPackage, type: :model do describe 'notification triggered by subtask update' do let!(:child) do - FactoryGirl.create :work_package, subject: "I'm a child", + FactoryBot.create :work_package, subject: "I'm a child", parent: work_package, done_ratio: 42 end diff --git a/spec/models/work_package/work_package_relations_spec.rb b/spec/models/work_package/work_package_relations_spec.rb index 2bd20eabb6..ba18263689 100644 --- a/spec/models/work_package/work_package_relations_spec.rb +++ b/spec/models/work_package/work_package_relations_spec.rb @@ -31,31 +31,31 @@ require 'spec_helper' describe WorkPackage, type: :model do describe '#relation' do let(:closed_state) do - FactoryGirl.create(:status, + FactoryBot.create(:status, is_closed: true) end describe '#duplicate' do - let(:original) { FactoryGirl.create(:work_package) } + let(:original) { FactoryBot.create(:work_package) } let(:dup_1) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: original.project, type: original.type, status: original.status) end let(:relation_org_dup_1) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: dup_1, to: original, relation_type: Relation::TYPE_DUPLICATES) end let(:workflow) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: original.status, new_status: closed_state, type_id: original.type_id) end - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do allow(User).to receive(:current).and_return user @@ -65,20 +65,20 @@ describe WorkPackage, type: :model do context 'closes duplicates' do let(:dup_2) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: original.project, type: original.type, status: original.status) end let(:relation_dup_1_dup_2) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: dup_2, to: dup_1, relation_type: Relation::TYPE_DUPLICATES) end # circular dependency let(:relation_dup_2_org) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: dup_2, to: original, relation_type: Relation::TYPE_DUPLICATES) @@ -119,27 +119,27 @@ describe WorkPackage, type: :model do end describe '#blocks' do - let(:user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role) } - let(:type) { FactoryGirl.create(:type) } + let(:user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role) } + let(:type) { FactoryBot.create(:type) } let(:project) do - FactoryGirl.create(:project, + FactoryBot.create(:project, types: [type]) end - let(:status) { FactoryGirl.create(:status) } + let(:status) { FactoryBot.create(:status) } let(:blocks) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, status: status) end let(:blocked) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: blocks.type, status: status) end let(:relation_blocks) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: blocks, to: blocked, relation_type: Relation::TYPE_BLOCKS) @@ -165,19 +165,19 @@ describe WorkPackage, type: :model do describe 'closed state' do let(:project_member) do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: user, roles: [role]) end let(:workflow_1) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, role: role, old_status: status, new_status: status) end let(:workflow_2) do - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, role: role, old_status: status, new_status: closed_state) @@ -227,18 +227,18 @@ describe WorkPackage, type: :model do end describe '#soonest_start' do - let(:work_package_1) { FactoryGirl.create(:work_package) } + let(:work_package_1) { FactoryBot.create(:work_package) } let(:work_package_2) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: work_package_1.project) end let!(:work_package_2_1) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, parent: work_package_2, project: work_package_1.project) end let!(:relation_1) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: work_package_1, to: work_package_2, relation_type: Relation::TYPE_PRECEDES) diff --git a/spec/models/work_package/work_package_reschedule_after_spec.rb b/spec/models/work_package/work_package_reschedule_after_spec.rb index ee7d8307c4..1d60f68394 100644 --- a/spec/models/work_package/work_package_reschedule_after_spec.rb +++ b/spec/models/work_package/work_package_reschedule_after_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe WorkPackage, '#reschedule_after', type: :model do - let(:user) { FactoryGirl.create(:admin) } - let(:project) { FactoryGirl.build(:project_with_types) } - let(:work_package) { FactoryGirl.create(:work_package, project: project, type: project.types.first) } - let(:work_package2) { FactoryGirl.create(:work_package, project: project, type: project.types.first) } - let(:work_package3) { FactoryGirl.create(:work_package, project: project, type: project.types.first) } + let(:user) { FactoryBot.create(:admin) } + let(:project) { FactoryBot.build(:project_with_types) } + let(:work_package) { FactoryBot.create(:work_package, project: project, type: project.types.first) } + let(:work_package2) { FactoryBot.create(:work_package, project: project, type: project.types.first) } + let(:work_package3) { FactoryBot.create(:work_package, project: project, type: project.types.first) } let(:instance) { work_package } let(:child) do diff --git a/spec/models/work_package/work_package_scheduling_spec.rb b/spec/models/work_package/work_package_scheduling_spec.rb index eb82209333..5811da7931 100644 --- a/spec/models/work_package/work_package_scheduling_spec.rb +++ b/spec/models/work_package/work_package_scheduling_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe WorkPackage, type: :model do describe '#overdue' do let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, due_date: due_date) end @@ -74,7 +74,7 @@ describe WorkPackage, type: :model do context 'status closed' do let(:due_date) { 1.day.ago.to_date } let(:status) do - FactoryGirl.create(:status, + FactoryBot.create(:status, is_closed: true) end @@ -88,7 +88,7 @@ describe WorkPackage, type: :model do describe '#behind_schedule?' do let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, start_date: start_date, due_date: due_date, done_ratio: done_ratio) diff --git a/spec/models/work_package/work_package_status_spec.rb b/spec/models/work_package/work_package_status_spec.rb index bd24f87553..0008a18c5a 100644 --- a/spec/models/work_package/work_package_status_spec.rb +++ b/spec/models/work_package/work_package_status_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe WorkPackage, 'status', type: :model do - let(:status) { FactoryGirl.create(:status) } + let(:status) { FactoryBot.create(:status) } let!(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, status: status) end @@ -41,21 +41,21 @@ describe WorkPackage, 'status', type: :model do end describe '#new_statuses_allowed_to' do - let(:role) { FactoryGirl.build_stubbed(:role) } - let(:type) { FactoryGirl.build_stubbed(:type) } - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:assignee_user) { FactoryGirl.build_stubbed(:user) } - let(:author_user) { FactoryGirl.build_stubbed(:user) } - let(:current_status) { FactoryGirl.build_stubbed(:status) } + let(:role) { FactoryBot.build_stubbed(:role) } + let(:type) { FactoryBot.build_stubbed(:type) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:assignee_user) { FactoryBot.build_stubbed(:user) } + let(:author_user) { FactoryBot.build_stubbed(:user) } + let(:current_status) { FactoryBot.build_stubbed(:status) } let(:work_package) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, assigned_to: assignee_user, author: author_user, status: current_status, type: type) end let(:default_status) do - status = FactoryGirl.build_stubbed(:status) + status = FactoryBot.build_stubbed(:status) allow(Status) .to receive(:default) diff --git a/spec/models/work_package/work_package_visibility_spec.rb b/spec/models/work_package/work_package_visibility_spec.rb index b0bfd4bb1e..560e874016 100644 --- a/spec/models/work_package/work_package_visibility_spec.rb +++ b/spec/models/work_package/work_package_visibility_spec.rb @@ -29,17 +29,17 @@ require 'spec_helper' describe 'WorkPackage-Visibility', type: :model do - let(:admin) { FactoryGirl.create(:admin) } - let(:anonymous) { FactoryGirl.create(:anonymous) } - let(:user) { FactoryGirl.create(:user) } - let(:public_project) { FactoryGirl.create(:project, is_public: true) } - let(:private_project) { FactoryGirl.create(:project, is_public: false) } - let(:other_project) { FactoryGirl.create(:project, is_public: true) } - let(:view_work_packages) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:view_work_packages_role2) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:admin) { FactoryBot.create(:admin) } + let(:anonymous) { FactoryBot.create(:anonymous) } + let(:user) { FactoryBot.create(:user) } + let(:public_project) { FactoryBot.create(:project, is_public: true) } + let(:private_project) { FactoryBot.create(:project, is_public: false) } + let(:other_project) { FactoryBot.create(:project, is_public: true) } + let(:view_work_packages) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:view_work_packages_role2) { FactoryBot.create(:role, permissions: [:view_work_packages]) } describe 'of public projects' do - subject { FactoryGirl.create(:work_package, project: public_project) } + subject { FactoryBot.create(:work_package, project: public_project) } it 'is viewable by anonymous, with the view_work_packages permissison' do # it is not really clear, where these kind of "preconditions" belong to: This setting @@ -51,7 +51,7 @@ describe 'WorkPackage-Visibility', type: :model do end describe 'of private projects' do - subject { FactoryGirl.create(:work_package, project: private_project) } + subject { FactoryBot.create(:work_package, project: private_project) } it 'is visible for the admin, even if the project is private' do expect(WorkPackage.visible(admin)).to match_array [subject] @@ -62,7 +62,7 @@ describe 'WorkPackage-Visibility', type: :model do end it 'is visible for members of the project, with the view_work_packages permissison' do - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: private_project, role_ids: [view_work_packages.id]) @@ -73,7 +73,7 @@ describe 'WorkPackage-Visibility', type: :model do it 'is only returned once for members with two roles having view_work_packages permission' do subject - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: private_project, role_ids: [view_work_packages.id, @@ -87,8 +87,8 @@ describe 'WorkPackage-Visibility', type: :model do end it 'is not visible for members of the project, without the view_work_packages permissison' do - no_permission = FactoryGirl.create(:role, permissions: [:no_permission]) - FactoryGirl.create(:member, + no_permission = FactoryBot.create(:role, permissions: [:no_permission]) + FactoryBot.create(:member, user: user, project: private_project, role_ids: [no_permission.id]) diff --git a/spec/models/work_package_custom_field_spec.rb b/spec/models/work_package_custom_field_spec.rb index 4dc4f3ac2b..a26b79010e 100644 --- a/spec/models/work_package_custom_field_spec.rb +++ b/spec/models/work_package_custom_field_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe WorkPackageCustomField, type: :model do describe '.summable' do let (:custom_field) { - FactoryGirl.create(:work_package_custom_field, + FactoryBot.create(:work_package_custom_field, name: 'Database', field_format: 'list', possible_values: ['MySQL', 'PostgreSQL', 'Oracle'], diff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rb index 7d05504f07..9ab02ebf8f 100644 --- a/spec/models/work_package_spec.rb +++ b/spec/models/work_package_spec.rb @@ -29,15 +29,15 @@ require 'spec_helper' describe WorkPackage, type: :model do - let(:stub_work_package) { FactoryGirl.build_stubbed(:work_package) } - let(:stub_version) { FactoryGirl.build_stubbed(:version) } - let(:stub_project) { FactoryGirl.build_stubbed(:project) } - let(:user) { FactoryGirl.create(:user) } - - let(:type) { FactoryGirl.create(:type_standard) } - let(:project) { FactoryGirl.create(:project, types: [type]) } - let(:status) { FactoryGirl.create(:status) } - let(:priority) { FactoryGirl.create(:priority) } + let(:stub_work_package) { FactoryBot.build_stubbed(:work_package) } + let(:stub_version) { FactoryBot.build_stubbed(:version) } + let(:stub_project) { FactoryBot.build_stubbed(:project) } + let(:user) { FactoryBot.create(:user) } + + let(:type) { FactoryBot.create(:type_standard) } + let(:project) { FactoryBot.create(:project, types: [type]) } + let(:status) { FactoryBot.create(:status) } + let(:priority) { FactoryBot.create(:priority) } let(:work_package) do WorkPackage.new.tap do |w| w.attributes = { project_id: project.id, @@ -53,8 +53,8 @@ describe WorkPackage, type: :model do describe '.new' do context 'type' do - let(:type2) { FactoryGirl.create(:type) } - let(:project) { FactoryGirl.create(:project, types: [type, type2]) } + let(:type2) { FactoryBot.create(:type) } + let(:project) { FactoryBot.create(:project, types: [type, type2]) } before do project # loads types as well @@ -126,14 +126,14 @@ describe WorkPackage, type: :model do describe '#assigned_to' do context 'group_assignment' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } before do allow(Setting).to receive(:work_package_group_assignment).and_return(true) end subject { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, assigned_to: group).assigned_to } @@ -143,9 +143,9 @@ describe WorkPackage, type: :model do end describe '#category' do - let(:user_2) { FactoryGirl.create(:user, member_in_project: project) } + let(:user_2) { FactoryBot.create(:user, member_in_project: project) } let(:category) do - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project, assigned_to: user_2) end @@ -189,9 +189,9 @@ describe WorkPackage, type: :model do end describe 'responsible' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } - before { work_package.project.add_member! group, FactoryGirl.create(:role) } + before { work_package.project.add_member! group, FactoryBot.create(:role) } shared_context 'assign group as responsible' do before { work_package.responsible = group } @@ -209,7 +209,7 @@ describe WorkPackage, type: :model do end describe '#assignable_versions' do - let(:stub_version2) { FactoryGirl.build_stubbed(:version) } + let(:stub_version2) { FactoryBot.build_stubbed(:version) } def stub_shared_versions(v = nil) versions = v ? [v] : [] @@ -247,7 +247,7 @@ describe WorkPackage, type: :model do describe '#assignable_versions' do let!(:work_package) do - wp = FactoryGirl.create(:work_package, + wp = FactoryBot.create(:work_package, project: project, fixed_version: version_current) # remove changes to fixed version factored into @@ -256,27 +256,27 @@ describe WorkPackage, type: :model do wp end let!(:version_current) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'closed', project: project) end let!(:version_open) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', project: project) end let!(:version_locked) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'locked', project: project) end let!(:version_closed) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'closed', project: project) end let!(:version_other_project) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open') end @@ -288,12 +288,12 @@ describe WorkPackage, type: :model do describe '#destroy' do let(:time_entry_1) { - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, project: project, work_package: work_package) } let(:time_entry_2) { - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, project: project, work_package: work_package) } @@ -320,25 +320,25 @@ describe WorkPackage, type: :model do describe '#done_ratio' do let(:status_new) { - FactoryGirl.create(:status, + FactoryBot.create(:status, name: 'New', is_default: true, is_closed: false, default_done_ratio: 50) } let(:status_assigned) { - FactoryGirl.create(:status, + FactoryBot.create(:status, name: 'Assigned', is_default: true, is_closed: false, default_done_ratio: 0) } let(:work_package_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, status: status_new) } let(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: work_package_1.project, status: status_assigned, done_ratio: 30) @@ -412,29 +412,29 @@ describe WorkPackage, type: :model do end describe '#group_by' do - let(:type_2) { FactoryGirl.create(:type) } - let(:priority_2) { FactoryGirl.create(:priority) } - let(:project) { FactoryGirl.create(:project, types: [type, type_2]) } + let(:type_2) { FactoryBot.create(:type) } + let(:priority_2) { FactoryBot.create(:priority) } + let(:project) { FactoryBot.create(:project, types: [type, type_2]) } let(:version_1) { - FactoryGirl.create(:version, + FactoryBot.create(:version, project: project) } let(:version_2) { - FactoryGirl.create(:version, + FactoryBot.create(:version, project: project) } let(:category_1) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } let(:category_2) { - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) } - let(:user_2) { FactoryGirl.create(:user) } + let(:user_2) { FactoryBot.create(:user) } let(:work_package_1) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user, assigned_to: user, responsible: user, @@ -445,7 +445,7 @@ describe WorkPackage, type: :model do category: category_1) } let(:work_package_2) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, author: user_2, assigned_to: user_2, responsible: user_2, @@ -522,11 +522,11 @@ describe WorkPackage, type: :model do context 'by project' do let(:project_2) { - FactoryGirl.create(:project, + FactoryBot.create(:project, parent: project) } let(:work_package_3) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_2) } @@ -539,8 +539,8 @@ describe WorkPackage, type: :model do end describe '#recently_updated' do - let(:work_package_1) { FactoryGirl.create(:work_package) } - let(:work_package_2) { FactoryGirl.create(:work_package) } + let(:work_package_1) { FactoryBot.create(:work_package) } + let(:work_package_2) { FactoryBot.create(:work_package) } before do work_package_1 @@ -561,12 +561,12 @@ describe WorkPackage, type: :model do describe '#on_active_project' do let(:project_archived) { - FactoryGirl.create(:project, + FactoryBot.create(:project, status: Project::STATUS_ARCHIVED) } - let!(:work_package) { FactoryGirl.create(:work_package) } + let!(:work_package) { FactoryBot.create(:work_package) } let(:work_package_in_archived_project) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_archived) } @@ -584,14 +584,14 @@ describe WorkPackage, type: :model do end describe '#with_author' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:project_archived) { - FactoryGirl.create(:project, + FactoryBot.create(:project, status: Project::STATUS_ARCHIVED) } - let!(:work_package) { FactoryGirl.create(:work_package, author: user) } + let!(:work_package) { FactoryBot.create(:work_package, author: user) } let(:work_package_in_archived_project) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project_archived, author: user) } @@ -610,13 +610,13 @@ describe WorkPackage, type: :model do end describe '#recipients' do - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:member) { FactoryGirl.build_stubbed(:user) } - let(:author) { FactoryGirl.build_stubbed(:user) } - let(:assignee) { FactoryGirl.build_stubbed(:user) } - let(:responsible) { FactoryGirl.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:member) { FactoryBot.build_stubbed(:user) } + let(:author) { FactoryBot.build_stubbed(:user) } + let(:assignee) { FactoryBot.build_stubbed(:user) } + let(:responsible) { FactoryBot.build_stubbed(:user) } let(:work_package) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, author: author, assigned_to: assignee, responsible: responsible, @@ -692,9 +692,9 @@ describe WorkPackage, type: :model do end context 'with a group' do - let(:user1) { FactoryGirl.build_stubbed(:user) } - let(:user2) { FactoryGirl.build_stubbed(:user) } - let(:user3) { FactoryGirl.build_stubbed(:user) } + let(:user1) { FactoryBot.build_stubbed(:user) } + let(:user2) { FactoryBot.build_stubbed(:user) } + let(:user3) { FactoryBot.build_stubbed(:user) } let(:users_with_view_permission) do [user1, user3] @@ -716,7 +716,7 @@ describe WorkPackage, type: :model do context 'for assignee' do let(:assignee) do - group = FactoryGirl.build_stubbed(:group) + group = FactoryBot.build_stubbed(:group) allow(group) .to receive(:users) .and_return([user1, user2, user3]) @@ -732,7 +732,7 @@ describe WorkPackage, type: :model do context 'for responsible' do let(:responsible) do - group = FactoryGirl.build_stubbed(:group) + group = FactoryBot.build_stubbed(:group) allow(group) .to receive(:users) .and_return([user1, user2, user3]) @@ -769,10 +769,10 @@ describe WorkPackage, type: :model do end describe '.allowed_target_project_on_move' do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:move_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:move_work_packages]) } let(:user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } context 'when having the move_work_packages permission' do @@ -783,7 +783,7 @@ describe WorkPackage, type: :model do end context 'when lacking the move_work_packages permission' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } it 'does not return the project' do expect(WorkPackage.allowed_target_projects_on_move(user)) @@ -793,10 +793,10 @@ describe WorkPackage, type: :model do end describe '.allowed_target_project_on_create' do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:add_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:add_work_packages]) } let(:user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } context 'when having the add_work_packages permission' do @@ -807,7 +807,7 @@ describe WorkPackage, type: :model do end context 'when lacking the add_work_packages permission' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } it 'does not return the project' do expect(WorkPackage.allowed_target_projects_on_create(user)) @@ -869,8 +869,8 @@ describe WorkPackage, type: :model do end describe 'custom fields' do - let(:included_cf) { FactoryGirl.build(:work_package_custom_field) } - let(:other_cf) { FactoryGirl.build(:work_package_custom_field) } + let(:included_cf) { FactoryBot.build(:work_package_custom_field) } + let(:other_cf) { FactoryBot.build(:work_package_custom_field) } before do included_cf.save @@ -897,11 +897,11 @@ describe WorkPackage, type: :model do end it 'should not duplicate error messages when invalid' do - cf1 = FactoryGirl.create(:work_package_custom_field, is_required: true) - cf2 = FactoryGirl.create(:work_package_custom_field, is_required: true) + cf1 = FactoryBot.create(:work_package_custom_field, is_required: true) + cf2 = FactoryBot.create(:work_package_custom_field, is_required: true) # create work_package with one required custom field - work_package = FactoryGirl.create :work_package + work_package = FactoryBot.create :work_package work_package.reload work_package.project.work_package_custom_fields << cf1 work_package.type.custom_fields << cf1 @@ -928,7 +928,7 @@ describe WorkPackage, type: :model do describe 'changed_since' do let!(:work_package) do Timecop.travel(5.hours.ago) do - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end end diff --git a/spec/models/workflow_spec.rb b/spec/models/workflow_spec.rb index 7caa679116..c585f0a509 100644 --- a/spec/models/workflow_spec.rb +++ b/spec/models/workflow_spec.rb @@ -29,14 +29,14 @@ require 'spec_helper' describe Workflow, type: :model do - let(:status_0) { FactoryGirl.create(:status) } - let(:status_1) { FactoryGirl.create(:status) } - let(:role) { FactoryGirl.create(:role) } - let(:type) { FactoryGirl.create(:type) } + let(:status_0) { FactoryBot.create(:status) } + let(:status_1) { FactoryBot.create(:status) } + let(:role) { FactoryBot.create(:role) } + let(:type) { FactoryBot.create(:type) } describe '#self.copy' do - let(:role_target) { FactoryGirl.create(:role) } - let(:type_target) { FactoryGirl.create(:type) } + let(:role_target) { FactoryBot.create(:role) } + let(:type_target) { FactoryBot.create(:type) } shared_examples_for 'copied workflow' do before do Workflow.copy(type, role, type_target, role_target) end @@ -58,7 +58,7 @@ describe Workflow, type: :model do describe 'workflow w/o author or assignee' do let!(:workflow_src) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: status_0, new_status: status_1, type_id: type.id, @@ -69,7 +69,7 @@ describe Workflow, type: :model do describe 'workflow with author' do let!(:workflow_src) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: status_0, new_status: status_1, type_id: type.id, @@ -81,7 +81,7 @@ describe Workflow, type: :model do describe 'workflow with assignee' do let!(:workflow_src) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: status_0, new_status: status_1, type_id: type.id, diff --git a/spec/policies/query_policy_spec.rb b/spec/policies/query_policy_spec.rb index 99322fc238..ed903252a1 100644 --- a/spec/policies/query_policy_spec.rb +++ b/spec/policies/query_policy_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe QueryPolicy, type: :controller do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:query) { FactoryGirl.build_stubbed(:query, project: project, user: user) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project, user: user) } describe '#allowed?' do let(:subject) { described_class.new(user) } @@ -44,7 +44,7 @@ describe QueryPolicy, type: :controller do shared_examples 'viewing queries' do |global| context "#{ global ? 'in global context' : 'in project context' }" do - let(:other_user) { FactoryGirl.build_stubbed(:user) } + let(:other_user) { FactoryBot.build_stubbed(:user) } if global let(:project) { nil } end @@ -57,7 +57,7 @@ describe QueryPolicy, type: :controller do context 'query belongs to a different user' do let(:query) do - FactoryGirl.build_stubbed(:query, + FactoryBot.build_stubbed(:query, project: project, user: user, is_public: false) @@ -121,7 +121,7 @@ describe QueryPolicy, type: :controller do global: project.nil?) .and_return true - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) expect(subject.allowed?(query, action)).to be_falsy end @@ -145,7 +145,7 @@ describe QueryPolicy, type: :controller do project, global: project.nil?) .and_return true - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) query.is_public = true expect(subject.allowed?(query, action)).to be_truthy @@ -158,7 +158,7 @@ describe QueryPolicy, type: :controller do project, global: project.nil?) .and_return false - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) query.is_public = true expect(subject.allowed?(query, action)).to be_falsy @@ -171,7 +171,7 @@ describe QueryPolicy, type: :controller do project, global: project.nil?) .and_return true - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) query.is_public = false expect(subject.allowed?(query, action)).to be_falsy @@ -248,7 +248,7 @@ describe QueryPolicy, type: :controller do project, global: project.nil?) .and_return true - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) query.is_public = false expect(subject.allowed?(query, :publicize)).to be_falsy @@ -276,7 +276,7 @@ describe QueryPolicy, type: :controller do global: project.nil?) .and_return true - query.user = FactoryGirl.build_stubbed(:user) + query.user = FactoryBot.build_stubbed(:user) query.is_public = true expect(subject.allowed?(query, :depublicize)).to be_truthy diff --git a/spec/policies/work_package_policy_spec.rb b/spec/policies/work_package_policy_spec.rb index 80e82c2bc8..7eab54eaea 100644 --- a/spec/policies/work_package_policy_spec.rb +++ b/spec/policies/work_package_policy_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe WorkPackagePolicy, type: :controller do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:work_package) { FactoryGirl.build_stubbed(:work_package, project: project) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:work_package) { FactoryBot.build_stubbed(:work_package, project: project) } describe '#allowed?' do let(:subject) { described_class.new(user) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4d31e21a13..f818b3d652 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -28,7 +28,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'spec_helper' -require 'factory_girl_rails' +require 'factory_bot_rails' require 'rspec/rails' require 'shoulda/matchers' require 'rspec/example_disabler' diff --git a/spec/requests/api/v3/activities_api_spec.rb b/spec/requests/api/v3/activities_api_spec.rb index b7b44d66c2..424fe1c7e6 100644 --- a/spec/requests/api/v3/activities_api_spec.rb +++ b/spec/requests/api/v3/activities_api_spec.rb @@ -33,7 +33,7 @@ describe API::V3::Activities::ActivitiesAPI, type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } let(:comment) { 'This is a test comment!' } shared_examples_for 'safeguarded API' do @@ -59,10 +59,10 @@ describe API::V3::Activities::ActivitiesAPI, type: :request do end describe 'PATCH /api/v3/activities/:activityId' do - let(:work_package) { FactoryGirl.create(:work_package) } - let(:wp_journal) { FactoryGirl.build(:journal_work_package_journal) } + let(:work_package) { FactoryBot.create(:work_package) } + let(:wp_journal) { FactoryBot.build(:journal_work_package_journal) } let(:journal) { - FactoryGirl.create(:work_package_journal, + FactoryBot.create(:work_package_journal, data: wp_journal, journable_id: work_package.id) } diff --git a/spec/requests/api/v3/activities_by_work_package_resource_spec.rb b/spec/requests/api/v3/activities_by_work_package_resource_spec.rb index 389ab3b29e..9727a4f2e9 100644 --- a/spec/requests/api/v3/activities_by_work_package_resource_spec.rb +++ b/spec/requests/api/v3/activities_by_work_package_resource_spec.rb @@ -34,12 +34,12 @@ describe API::V3::Activities::ActivitiesByWorkPackageAPI, type: :request do describe 'activities' do let(:project) { work_package.project } - let(:work_package) { FactoryGirl.create(:work_package) } + let(:work_package) { FactoryBot.create(:work_package) } let(:comment) { 'This is a test comment!' } let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { %i(view_work_packages add_work_package_notes) } before do @@ -56,7 +56,7 @@ describe API::V3::Activities::ActivitiesByWorkPackageAPI, type: :request do end context 'not allowed to see work package' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } it 'fails with HTTP Not Found' do expect(last_response.status).to eql 404 @@ -65,7 +65,7 @@ describe API::V3::Activities::ActivitiesByWorkPackageAPI, type: :request do end describe 'POST /api/v3/work_packages/:id/activities' do - let(:work_package) { FactoryGirl.create(:work_package) } + let(:work_package) { FactoryBot.create(:work_package) } shared_context 'create activity' do before do diff --git a/spec/requests/api/v3/activity_resource_spec.rb b/spec/requests/api/v3/activity_resource_spec.rb index 76b340a60b..3e0cf907cc 100644 --- a/spec/requests/api/v3/activity_resource_spec.rb +++ b/spec/requests/api/v3/activity_resource_spec.rb @@ -34,11 +34,11 @@ describe 'API v3 Activity resource', type: :request do include API::V3::Utilities::PathHelper let(:current_user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:work_package) { FactoryGirl.create(:work_package, author: current_user, project: project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages, :edit_work_package_notes] } let(:activity) { work_package.journals.first } @@ -75,9 +75,9 @@ describe 'API v3 Activity resource', type: :request do end context 'requesting activity without sufficient permissions' do - let(:another_project) { FactoryGirl.create(:project, is_public: false) } - let(:another_work_package) { FactoryGirl.create(:work_package, project: another_project) } - let(:another_activity) { FactoryGirl.create(:work_package_journal, journable: another_work_package) } + let(:another_project) { FactoryBot.create(:project, is_public: false) } + let(:another_work_package) { FactoryBot.create(:work_package, project: another_project) } + let(:another_activity) { FactoryBot.create(:work_package_journal, journable: another_work_package) } let(:get_path) { api_v3_paths.activity another_activity.id } it_behaves_like 'unauthorized access' @@ -85,7 +85,7 @@ describe 'API v3 Activity resource', type: :request do end it_behaves_like 'handling anonymous user' do - let(:project) { FactoryGirl.create(:project, is_public: true) } + let(:project) { FactoryBot.create(:project, is_public: true) } let(:path) { api_v3_paths.activity activity.id } end end diff --git a/spec/requests/api/v3/attachments/attachment_resource_spec.rb b/spec/requests/api/v3/attachments/attachment_resource_spec.rb index 6190deda65..c802e5d835 100644 --- a/spec/requests/api/v3/attachments/attachment_resource_spec.rb +++ b/spec/requests/api/v3/attachments/attachment_resource_spec.rb @@ -34,13 +34,13 @@ describe 'API v3 Attachment resource', type: :request, content_type: :json do include API::V3::Utilities::PathHelper let(:current_user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } - let(:work_package) { FactoryGirl.create(:work_package, author: current_user, project: project) } - let(:attachment) { FactoryGirl.create(:attachment, container: work_package) } + let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) } + let(:attachment) { FactoryBot.create(:attachment, container: work_package) } before do allow(User).to receive(:current).and_return current_user diff --git a/spec/requests/api/v3/attachments/attachments_by_work_package_resource_spec.rb b/spec/requests/api/v3/attachments/attachments_by_work_package_resource_spec.rb index ec5a9576ed..d6ffedace0 100644 --- a/spec/requests/api/v3/attachments/attachments_by_work_package_resource_spec.rb +++ b/spec/requests/api/v3/attachments/attachments_by_work_package_resource_spec.rb @@ -35,20 +35,20 @@ describe 'API v3 Attachments by work package resource', type: :request do include FileHelpers let(:current_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } - let(:work_package) { FactoryGirl.create(:work_package, author: current_user, project: project) } + let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) } subject(:response) { last_response } before do allow(User).to receive(:current).and_return current_user - FactoryGirl.create_list(:attachment, 5, container: work_package) + FactoryBot.create_list(:attachment, 5, container: work_package) end describe '#get' do diff --git a/spec/requests/api/v3/authentication_spec.rb b/spec/requests/api/v3/authentication_spec.rb index 571153aecf..f677ca27fb 100644 --- a/spec/requests/api/v3/authentication_spec.rb +++ b/spec/requests/api/v3/authentication_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe API::V3, type: :request do describe 'basic auth' do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } let(:resource) { "/api/v3/users/#{user.id}" } let(:response_401) do @@ -166,7 +166,7 @@ describe API::V3, type: :request do it_behaves_like 'it is basic auth protected' describe 'user basic auth' do - let(:api_key) { FactoryGirl.create :api_token } + let(:api_key) { FactoryBot.create :api_token } let(:username) { 'apikey' } let(:password) { api_key.plain_value } @@ -177,7 +177,7 @@ describe API::V3, type: :request do end describe 'user basic auth' do - let(:api_key) { FactoryGirl.create :api_token } + let(:api_key) { FactoryBot.create :api_token } let(:username) { 'apikey' } let(:password) { api_key.plain_value } @@ -198,8 +198,8 @@ describe API::V3, type: :request do let(:username) { 'hancholo' } let(:password) { 'olooleol' } - let(:api_user) { FactoryGirl.create :user, login: 'user_account' } - let(:api_key) { FactoryGirl.create :api_token, user: api_user } + let(:api_user) { FactoryBot.create :user, login: 'user_account' } + let(:api_key) { FactoryBot.create :api_token, user: api_user } before do config = { user: 'global_account', password: 'global_password' } diff --git a/spec/requests/api/v3/category_resource_spec.rb b/spec/requests/api/v3/category_resource_spec.rb index b5cfccce92..d88b5a77ce 100644 --- a/spec/requests/api/v3/category_resource_spec.rb +++ b/spec/requests/api/v3/category_resource_spec.rb @@ -33,20 +33,20 @@ describe 'API v3 Category resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:role) { FactoryGirl.create(:role, permissions: []) } - let(:private_project) { FactoryGirl.create(:project, is_public: false) } - let(:public_project) { FactoryGirl.create(:project, is_public: true) } - let(:anonymous_user) { FactoryGirl.create(:user) } + let(:role) { FactoryBot.create(:role, permissions: []) } + let(:private_project) { FactoryBot.create(:project, is_public: false) } + let(:public_project) { FactoryBot.create(:project, is_public: true) } + let(:anonymous_user) { FactoryBot.create(:user) } let(:privileged_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: private_project, member_through_role: role) end - let!(:categories) { FactoryGirl.create_list(:category, 3, project: private_project) } - let!(:other_categories) { FactoryGirl.create_list(:category, 2, project: public_project) } + let!(:categories) { FactoryBot.create_list(:category, 3, project: private_project) } + let!(:other_categories) { FactoryBot.create_list(:category, 2, project: public_project) } let!(:user_categories) do - FactoryGirl.create_list(:category, + FactoryBot.create_list(:category, 2, project: private_project, assigned_to: privileged_user) diff --git a/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb b/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb index 50a936af95..8059883d70 100644 --- a/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb +++ b/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb @@ -33,22 +33,22 @@ describe 'API::V3::CustomActions::CustomActionsAPI', type: :request do include API::V3::Utilities::PathHelper let(:role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: %i[edit_work_packages view_work_packages]) end - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, assigned_to: user) end let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:action) do - FactoryGirl.create(:custom_action, actions: [CustomActions::Actions::AssignedTo.new(nil)]) + FactoryBot.create(:custom_action, actions: [CustomActions::Actions::AssignedTo.new(nil)]) end let(:parameters) do { @@ -93,7 +93,7 @@ describe 'API::V3::CustomActions::CustomActionsAPI', type: :request do end context 'when lacking permissions' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } include_context 'get request' @@ -188,7 +188,7 @@ describe 'API::V3::CustomActions::CustomActionsAPI', type: :request do end context 'with a non visible work package' do - let(:invisible_work_package) { FactoryGirl.create(:work_package) } + let(:invisible_work_package) { FactoryBot.create(:work_package) } let(:parameters) do { diff --git a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb index a609337bf1..51470942df 100644 --- a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb +++ b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb @@ -34,22 +34,22 @@ describe 'API v3 Custom Options resource' do include API::V3::Utilities::PathHelper let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:custom_field) do - cf = FactoryGirl.create(:list_wp_custom_field) + cf = FactoryBot.create(:list_wp_custom_field) project.work_package_custom_fields << cf cf end let(:custom_option) do - FactoryGirl.create(:custom_option, + FactoryBot.create(:custom_option, custom_field: custom_field) end @@ -98,7 +98,7 @@ describe 'API v3 Custom Options resource' do context 'when custom option not in project' do let(:custom_field) do # not added to project - FactoryGirl.create(:list_wp_custom_field) + FactoryBot.create(:list_wp_custom_field) end it 'is 404' do diff --git a/spec/requests/api/v3/groups/group_resource_spec.rb b/spec/requests/api/v3/groups/group_resource_spec.rb index 1ca9221a61..439ba3d38b 100644 --- a/spec/requests/api/v3/groups/group_resource_spec.rb +++ b/spec/requests/api/v3/groups/group_resource_spec.rb @@ -33,17 +33,17 @@ describe 'API v3 Group resource', type: :request, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:group) do - FactoryGirl.create(:group, + FactoryBot.create(:group, member_in_project: project, member_through_role: role) end let(:group_project) { project } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_members] } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb index c938fd541f..109e542f3e 100644 --- a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb +++ b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb @@ -33,10 +33,10 @@ describe 'API v3 Help texts resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end @@ -46,12 +46,12 @@ describe 'API v3 Help texts resource' do # Type.translated_work_package_form_attributes Rails.cache.clear - custom_field = FactoryGirl.create :text_wp_custom_field + custom_field = FactoryBot.create :text_wp_custom_field [ - FactoryGirl.create(:work_package_help_text, attribute_name: 'assignee'), - FactoryGirl.create(:work_package_help_text, attribute_name: 'status'), - FactoryGirl.create(:work_package_help_text, attribute_name: "custom_field_#{custom_field.id}") + FactoryBot.create(:work_package_help_text, attribute_name: 'assignee'), + FactoryBot.create(:work_package_help_text, attribute_name: 'status'), + FactoryBot.create(:work_package_help_text, attribute_name: "custom_field_#{custom_field.id}") ] end diff --git a/spec/requests/api/v3/locale_spec.rb b/spec/requests/api/v3/locale_spec.rb index 5697d9461f..8c00614944 100644 --- a/spec/requests/api/v3/locale_spec.rb +++ b/spec/requests/api/v3/locale_spec.rb @@ -36,10 +36,10 @@ describe 'API localization', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } - let(:type) { FactoryGirl.create(:type) } + let(:project) { FactoryBot.create(:project) } + let(:type) { FactoryBot.create(:type) } let(:schema_path) { api_v3_paths.work_package_schema project.id, type.id } - let(:current_user) { FactoryGirl.build(:user, member_in_project: project, language: :fr) } + let(:current_user) { FactoryBot.build(:user, member_in_project: project, language: :fr) } describe 'GET /api/v3/work_packages/schemas/:id' do before do diff --git a/spec/requests/api/v3/principals/principals_resource_spec.rb b/spec/requests/api/v3/principals/principals_resource_spec.rb index 7da3cd7a3d..42a94947e5 100644 --- a/spec/requests/api/v3/principals/principals_resource_spec.rb +++ b/spec/requests/api/v3/principals/principals_resource_spec.rb @@ -51,13 +51,13 @@ describe 'API v3 Principals resource', type: :request do end let(:order) { { name: :desc } } let(:filter) { nil } - let(:project) { FactoryGirl.create(:project) } - let(:other_project) { FactoryGirl.create(:project) } - let(:non_member_project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:other_project) { FactoryBot.create(:project) } + let(:non_member_project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [] } let(:user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role, lastname: 'aaaa') @@ -67,19 +67,19 @@ describe 'API v3 Principals resource', type: :request do user end let(:other_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: other_project, member_through_role: role, lastname: 'bbbb') end let(:user_in_non_member_project) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: non_member_project, member_through_role: role, lastname: 'cccc') end let(:group) do - group = FactoryGirl.create(:group, + group = FactoryBot.create(:group, lastname: 'gggg') project.add_member! group, role @@ -145,7 +145,7 @@ describe 'API v3 Principals resource', type: :request do end context 'user without a project membership' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } # The user herself it_behaves_like 'API V3 collection response', 1, 1, 'User' do diff --git a/spec/requests/api/v3/priority_resource_spec.rb b/spec/requests/api/v3/priority_resource_spec.rb index 401be5f435..ad0d60566a 100644 --- a/spec/requests/api/v3/priority_resource_spec.rb +++ b/spec/requests/api/v3/priority_resource_spec.rb @@ -33,15 +33,15 @@ describe 'API v3 Priority resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, is_public: false) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let!(:priorities) { FactoryGirl.create_list(:priority, 2) } + let!(:priorities) { FactoryBot.create_list(:priority, 2) } describe 'priorities' do subject(:response) { last_response } diff --git a/spec/requests/api/v3/project_resource_spec.rb b/spec/requests/api/v3/project_resource_spec.rb index c1990e3ccb..6d5de04bd5 100644 --- a/spec/requests/api/v3/project_resource_spec.rb +++ b/spec/requests/api/v3/project_resource_spec.rb @@ -34,13 +34,13 @@ describe 'API v3 Project resource' do include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:project) { FactoryGirl.create(:project, is_public: false) } + let(:project) { FactoryBot.create(:project, is_public: false) } let(:other_project) do - FactoryGirl.create(:project, is_public: false) + FactoryBot.create(:project, is_public: false) end - let(:role) { FactoryGirl.create(:role) } + let(:role) { FactoryBot.create(:role) } before do allow(User).to receive(:current).and_return current_user @@ -84,7 +84,7 @@ describe 'API v3 Project resource' do end context 'not logged in user' do - let(:current_user) { FactoryGirl.create(:anonymous) } + let(:current_user) { FactoryBot.create(:anonymous) } before do get get_path @@ -113,7 +113,7 @@ describe 'API v3 Project resource' do context 'filtering for project by ancestor' do let(:parent_project) do - parent_project = FactoryGirl.create(:project, is_public: false) + parent_project = FactoryBot.create(:project, is_public: false) project.update_attribute(:parent_id, parent_project.id) diff --git a/spec/requests/api/v3/projects/version_resource_spec.rb b/spec/requests/api/v3/projects/version_resource_spec.rb index 2bc4751212..754302cb60 100644 --- a/spec/requests/api/v3/projects/version_resource_spec.rb +++ b/spec/requests/api/v3/projects/version_resource_spec.rb @@ -34,7 +34,7 @@ describe "API v3 project's versions resource" do include API::V3::Utilities::PathHelper let(:current_user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role) @@ -42,11 +42,11 @@ describe "API v3 project's versions resource" do user end - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:other_project) { FactoryGirl.create(:project, is_public: false) } - let(:versions) { FactoryGirl.create_list(:version, 4, project: project) } - let(:other_versions) { FactoryGirl.create_list(:version, 2) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:other_project) { FactoryBot.create(:project, is_public: false) } + let(:versions) { FactoryBot.create_list(:version, 4, project: project) } + let(:other_versions) { FactoryBot.create_list(:version, 2) } subject(:response) { last_response } @@ -67,7 +67,7 @@ describe "API v3 project's versions resource" do end context 'logged in user without permission' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } before do current_user diff --git a/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb b/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb index aec668dc99..2f38b050af 100644 --- a/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb +++ b/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb @@ -36,11 +36,11 @@ describe 'API v3 Query Column resource', type: :request do describe '#get queries/columns/:id' do let(:path) { api_v3_paths.query_column(column_name) } let(:column_name) { 'status' } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/create_form_api_spec.rb b/spec/requests/api/v3/queries/create_form_api_spec.rb index 68438c4fa2..07f2d37fe7 100644 --- a/spec/requests/api/v3/queries/create_form_api_spec.rb +++ b/spec/requests/api/v3/queries/create_form_api_spec.rb @@ -34,8 +34,8 @@ describe "POST /api/v3/queries/form", type: :request do include API::V3::Utilities::PathHelper let(:path) { api_v3_paths.create_query_form } - let(:user) { FactoryGirl.create(:admin) } - let!(:project) { FactoryGirl.create(:project_with_types) } + let(:user) { FactoryBot.create(:admin) } + let!(:project) { FactoryBot.create(:project_with_types) } let(:parameters) { {} } let(:override_params) { {} } @@ -158,7 +158,7 @@ describe "POST /api/v3/queries/form", type: :request do let(:relation_columns_allowed) { true } let(:custom_field) do - cf = FactoryGirl.create(:list_wp_custom_field) + cf = FactoryBot.create(:list_wp_custom_field) project.work_package_custom_fields << cf cf.types << project.types.first @@ -166,7 +166,7 @@ describe "POST /api/v3/queries/form", type: :request do end let(:non_project_type) do - FactoryGirl.create(:type) + FactoryBot.create(:type) end let(:additional_setup) do @@ -251,7 +251,7 @@ describe "POST /api/v3/queries/form", type: :request do let(:relation_columns_allowed) { true } let(:custom_field) do - cf = FactoryGirl.create(:list_wp_custom_field) + cf = FactoryBot.create(:list_wp_custom_field) project.work_package_custom_fields << cf cf.types << project.types.first @@ -259,7 +259,7 @@ describe "POST /api/v3/queries/form", type: :request do end let(:non_project_type) do - FactoryGirl.create(:type) + FactoryBot.create(:type) end let(:additional_setup) do @@ -329,7 +329,7 @@ describe "POST /api/v3/queries/form", type: :request do end describe 'with all parameters given' do - let(:status) { FactoryGirl.create :status } + let(:status) { FactoryBot.create :status } let(:parameters) do { @@ -554,7 +554,7 @@ describe "POST /api/v3/queries/form", type: :request do end context "with an unauthorized user trying to set the query public" do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } it "should reject the request" do expect(form.dig("_embedded", "validationErrors", "public", "message")) diff --git a/spec/requests/api/v3/queries/create_query_spec.rb b/spec/requests/api/v3/queries/create_query_spec.rb index f45155d5cb..dec5d31e2b 100644 --- a/spec/requests/api/v3/queries/create_query_spec.rb +++ b/spec/requests/api/v3/queries/create_query_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe "POST /api/v3/queries", type: :request do - let(:user) { FactoryGirl.create :admin } - let(:status) { FactoryGirl.create :status } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:status) { FactoryBot.create :status } + let(:project) { FactoryBot.create :project } let(:params) do { diff --git a/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb b/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb index 3b73ac9cc8..3b94f37fb0 100644 --- a/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb +++ b/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb @@ -36,11 +36,11 @@ describe 'API v3 Query Filter resource', type: :request do describe '#get queries/filters/:id' do let(:path) { api_v3_paths.query_filter(filter_name) } let(:filter_name) { 'assignee' } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end @@ -80,7 +80,7 @@ describe 'API v3 Query Filter resource', type: :request do end context 'custom field filter' do - let(:list_wp_custom_field) { FactoryGirl.create(:list_wp_custom_field) } + let(:list_wp_custom_field) { FactoryBot.create(:list_wp_custom_field) } let(:filter_name) { "customField#{list_wp_custom_field.id}" } it 'succeeds' do diff --git a/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb b/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb index 3505c80a27..9a97dd78ca 100644 --- a/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb +++ b/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb @@ -36,11 +36,11 @@ describe 'API v3 Query Group By resource', type: :request do describe '#get queries/group_bys/:id' do let(:path) { api_v3_paths.query_group_by(group_by_name) } let(:group_by_name) { 'status' } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb b/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb index 0437f63b5b..f257414762 100644 --- a/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb +++ b/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb @@ -36,11 +36,11 @@ describe 'API v3 Query Operator resource', type: :request do describe '#get queries/operators/:id' do let(:path) { api_v3_paths.query_operator(CGI.escape(operator)) } let(:operator) { '=' } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/queries_by_project_resource_spec.rb b/spec/requests/api/v3/queries/queries_by_project_resource_spec.rb index 9dc26cc4f1..06c499f258 100644 --- a/spec/requests/api/v3/queries/queries_by_project_resource_spec.rb +++ b/spec/requests/api/v3/queries/queries_by_project_resource_spec.rb @@ -33,11 +33,11 @@ describe 'API v3 Query resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project, identifier: 'test_project', is_public: false) } + let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) } let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } before do diff --git a/spec/requests/api/v3/queries/query_resource_spec.rb b/spec/requests/api/v3/queries/query_resource_spec.rb index cf035a7424..12f70e20de 100644 --- a/spec/requests/api/v3/queries/query_resource_spec.rb +++ b/spec/requests/api/v3/queries/query_resource_spec.rb @@ -33,20 +33,20 @@ describe 'API v3 Query resource', type: :request, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project, identifier: 'test_project', is_public: false) } - let(:other_project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) } + let(:other_project) { FactoryBot.create(:project) } let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:manage_public_queries_role) do - FactoryGirl.create(:role, permissions: [:manage_public_queries]) + FactoryBot.create(:role, permissions: [:manage_public_queries]) end - let(:query) { FactoryGirl.create(:public_query, project: project) } - let(:other_query) { FactoryGirl.create(:public_query, project: other_project) } - let(:global_query) { FactoryGirl.create(:global_query) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:query) { FactoryBot.create(:public_query, project: project) } + let(:other_query) { FactoryBot.create(:public_query, project: other_project) } + let(:global_query) { FactoryBot.create(:global_query) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } before do allow(User).to receive(:current).and_return current_user @@ -77,7 +77,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do context 'user not allowed to see queries' do include_context 'with non-member permissions from non_member_permissions' - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } let(:non_member_permissions) { [:view_work_packages] } it 'should succeed' do @@ -103,7 +103,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do global_query other_query - FactoryGirl.create(:member, + FactoryBot.create(:member, roles: [role], project: other_query.project, user: current_user) @@ -134,7 +134,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do global_query other_query - FactoryGirl.create(:member, + FactoryBot.create(:member, roles: [role], project: other_query.project, user: current_user) @@ -297,7 +297,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do describe 'private queries' do context 'user with permission to save queries' do - let(:query) { FactoryGirl.create(:private_query, project: project, user: current_user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) } let(:permissions) { [:view_work_packages, :save_queries] } context 'starring his own query' do @@ -311,15 +311,15 @@ describe 'API v3 Query resource', type: :request, content_type: :json do end context 'trying to star somebody else\'s query' do - let(:another_user) { FactoryGirl.create(:user) } - let(:query) { FactoryGirl.create(:private_query, project: project, user: another_user) } + let(:another_user) { FactoryBot.create(:user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: another_user) } it_behaves_like 'not found' end end context 'user without permission to save queries' do - let(:query) { FactoryGirl.create(:private_query, project: project, user: current_user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) } let(:permissions) { [:view_work_packages] } it_behaves_like 'unauthorized access' @@ -331,14 +331,14 @@ describe 'API v3 Query resource', type: :request, content_type: :json do let(:unstar_path) { api_v3_paths.query_unstar query.id } describe 'public queries' do - let(:query) { FactoryGirl.create(:public_query, project: project) } + let(:query) { FactoryBot.create(:public_query, project: project) } context 'user with permission to manage public queries' do let(:permissions) { [:view_work_packages, :manage_public_queries] } context 'when unstarring a starred query' do before(:each) do - FactoryGirl.create(:query_menu_item, query: query) + FactoryBot.create(:query_menu_item, query: query) patch unstar_path end @@ -390,7 +390,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do describe 'private queries' do context 'user with permission to save queries' do - let(:query) { FactoryGirl.create(:private_query, project: project, user: current_user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) } let(:permissions) { [:view_work_packages, :save_queries] } before(:each) do patch unstar_path @@ -407,15 +407,15 @@ describe 'API v3 Query resource', type: :request, content_type: :json do end context 'trying to unstar somebody else\'s query' do - let(:another_user) { FactoryGirl.create(:user) } - let(:query) { FactoryGirl.create(:private_query, project: project, user: another_user) } + let(:another_user) { FactoryBot.create(:user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: another_user) } it_behaves_like 'not found' end end context 'user without permission to save queries' do - let(:query) { FactoryGirl.create(:private_query, project: project, user: current_user) } + let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) } let(:permissions) { [:view_work_packages] } before(:each) do patch unstar_path diff --git a/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb b/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb index 2bfd4acc4b..de057f493c 100644 --- a/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb +++ b/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb @@ -33,17 +33,17 @@ describe 'API v3 Query Filter Schema resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:visible_child) do - child = FactoryGirl.create(:project, parent: project) + child = FactoryBot.create(:project, parent: project) child.add_member! user, role child end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/schemas/query_project_schema_resource_spec.rb b/spec/requests/api/v3/queries/schemas/query_project_schema_resource_spec.rb index 95cb77a702..8a675e47bf 100644 --- a/spec/requests/api/v3/queries/schemas/query_project_schema_resource_spec.rb +++ b/spec/requests/api/v3/queries/schemas/query_project_schema_resource_spec.rb @@ -33,11 +33,11 @@ describe 'API v3 Query Schema resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb b/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb index fca50618bd..a72ea1f4b8 100644 --- a/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb +++ b/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb @@ -33,11 +33,11 @@ describe 'API v3 Query Schema resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb b/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb index 292accc1c5..ad7e5c4199 100644 --- a/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb +++ b/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb @@ -37,11 +37,11 @@ describe 'API v3 Query Sort Bys resource', type: :request do let(:path) { api_v3_paths.query_sort_by(column_name, direction) } let(:column_name) { 'status' } let(:direction) { 'desc' } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end diff --git a/spec/requests/api/v3/queries/update_form_api_spec.rb b/spec/requests/api/v3/queries/update_form_api_spec.rb index a702ff2957..96bbd6781f 100644 --- a/spec/requests/api/v3/queries/update_form_api_spec.rb +++ b/spec/requests/api/v3/queries/update_form_api_spec.rb @@ -34,14 +34,14 @@ describe "POST /api/v3/queries/form", type: :request do include API::V3::Utilities::PathHelper let(:path) { api_v3_paths.query_form(query.id) } - let(:user) { FactoryGirl.create(:admin) } - let(:role) { FactoryGirl.create :existing_role, permissions: permissions } + let(:user) { FactoryBot.create(:admin) } + let(:role) { FactoryBot.create :existing_role, permissions: permissions } let(:permissions) { %i(view_work_packages manage_public_queries) } - let!(:project) { FactoryGirl.create(:project_with_types) } + let!(:project) { FactoryBot.create(:project_with_types) } let(:query) do - FactoryGirl.create( + FactoryBot.create( :query, name: "Existing Query", is_public: false, @@ -128,7 +128,7 @@ describe "POST /api/v3/queries/form", type: :request do end let(:custom_field) do - cf = FactoryGirl.create(:list_wp_custom_field) + cf = FactoryBot.create(:list_wp_custom_field) project.work_package_custom_fields << cf cf.types << project.types.first @@ -136,7 +136,7 @@ describe "POST /api/v3/queries/form", type: :request do end let(:non_project_type) do - FactoryGirl.create(:type) + FactoryBot.create(:type) end let(:static_columns_json) do @@ -307,7 +307,7 @@ describe "POST /api/v3/queries/form", type: :request do end describe 'with all parameters given' do - let(:status) { FactoryGirl.create :status } + let(:status) { FactoryBot.create :status } let(:parameters) do { @@ -516,7 +516,7 @@ describe "POST /api/v3/queries/form", type: :request do end context "with an unauthorized user trying to set the query public" do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:permissions) { [:view_work_packages] } it "should reject the request" do diff --git a/spec/requests/api/v3/queries/update_query_spec.rb b/spec/requests/api/v3/queries/update_query_spec.rb index be23d12644..31dc7ebddb 100644 --- a/spec/requests/api/v3/queries/update_query_spec.rb +++ b/spec/requests/api/v3/queries/update_query_spec.rb @@ -29,16 +29,16 @@ require 'spec_helper' describe "PATCH /api/v3/queries/:id", type: :request do - let(:user) { FactoryGirl.create :admin } - let(:status) { FactoryGirl.create :status } - let(:project) { FactoryGirl.create :project } + let(:user) { FactoryBot.create :admin } + let(:status) { FactoryBot.create :status } + let(:project) { FactoryBot.create :project } def json JSON.parse last_response.body end let!(:query) do - FactoryGirl.create( + FactoryBot.create( :global_query, name: "A Query", user: user, diff --git a/spec/requests/api/v3/relations/relations_api_spec.rb b/spec/requests/api/v3/relations/relations_api_spec.rb index 0e7eb47f24..4a94e7a0db 100644 --- a/spec/requests/api/v3/relations/relations_api_spec.rb +++ b/spec/requests/api/v3/relations/relations_api_spec.rb @@ -31,10 +31,10 @@ require 'spec_helper' describe 'API v3 Relation resource', type: :request, content_type: :json do include API::V3::Utilities::PathHelper - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let!(:from) { FactoryGirl.create :work_package } - let!(:to) { FactoryGirl.create :work_package } + let!(:from) { FactoryBot.create :work_package } + let!(:to) { FactoryBot.create :work_package } let(:type) { "follows" } let(:description) { "This first" } @@ -56,7 +56,7 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do } end let(:relation) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: from, to: to, relation_type: type, @@ -105,13 +105,13 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do context 'relation that would create a circular scheduling dependency' do let(:from_child) do - FactoryGirl.create(:work_package, parent: from) + FactoryBot.create(:work_package, parent: from) end let(:to_child) do - FactoryGirl.create(:work_package, parent: to) + FactoryBot.create(:work_package, parent: to) end let(:children_follows_relation) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: to_child, to: from_child, relation_type: Relation::TYPE_FOLLOWS @@ -134,19 +134,19 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do context 'follows relation within siblings' do let(:sibling) do - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end let(:other_sibling) do - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end let(:parent) do - wp = FactoryGirl.create(:work_package) + wp = FactoryBot.create(:work_package) wp.children = [sibling, from, to, other_sibling] end let(:existing_follows) do - FactoryGirl.create(:relation, relation_type: 'follows', from: to, to: sibling) - FactoryGirl.create(:relation, relation_type: 'follows', from: other_sibling, to: from) + FactoryBot.create(:relation, relation_type: 'follows', from: to, to: sibling) + FactoryBot.create(:relation, relation_type: 'follows', from: other_sibling, to: from) end let(:setup) do @@ -159,18 +159,18 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do context 'follows relation to sibling\'s child' do let(:sibling) do - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end let(:sibling_child) do - FactoryGirl.create(:work_package, parent: sibling) + FactoryBot.create(:work_package, parent: sibling) end let(:parent) do - wp = FactoryGirl.create(:work_package) + wp = FactoryBot.create(:work_package) wp.children = [sibling, from, to] end let(:existing_follows) do - FactoryGirl.create(:relation, relation_type: 'follows', from: to, to: sibling_child) + FactoryBot.create(:relation, relation_type: 'follows', from: to, to: sibling_child) end let(:setup) do @@ -237,7 +237,7 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do end context "with trying to change an immutable attribute" do - let(:other_wp) { FactoryGirl.create :work_package } + let(:other_wp) { FactoryBot.create :work_package } let(:update) do { @@ -268,18 +268,18 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do end describe "permissions" do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } let(:permissions) { %i(view_work_packages manage_work_package_relations) } let(:role) do - FactoryGirl.create :existing_role, permissions: permissions + FactoryBot.create :existing_role, permissions: permissions end - let(:project) { FactoryGirl.create :project } + let(:project) { FactoryBot.create :project } - let!(:from) { FactoryGirl.create :work_package, project: project } - let!(:to) { FactoryGirl.create :work_package, project: project } + let!(:from) { FactoryBot.create :work_package, project: project } + let!(:to) { FactoryBot.create :work_package, project: project } before do project.add_member! user, role @@ -307,7 +307,7 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do # is in another project for which the user does not have permission to # view work packages. context "without manage_work_package_relations" do - let!(:to) { FactoryGirl.create :work_package } + let!(:to) { FactoryBot.create :work_package } it "should return 422" do expect(last_response.status).to eq 422 @@ -341,35 +341,35 @@ describe 'API v3 Relation resource', type: :request, content_type: :json do end describe 'GET /api/v3/relations?[filter]' do - let(:user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:member_project_to) do - FactoryGirl.build(:member, + FactoryBot.build(:member, project: to.project, user: user, roles: [role]) end let(:member_project_from) do - FactoryGirl.build(:member, + FactoryBot.build(:member, project: from.project, user: user, roles: [role]) end let(:invisible_relation) do - invisible_wp = FactoryGirl.create(:work_package) + invisible_wp = FactoryBot.create(:work_package) - FactoryGirl.create :relation, + FactoryBot.create :relation, from: from, to: invisible_wp end let(:other_visible_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: to.project, type: to.type) end let(:other_visible_relation) do - FactoryGirl.create :relation, + FactoryBot.create :relation, from: to, to: other_visible_work_package end diff --git a/spec/requests/api/v3/relations/relations_index_spec.rb b/spec/requests/api/v3/relations/relations_index_spec.rb index 5523bbf625..f25a16ab44 100644 --- a/spec/requests/api/v3/relations/relations_index_spec.rb +++ b/spec/requests/api/v3/relations/relations_index_spec.rb @@ -29,21 +29,21 @@ require 'spec_helper' describe 'GET /api/v3/relations', type: :request do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:work_package) { FactoryGirl.create :work_package } - let(:other_work_package) { FactoryGirl.create :work_package } + let(:work_package) { FactoryBot.create :work_package } + let(:other_work_package) { FactoryBot.create :work_package } let!(:relations) do def new_relation(opts = {}) relation_type = opts.delete(:type) - relation = FactoryGirl.create :relation, opts.merge(relation_type: relation_type) + relation = FactoryBot.create :relation, opts.merge(relation_type: relation_type) relation.id end def new_work_package - FactoryGirl.create :work_package + FactoryBot.create :work_package end [ diff --git a/spec/requests/api/v3/relations_resource_spec.rb b/spec/requests/api/v3/relations_resource_spec.rb index 006c38a1c8..2582d51a4a 100644 --- a/spec/requests/api/v3/relations_resource_spec.rb +++ b/spec/requests/api/v3/relations_resource_spec.rb @@ -33,36 +33,36 @@ describe 'API v3 Relation resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project_with_types) } + let(:project) { FactoryBot.create(:project_with_types) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:permissions) { [] } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: project.types.first) end let(:visible_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: project.types.first) end let(:invisible_work_package) do # will be inside another project - FactoryGirl.create(:work_package) + FactoryBot.create(:work_package) end let(:visible_relation) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: work_package, to: visible_work_package) end let(:invisible_relation) do - FactoryGirl.create(:relation, + FactoryBot.create(:relation, from: work_package, to: invisible_work_package) end diff --git a/spec/requests/api/v3/render_resource_spec.rb b/spec/requests/api/v3/render_resource_spec.rb index f8783a647a..c5804cb1cf 100644 --- a/spec/requests/api/v3/render_resource_spec.rb +++ b/spec/requests/api/v3/render_resource_spec.rb @@ -33,9 +33,9 @@ describe 'API v3 Render resource', type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } - let(:user) { FactoryGirl.create(:user, member_in_project: project) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } + let(:user) { FactoryBot.create(:user, member_in_project: project) } let(:content_type) { 'text/plain, charset=UTF-8' } let(:path) { api_v3_paths.render_markup format: format, link: context } let(:format) { nil } @@ -127,7 +127,7 @@ describe 'API v3 Render resource', type: :request do end describe 'work package not visible' do - let(:invisible_work_package) { FactoryGirl.create(:work_package) } + let(:invisible_work_package) { FactoryBot.create(:work_package) } let(:context) { api_v3_paths.work_package invisible_work_package.id } it_behaves_like 'invalid render context', diff --git a/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb b/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb index bf7b761cdb..10abc9294d 100644 --- a/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb +++ b/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb @@ -35,15 +35,15 @@ describe 'API v3 Revisions by work package resource', type: :request do include FileHelpers let(:current_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages, :view_changesets] } - let(:repository) { FactoryGirl.create(:repository_subversion, project: project) } - let(:work_package) { FactoryGirl.create(:work_package, author: current_user, project: project) } + let(:repository) { FactoryBot.create(:repository_subversion, project: project) } + let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) } let(:revisions) { [] } subject(:response) { last_response } @@ -69,7 +69,7 @@ describe 'API v3 Revisions by work package resource', type: :request do context 'with existing revisions' do let(:revisions) { - FactoryGirl.build_list(:changeset, + FactoryBot.build_list(:changeset, 5, comments: "This commit references ##{work_package.id}", repository: repository @@ -86,7 +86,7 @@ describe 'API v3 Revisions by work package resource', type: :request do end context 'user unauthorized to view work package' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } it 'should respond with 404' do expect(subject.status).to eq(404) @@ -94,10 +94,10 @@ describe 'API v3 Revisions by work package resource', type: :request do end describe 'revisions linked from another project' do - let(:subproject) { FactoryGirl.create(:project, parent: project) } - let(:repository) { FactoryGirl.create(:repository_subversion, project: subproject) } + let(:subproject) { FactoryBot.create(:project, parent: project) } + let(:repository) { FactoryBot.create(:repository_subversion, project: subproject) } let!(:revisions) { - FactoryGirl.build_list(:changeset, + FactoryBot.build_list(:changeset, 2, comments: "This commit references ##{work_package.id}", repository: repository @@ -106,7 +106,7 @@ describe 'API v3 Revisions by work package resource', type: :request do context 'with permissions in subproject' do let(:current_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_projects: [project, subproject], member_through_role: role) } diff --git a/spec/requests/api/v3/repositories/revisions_resource_spec.rb b/spec/requests/api/v3/repositories/revisions_resource_spec.rb index 6472fdb5d1..0d9492a8f7 100644 --- a/spec/requests/api/v3/repositories/revisions_resource_spec.rb +++ b/spec/requests/api/v3/repositories/revisions_resource_spec.rb @@ -35,27 +35,27 @@ describe 'API v3 Revisions resource', type: :request do include API::V3::Utilities::PathHelper let(:revision) { - FactoryGirl.create(:changeset, + FactoryBot.create(:changeset, repository: repository, comments: 'Some commit message', committer: 'foo bar ' ) } let(:repository) { - FactoryGirl.create(:repository_subversion, project: project) + FactoryBot.create(:repository_subversion, project: project) } let(:project) { - FactoryGirl.create(:project, identifier: 'test_project', is_public: false) + FactoryBot.create(:project, identifier: 'test_project', is_public: false) } let(:role) { - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: [:view_changesets]) } let(:current_user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:unauthorized_user) { FactoryGirl.create(:user) } + let(:unauthorized_user) { FactoryBot.create(:user) } describe '#get' do let(:get_path) { api_v3_paths.revision revision.id } diff --git a/spec/requests/api/v3/roles/role_resource_spec.rb b/spec/requests/api/v3/roles/role_resource_spec.rb index eabbfc3e8d..bbd06ea877 100644 --- a/spec/requests/api/v3/roles/role_resource_spec.rb +++ b/spec/requests/api/v3/roles/role_resource_spec.rb @@ -33,8 +33,8 @@ describe 'API v3 Role resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:current_user) { FactoryGirl.create(:user) } - let(:role) { FactoryGirl.create(:role) } + let(:current_user) { FactoryBot.create(:user) } + let(:role) { FactoryBot.create(:role) } before do # Avoid having a builtin role left over from another spec diff --git a/spec/requests/api/v3/root_resource_spec.rb b/spec/requests/api/v3/root_resource_spec.rb index b36e3d8256..49efc445e7 100644 --- a/spec/requests/api/v3/root_resource_spec.rb +++ b/spec/requests/api/v3/root_resource_spec.rb @@ -34,10 +34,10 @@ describe 'API v3 Root resource' do include API::V3::Utilities::PathHelper let(:current_user) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:role) { FactoryGirl.create(:role, permissions: []) } - let(:project) { FactoryGirl.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: []) } + let(:project) { FactoryBot.create(:project, is_public: false) } describe '#get' do let(:response) { last_response } diff --git a/spec/requests/api/v3/status_resource_spec.rb b/spec/requests/api/v3/status_resource_spec.rb index cbf9410a02..cb7d8d8a43 100644 --- a/spec/requests/api/v3/status_resource_spec.rb +++ b/spec/requests/api/v3/status_resource_spec.rb @@ -33,15 +33,15 @@ describe 'API v3 Status resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, is_public: false) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let!(:statuses) { FactoryGirl.create_list(:status, 4) } + let!(:statuses) { FactoryBot.create_list(:status, 4) } describe 'statuses' do describe '#get' do diff --git a/spec/requests/api/v3/support/api_helper.rb b/spec/requests/api/v3/support/api_helper.rb index 1660fcb952..b46b3e1684 100644 --- a/spec/requests/api/v3/support/api_helper.rb +++ b/spec/requests/api/v3/support/api_helper.rb @@ -32,7 +32,7 @@ end shared_examples_for 'valid activity request' do let(:status_code) { 200 } - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return(admin) @@ -50,7 +50,7 @@ shared_examples_for 'valid activity request' do end shared_examples_for 'invalid activity request' do - let(:admin) { FactoryGirl.create(:admin) } + let(:admin) { FactoryBot.create(:admin) } before do allow(User).to receive(:current).and_return(admin) end diff --git a/spec/requests/api/v3/time_entry_activity_resource_spec.rb b/spec/requests/api/v3/time_entry_activity_resource_spec.rb index b653c5c7e0..a36410ca79 100644 --- a/spec/requests/api/v3/time_entry_activity_resource_spec.rb +++ b/spec/requests/api/v3/time_entry_activity_resource_spec.rb @@ -34,11 +34,11 @@ describe 'API v3 time_entry_activity resource', type: :request do include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:activity) { FactoryGirl.create(:time_entry_activity) } - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:activity) { FactoryBot.create(:time_entry_activity) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { %i(view_time_entries) } subject(:response) { last_response } diff --git a/spec/requests/api/v3/time_entry_resource_spec.rb b/spec/requests/api/v3/time_entry_resource_spec.rb index a6e2d945d3..511f78146f 100644 --- a/spec/requests/api/v3/time_entry_resource_spec.rb +++ b/spec/requests/api/v3/time_entry_resource_spec.rb @@ -34,27 +34,27 @@ describe 'API v3 time_entry resource', type: :request do include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:time_entry) do - FactoryGirl.create(:time_entry, project: project, work_package: work_package, user: current_user) + FactoryBot.create(:time_entry, project: project, work_package: work_package, user: current_user) end let(:other_time_entry) do - FactoryGirl.create(:time_entry, project: project, work_package: work_package, user: other_user) + FactoryBot.create(:time_entry, project: project, work_package: work_package, user: other_user) end let(:other_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:invisible_time_entry) do - FactoryGirl.create(:time_entry, project: other_project, work_package: other_work_package, user: other_user) + FactoryBot.create(:time_entry, project: other_project, work_package: other_work_package, user: other_user) end let(:project) { work_package.project } - let(:work_package) { FactoryGirl.create(:work_package) } - let(:other_work_package) { FactoryGirl.create(:work_package) } + let(:work_package) { FactoryBot.create(:work_package) } + let(:other_work_package) { FactoryBot.create(:work_package) } let(:other_project) { other_work_package.project } - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { %i(view_time_entries view_work_packages) } - let(:custom_field) { FactoryGirl.create(:time_entry_custom_field) } + let(:custom_field) { FactoryBot.create(:time_entry_custom_field) } let(:custom_value) do CustomValue.create(custom_field: custom_field, value: '1234', @@ -136,7 +136,7 @@ describe 'API v3 time_entry resource', type: :request do context 'filtering by user' do let(:invisible_time_entry) do - FactoryGirl.create(:time_entry, project: other_project, work_package: other_work_package, user: other_user) + FactoryBot.create(:time_entry, project: other_project, work_package: other_work_package, user: other_user) end before do @@ -169,11 +169,11 @@ describe 'API v3 time_entry resource', type: :request do context 'filtering by work package' do let(:unwanted_work_package) do - FactoryGirl.create(:work_package, project: project, type: project.types.first) + FactoryBot.create(:work_package, project: project, type: project.types.first) end let(:other_time_entry) do - FactoryGirl.create(:time_entry, project: project, work_package: unwanted_work_package, user: current_user) + FactoryBot.create(:time_entry, project: project, work_package: unwanted_work_package, user: current_user) end let(:path) do @@ -206,11 +206,11 @@ describe 'API v3 time_entry resource', type: :request do context 'filtering by project' do let(:other_time_entry) do - FactoryGirl.create(:time_entry, project: other_project, work_package: other_work_package, user: current_user) + FactoryBot.create(:time_entry, project: other_project, work_package: other_work_package, user: current_user) end before do - FactoryGirl.create(:member, + FactoryBot.create(:member, roles: [role], project: other_project, user: current_user) diff --git a/spec/requests/api/v3/types/type_resource_spec.rb b/spec/requests/api/v3/types/type_resource_spec.rb index 1538062f42..b125b2759d 100644 --- a/spec/requests/api/v3/types/type_resource_spec.rb +++ b/spec/requests/api/v3/types/type_resource_spec.rb @@ -33,15 +33,15 @@ describe 'API v3 Type resource' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, no_types: true, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, no_types: true, is_public: false) } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let!(:types) { FactoryGirl.create_list(:type, 4) } + let!(:types) { FactoryBot.create_list(:type, 4) } describe 'types' do describe '#get' do diff --git a/spec/requests/api/v3/types/types_by_project_resource_spec.rb b/spec/requests/api/v3/types/types_by_project_resource_spec.rb index f140152e79..9faa55abaf 100644 --- a/spec/requests/api/v3/types/types_by_project_resource_spec.rb +++ b/spec/requests/api/v3/types/types_by_project_resource_spec.rb @@ -33,17 +33,17 @@ describe '/api/v3/projects/:id/types' do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, no_types: true, is_public: false) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, no_types: true, is_public: false) } let(:requested_project) { project } let(:current_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let!(:irrelevant_types) { FactoryGirl.create_list(:type, 4) } - let!(:expected_types) { FactoryGirl.create_list(:type, 4) } + let!(:irrelevant_types) { FactoryBot.create_list(:type, 4) } + let!(:expected_types) { FactoryBot.create_list(:type, 4) } describe '#get' do let(:get_path) { api_v3_paths.types_by_project requested_project.id } @@ -79,7 +79,7 @@ describe '/api/v3/projects/:id/types' do end context 'in a foreign project' do - let(:requested_project) { FactoryGirl.create(:project, is_public: false) } + let(:requested_project) { FactoryBot.create(:project, is_public: false) } it_behaves_like 'not found' end diff --git a/spec/requests/api/v3/user/create_user_resource_spec.rb b/spec/requests/api/v3/user/create_user_resource_spec.rb index 0324ffbc2f..bccde2cf8f 100644 --- a/spec/requests/api/v3/user/create_user_resource_spec.rb +++ b/spec/requests/api/v3/user/create_user_resource_spec.rb @@ -33,7 +33,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do include API::V3::Utilities::PathHelper let(:path) { api_v3_paths.users } - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } let(:parameters) { {} } before do @@ -97,7 +97,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do context 'with auth_source' do let(:auth_source_id) { 'some_ldap' } - let(:auth_source) { FactoryGirl.create :auth_source, name: auth_source_id } + let(:auth_source) { FactoryBot.create :auth_source, name: auth_source_id } context 'ID' do before do @@ -285,7 +285,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do end describe 'unauthorized user' do - let(:user) { FactoryGirl.build(:user) } + let(:user) { FactoryBot.build(:user) } let(:parameters) { { status: 'invited', email: 'foo@example.org' } } it 'returns an erroneous response' do diff --git a/spec/requests/api/v3/user/filters_spec.rb b/spec/requests/api/v3/user/filters_spec.rb index 5d768497d9..2b7029688a 100644 --- a/spec/requests/api/v3/user/filters_spec.rb +++ b/spec/requests/api/v3/user/filters_spec.rb @@ -32,10 +32,10 @@ require 'spec_helper' describe 'GET /api/v3/users', type: :request do let!(:users) do [ - FactoryGirl.create(:admin, login: 'admin', status: Principal::STATUSES[:active]), - FactoryGirl.create(:user, login: 'h.wurst', status: Principal::STATUSES[:active]), - FactoryGirl.create(:user, login: 'h.heine', status: Principal::STATUSES[:locked]), - FactoryGirl.create(:user, login: 'm.mario', status: Principal::STATUSES[:active]) + FactoryBot.create(:admin, login: 'admin', status: Principal::STATUSES[:active]), + FactoryBot.create(:user, login: 'h.wurst', status: Principal::STATUSES[:active]), + FactoryBot.create(:user, login: 'h.heine', status: Principal::STATUSES[:locked]), + FactoryBot.create(:user, login: 'm.mario', status: Principal::STATUSES[:active]) ] end diff --git a/spec/requests/api/v3/user/update_user_resource_spec.rb b/spec/requests/api/v3/user/update_user_resource_spec.rb index cc493a93bb..f9bddd2e89 100644 --- a/spec/requests/api/v3/user/update_user_resource_spec.rb +++ b/spec/requests/api/v3/user/update_user_resource_spec.rb @@ -33,9 +33,9 @@ describe ::API::V3::Users::UsersAPI, type: :request do include API::V3::Utilities::PathHelper let(:path) { api_v3_paths.user(user.id) } - let(:current_user) { FactoryGirl.build(:admin) } + let(:current_user) { FactoryBot.build(:admin) } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } let(:parameters) { {} } before do @@ -89,7 +89,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do describe 'attribute collision' do let(:parameters) { { email: 'foo@example.org' } } - let(:collision) { FactoryGirl.create(:user, mail: 'foo@example.org') } + let(:collision) { FactoryBot.create(:user, mail: 'foo@example.org') } before do collision end @@ -120,7 +120,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do end describe 'unauthorized user' do - let(:current_user) { FactoryGirl.build(:user) } + let(:current_user) { FactoryBot.build(:user) } let(:parameters) { { email: 'new@example.org' } } it 'returns an erroneous response' do diff --git a/spec/requests/api/v3/user/user_resource_spec.rb b/spec/requests/api/v3/user/user_resource_spec.rb index 0c2015e693..3e2d428d04 100644 --- a/spec/requests/api/v3/user/user_resource_spec.rb +++ b/spec/requests/api/v3/user/user_resource_spec.rb @@ -33,8 +33,8 @@ describe 'API v3 User resource', type: :request, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:current_user) { FactoryGirl.create(:user) } - let(:user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } + let(:user) { FactoryBot.create(:user) } subject(:response) { last_response } @@ -48,7 +48,7 @@ describe 'API v3 User resource', type: :request, content_type: :json do end context 'admin user' do - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } it 'should respond with 200' do expect(subject.status).to eq(200) @@ -243,7 +243,7 @@ describe 'API v3 User resource', type: :request, content_type: :json do end context 'with non-admin user' do - let(:current_user) { FactoryGirl.create :user, admin: false } + let(:current_user) { FactoryBot.create :user, admin: false } it 'responds with 403' do expect(subject.status).to eq 403 @@ -262,7 +262,7 @@ describe 'API v3 User resource', type: :request, content_type: :json do end context 'as admin' do - let(:current_user) { FactoryGirl.create :admin } + let(:current_user) { FactoryBot.create :admin } context 'with users deletable by admins' do let(:admin_delete) { true } @@ -278,7 +278,7 @@ describe 'API v3 User resource', type: :request, content_type: :json do end context 'as non-admin' do - let(:current_user) { FactoryGirl.create :user, admin: false } + let(:current_user) { FactoryBot.create :user, admin: false } it_behaves_like 'deletion is not allowed' end @@ -300,7 +300,7 @@ describe 'API v3 User resource', type: :request, content_type: :json do end context 'as anonymous user' do - let(:current_user) { FactoryGirl.create :anonymous } + let(:current_user) { FactoryBot.create :anonymous } it_behaves_like 'deletion is not allowed' diff --git a/spec/requests/api/v3/user/userlock_resource_spec.rb b/spec/requests/api/v3/user/userlock_resource_spec.rb index 2159d32ca3..9f89d952a7 100644 --- a/spec/requests/api/v3/user/userlock_resource_spec.rb +++ b/spec/requests/api/v3/user/userlock_resource_spec.rb @@ -33,8 +33,8 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:current_user) { FactoryGirl.build_stubbed(:user) } - let(:user) { FactoryGirl.create(:user, status: User::STATUSES[:active]) } + let(:current_user) { FactoryBot.build_stubbed(:user) } + let(:user) { FactoryBot.create(:user, status: User::STATUSES[:active]) } let(:model) { ::API::V3::Users::UserModel.new(user) } let(:representer) { ::API::V3::Users::UserRepresenter.new(model) } let(:lock_path) { api_v3_paths.user_lock user.id } @@ -50,7 +50,7 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do # Locking is only available for admins context 'when logged in as admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } context 'user account can be locked' do it 'should respond with 200' do @@ -64,7 +64,7 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do context 'user account is incompatible' do let(:user) { - FactoryGirl.create(:user, status: User::STATUSES[:registered]) + FactoryBot.create(:user, status: User::STATUSES[:registered]) } it 'should fail for invalid transitions' do expect(subject.status).to eq(400) @@ -97,7 +97,7 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do # Unlocking is only available for admins context 'when logged in as admin' do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } context 'user account can be unlocked' do it 'should respond with 200' do @@ -111,7 +111,7 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do context 'user account is incompatible' do let(:user) { - FactoryGirl.create(:user, status: User::STATUSES[:registered]) + FactoryBot.create(:user, status: User::STATUSES[:registered]) } it 'should fail for invalid transitions' do expect(subject.status).to eq(400) diff --git a/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb b/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb index 10d3d76aff..0f04639013 100644 --- a/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb +++ b/spec/requests/api/v3/user_preferences/user_preferences_resource_spec.rb @@ -33,8 +33,8 @@ describe 'API v3 UserPreferences resource', type: :request do include Rack::Test::Methods include ::API::V3::Utilities::PathHelper - let(:user) { FactoryGirl.create(:user) } - let(:preference) { FactoryGirl.create(:user_preference, user: user) } + let(:user) { FactoryBot.create(:user) } + let(:preference) { FactoryBot.create(:user_preference, user: user) } let(:representer) { described_class.new(preference, current_user: user) } let(:preference_path) { api_v3_paths.my_preferences } subject(:response) { last_response } diff --git a/spec/requests/api/v3/version_resource_spec.rb b/spec/requests/api/v3/version_resource_spec.rb index 3216be80f3..aa871d2f9d 100644 --- a/spec/requests/api/v3/version_resource_spec.rb +++ b/spec/requests/api/v3/version_resource_spec.rb @@ -34,7 +34,7 @@ describe 'API v3 Version resource' do include API::V3::Utilities::PathHelper let(:current_user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role) @@ -42,12 +42,12 @@ describe 'API v3 Version resource' do user end - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:other_project) { FactoryGirl.create(:project, is_public: false) } - let(:version_in_project) { FactoryGirl.build(:version, project: project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:other_project) { FactoryBot.create(:project, is_public: false) } + let(:version_in_project) { FactoryBot.build(:version, project: project) } let(:version_in_other_project) do - FactoryGirl.build(:version, project: other_project, + FactoryBot.build(:version, project: other_project, sharing: 'system') end @@ -96,7 +96,7 @@ describe 'API v3 Version resource' do end context 'logged in user without permission' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } before(:each) do version_in_project.save! @@ -136,7 +136,7 @@ describe 'API v3 Version resource' do context 'filtering for project by sharing' do let(:shared_version_in_project) do - FactoryGirl.build(:version, project: project, sharing: 'system') + FactoryBot.build(:version, project: project, sharing: 'system') end let(:versions) { [version_in_project, shared_version_in_project] } diff --git a/spec/requests/api/v3/versions/project_resource_spec.rb b/spec/requests/api/v3/versions/project_resource_spec.rb index fdb800b5db..ca9854239a 100644 --- a/spec/requests/api/v3/versions/project_resource_spec.rb +++ b/spec/requests/api/v3/versions/project_resource_spec.rb @@ -34,7 +34,7 @@ describe "API v3 version's projects resource" do include API::V3::Utilities::PathHelper let(:current_user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role) @@ -42,13 +42,13 @@ describe "API v3 version's projects resource" do user end - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:role_without_permissions) { FactoryGirl.create(:role, permissions: []) } - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:project2) { FactoryGirl.create(:project, is_public: false) } - let(:project3) { FactoryGirl.create(:project, is_public: false) } - let(:project4) { FactoryGirl.create(:project, is_public: false) } - let(:version) { FactoryGirl.create(:version, project: project, sharing: 'system') } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:role_without_permissions) { FactoryBot.create(:role, permissions: []) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:project2) { FactoryBot.create(:project, is_public: false) } + let(:project3) { FactoryBot.create(:project, is_public: false) } + let(:project4) { FactoryBot.create(:project, is_public: false) } + let(:version) { FactoryBot.create(:version, project: project, sharing: 'system') } subject(:response) { last_response } @@ -60,12 +60,12 @@ describe "API v3 version's projects resource" do current_user # this is to be included - FactoryGirl.create(:member, user: current_user, + FactoryBot.create(:member, user: current_user, project: project2, roles: [role]) # this is to be included as the user is a member of the project, the # lack of permissions is irrelevant. - FactoryGirl.create(:member, user: current_user, + FactoryBot.create(:member, user: current_user, project: project3, roles: [role_without_permissions]) # project4 should NOT be included diff --git a/spec/requests/api/v3/watcher_resource_spec.rb b/spec/requests/api/v3/watcher_resource_spec.rb index bf84204210..bfac4ce184 100644 --- a/spec/requests/api/v3/watcher_resource_spec.rb +++ b/spec/requests/api/v3/watcher_resource_spec.rb @@ -33,16 +33,16 @@ describe 'API v3 Watcher resource', type: :request, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project, identifier: 'test_project', is_public: false) } + let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) } let(:current_user) do - FactoryGirl.create :user, member_in_project: project, member_through_role: role + FactoryBot.create :user, member_in_project: project, member_through_role: role end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [] } - let(:view_work_packages_role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:view_work_packages_role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:available_watcher) do - FactoryGirl.create :user, + FactoryBot.create :user, firstname: 'Something', lastname: 'Strange', member_in_project: project, @@ -50,12 +50,12 @@ describe 'API v3 Watcher resource', type: :request, content_type: :json do end let(:watching_user) do - FactoryGirl.create :user, + FactoryBot.create :user, member_in_project: project, member_through_role: view_work_packages_role end let(:existing_watcher) do - FactoryGirl.create(:watcher, watchable: work_package, user: watching_user) + FactoryBot.create(:watcher, watchable: work_package, user: watching_user) end subject(:response) { last_response } @@ -143,7 +143,7 @@ describe 'API v3 Watcher resource', type: :request, content_type: :json do end context 'when the target user is not allowed to watch the work package' do - let(:new_watcher) { FactoryGirl.create(:user) } + let(:new_watcher) { FactoryBot.create(:user) } it_behaves_like 'constraint violation' do let(:message) { 'User is invalid' } diff --git a/spec/requests/api/v3/work_package_resource_spec.rb b/spec/requests/api/v3/work_package_resource_spec.rb index afd3ce5623..169e2e5cbc 100644 --- a/spec/requests/api/v3/work_package_resource_spec.rb +++ b/spec/requests/api/v3/work_package_resource_spec.rb @@ -34,34 +34,34 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do include Capybara::RSpecMatchers include API::V3::Utilities::PathHelper - let(:closed_status) { FactoryGirl.create(:closed_status) } + let(:closed_status) { FactoryBot.create(:closed_status) } let(:work_package) { - FactoryGirl.create(:work_package, project_id: project.id, + FactoryBot.create(:work_package, project_id: project.id, description: 'lorem ipsum' ) } let(:project) do - FactoryGirl.create(:project, identifier: 'test_project', is_public: false) + FactoryBot.create(:project, identifier: 'test_project', is_public: false) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages, :edit_work_packages] } let(:current_user) do - user = FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + user = FactoryBot.create(:user, member_in_project: project, member_through_role: role) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) user end let(:watcher) do - FactoryGirl + FactoryBot .create(:user, member_in_project: project, member_through_role: role) .tap do |user| work_package.add_watcher(user) end end - let(:unauthorize_user) { FactoryGirl.create(:user) } - let(:type) { FactoryGirl.create(:type) } + let(:unauthorize_user) { FactoryBot.create(:user) } + let(:type) { FactoryBot.create(:type) } before do allow(User).to receive(:current).and_return current_user @@ -84,12 +84,12 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end it 'returns visible work packages' do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) expect(subject.body).to be_json_eql(1.to_json).at_path('total') end it 'embedds the work package schemas' do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) expect(subject.body) .to be_json_eql(api_v3_paths.work_package_schema(project.id, work_package.type.id).to_json) @@ -98,7 +98,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do context 'user not seeing any work packages' do include_context 'with non-member permissions from non_member_permissions' - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } let(:non_member_permissions) { [:view_work_packages] } it 'succeeds' do @@ -106,7 +106,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end it 'returns no work packages' do - FactoryGirl.create(:work_package, project: project) + FactoryBot.create(:work_package, project: project) expect(subject.body).to be_json_eql(0.to_json).at_path('total') end @@ -134,11 +134,11 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do describe 'response body' do subject(:parsed_response) { JSON.parse(last_response.body) } let!(:other_wp) { - FactoryGirl.create(:work_package, project_id: project.id, + FactoryBot.create(:work_package, project_id: project.id, status: closed_status) } let(:work_package) { - FactoryGirl.create(:work_package, project_id: project.id, + FactoryBot.create(:work_package, project_id: project.id, description: description ) } @@ -234,8 +234,8 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do context 'user without needed permissions' do context 'no permission to see the work package' do - let(:work_package) { FactoryGirl.create(:work_package) } - let(:current_user) { FactoryGirl.create :user } + let(:work_package) { FactoryBot.create(:work_package) } + let(:current_user) { FactoryBot.create :user } let(:params) { valid_params } include_context 'patch request' @@ -244,9 +244,9 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'no permission to edit the work package' do - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:current_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: work_package.project, member_through_role: role) } @@ -383,7 +383,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'status' do - let(:target_status) { FactoryGirl.create(:status) } + let(:target_status) { FactoryBot.create(:status) } let(:status_link) { api_v3_paths.status target_status.id } let(:status_parameter) { { _links: { status: { href: status_link } } } } let(:params) { valid_params.merge(status_parameter) } @@ -392,7 +392,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do context 'valid status' do let!(:workflow) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, type_id: work_package.type.id, old_status: work_package.status, new_status: target_status, @@ -439,7 +439,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'type' do - let(:target_type) { FactoryGirl.create(:type) } + let(:target_type) { FactoryBot.create(:type) } let(:type_link) { api_v3_paths.type target_type.id } let(:type_parameter) { { _links: { type: { href: type_link } } } } let(:params) { valid_params.merge(type_parameter) } @@ -464,7 +464,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'valid type changing custom fields' do - let(:custom_field) { FactoryGirl.create(:work_package_custom_field) } + let(:custom_field) { FactoryBot.create(:work_package_custom_field) } let(:custom_field_parameter) { { :"customField#{custom_field.id}" => true } } let(:params) { valid_params.merge(type_parameter).merge(custom_field_parameter) } @@ -509,17 +509,17 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do context 'project' do let(:target_project) do - FactoryGirl.create(:project, is_public: false) + FactoryBot.create(:project, is_public: false) end let(:project_link) { api_v3_paths.project target_project.id } let(:project_parameter) { { _links: { project: { href: project_link } } } } let(:params) { valid_params.merge(project_parameter) } before do - FactoryGirl.create :member, + FactoryBot.create :member, user: current_user, project: target_project, - roles: [FactoryGirl.create(:role, permissions: [:move_work_packages])] + roles: [FactoryBot.create(:role, permissions: [:move_work_packages])] allow(User).to receive(:current).and_return current_user end @@ -543,7 +543,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'with a custom field defined on the target project' do - let(:custom_field) { FactoryGirl.create(:work_package_custom_field) } + let(:custom_field) { FactoryBot.create(:work_package_custom_field) } let(:custom_field_parameter) { { :"customField#{custom_field.id}" => true } } let(:params) { valid_params.merge(project_parameter).merge(custom_field_parameter) } @@ -563,10 +563,10 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'assignee and responsible' do - let(:user) { FactoryGirl.create(:user, member_in_project: project) } + let(:user) { FactoryBot.create(:user, member_in_project: project) } let(:params) { valid_params.merge(user_parameter) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, assigned_to: current_user, responsible: current_user) @@ -575,10 +575,10 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do before do allow(User).to receive(:current).and_return current_user end shared_context 'setup group membership' do |group_assignment| - let(:group) { FactoryGirl.create(:group) } - let(:group_role) { FactoryGirl.create(:role) } + let(:group) { FactoryBot.create(:group) } + let(:group_role) { FactoryBot.create(:role) } let(:group_member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, principal: group, project: project, roles: [group_role]) @@ -659,7 +659,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'user is not visible' do - let(:invalid_user) { FactoryGirl.create(:user) } + let(:invalid_user) { FactoryBot.create(:user) } let(:user_href) { api_v3_paths.user invalid_user.id } it_behaves_like 'constraint violation' do @@ -711,7 +711,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'version' do - let(:target_version) { FactoryGirl.create(:version, project: project) } + let(:target_version) { FactoryBot.create(:version, project: project) } let(:version_link) { api_v3_paths.version target_version.id } let(:version_parameter) { { _links: { version: { href: version_link } } } } let(:params) { valid_params.merge(version_parameter) } @@ -733,7 +733,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'category' do - let(:target_category) { FactoryGirl.create(:category, project: project) } + let(:target_category) { FactoryBot.create(:category, project: project) } let(:category_link) { api_v3_paths.category target_category.id } let(:category_parameter) { { _links: { category: { href: category_link } } } } let(:params) { valid_params.merge(category_parameter) } @@ -755,7 +755,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'priority' do - let(:target_priority) { FactoryGirl.create(:priority) } + let(:target_priority) { FactoryBot.create(:priority) } let(:priority_link) { api_v3_paths.priority target_priority.id } let(:priority_parameter) { { _links: { priority: { href: priority_link } } } } let(:params) { valid_params.merge(priority_parameter) } @@ -778,7 +778,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do context 'list custom field' do let(:custom_field) do - FactoryGirl.create(:list_wp_custom_field) + FactoryBot.create(:list_wp_custom_field) end let(:target_value) { custom_field.possible_values.last } @@ -966,8 +966,8 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do describe '#post' do let(:path) { api_v3_paths.work_packages } let(:permissions) { [:add_work_packages, :view_project] } - let(:status) { FactoryGirl.build(:status, is_default: true) } - let(:priority) { FactoryGirl.build(:priority, is_default: true) } + let(:status) { FactoryBot.build(:status, is_default: true) } + let(:priority) { FactoryBot.build(:priority, is_default: true) } let(:type) { project.types.first } let(:parameters) do { @@ -987,7 +987,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do status.save! priority.save! - FactoryGirl.create(:user_preference, user: current_user, others: { no_self_notified: false }) + FactoryBot.create(:user_preference, user: current_user, others: { no_self_notified: false }) post path, parameters.to_json, 'CONTENT_TYPE' => 'application/json' end @@ -1036,7 +1036,7 @@ describe 'API v3 Work package resource', type: :request, content_type: :json do end context 'no permissions' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } it 'should hide the endpoint' do expect(last_response.status).to eq(403) diff --git a/spec/requests/api/v3/work_packages/available_projects_on_create_api_spec.rb b/spec/requests/api/v3/work_packages/available_projects_on_create_api_spec.rb index 28652b26e7..84f5bd590e 100644 --- a/spec/requests/api/v3/work_packages/available_projects_on_create_api_spec.rb +++ b/spec/requests/api/v3/work_packages/available_projects_on_create_api_spec.rb @@ -33,11 +33,11 @@ describe API::V3::WorkPackages::AvailableProjectsOnCreateAPI, type: :request do include API::V3::Utilities::PathHelper let(:add_role) do - FactoryGirl.create(:role, permissions: [:add_work_packages]) + FactoryBot.create(:role, permissions: [:add_work_packages]) end - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: add_role) end @@ -59,7 +59,7 @@ describe API::V3::WorkPackages::AvailableProjectsOnCreateAPI, type: :request do context 'w/o any add_work_packages permission' do let(:add_role) do - FactoryGirl.create(:role, permissions: []) + FactoryBot.create(:role, permissions: []) end it { expect(last_response.status).to eq(403) } diff --git a/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb b/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb index 91ed5a4b9d..0ce5244666 100644 --- a/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb +++ b/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb @@ -33,21 +33,21 @@ describe 'API::V3::WorkPackages::AvailableProjectsOnEditAPI', type: :request do include API::V3::Utilities::PathHelper let(:edit_role) do - FactoryGirl.create(:role, permissions: [:edit_work_packages, + FactoryBot.create(:role, permissions: [:edit_work_packages, :view_work_packages]) end let(:move_role) do - FactoryGirl.create(:role, permissions: [:move_work_packages]) + FactoryBot.create(:role, permissions: [:move_work_packages]) end - let(:project) { FactoryGirl.create(:project) } - let(:target_project) { FactoryGirl.create(:project) } - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:project) { FactoryBot.create(:project) } + let(:target_project) { FactoryBot.create(:project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:user) do - user = FactoryGirl.create(:user, + user = FactoryBot.create(:user, member_in_project: project, member_through_role: edit_role) - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: target_project, roles: [move_role]) @@ -70,7 +70,7 @@ describe 'API::V3::WorkPackages::AvailableProjectsOnEditAPI', type: :request do context 'w/o the edit_work_packages permission' do let(:edit_role) do - FactoryGirl.create(:role, permissions: [:view_work_packages]) + FactoryBot.create(:role, permissions: [:view_work_packages]) end it { expect(last_response.status).to eq(403) } @@ -78,7 +78,7 @@ describe 'API::V3::WorkPackages::AvailableProjectsOnEditAPI', type: :request do context 'w/o the view_work_packages permission' do let(:edit_role) do - FactoryGirl.create(:role, permissions: [:edit_work_packages]) + FactoryBot.create(:role, permissions: [:edit_work_packages]) end it { expect(last_response.status).to eq(404) } diff --git a/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb b/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb index 068f5886a3..95a7796f0f 100644 --- a/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb +++ b/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb @@ -29,32 +29,32 @@ require 'spec_helper' describe ::API::V3::Relations::RelationRepresenter, type: :request do - let(:user) { FactoryGirl.create :admin } + let(:user) { FactoryBot.create :admin } - let(:project_1) { FactoryGirl.create :project } + let(:project_1) { FactoryBot.create :project } - let!(:wp_1) { FactoryGirl.create :work_package, project: project_1, subject: "WP 1" } + let!(:wp_1) { FactoryBot.create :work_package, project: project_1, subject: "WP 1" } let!(:wp_1_1) do - FactoryGirl.create :work_package, parent: wp_1, project: project_1, subject: "WP 1.1" + FactoryBot.create :work_package, parent: wp_1, project: project_1, subject: "WP 1.1" end let!(:wp_1_2) do - FactoryGirl.create :work_package, parent: wp_1, project: project_1, subject: "WP 1.2" + FactoryBot.create :work_package, parent: wp_1, project: project_1, subject: "WP 1.2" end let!(:wp_1_2_1) do - FactoryGirl.create :work_package, parent: wp_1_2, project: project_1, subject: "WP 1.2.1" + FactoryBot.create :work_package, parent: wp_1_2, project: project_1, subject: "WP 1.2.1" end - let(:project_2) { FactoryGirl.create :project } + let(:project_2) { FactoryBot.create :project } - let!(:wp_2) { FactoryGirl.create :work_package, project: project_2, subject: "WP 2" } - let!(:wp_2_1) { FactoryGirl.create :work_package, project: project_2, subject: "WP 2.1" } - let!(:wp_2_2) { FactoryGirl.create :work_package, project: project_2, subject: "WP 2.2" } + let!(:wp_2) { FactoryBot.create :work_package, project: project_2, subject: "WP 2" } + let!(:wp_2_1) { FactoryBot.create :work_package, project: project_2, subject: "WP 2.1" } + let!(:wp_2_2) { FactoryBot.create :work_package, project: project_2, subject: "WP 2.2" } let!(:relation_wp_2_1_to_wp_2_2) do - FactoryGirl.create :relation, from: wp_2_1, to: wp_2_2, relation_type: "relates" + FactoryBot.create :relation, from: wp_2_1, to: wp_2_2, relation_type: "relates" end let(:href) { "/api/v3/work_packages/#{wp_1.id}/available_relation_candidates?query=WP" } @@ -74,7 +74,7 @@ describe ::API::V3::Relations::RelationRepresenter, type: :request do end context 'with no permissions' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } it 'does not return any work packages' do expect(result["errorIdentifier"]).to eq('urn:openproject-org:api:v3:errors:NotFound') @@ -139,11 +139,11 @@ describe ::API::V3::Relations::RelationRepresenter, type: :request do describe 'with an already existing relationship from the work package' do let!(:relation_wp_2_to_wp_2_2) do - FactoryGirl.create :relation, from: wp_2, to: wp_2_2, relation_type: "relates" + FactoryBot.create :relation, from: wp_2, to: wp_2_2, relation_type: "relates" end let!(:relation_wp_1_1_to_wp_2) do - FactoryGirl.create :relation, from: wp_1_1, to: wp_2, relation_type: "relates" + FactoryBot.create :relation, from: wp_1_1, to: wp_2, relation_type: "relates" end it 'does not contain the work packages with which a relationship already exists' do @@ -153,7 +153,7 @@ describe ::API::V3::Relations::RelationRepresenter, type: :request do end context 'when a project is archived' do - let(:project_1) { FactoryGirl.create :project, status: Project::STATUS_ARCHIVED } + let(:project_1) { FactoryBot.create :project, status: Project::STATUS_ARCHIVED } let(:href) { "/api/v3/work_packages/#{wp_2.id}/available_relation_candidates?query=WP" } it 'does not return work packages from that project' do diff --git a/spec/requests/api/v3/work_packages/create_form_resource_spec.rb b/spec/requests/api/v3/work_packages/create_form_resource_spec.rb index ad666091d2..182f3942f0 100644 --- a/spec/requests/api/v3/work_packages/create_form_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/create_form_resource_spec.rb @@ -35,10 +35,10 @@ describe ::API::V3::WorkPackages::CreateProjectFormAPI do include API::V3::Utilities::PathHelper shared_let(:path) { api_v3_paths.create_work_package_form } - shared_let(:status) { FactoryGirl.create(:default_status) } - shared_let(:priority) { FactoryGirl.create(:default_priority) } - shared_let(:user) { FactoryGirl.build(:admin) } - shared_let(:project) { FactoryGirl.create(:project_with_types) } + shared_let(:status) { FactoryBot.create(:default_status) } + shared_let(:priority) { FactoryBot.create(:default_priority) } + shared_let(:user) { FactoryBot.build(:admin) } + shared_let(:project) { FactoryBot.create(:project_with_types) } let(:parameters) { {} } before do diff --git a/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb b/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb index 1efdbdef2c..d691ccc84e 100644 --- a/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb @@ -33,9 +33,9 @@ describe ::API::V3::WorkPackages::CreateProjectFormAPI, content_type: :json do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project, id: 5) } + let(:project) { FactoryBot.create(:project, id: 5) } let(:post_path) { api_v3_paths.create_project_work_package_form(project.id) } - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } before do login_as(user) diff --git a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb index b7d5dcfd34..37c120f1d7 100644 --- a/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb @@ -34,10 +34,10 @@ describe 'API v3 Work package form resource', type: :request do include Capybara::RSpecMatchers include API::V3::Utilities::PathHelper - shared_let(:project) { FactoryGirl.create(:project, is_public: false) } - shared_let(:work_package, reload: true) { FactoryGirl.create(:work_package, project: project) } - shared_let(:authorized_user) { FactoryGirl.create(:user, member_in_project: project) } - shared_let(:unauthorized_user) { FactoryGirl.create(:user) } + shared_let(:project) { FactoryBot.create(:project, is_public: false) } + shared_let(:work_package, reload: true) { FactoryBot.create(:work_package, project: project) } + shared_let(:authorized_user) { FactoryBot.create(:user, member_in_project: project) } + shared_let(:unauthorized_user) { FactoryBot.create(:user) } describe '#post' do let(:post_path) { api_v3_paths.work_package_form work_package.id } @@ -308,14 +308,14 @@ describe 'API v3 Work package form resource', type: :request do describe 'status' do let(:path) { '_embedded/payload/_links/status/href' } - let(:target_status) { FactoryGirl.create(:status) } + let(:target_status) { FactoryBot.create(:status) } let(:status_link) { api_v3_paths.status target_status.id } let(:status_parameter) { { _links: { status: { href: status_link } } } } let(:params) { valid_params.merge(status_parameter) } context 'valid status' do let!(:workflow) { - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, type_id: work_package.type.id, old_status: work_package.status, new_status: target_status, @@ -387,10 +387,10 @@ describe 'API v3 Work package form resource', type: :request do describe 'assignee and responsible' do shared_context 'setup group membership' do |group_assignment| - let(:group) { FactoryGirl.create(:group) } - let(:role) { FactoryGirl.create(:role) } + let(:group) { FactoryBot.create(:group) } + let(:role) { FactoryBot.create(:role) } let(:group_member) { - FactoryGirl.create(:member, + FactoryBot.create(:member, principal: group, project: project, roles: [role]) @@ -407,7 +407,7 @@ describe 'API v3 Work package form resource', type: :request do shared_examples_for 'handling people' do |property| let(:path) { "_embedded/payload/_links/#{property}/href" } let(:visible_user) { - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project) } let(:user_parameter) { { _links: { property => { href: user_link } } } } @@ -511,8 +511,8 @@ describe 'API v3 Work package form resource', type: :request do describe 'version' do let(:path) { '_embedded/payload/_links/version/href' } - let(:target_version) { FactoryGirl.create(:version, project: project) } - let(:other_version) { FactoryGirl.create(:version, project: project) } + let(:target_version) { FactoryBot.create(:version, project: project) } + let(:other_version) { FactoryBot.create(:version, project: project) } let(:version_link) { api_v3_paths.version target_version.id } let(:other_version_link) { api_v3_paths.version other_version.id } let(:version_parameter) { { _links: { version: { href: version_link } } } } @@ -549,8 +549,8 @@ describe 'API v3 Work package form resource', type: :request do describe 'category' do let(:path) { '_embedded/payload/_links/category/href' } let(:links_path) { '_embedded/schema/category/_links' } - let(:target_category) { FactoryGirl.create(:category, project: project) } - let(:other_category) { FactoryGirl.create(:category, project: project) } + let(:target_category) { FactoryBot.create(:category, project: project) } + let(:other_category) { FactoryBot.create(:category, project: project) } let(:category_link) { api_v3_paths.category target_category.id } let(:other_category_link) { api_v3_paths.category other_category.id } let(:category_parameter) { { _links: { category: { href: category_link } } } } @@ -587,7 +587,7 @@ describe 'API v3 Work package form resource', type: :request do describe 'priority' do let(:path) { '_embedded/payload/_links/priority/href' } let(:links_path) { '_embedded/schema/priority/_links' } - let(:target_priority) { FactoryGirl.create(:priority) } + let(:target_priority) { FactoryBot.create(:priority) } let(:other_priority) { work_package.priority } let(:priority_link) { api_v3_paths.priority target_priority.id } let(:other_priority_link) { api_v3_paths.priority other_priority.id } @@ -625,7 +625,7 @@ describe 'API v3 Work package form resource', type: :request do describe 'type' do let(:path) { '_embedded/payload/_links/type/href' } let(:links_path) { '_embedded/schema/type/_links' } - let(:target_type) { FactoryGirl.create(:type) } + let(:target_type) { FactoryBot.create(:type) } let(:other_type) { work_package.type } let(:type_link) { api_v3_paths.type target_type.id } let(:other_type_link) { api_v3_paths.type other_type.id } diff --git a/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb b/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb index aca9315078..15d0a4ec0a 100644 --- a/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb @@ -34,11 +34,11 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.build(:user, member_in_project: project, member_through_role: role) + FactoryBot.build(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) { [:view_work_packages] } - let(:project) { FactoryGirl.create(:project_with_types, is_public: false) } + let(:project) { FactoryBot.create(:project_with_types, is_public: false) } let(:path) { api_v3_paths.work_packages_by_project project.id } before do @@ -59,7 +59,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do end context 'not allowed to see the project' do - let(:current_user) { FactoryGirl.build(:user) } + let(:current_user) { FactoryBot.build(:user) } it 'fails with HTTP Not Found' do expect(subject.status).to eql 404 @@ -81,7 +81,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do describe 'sorting' do let(:query) { { sortBy: '[["id", "desc"]]' } } - let(:work_packages) { FactoryGirl.create_list(:work_package, 2, project: project) } + let(:work_packages) { FactoryBot.create_list(:work_package, 2, project: project) } it 'returns both elements' do expect(subject.body).to be_json_eql(2).at_path('count') @@ -110,12 +110,12 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do ].to_json } end - let(:priority1) { FactoryGirl.create(:priority, name: 'Prio A') } - let(:priority2) { FactoryGirl.create(:priority, name: 'Prio B') } + let(:priority1) { FactoryBot.create(:priority, name: 'Prio A') } + let(:priority2) { FactoryBot.create(:priority, name: 'Prio B') } let(:work_packages) do [ - FactoryGirl.create(:work_package, project: project, priority: priority1), - FactoryGirl.create(:work_package, project: project, priority: priority2) + FactoryBot.create(:work_package, project: project, priority: priority1), + FactoryBot.create(:work_package, project: project, priority: priority2) ] end @@ -132,19 +132,19 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do describe 'grouping' do let(:query) { { groupBy: 'priority' } } - let(:priority1) { FactoryGirl.build(:priority, name: 'Prio A', position: 2) } - let(:priority2) { FactoryGirl.build(:priority, name: 'Prio B', position: 1) } + let(:priority1) { FactoryBot.build(:priority, name: 'Prio A', position: 2) } + let(:priority2) { FactoryBot.build(:priority, name: 'Prio B', position: 1) } let(:work_packages) do [ - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, priority: priority1, estimated_hours: 1), - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, priority: priority2, estimated_hours: 2), - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, priority: priority1, estimated_hours: 3) @@ -253,8 +253,8 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do let(:query) { { showSums: 'true' } } let(:work_packages) do [ - FactoryGirl.create(:work_package, project: project, estimated_hours: 1), - FactoryGirl.create(:work_package, project: project, estimated_hours: 2) + FactoryBot.create(:work_package, project: project, estimated_hours: 1), + FactoryBot.create(:work_package, project: project, estimated_hours: 2) ] end @@ -276,8 +276,8 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do describe '#post' do let(:permissions) { [:add_work_packages, :view_project] } - let(:status) { FactoryGirl.build(:status, is_default: true) } - let(:priority) { FactoryGirl.build(:priority, is_default: true) } + let(:status) { FactoryBot.build(:status, is_default: true) } + let(:priority) { FactoryBot.build(:priority, is_default: true) } let(:parameters) do { subject: 'new work packages', @@ -293,7 +293,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do status.save! priority.save! - FactoryGirl.create(:user_preference, user: current_user, others: { no_self_notified: false }) + FactoryBot.create(:user_preference, user: current_user, others: { no_self_notified: false }) post path, parameters.to_json, 'CONTENT_TYPE' => 'application/json' end @@ -334,7 +334,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do end context 'no permissions' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } it 'should hide the endpoint' do expect(last_response.status).to eq(404) diff --git a/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb b/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb index bc322da571..b5f105e385 100644 --- a/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb +++ b/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb @@ -33,11 +33,11 @@ describe API::V3::WorkPackages::Schema::WorkPackageSchemasAPI, type: :request do include Rack::Test::Methods include API::V3::Utilities::PathHelper - let(:project) { FactoryGirl.create(:project) } - let(:type) { FactoryGirl.create(:type) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:type) { FactoryBot.create(:type) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:current_user) do - FactoryGirl.build(:user, member_in_project: project, member_through_role: role) + FactoryBot.build(:user, member_in_project: project, member_through_role: role) end describe 'GET /api/v3/work_packages/schemas/filters=...' do @@ -119,7 +119,7 @@ describe API::V3::WorkPackages::Schema::WorkPackageSchemasAPI, type: :request do end context 'not authorized' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } it 'returns HTTP 403' do expect(last_response.status).to eql(403) diff --git a/spec/requests/attachments_routes_spec.rb b/spec/requests/attachments_routes_spec.rb index d484cb8299..2643a44c67 100644 --- a/spec/requests/attachments_routes_spec.rb +++ b/spec/requests/attachments_routes_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe 'attachments routes', type: :request do - let(:user) { FactoryGirl.create :admin } - let(:attachment) { FactoryGirl.create :attachment } + let(:user) { FactoryBot.create :admin } + let(:attachment) { FactoryBot.create :attachment } describe 'for backwards compatibility' do it 'redirects /attachments/download with filename to attachments#download' do diff --git a/spec/requests/current_user_spec.rb b/spec/requests/current_user_spec.rb index 7e771d5191..3fa34d7000 100644 --- a/spec/requests/current_user_spec.rb +++ b/spec/requests/current_user_spec.rb @@ -49,7 +49,7 @@ module ResetCurrentUserCallback end describe ResetCurrentUser, type: :rails_request do - let!(:user) { FactoryGirl.create :user } + let!(:user) { FactoryBot.create :user } before do ApplicationController.prepend InsertUserSetupCallback diff --git a/spec/routing/users_routing_spec.rb b/spec/routing/users_routing_spec.rb index 66b69fc49b..ce1e94ed74 100644 --- a/spec/routing/users_routing_spec.rb +++ b/spec/routing/users_routing_spec.rb @@ -52,7 +52,7 @@ describe UsersController, type: :routing do end describe 'my' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before do login_as(user) diff --git a/spec/services/add_attachment_service_spec.rb b/spec/services/add_attachment_service_spec.rb index 3a2f094e21..75960a510b 100644 --- a/spec/services/add_attachment_service_spec.rb +++ b/spec/services/add_attachment_service_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe AddAttachmentService do - let(:user) { FactoryGirl.create(:user) } - let(:work_package) { FactoryGirl.create(:work_package) } + let(:user) { FactoryBot.create(:user) } + let(:work_package) { FactoryBot.create(:work_package) } let(:container) { work_package } let(:description) { 'a fancy description' } diff --git a/spec/services/add_work_package_note_service_spec.rb b/spec/services/add_work_package_note_service_spec.rb index c77b2a841b..9ba8c91276 100644 --- a/spec/services/add_work_package_note_service_spec.rb +++ b/spec/services/add_work_package_note_service_spec.rb @@ -30,8 +30,8 @@ require 'spec_helper' describe AddWorkPackageNoteService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:work_package) { FactoryGirl.build_stubbed(:work_package) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:work_package) { FactoryBot.build_stubbed(:work_package) } let(:instance) do described_class.new(user: user, work_package: work_package) diff --git a/spec/services/api/v3/update_query_from_v3_params_service_spec.rb b/spec/services/api/v3/update_query_from_v3_params_service_spec.rb index 514ef0ff7d..50d6f01bb9 100644 --- a/spec/services/api/v3/update_query_from_v3_params_service_spec.rb +++ b/spec/services/api/v3/update_query_from_v3_params_service_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe ::API::V3::UpdateQueryFromV3ParamsService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:query) { FactoryGirl.build_stubbed(:query) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:query) { FactoryBot.build_stubbed(:query) } let(:params) { double('params') } let(:parsed_params) { double('parsed_params') } diff --git a/spec/services/api/v3/work_package_collection_from_query_params_service_spec.rb b/spec/services/api/v3/work_package_collection_from_query_params_service_spec.rb index f4119db7d0..5333fed2b9 100644 --- a/spec/services/api/v3/work_package_collection_from_query_params_service_spec.rb +++ b/spec/services/api/v3/work_package_collection_from_query_params_service_spec.rb @@ -53,9 +53,9 @@ describe ::API::V3::WorkPackageCollectionFromQueryParamsService, let(:mock_wp_collection_service_errors) { nil } let(:mock_wp_collection_service_result) { double('result') } - let(:query) { FactoryGirl.build_stubbed(:query) } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:query) { FactoryBot.build_stubbed(:query) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user) } diff --git a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb index 02dca91767..e74f496840 100644 --- a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb +++ b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb @@ -33,7 +33,7 @@ describe ::API::V3::WorkPackageCollectionFromQueryService, include API::V3::Utilities::PathHelper let(:query) do - query = FactoryGirl.build_stubbed(:query) + query = FactoryBot.build_stubbed(:query) allow(query) .to receive(:results) .and_return(results) @@ -73,8 +73,8 @@ describe ::API::V3::WorkPackageCollectionFromQueryService, results end - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:mock_wp_representer) do Struct.new(:work_packages, :self_link, @@ -152,7 +152,7 @@ describe ::API::V3::WorkPackageCollectionFromQueryService, let(:update_query_service_errors) { nil } let(:update_query_service_result) { query } - let(:work_package) { FactoryGirl.build_stubbed(:work_package) } + let(:work_package) { FactoryBot.build_stubbed(:work_package) } let(:instance) { described_class.new(query, user) } @@ -205,7 +205,7 @@ describe ::API::V3::WorkPackageCollectionFromQueryService, context 'self_link' do context 'if the project is nil' do - let(:query) { FactoryGirl.build_stubbed(:query, project: nil) } + let(:query) { FactoryBot.build_stubbed(:query, project: nil) } it 'is the global work_package link' do expect(subject.self_link) @@ -214,7 +214,7 @@ describe ::API::V3::WorkPackageCollectionFromQueryService, end context 'if the project is set' do - let(:query) { FactoryGirl.build_stubbed(:query, project: project) } + let(:query) { FactoryBot.build_stubbed(:query, project: project) } it 'is the global work_package link' do expect(subject.self_link) diff --git a/spec/services/authorization/user_allowed_query_spec.rb b/spec/services/authorization/user_allowed_query_spec.rb index 9efd4196b1..d117fd0c06 100644 --- a/spec/services/authorization/user_allowed_query_spec.rb +++ b/spec/services/authorization/user_allowed_query_spec.rb @@ -31,15 +31,15 @@ require 'spec_helper' describe Authorization::UserAllowedQuery do describe '.query' do let(:user) { member.principal } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:project) { FactoryGirl.build(:project, is_public: false) } - let(:project2) { FactoryGirl.build(:project, is_public: false) } - let(:role) { FactoryGirl.build(:role) } - let(:role2) { FactoryGirl.build(:role) } - let(:anonymous_role) { FactoryGirl.build(:anonymous_role) } - let(:non_member_role) { FactoryGirl.build(:non_member) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:project) { FactoryBot.build(:project, is_public: false) } + let(:project2) { FactoryBot.build(:project, is_public: false) } + let(:role) { FactoryBot.build(:role) } + let(:role2) { FactoryBot.build(:role) } + let(:anonymous_role) { FactoryBot.build(:anonymous_role) } + let(:non_member_role) { FactoryBot.build(:non_member) } let(:member) do - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role]) end diff --git a/spec/services/authorization/user_allowed_service_spec.rb b/spec/services/authorization/user_allowed_service_spec.rb index 18dfc9b29e..56c519606f 100644 --- a/spec/services/authorization/user_allowed_service_spec.rb +++ b/spec/services/authorization/user_allowed_service_spec.rb @@ -29,13 +29,13 @@ require 'spec_helper' describe Authorization::UserAllowedService do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user) } let(:action) { :an_action } let(:action_hash) { { controller: '/controller', action: 'action' } } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:other_project) { FactoryGirl.build_stubbed(:project) } - let(:role) { FactoryGirl.build_stubbed(:role) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:other_project) { FactoryBot.build_stubbed(:project) } + let(:role) { FactoryBot.build_stubbed(:role) } let(:user_roles_in_project) { [role] } let(:role_grants_action) { true } let(:project_allows_to) { true } diff --git a/spec/services/authorization/user_global_roles_query_spec.rb b/spec/services/authorization/user_global_roles_query_spec.rb index e102a7094b..33871fc7e8 100644 --- a/spec/services/authorization/user_global_roles_query_spec.rb +++ b/spec/services/authorization/user_global_roles_query_spec.rb @@ -29,22 +29,22 @@ require 'spec_helper' describe Authorization::UserGlobalRolesQuery do - let(:user) { FactoryGirl.build(:user) } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:project) { FactoryGirl.build(:project, is_public: false) } - let(:project2) { FactoryGirl.build(:project, is_public: false) } - let(:public_project) { FactoryGirl.build(:project, is_public: true) } - let(:role) { FactoryGirl.build(:role) } - let(:role2) { FactoryGirl.build(:role) } - let(:anonymous_role) { FactoryGirl.build(:anonymous_role) } - let(:non_member) { FactoryGirl.build(:non_member) } + let(:user) { FactoryBot.build(:user) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:project) { FactoryBot.build(:project, is_public: false) } + let(:project2) { FactoryBot.build(:project, is_public: false) } + let(:public_project) { FactoryBot.build(:project, is_public: true) } + let(:role) { FactoryBot.build(:role) } + let(:role2) { FactoryBot.build(:role) } + let(:anonymous_role) { FactoryBot.build(:anonymous_role) } + let(:non_member) { FactoryBot.build(:non_member) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } let(:member2) { - FactoryGirl.build(:member, project: project2, + FactoryBot.build(:member, project: project2, roles: [role2], principal: user) } diff --git a/spec/services/authorization/user_project_roles_query_spec.rb b/spec/services/authorization/user_project_roles_query_spec.rb index fe9a837647..edfd862cdb 100644 --- a/spec/services/authorization/user_project_roles_query_spec.rb +++ b/spec/services/authorization/user_project_roles_query_spec.rb @@ -29,22 +29,22 @@ require 'spec_helper' describe Authorization::UserProjectRolesQuery do - let(:user) { FactoryGirl.build(:user) } - let(:anonymous) { FactoryGirl.build(:anonymous) } - let(:project) { FactoryGirl.build(:project, is_public: false) } - let(:project2) { FactoryGirl.build(:project, is_public: false) } - let(:public_project) { FactoryGirl.build(:project, is_public: true) } - let(:role) { FactoryGirl.build(:role) } - let(:role2) { FactoryGirl.build(:role) } - let(:anonymous_role) { FactoryGirl.build(:anonymous_role) } - let(:non_member) { FactoryGirl.build(:non_member) } + let(:user) { FactoryBot.build(:user) } + let(:anonymous) { FactoryBot.build(:anonymous) } + let(:project) { FactoryBot.build(:project, is_public: false) } + let(:project2) { FactoryBot.build(:project, is_public: false) } + let(:public_project) { FactoryBot.build(:project, is_public: true) } + let(:role) { FactoryBot.build(:role) } + let(:role2) { FactoryBot.build(:role) } + let(:anonymous_role) { FactoryBot.build(:anonymous_role) } + let(:non_member) { FactoryBot.build(:non_member) } let(:member) { - FactoryGirl.build(:member, project: project, + FactoryBot.build(:member, project: project, roles: [role], principal: user) } let(:member2) { - FactoryGirl.build(:member, project: project2, + FactoryBot.build(:member, project: project2, roles: [role2], principal: user) } diff --git a/spec/services/create_type_service_spec.rb b/spec/services/create_type_service_spec.rb index c399796e31..0307f2866a 100644 --- a/spec/services/create_type_service_spec.rb +++ b/spec/services/create_type_service_spec.rb @@ -32,7 +32,7 @@ require 'services/shared_type_service' describe CreateTypeService do let(:type) { instance.type } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user) } let(:service_call) { instance.call(params, {}) } diff --git a/spec/services/create_work_package_service_spec.rb b/spec/services/create_work_package_service_spec.rb index b83132420e..e98d25fa8c 100644 --- a/spec/services/create_work_package_service_spec.rb +++ b/spec/services/create_work_package_service_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe CreateWorkPackageService do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:work_package) { FactoryGirl.build_stubbed(:work_package, author: nil) } - let(:project) { FactoryGirl.build_stubbed(:project_with_types) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:work_package) { FactoryBot.build_stubbed(:work_package, author: nil) } + let(:project) { FactoryBot.build_stubbed(:project_with_types) } let(:instance) { described_class.new(user: user) } let(:errors) { double('errors') } diff --git a/spec/services/custom_actions/update_service_spec.rb b/spec/services/custom_actions/update_service_spec.rb index dd74a8f383..292303d1e6 100644 --- a/spec/services/custom_actions/update_service_spec.rb +++ b/spec/services/custom_actions/update_service_spec.rb @@ -32,7 +32,7 @@ require 'spec_helper' describe CustomActions::UpdateService do let(:action) do - action = FactoryGirl.build_stubbed(:custom_action) + action = FactoryBot.build_stubbed(:custom_action) allow(action) .to receive(:save) @@ -40,7 +40,7 @@ describe CustomActions::UpdateService do action end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:save_success) { true } let(:contract_success) { true } let(:contract_errors) { double('contract errors') } @@ -155,8 +155,8 @@ describe CustomActions::UpdateService do end it 'updates the conditions' do - old_status = FactoryGirl.create(:status) - new_status = FactoryGirl.create(:status) + old_status = FactoryBot.create(:status) + new_status = FactoryBot.create(:status) action.conditions = [CustomActions::Conditions::Status.new(old_status.id)] diff --git a/spec/services/custom_actions/update_work_package_service_spec.rb b/spec/services/custom_actions/update_work_package_service_spec.rb index 0c84be133c..183de6abe2 100644 --- a/spec/services/custom_actions/update_work_package_service_spec.rb +++ b/spec/services/custom_actions/update_work_package_service_spec.rb @@ -32,7 +32,7 @@ require 'spec_helper' describe CustomActions::UpdateWorkPackageService do let(:custom_action) do - action = FactoryGirl.build_stubbed(:custom_action) + action = FactoryBot.build_stubbed(:custom_action) allow(action) .to receive(:actions) @@ -58,7 +58,7 @@ describe CustomActions::UpdateWorkPackageService do action end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(action: custom_action, user: user) } let!(:update_wp_service) do wp_service_instance = double('WorkPackages::UpdateService instance') @@ -74,7 +74,7 @@ describe CustomActions::UpdateWorkPackageService do wp_service_instance end - let(:work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } let(:result) do ServiceResult.new(result: work_package, success: true) end diff --git a/spec/services/parse_schema_filter_params_service_spec.rb b/spec/services/parse_schema_filter_params_service_spec.rb index 18cb09c887..8e7abd6fa7 100644 --- a/spec/services/parse_schema_filter_params_service_spec.rb +++ b/spec/services/parse_schema_filter_params_service_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe ParseSchemaFilterParamsService do - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user: current_user) } - let(:project) { FactoryGirl.build_stubbed(:project) } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:project) { FactoryBot.build_stubbed(:project) } + let(:type) { FactoryBot.build_stubbed(:type) } describe '#call' do let(:filter) do diff --git a/spec/services/queries/update_query_from_params_service_spec.rb b/spec/services/queries/update_query_from_params_service_spec.rb index 35bf03b41b..4b359dcfef 100644 --- a/spec/services/queries/update_query_from_params_service_spec.rb +++ b/spec/services/queries/update_query_from_params_service_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe UpdateQueryFromParamsService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:query) { FactoryGirl.build_stubbed(:query) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:query) { FactoryBot.build_stubbed(:query) } let(:instance) { described_class.new(query, user) } diff --git a/spec/services/queries/update_query_service_spec.rb b/spec/services/queries/update_query_service_spec.rb index a64e5f5b40..e7b0271ab7 100644 --- a/spec/services/queries/update_query_service_spec.rb +++ b/spec/services/queries/update_query_service_spec.rb @@ -31,12 +31,12 @@ require 'spec_helper' describe UpdateQueryService do - let(:query) { FactoryGirl.create(:query) } + let(:query) { FactoryBot.create(:query) } let(:menu_item) do - FactoryGirl.create(:query_menu_item, + FactoryBot.create(:query_menu_item, query: query) end - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } let(:instance) { UpdateQueryService.new(user: user) } describe "a query's menu item" do @@ -64,7 +64,7 @@ describe UpdateQueryService do context 'unsuccessful saving of the menu item' do before do # violating the validations - violating_menu_item = FactoryGirl.build(:query_menu_item, + violating_menu_item = FactoryBot.build(:query_menu_item, name: menu_item.name, navigatable_id: menu_item.navigatable_id) diff --git a/spec/services/relations/create_service_spec.rb b/spec/services/relations/create_service_spec.rb index ba89de3a16..28cf346a27 100644 --- a/spec/services/relations/create_service_spec.rb +++ b/spec/services/relations/create_service_spec.rb @@ -40,12 +40,12 @@ describe Relations::CreateService do let(:delay) { 3 } let(:work_package1) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, due_date: work_package1_due_date, start_date: work_package1_start_date) end let(:work_package2) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, due_date: work_package2_due_date, start_date: work_package2_start_date) end @@ -69,7 +69,7 @@ describe Relations::CreateService do } end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:model_valid) { true } let(:contract_valid) { true } let(:contract) { double('contract') } diff --git a/spec/services/relations/update_service_spec.rb b/spec/services/relations/update_service_spec.rb index 1e083b51fe..6a4b7a3a37 100644 --- a/spec/services/relations/update_service_spec.rb +++ b/spec/services/relations/update_service_spec.rb @@ -40,12 +40,12 @@ describe Relations::UpdateService do let(:delay) { 3 } let(:work_package1) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, due_date: work_package1_due_date, start_date: work_package1_start_date) end let(:work_package2) do - FactoryGirl.build_stubbed(:work_package, + FactoryBot.build_stubbed(:work_package, due_date: work_package2_due_date, start_date: work_package2_start_date) end @@ -53,7 +53,7 @@ describe Relations::UpdateService do described_class.new(user: user, relation: relation) end let(:relation) do - relation = FactoryGirl.build_stubbed(:relation) + relation = FactoryBot.build_stubbed(:relation) allow(relation) .to receive(:follows?) @@ -69,7 +69,7 @@ describe Relations::UpdateService do } end - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:model_valid) { true } let(:contract_valid) { true } let(:contract) { double('contract') } diff --git a/spec/services/scm/checkout_instructions_service_spec.rb b/spec/services/scm/checkout_instructions_service_spec.rb index 9faf5d9788..81b730dd96 100644 --- a/spec/services/scm/checkout_instructions_service_spec.rb +++ b/spec/services/scm/checkout_instructions_service_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe Scm::CheckoutInstructionsService do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.build(:project) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.build(:project) } let(:url) { 'file:///tmp/some/svn/repo' } let(:repository) { - FactoryGirl.build(:repository_subversion, + FactoryBot.build(:repository_subversion, url: url, project: project) } @@ -133,7 +133,7 @@ describe Scm::CheckoutInstructionsService do end context 'disabled repository' do - let(:repository) { FactoryGirl.build(:repository_git) } + let(:repository) { FactoryBot.build(:repository_git) } it 'git is not available for checkout' do expect(service.available?).to be false diff --git a/spec/services/scm/create_managed_repository_service_spec.rb b/spec/services/scm/create_managed_repository_service_spec.rb index fd06ad98e0..9c1e23d9a8 100644 --- a/spec/services/scm/create_managed_repository_service_spec.rb +++ b/spec/services/scm/create_managed_repository_service_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe Scm::CreateManagedRepositoryService do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.build(:project) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.build(:project) } - let(:repository) { FactoryGirl.build(:repository_subversion) } + let(:repository) { FactoryBot.build(:repository_subversion) } subject(:service) { Scm::CreateManagedRepositoryService.new(repository) } let(:config) { {} } @@ -146,7 +146,7 @@ describe Scm::CreateManagedRepositoryService do } let(:repository) { - repo = FactoryGirl.build(:repository_subversion, scm_type: :managed) + repo = FactoryBot.build(:repository_subversion, scm_type: :managed) repo.project = project repo.configure(:managed, nil) repo diff --git a/spec/services/scm/delete_managed_repository_service_spec.rb b/spec/services/scm/delete_managed_repository_service_spec.rb index 74a8aa8511..4c5723caba 100644 --- a/spec/services/scm/delete_managed_repository_service_spec.rb +++ b/spec/services/scm/delete_managed_repository_service_spec.rb @@ -29,10 +29,10 @@ require 'spec_helper' describe Scm::DeleteManagedRepositoryService do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.build(:project) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.build(:project) } - let(:repository) { FactoryGirl.build(:repository_subversion) } + let(:repository) { FactoryBot.build(:repository_subversion) } subject(:service) { Scm::DeleteManagedRepositoryService.new(repository) } let(:config) { {} } @@ -55,7 +55,7 @@ describe Scm::DeleteManagedRepositoryService do end context 'with managed repository, but no config' do - let(:repository) { FactoryGirl.build(:repository_subversion, scm_type: :managed) } + let(:repository) { FactoryBot.build(:repository_subversion, scm_type: :managed) } it 'does allow to delete the repository' do expect(repository.managed?).to be true @@ -96,8 +96,8 @@ describe Scm::DeleteManagedRepositoryService do end context 'and parent project' do - let(:parent) { FactoryGirl.create(:project) } - let(:project) { FactoryGirl.create(:project, parent: parent) } + let(:parent) { FactoryBot.create(:project) } + let(:project) { FactoryBot.create(:project, parent: parent) } let(:repo_path) { Pathname.new(File.join(tmpdir, 'svn', project.identifier)) } diff --git a/spec/services/scm/repository_factory_service_spec.rb b/spec/services/scm/repository_factory_service_spec.rb index 1f7f943018..a9c05b596b 100644 --- a/spec/services/scm/repository_factory_service_spec.rb +++ b/spec/services/scm/repository_factory_service_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Scm::RepositoryFactoryService do - let(:user) { FactoryGirl.build(:user) } - let(:project) { FactoryGirl.build(:project) } + let(:user) { FactoryBot.build(:user) } + let(:project) { FactoryBot.build(:project) } let(:enabled_scms) { ['subversion', 'git'] } diff --git a/spec/services/set_localization_service_spec.rb b/spec/services/set_localization_service_spec.rb index f011d0cd24..8f28d85956 100644 --- a/spec/services/set_localization_service_spec.rb +++ b/spec/services/set_localization_service_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe SetLocalizationService do - let(:user) { FactoryGirl.build_stubbed(:user, language: user_language) } + let(:user) { FactoryBot.build_stubbed(:user, language: user_language) } let(:http_accept_header) { "#{http_accept_language},en-US;q=0.8,en;q=0.6" } let(:instance) { described_class.new(user, http_accept_header) } let(:user_language) { :bogus_language } @@ -116,7 +116,7 @@ describe SetLocalizationService do end context 'for an anonymous user' do - let(:user) { FactoryGirl.build_stubbed(:anonymous) } + let(:user) { FactoryBot.build_stubbed(:anonymous) } it_behaves_like 'falls back to the header' diff --git a/spec/services/shared_type_service.rb b/spec/services/shared_type_service.rb index a3eb7a52ae..e71913084f 100644 --- a/spec/services/shared_type_service.rb +++ b/spec/services/shared_type_service.rb @@ -57,8 +57,8 @@ shared_examples_for 'type service' do end describe 'custom fields' do - let(:cf1) { FactoryGirl.create :work_package_custom_field, field_format: 'text' } - let(:cf2) { FactoryGirl.create :work_package_custom_field, field_format: 'text' } + let(:cf1) { FactoryBot.create :work_package_custom_field, field_format: 'text' } + let(:cf2) { FactoryBot.create :work_package_custom_field, field_format: 'text' } let(:params) do { attribute_groups: [['group1', ["custom_field_#{cf1.id}", 'custom_field_54']], @@ -90,7 +90,7 @@ shared_examples_for 'type service' do ['group1', query_params] end let(:params) { { attribute_groups: [query_group_params] } } - let(:query) { FactoryGirl.build_stubbed(:query) } + let(:query) { FactoryBot.build_stubbed(:query) } let(:service_result) { ServiceResult.new(success: true, result: query) } before do diff --git a/spec/services/update_query_from_params_service_spec.rb b/spec/services/update_query_from_params_service_spec.rb index f7f90f22b0..ee53674de8 100644 --- a/spec/services/update_query_from_params_service_spec.rb +++ b/spec/services/update_query_from_params_service_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' describe UpdateQueryFromParamsService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:query) { FactoryGirl.build_stubbed(:query) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:query) { FactoryBot.build_stubbed(:query) } let(:instance) { described_class.new(query, user) } diff --git a/spec/services/update_type_service_spec.rb b/spec/services/update_type_service_spec.rb index 4e1493e654..b19f064556 100644 --- a/spec/services/update_type_service_spec.rb +++ b/spec/services/update_type_service_spec.rb @@ -31,8 +31,8 @@ require 'spec_helper' require 'services/shared_type_service' describe UpdateTypeService do - let(:type) { FactoryGirl.build_stubbed(:type) } - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:type) { FactoryBot.build_stubbed(:type) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(type, user) } let(:service_call) { instance.call(params) } diff --git a/spec/services/users/create_user_service_spec.rb b/spec/services/users/create_user_service_spec.rb index e8f136ba6e..f1324231b8 100644 --- a/spec/services/users/create_user_service_spec.rb +++ b/spec/services/users/create_user_service_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Users::CreateUserService do - let(:current_user) { FactoryGirl.build_stubbed(:user) } - let(:new_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } + let(:new_user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(current_user: current_user) } describe '.contract' do diff --git a/spec/services/users/update_user_service_spec.rb b/spec/services/users/update_user_service_spec.rb index ae115af421..6d89c1b8c7 100644 --- a/spec/services/users/update_user_service_spec.rb +++ b/spec/services/users/update_user_service_spec.rb @@ -29,8 +29,8 @@ require 'spec_helper' describe Users::UpdateUserService do - let(:current_user) { FactoryGirl.build_stubbed(:admin) } - let(:update_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:admin) } + let(:update_user) { FactoryBot.build_stubbed(:user) } let(:instance) { described_class.new(user: update_user, current_user: current_user) } describe '.contract' do @@ -46,7 +46,7 @@ describe Users::UpdateUserService do end describe 'updating attributes' do - let(:update_user) { FactoryGirl.create(:user, mail: 'correct@example.org') } + let(:update_user) { FactoryBot.create(:user, mail: 'correct@example.org') } subject { instance.call(attributes: attributes) } context 'when invalid' do @@ -73,7 +73,7 @@ describe Users::UpdateUserService do end context 'if current_user is no admin' do - let(:current_user) { FactoryGirl.build_stubbed(:user) } + let(:current_user) { FactoryBot.build_stubbed(:user) } it 'is unsuccessful' do expect(subject).to_not be_success end diff --git a/spec/services/work_packages/copy_service_integration_spec.rb b/spec/services/work_packages/copy_service_integration_spec.rb index 08479ee2ff..48cbd4ac51 100644 --- a/spec/services/work_packages/copy_service_integration_spec.rb +++ b/spec/services/work_packages/copy_service_integration_spec.rb @@ -30,12 +30,12 @@ require 'spec_helper' describe WorkPackages::CopyService, 'integration', type: :model do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: permissions) end @@ -44,19 +44,19 @@ describe WorkPackages::CopyService, 'integration', type: :model do end let(:type) do - FactoryGirl.create(:type_standard, + FactoryBot.create(:type_standard, custom_fields: [custom_field]) end - let(:project) { FactoryGirl.create(:project, types: [type]) } + let(:project) { FactoryBot.create(:project, types: [type]) } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type) end let(:instance) { described_class.new(work_package: work_package, user: user) } - let(:custom_field) { FactoryGirl.create(:work_package_custom_field) } + let(:custom_field) { FactoryBot.create(:work_package_custom_field) } let(:custom_value) do - FactoryGirl.create(:work_package_custom_value, + FactoryBot.create(:work_package_custom_value, custom_field: custom_field, customized: work_package, value: false) @@ -95,13 +95,13 @@ describe WorkPackages::CopyService, 'integration', type: :model do end describe 'to a different project' do - let(:target_type) { FactoryGirl.create(:type, custom_fields: target_custom_fields) } + let(:target_type) { FactoryBot.create(:type, custom_fields: target_custom_fields) } let(:target_project) do - p = FactoryGirl.create(:project, + p = FactoryBot.create(:project, types: [target_type], work_package_custom_fields: target_custom_fields) - FactoryGirl.create(:member, + FactoryBot.create(:member, project: p, roles: [target_role], user: user) @@ -109,7 +109,7 @@ describe WorkPackages::CopyService, 'integration', type: :model do p end let(:target_custom_fields) { [] } - let(:target_role) { FactoryGirl.create(:role, permissions: target_permissions) } + let(:target_role) { FactoryBot.create(:role, permissions: target_permissions) } let(:target_permissions) { %i(add_work_packages manage_subtasks) } let(:attributes) { { project: target_project, type: target_type } } @@ -139,7 +139,7 @@ describe WorkPackages::CopyService, 'integration', type: :model do context 'required custom field in the target project' do let(:custom_field) do - FactoryGirl.create( + FactoryBot.create( :work_package_custom_field, field_format: 'text', is_required: true, @@ -155,12 +155,12 @@ describe WorkPackages::CopyService, 'integration', type: :model do describe '#attributes' do context 'assigned_to' do - let(:target_user) { FactoryGirl.create(:user) } + let(:target_user) { FactoryBot.create(:user) } let(:target_project_member) do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: target_project, principal: target_user, - roles: [FactoryGirl.create(:role)]) + roles: [FactoryBot.create(:role)]) end let(:attributes) { { assigned_to_id: target_user.id } } @@ -176,7 +176,7 @@ describe WorkPackages::CopyService, 'integration', type: :model do end context 'status' do - let(:target_status) { FactoryGirl.create(:status) } + let(:target_status) { FactoryBot.create(:status) } let(:attributes) { { status_id: target_status.id } } it_behaves_like 'copied work package' @@ -214,10 +214,10 @@ describe WorkPackages::CopyService, 'integration', type: :model do describe 'with children' do let(:instance) { described_class.new(work_package: child, user: user) } let!(:child) do - FactoryGirl.create(:work_package, parent: work_package, project: source_project) + FactoryBot.create(:work_package, parent: work_package, project: source_project) end let(:grandchild) do - FactoryGirl.create(:work_package, parent: child, project: source_project) + FactoryBot.create(:work_package, parent: child, project: source_project) end context 'cross project relations deactivated' do diff --git a/spec/services/work_packages/create_service_integration_spec.rb b/spec/services/work_packages/create_service_integration_spec.rb index e43aefae00..fc2909f635 100644 --- a/spec/services/work_packages/create_service_integration_spec.rb +++ b/spec/services/work_packages/create_service_integration_spec.rb @@ -30,12 +30,12 @@ require 'spec_helper' describe WorkPackages::CreateService, 'integration', type: :model do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:role) do - FactoryGirl.create(:role, + FactoryBot.create(:role, permissions: permissions) end @@ -44,24 +44,24 @@ describe WorkPackages::CreateService, 'integration', type: :model do end let(:type) do - FactoryGirl.create(:type, + FactoryBot.create(:type, custom_fields: [custom_field]) end let(:default_type) do - FactoryGirl.create(:type_standard) + FactoryBot.create(:type_standard) end - let(:project) { FactoryGirl.create(:project, types: [type, default_type]) } + let(:project) { FactoryBot.create(:project, types: [type, default_type]) } let(:parent) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, type: type) end let(:instance) { described_class.new(user: user) } - let(:custom_field) { FactoryGirl.create(:work_package_custom_field) } - let(:other_status) { FactoryGirl.create(:status) } - let(:default_status) { FactoryGirl.create(:default_status) } - let(:priority) { FactoryGirl.create(:priority) } - let(:default_priority) { FactoryGirl.create(:default_priority) } + let(:custom_field) { FactoryBot.create(:work_package_custom_field) } + let(:other_status) { FactoryBot.create(:status) } + let(:default_status) { FactoryBot.create(:default_status) } + let(:priority) { FactoryBot.create(:priority) } + let(:default_priority) { FactoryBot.create(:default_priority) } let(:attributes) { {} } let(:new_work_package) do service_result diff --git a/spec/services/work_packages/destroy_service_spec.rb b/spec/services/work_packages/destroy_service_spec.rb index b9dbbd25a2..833d82cee6 100644 --- a/spec/services/work_packages/destroy_service_spec.rb +++ b/spec/services/work_packages/destroy_service_spec.rb @@ -32,10 +32,10 @@ require 'spec_helper' describe WorkPackages::DestroyService do let(:user) do - FactoryGirl.build_stubbed(:user) + FactoryBot.build_stubbed(:user) end let(:work_package) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:instance) do described_class @@ -85,10 +85,10 @@ describe WorkPackages::DestroyService do context 'with ancestors' do let(:parent) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:grandparent) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:expect_inherited_attributes_service_calls) do inherited_service_instance = double(WorkPackages::UpdateAncestorsService) @@ -136,10 +136,10 @@ describe WorkPackages::DestroyService do context 'with descendants' do let(:child) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:grandchild) do - FactoryGirl.build_stubbed(:work_package) + FactoryBot.build_stubbed(:work_package) end let(:descendants) do [child, grandchild] diff --git a/spec/services/work_packages/move_service_spec.rb b/spec/services/work_packages/move_service_spec.rb index d31c761c73..648e472c07 100644 --- a/spec/services/work_packages/move_service_spec.rb +++ b/spec/services/work_packages/move_service_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe WorkPackages::MoveService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package) + FactoryBot.build_stubbed(:stubbed_work_package) end - let(:type) { FactoryGirl.build_stubbed(:type) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:type) { FactoryBot.build_stubbed(:type) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:instance) { described_class.new(work_package, user) } let(:child_service_result_work_package) { work_package } @@ -45,7 +45,7 @@ describe WorkPackages::MoveService, type: :model do context 'when copying' do let(:expected_attributes) { { project: project } } - let(:child_service_result_work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:child_service_result_work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } before do copy_double = double('copy service double') @@ -86,10 +86,10 @@ describe WorkPackages::MoveService, type: :model do context 'for a parent' do let(:child_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, parent: work_package) + FactoryBot.build_stubbed(:stubbed_work_package, parent: work_package) end let(:copied_child_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package) + FactoryBot.build_stubbed(:stubbed_work_package) end let(:child_child_service_result) do ServiceResult.new success: true, diff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rb index 1fbb1ffe1c..b358de9102 100644 --- a/spec/services/work_packages/set_attributes_service_spec.rb +++ b/spec/services/work_packages/set_attributes_service_spec.rb @@ -31,16 +31,16 @@ require 'spec_helper' describe WorkPackages::SetAttributesService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:project) do - p = FactoryGirl.build_stubbed(:project) + p = FactoryBot.build_stubbed(:project) allow(p).to receive(:shared_versions).and_return([]) p end let(:work_package) do - wp = FactoryGirl.build_stubbed(:work_package, project: project) - wp.type = FactoryGirl.build_stubbed(:type) + wp = FactoryBot.build_stubbed(:work_package, project: project) + wp.type = FactoryBot.build_stubbed(:type) wp.send(:clear_changes_information) allow(wp) @@ -166,8 +166,8 @@ describe WorkPackages::SetAttributesService, type: :model do end context 'status' do - let(:default_status) { FactoryGirl.build_stubbed(:default_status) } - let(:other_status) { FactoryGirl.build_stubbed(:status) } + let(:default_status) { FactoryBot.build_stubbed(:default_status) } + let(:other_status) { FactoryBot.build_stubbed(:status) } let(:new_statuses) { [other_status, default_status] } before do @@ -237,7 +237,7 @@ describe WorkPackages::SetAttributesService, type: :model do end context 'author' do - let(:other_user) { FactoryGirl.build_stubbed(:user) } + let(:other_user) { FactoryBot.build_stubbed(:user) } context 'no value set before for a new work package' do let(:call_attributes) { {} } @@ -296,8 +296,8 @@ describe WorkPackages::SetAttributesService, type: :model do end context 'priority' do - let(:default_priority) { FactoryGirl.build_stubbed(:priority) } - let(:other_priority) { FactoryGirl.build_stubbed(:priority) } + let(:default_priority) { FactoryBot.build_stubbed(:priority) } + let(:other_priority) { FactoryBot.build_stubbed(:priority) } before do allow(IssuePriority) @@ -362,7 +362,7 @@ describe WorkPackages::SetAttributesService, type: :model do end context 'when switching the type' do - let(:target_type) { FactoryGirl.build_stubbed(:type) } + let(:target_type) { FactoryBot.build_stubbed(:type) } context 'with a type that is no milestone' do before do @@ -408,17 +408,17 @@ describe WorkPackages::SetAttributesService, type: :model do end context 'when switching the project' do - let(:new_project) { FactoryGirl.build_stubbed(:project) } - let(:version) { FactoryGirl.build_stubbed(:version) } - let(:category) { FactoryGirl.build_stubbed(:category) } - let(:new_category) { FactoryGirl.build_stubbed(:category, name: category.name) } + let(:new_project) { FactoryBot.build_stubbed(:project) } + let(:version) { FactoryBot.build_stubbed(:version) } + let(:category) { FactoryBot.build_stubbed(:category) } + let(:new_category) { FactoryBot.build_stubbed(:category, name: category.name) } let(:new_statuses) { [work_package.status] } let(:new_versions) { [] } let(:type) { work_package.type } let(:new_types) { [type] } - let(:default_type) { FactoryGirl.build_stubbed(:type_standard) } - let(:other_type) { FactoryGirl.build_stubbed(:type) } - let(:yet_another_type) { FactoryGirl.build_stubbed(:type) } + let(:default_type) { FactoryBot.build_stubbed(:type_standard) } + let(:other_type) { FactoryBot.build_stubbed(:type) } + let(:yet_another_type) { FactoryBot.build_stubbed(:type) } let(:call_attributes) { {} } let(:new_project_categories) do diff --git a/spec/services/work_packages/set_schedule_service_spec.rb b/spec/services/work_packages/set_schedule_service_spec.rb index ef10b45b44..0586b23d34 100644 --- a/spec/services/work_packages/set_schedule_service_spec.rb +++ b/spec/services/work_packages/set_schedule_service_spec.rb @@ -32,7 +32,7 @@ require 'spec_helper' describe WorkPackages::SetScheduleService do let(:work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, start_date: work_package_start_date, due_date: work_package_due_date) end @@ -44,17 +44,17 @@ describe WorkPackages::SetScheduleService do let(:following) do { [work_package] => [] } end - let(:user) { FactoryGirl.build_stubbed(:user) } - let(:type) { FactoryGirl.build_stubbed(:type) } + let(:user) { FactoryBot.build_stubbed(:user) } + let(:type) { FactoryBot.build_stubbed(:type) } def stub_follower(start_date, due_date, predecessors) - work_package = FactoryGirl.build_stubbed(:stubbed_work_package, + work_package = FactoryBot.build_stubbed(:stubbed_work_package, type: type, start_date: start_date, due_date: due_date) relations = predecessors.map do |predecessor, delay| - FactoryGirl.build_stubbed(:follows_relation, + FactoryBot.build_stubbed(:follows_relation, delay: delay, from: work_package, to: predecessor) @@ -72,7 +72,7 @@ describe WorkPackages::SetScheduleService do due, {}) - relation = FactoryGirl.build_stubbed(:hierarchy_relation, + relation = FactoryBot.build_stubbed(:hierarchy_relation, from: parent, to: child) @@ -116,7 +116,7 @@ describe WorkPackages::SetScheduleService do parent_follower1_due_date, {}) - relation = FactoryGirl.build_stubbed(:hierarchy_relation, + relation = FactoryBot.build_stubbed(:hierarchy_relation, from: work_package, to: following_work_package1) @@ -132,7 +132,7 @@ describe WorkPackages::SetScheduleService do follower1_due_date + 4.days, {}) - relation = FactoryGirl.build_stubbed(:hierarchy_relation, + relation = FactoryBot.build_stubbed(:hierarchy_relation, from: parent_following_work_package1, to: sibling) @@ -319,20 +319,20 @@ describe WorkPackages::SetScheduleService do context 'moving backwards with the follower having another relation limiting movement' do let(:other_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, type: type, start_date: follower1_start_date - 8.days, due_date: follower1_start_date - 5.days) end let(:follow_relation) do - FactoryGirl.build_stubbed(:follows_relation, + FactoryBot.build_stubbed(:follows_relation, to: work_package, from: following_work_package1) end let(:other_follow_relation) do - FactoryGirl.build_stubbed(:follows_relation, + FactoryBot.build_stubbed(:follows_relation, delay: 3, to: other_work_package, from: following_work_package1) @@ -428,7 +428,7 @@ describe WorkPackages::SetScheduleService do another_successor => 0) end let(:another_successor) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, start_date: nil, due_date: nil) end @@ -461,7 +461,7 @@ describe WorkPackages::SetScheduleService do context 'with only a parent' do let(:parent_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package) + FactoryBot.build_stubbed(:stubbed_work_package) end let(:work_package_start_date) { Date.today - 5.days } let(:following) do @@ -559,14 +559,14 @@ describe WorkPackages::SetScheduleService do context 'moving backwards with the parent having another relation limiting movement' do let(:other_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, type: type, start_date: Date.today - 8.days, due_date: Date.today - 4.days) end let(:other_follow_relation) do - FactoryGirl.build_stubbed(:follows_relation, + FactoryBot.build_stubbed(:follows_relation, delay: 2, to: other_work_package, from: parent_following_work_package1) @@ -594,14 +594,14 @@ describe WorkPackages::SetScheduleService do context 'moving backwards with the parent having another relation not limiting movement' do let(:other_work_package) do - FactoryGirl.build_stubbed(:stubbed_work_package, + FactoryBot.build_stubbed(:stubbed_work_package, type: type, start_date: Date.today - 10.days, due_date: Date.today - 9.days) end let(:other_follow_relation) do - FactoryGirl.build_stubbed(:follows_relation, + FactoryBot.build_stubbed(:follows_relation, delay: 2, to: other_work_package, from: parent_following_work_package1) @@ -942,7 +942,7 @@ describe WorkPackages::SetScheduleService do end context 'when setting the parent' do - let(:new_parent_work_package) { FactoryGirl.build_stubbed(:stubbed_work_package) } + let(:new_parent_work_package) { FactoryBot.build_stubbed(:stubbed_work_package) } let(:attributes) { [:parent] } before do diff --git a/spec/services/work_packages/update_ancestors_service_spec.rb b/spec/services/work_packages/update_ancestors_service_spec.rb index e751e5860c..20ac638be6 100644 --- a/spec/services/work_packages/update_ancestors_service_spec.rb +++ b/spec/services/work_packages/update_ancestors_service_spec.rb @@ -29,12 +29,12 @@ require 'spec_helper' describe WorkPackages::UpdateAncestorsService, type: :model do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } let(:estimated_hours) { [nil, nil, nil] } let(:done_ratios) { [0, 0, 0] } let(:statuses) { %i(open open open) } - let(:open_status) { FactoryGirl.create :status } - let(:closed_status) { FactoryGirl.create :closed_status } + let(:open_status) { FactoryBot.create :status } + let(:closed_status) { FactoryBot.create :closed_status } let(:aggregate_done_ratio) { 0.0 } context 'for the new ancestor chain' do @@ -66,14 +66,14 @@ describe WorkPackages::UpdateAncestorsService, type: :model do let(:children) do (statuses.size - 1).downto(0).map do |i| - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: parent, status: statuses[i] == :open ? open_status : closed_status, estimated_hours: estimated_hours[i], done_ratio: done_ratios[i] end end - let(:parent) { FactoryGirl.create :work_package, status: open_status } + let(:parent) { FactoryBot.create :work_package, status: open_status } subject do described_class @@ -191,14 +191,14 @@ describe WorkPackages::UpdateAncestorsService, type: :model do let(:sibling_estimated_hours) { 7.0 } let!(:grandparent) do - FactoryGirl.create :work_package + FactoryBot.create :work_package end let!(:parent) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: grandparent end let!(:sibling) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: parent, status: sibling_status, estimated_hours: sibling_estimated_hours, @@ -206,7 +206,7 @@ describe WorkPackages::UpdateAncestorsService, type: :model do end let!(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: parent end @@ -261,14 +261,14 @@ describe WorkPackages::UpdateAncestorsService, type: :model do let(:estimated_hours) { 7.0 } let!(:grandparent) do - FactoryGirl.create :work_package + FactoryBot.create :work_package end let!(:parent) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, parent: grandparent end let!(:work_package) do - FactoryGirl.create :work_package, + FactoryBot.create :work_package, status: status, estimated_hours: estimated_hours, done_ratio: done_ratio diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rb index 2f5850d552..e25c33f4fd 100644 --- a/spec/services/work_packages/update_service_integration_spec.rb +++ b/spec/services/work_packages/update_service_integration_spec.rb @@ -32,20 +32,20 @@ require 'spec_helper' describe WorkPackages::UpdateService, 'integration tests', type: :model do let(:user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } let(:permissions) do %i(view_work_packages edit_work_packages add_work_packages move_work_packages manage_subtasks) end - let(:type) { FactoryGirl.create(:type_standard) } + let(:type) { FactoryBot.create(:type_standard) } let(:project_types) { [type] } - let(:project) { FactoryGirl.create(:project, types: project_types) } - let(:status) { FactoryGirl.create(:status) } - let(:priority) { FactoryGirl.create(:priority) } + let(:project) { FactoryBot.create(:project, types: project_types) } + let(:status) { FactoryBot.create(:status) } + let(:priority) { FactoryBot.create(:priority) } let(:work_package_attributes) do { project_id: project.id, type_id: type.id, @@ -54,18 +54,18 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do priority: priority } end let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, work_package_attributes) end let(:parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, work_package_attributes).tap do |w| w.children << work_package work_package.reload end end let(:grandparent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, work_package_attributes).tap do |w| w.children << parent_work_package end @@ -77,25 +77,25 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do work_package_attributes.merge(parent: parent_work_package) end let(:sibling1_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, sibling1_attributes) end let(:sibling2_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, sibling2_attributes) end let(:child_attributes) do work_package_attributes.merge(parent: work_package) end let(:child_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, child_attributes) end let(:grandchild_attributes) do work_package_attributes.merge(parent: child_work_package) end let(:grandchild_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, grandchild_attributes) end let(:instance) do @@ -123,14 +123,14 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'updating project' do let(:target_project) do - p = FactoryGirl.create(:project, + p = FactoryBot.create(:project, types: target_types, parent: target_parent) - FactoryGirl.create(:member, + FactoryBot.create(:member, user: user, project: p, - roles: [FactoryGirl.create(:role, permissions: target_permissions)]) + roles: [FactoryBot.create(:role, permissions: target_permissions)]) p end @@ -150,10 +150,10 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'time_entries' do let!(:time_entries) do - [FactoryGirl.create(:time_entry, + [FactoryBot.create(:time_entry, project: project, work_package: work_package), - FactoryGirl.create(:time_entry, + FactoryBot.create(:time_entry, project: project, work_package: work_package)] end @@ -168,7 +168,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'categories' do let(:category) do - FactoryGirl.create(:category, + FactoryBot.create(:category, project: project) end @@ -179,7 +179,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do context 'with equally named category' do let!(:target_category) do - FactoryGirl.create(:category, + FactoryBot.create(:category, name: category.name, project: target_project) end @@ -195,7 +195,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do context 'w/o target category' do let!(:other_category) do - FactoryGirl.create(:category, + FactoryBot.create(:category, project: target_project) end @@ -212,13 +212,13 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'version' do let(:sharing) { 'none' } let(:version) do - FactoryGirl.create(:version, + FactoryBot.create(:version, status: 'open', project: project, sharing: sharing) end let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, fixed_version: version, project: project) end @@ -276,11 +276,11 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'type' do let(:target_types) { [type, other_type] } - let(:other_type) { FactoryGirl.create(:type) } + let(:other_type) { FactoryBot.create(:type) } let(:default_type) { type } let(:project_types) { [type, other_type] } # otherwise ar error - let!(:default_status) { FactoryGirl.create(:default_status) } + let!(:default_status) { FactoryBot.create(:default_status) } context 'with the type existing in the target project' do it 'keeps the type' do @@ -503,9 +503,9 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do describe 'closing duplicates on closing status' do let(:status_closed) do - FactoryGirl.create(:status, + FactoryBot.create(:status, is_closed: true).tap do |status_closed| - FactoryGirl.create(:workflow, + FactoryBot.create(:workflow, old_status: status, new_status: status_closed, type: type, @@ -513,7 +513,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do end end let(:duplicate_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, work_package_attributes).tap do |wp| wp.duplicated << work_package end @@ -563,7 +563,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 20.days) end let(:following_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following_attributes).tap do |wp| wp.follows << work_package end @@ -574,7 +574,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 20.days) end let(:following_parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following_parent_attributes) end let(:following2_attributes) do @@ -584,7 +584,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 25.days) end let(:following2_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following2_attributes) end let(:following2_parent_attributes) do @@ -593,7 +593,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 25.days) end let(:following2_parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following2_parent_attributes).tap do |wp| wp.follows << following_parent_work_package end @@ -605,7 +605,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 30.days) end let(:following3_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following3_attributes).tap do |wp| wp.follows << following2_work_package end @@ -616,7 +616,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 36.days) end let(:following3_parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following3_parent_attributes) end let(:following3_sibling_attributes) do @@ -626,7 +626,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 36.days) end let(:following3_sibling_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following3_sibling_attributes) end @@ -737,7 +737,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 20.days) end let(:following_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following_attributes).tap do |wp| wp.follows << work_package end @@ -748,7 +748,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 20.days) end let(:following_parent_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following_parent_attributes) end let(:other_attributes) do @@ -757,7 +757,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 18.days) end let(:other_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, other_attributes) end let(:following2_attributes) do @@ -767,7 +767,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 28.days) end let(:following2_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following2_attributes) end let(:following2_parent_attributes) do @@ -776,12 +776,12 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 28.days) end let(:following2_parent_work_package) do - following2 = FactoryGirl.create(:work_package, + following2 = FactoryBot.create(:work_package, following2_parent_attributes).tap do |wp| wp.follows << following_parent_work_package end - FactoryGirl.create(:relation, + FactoryBot.create(:relation, relation_type: Relation::TYPE_FOLLOWS, from: following2, to: other_work_package, @@ -795,7 +795,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do due_date: Date.today + 33.days) end let(:following3_work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, following3_attributes).tap do |wp| wp.follows << following2_work_package end @@ -878,7 +878,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do } end let(:former_parent_work_package) do - FactoryGirl.create(:work_package, former_parent_attributes) + FactoryBot.create(:work_package, former_parent_attributes) end let(:former_sibling_attributes) do @@ -890,7 +890,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do ) end let(:former_sibling_work_package) do - FactoryGirl.create(:work_package, former_sibling_attributes) + FactoryBot.create(:work_package, former_sibling_attributes) end let(:work_package_attributes) do @@ -913,7 +913,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do ) end let(:new_parent_work_package) do - FactoryGirl.create(:work_package, new_parent_attributes) + FactoryBot.create(:work_package, new_parent_attributes) end let(:new_sibling_attributes) do @@ -925,7 +925,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do ) end let(:new_sibling_work_package) do - FactoryGirl.create(:work_package, new_sibling_attributes) + FactoryBot.create(:work_package, new_sibling_attributes) end before do @@ -978,7 +978,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do ) end let(:new_parent_work_package) do - FactoryGirl.create(:work_package, new_parent_attributes) + FactoryBot.create(:work_package, new_parent_attributes) end let(:new_parent_predecessor_attributes) do @@ -990,7 +990,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do ) end let(:new_parent_predecessor_work_package) do - wp = FactoryGirl.create(:work_package, new_parent_predecessor_attributes) + wp = FactoryBot.create(:work_package, new_parent_predecessor_attributes) wp.precedes << new_parent_work_package @@ -1071,7 +1071,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do end let(:parent_work_package) do - FactoryGirl.create(:work_package, parent_attributes) + FactoryBot.create(:work_package, parent_attributes) end let(:sibling_attributes) do @@ -1083,7 +1083,7 @@ describe WorkPackages::UpdateService, 'integration tests', type: :model do end let(:sibling_work_package) do - wp = FactoryGirl.create(:work_package, sibling_attributes) + wp = FactoryBot.create(:work_package, sibling_attributes) wp.follows << work_package diff --git a/spec/services/work_packages/update_service_spec.rb b/spec/services/work_packages/update_service_spec.rb index ce30cdad96..59e9b23d0a 100644 --- a/spec/services/work_packages/update_service_spec.rb +++ b/spec/services/work_packages/update_service_spec.rb @@ -31,16 +31,16 @@ require 'spec_helper' describe WorkPackages::UpdateService, type: :model do - let(:user) { FactoryGirl.build_stubbed(:user) } + let(:user) { FactoryBot.build_stubbed(:user) } let(:project) do - p = FactoryGirl.build_stubbed(:project) + p = FactoryBot.build_stubbed(:project) allow(p).to receive(:shared_versions).and_return([]) p end let(:work_package) do - wp = FactoryGirl.build_stubbed(:work_package, project: project) - wp.type = FactoryGirl.build_stubbed(:type) + wp = FactoryBot.build_stubbed(:work_package, project: project) + wp.type = FactoryBot.build_stubbed(:type) wp.send(:clear_changes_information) wp @@ -180,7 +180,7 @@ describe WorkPackages::UpdateService, type: :model do context 'when switching the project' do let(:target_project) do - FactoryGirl.build_stubbed(:project) + FactoryBot.build_stubbed(:project) end let(:call_attributes) { attributes } let(:attributes) { { project: target_project } } @@ -235,7 +235,7 @@ describe WorkPackages::UpdateService, type: :model do end context 'when switching the type' do - let(:target_type) { FactoryGirl.build_stubbed(:type) } + let(:target_type) { FactoryBot.build_stubbed(:type) } context 'custom_values' do it 'resets the custom values' do diff --git a/spec/support/api/v3/shared_available_principals_examples.rb b/spec/support/api/v3/shared_available_principals_examples.rb index 3c1caf7201..132e78a73e 100644 --- a/spec/support/api/v3/shared_available_principals_examples.rb +++ b/spec/support/api/v3/shared_available_principals_examples.rb @@ -32,16 +32,16 @@ shared_examples_for 'available principals' do |principals| include API::V3::Utilities::PathHelper let(:current_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end let(:other_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:role) { FactoryGirl.create(:role, permissions: permissions) } - let(:project) { FactoryGirl.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: permissions) } + let(:project) { FactoryBot.create(:project) } let(:group) do - group = FactoryGirl.create(:group) - project.add_member! group, FactoryGirl.create(:role) + group = FactoryBot.create(:group) + project.add_member! group, FactoryBot.create(:role) group end let(:permissions) { [:view_work_packages] } diff --git a/spec/support/permission_specs.rb b/spec/support/permission_specs.rb index 04cc26ae84..798a926dfc 100644 --- a/spec/support/permission_specs.rb +++ b/spec/support/permission_specs.rb @@ -32,8 +32,8 @@ require File.expand_path('../shared/become_member', __FILE__) module PermissionSpecs def self.included(base) base.class_eval do - let(:project) { FactoryGirl.create(:project, is_public: false) } - let(:current_user) { FactoryGirl.create(:user) } + let(:project) { FactoryBot.create(:project, is_public: false) } + let(:current_user) { FactoryBot.create(:user) } include BecomeMember diff --git a/spec/support/queries/filters/shared_filter_examples.rb b/spec/support/queries/filters/shared_filter_examples.rb index 9b81803e44..98a361bf8b 100644 --- a/spec/support/queries/filters/shared_filter_examples.rb +++ b/spec/support/queries/filters/shared_filter_examples.rb @@ -41,8 +41,8 @@ end shared_examples_for 'basic query filter' do include_context 'filter tests' - let(:context) { FactoryGirl.build_stubbed(:query, project: project) } - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:context) { FactoryBot.build_stubbed(:query, project: project) } + let(:project) { FactoryBot.build_stubbed(:project) } let(:class_key) { raise 'needs to be defined' } let(:type) { raise 'needs to be defined' } let(:human_name) { nil } diff --git a/spec/support/queries/shared_get_individual_query_examples.rb b/spec/support/queries/shared_get_individual_query_examples.rb index c915a1a9fe..4d816b6d45 100644 --- a/spec/support/queries/shared_get_individual_query_examples.rb +++ b/spec/support/queries/shared_get_individual_query_examples.rb @@ -27,7 +27,7 @@ #++ shared_examples_for 'GET individual query' do - let(:work_package) { FactoryGirl.create(:work_package, project: project) } + let(:work_package) { FactoryBot.create(:work_package, project: project) } let(:filter) { [] } let(:path) do if filter.any? diff --git a/spec/support/repository_helpers.rb b/spec/support/repository_helpers.rb index bab8271dcb..5d6c348fcd 100644 --- a/spec/support/repository_helpers.rb +++ b/spec/support/repository_helpers.rb @@ -75,7 +75,7 @@ end # Instead, we wrap these repository specs in a virtual # subversion repository which does not exist on disk. def with_virtual_subversion_repository(&block) - let(:repository) { FactoryGirl.create(:repository_subversion) } + let(:repository) { FactoryBot.create(:repository_subversion) } before do allow(Setting).to receive(:enabled_scm).and_return(['subversion']) diff --git a/spec/support/scm/relocate_repository.rb b/spec/support/scm/relocate_repository.rb index c82db667f7..66e80cbf30 100644 --- a/spec/support/scm/relocate_repository.rb +++ b/spec/support/scm/relocate_repository.rb @@ -1,8 +1,8 @@ shared_examples_for 'repository can be relocated' do |vendor| let(:job) { ::Scm::RelocateRepositoryJob.new repository } - let(:project) { FactoryGirl.build :project } + let(:project) { FactoryBot.build :project } let(:repository) { - repo = FactoryGirl.build("repository_#{vendor}".to_sym, + repo = FactoryBot.build("repository_#{vendor}".to_sym, project: project, scm_type: :managed) @@ -49,7 +49,7 @@ shared_examples_for 'repository can be relocated' do |vendor| stub_request(:post, url) .to_return(status: 200, body: { success: true, url: 'file:///foo/bar', path: '/tmp/foo/bar' }.to_json) - FactoryGirl.create("repository_#{vendor}".to_sym, + FactoryBot.create("repository_#{vendor}".to_sym, project: project, scm_type: :managed) } diff --git a/spec/support/shared/acts_as_watchable.rb b/spec/support/shared/acts_as_watchable.rb index 87303e94c2..245def8165 100644 --- a/spec/support/shared/acts_as_watchable.rb +++ b/spec/support/shared/acts_as_watchable.rb @@ -43,17 +43,17 @@ MESSAGE let(:watcher_role) do permissions = is_public_permission ? [] : [watch_permission] - FactoryGirl.create(:role, permissions: permissions) + FactoryBot.create(:role, permissions: permissions) end - let(:non_watcher_role) { FactoryGirl.create(:role, permissions: []) } - let(:non_member_user) { FactoryGirl.create(:user) } + let(:non_watcher_role) { FactoryBot.create(:role, permissions: []) } + let(:non_member_user) { FactoryBot.create(:user) } let(:user_with_permission) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: watcher_role) end let(:locked_user_with_permission) do - FactoryGirl.create(:user, + FactoryBot.create(:user, status: Principal::STATUSES[:locked], member_in_project: project, member_through_role: watcher_role) @@ -61,17 +61,17 @@ MESSAGE let(:user_wo_permission) do if is_public_permission - FactoryGirl.create(:user) + FactoryBot.create(:user) else - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: non_watcher_role) end end - let(:admin) { FactoryGirl.build(:admin) } - let(:anonymous_user) { FactoryGirl.build(:anonymous) } + let(:admin) { FactoryBot.build(:admin) } + let(:anonymous_user) { FactoryBot.build(:anonymous) } let(:watching_user) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: watcher_role).tap do |user| Watcher.create(watchable: model_instance, user: user) @@ -101,7 +101,7 @@ MESSAGE shared_context 'anonymous role has the permission to watch' do let(:anonymous_role) do permissions = is_public_permission ? [] : [watch_permission] - FactoryGirl.build :anonymous_role, permissions: permissions + FactoryBot.build :anonymous_role, permissions: permissions end before do diff --git a/spec/support/shared/become_member.rb b/spec/support/shared/become_member.rb index eedab08d59..6c7bb8f7a6 100644 --- a/spec/support/shared/become_member.rb +++ b/spec/support/shared/become_member.rb @@ -34,14 +34,14 @@ module BecomeMember module InstanceMethods def become_member_with_permissions(project, user, permissions = []) - role = FactoryGirl.create :role, permissions: Array(permissions) + role = FactoryBot.create :role, permissions: Array(permissions) add_user_to_project! user: user, project: project, role: role end def add_user_to_project!(user:, project:, role: nil, permissions: nil) - role ||= FactoryGirl.create :existing_role, permissions: Array(permissions) - FactoryGirl.create :member, principal: user, project: project, roles: [role] + role ||= FactoryBot.create :existing_role, permissions: Array(permissions) + FactoryBot.create :member, principal: user, project: project, roles: [role] end end end diff --git a/spec/support/shared/permissions.rb b/spec/support/shared/permissions.rb index 6caa26963a..0d8da2d574 100644 --- a/spec/support/shared/permissions.rb +++ b/spec/support/shared/permissions.rb @@ -75,23 +75,23 @@ module PermissionSpecHelpers end shared_examples_for 'a controller action with unrestricted access' do - let(:valid_user) { FactoryGirl.create(:anonymous) } + let(:valid_user) { FactoryBot.create(:anonymous) } extend PermissionSpecHelpers spec_permissions(false) end shared_examples_for 'a controller action with require_login' do - let(:valid_user) { FactoryGirl.create(:user) } - let(:invalid_user) { FactoryGirl.create(:anonymous) } + let(:valid_user) { FactoryBot.create(:user) } + let(:invalid_user) { FactoryBot.create(:anonymous) } extend PermissionSpecHelpers spec_permissions end shared_examples_for 'a controller action with require_admin' do - let(:valid_user) { User.where(admin: true).first || FactoryGirl.create(:admin) } - let(:invalid_user) { FactoryGirl.create(:user) } + let(:valid_user) { User.where(admin: true).first || FactoryBot.create(:admin) } + let(:invalid_user) { FactoryBot.create(:user) } extend PermissionSpecHelpers spec_permissions @@ -100,7 +100,7 @@ end shared_examples_for 'a controller action which needs project permissions' do # Expecting the following environment # - # let(:project) { FactoryGirl.create(:project) } + # let(:project) { FactoryBot.create(:project) } # # def fetch # get 'action', project_id: project.identifier @@ -116,12 +116,12 @@ shared_examples_for 'a controller action which needs project permissions' do # # other - passed to response.should redirect_to(other) # true # end - let(:valid_user) { FactoryGirl.create(:user) } - let(:invalid_user) { FactoryGirl.create(:user) } + let(:valid_user) { FactoryBot.create(:user) } + let(:invalid_user) { FactoryBot.create(:user) } def add_membership(user, permissions) - role = FactoryGirl.create(:role, permissions: Array(permissions)) - member = FactoryGirl.build(:member, user: user, project: project) + role = FactoryBot.create(:role, permissions: Array(permissions)) + member = FactoryBot.build(:member, user: user, project: project) member.roles = [role] member.save! end diff --git a/spec/support/shared/previews.rb b/spec/support/shared/previews.rb index 151086eb07..2b15a000c6 100644 --- a/spec/support/shared/previews.rb +++ b/spec/support/shared/previews.rb @@ -43,7 +43,7 @@ shared_examples_for 'valid preview' do end shared_examples_for 'authorizes object access' do - let(:unauthorized_user) { FactoryGirl.create(:user) } + let(:unauthorized_user) { FactoryBot.create(:user) } before do allow(User).to receive(:current).and_return(unauthorized_user) diff --git a/spec/support/work_packages.rb b/spec/support/work_packages.rb index 68059c9640..8a7e39182c 100644 --- a/spec/support/work_packages.rb +++ b/spec/support/work_packages.rb @@ -27,11 +27,11 @@ #++ def become_admin - let(:current_user) { FactoryGirl.create(:admin) } + let(:current_user) { FactoryBot.create(:admin) } end def become_non_member(&block) - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do projects = block ? instance_eval(&block) : [project] @@ -43,12 +43,12 @@ def become_non_member(&block) end def become_member_with_permissions(permissions) - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } before do - role = FactoryGirl.create(:role, permissions: permissions) + role = FactoryBot.create(:role, permissions: permissions) - member = FactoryGirl.build(:member, user: current_user, project: project) + member = FactoryBot.build(:member, user: current_user, project: project) member.roles = [role] member.save! end diff --git a/spec/views/account/register.html.erb_spec.rb b/spec/views/account/register.html.erb_spec.rb index e296fd18ce..84788f1843 100644 --- a/spec/views/account/register.html.erb_spec.rb +++ b/spec/views/account/register.html.erb_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'account/register', type: :view do - let(:user) { FactoryGirl.build :user, auth_source: nil } + let(:user) { FactoryBot.build :user, auth_source: nil } context 'with the email_login setting disabled (default value)' do before do @@ -40,8 +40,8 @@ describe 'account/register', type: :view do end context 'with auth source' do - let(:auth_source) { FactoryGirl.create :auth_source } - let(:user) { FactoryGirl.build :user, auth_source: auth_source } + let(:auth_source) { FactoryBot.create :auth_source } + let(:user) { FactoryBot.build :user, auth_source: auth_source } it 'should not show a login field' do expect(rendered).not_to include('user[login]') @@ -64,8 +64,8 @@ describe 'account/register', type: :view do end context 'with auth source' do - let(:auth_source) { FactoryGirl.create :auth_source } - let(:user) { FactoryGirl.build :user, auth_source: auth_source } + let(:auth_source) { FactoryBot.create :auth_source } + let(:user) { FactoryBot.build :user, auth_source: auth_source } it 'should not show a login field' do expect(rendered).not_to include('user[login]') diff --git a/spec/views/custom_styles/show.html.erb_spec.rb b/spec/views/custom_styles/show.html.erb_spec.rb index ddebf76283..5a32afbf54 100644 --- a/spec/views/custom_styles/show.html.erb_spec.rb +++ b/spec/views/custom_styles/show.html.erb_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'custom_styles/show', type: :view do - let(:user) { FactoryGirl.build(:admin) } + let(:user) { FactoryBot.build(:admin) } before do login_as user @@ -48,7 +48,7 @@ describe 'custom_styles/show', type: :view do context "with existing custom logo" do before do - assign(:custom_style, FactoryGirl.build(:custom_style_with_logo)) + assign(:custom_style, FactoryBot.build(:custom_style_with_logo)) render end diff --git a/spec/views/layouts/admin.html.erb_spec.rb b/spec/views/layouts/admin.html.erb_spec.rb index 5c51e681e2..ebc6e4b3f1 100644 --- a/spec/views/layouts/admin.html.erb_spec.rb +++ b/spec/views/layouts/admin.html.erb_spec.rb @@ -32,7 +32,7 @@ describe 'layouts/admin', type: :view do include Redmine::MenuManager::MenuHelper helper Redmine::MenuManager::MenuHelper - let(:admin) { FactoryGirl.create :admin } + let(:admin) { FactoryBot.create :admin } before do allow(view).to receive(:current_menu_item).and_return('overview') diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rb index 8159f85487..ddba948986 100644 --- a/spec/views/layouts/base.html.erb_spec.rb +++ b/spec/views/layouts/base.html.erb_spec.rb @@ -36,8 +36,8 @@ describe 'layouts/base', type: :view do include Redmine::MenuManager::MenuHelper helper Redmine::MenuManager::MenuHelper - let!(:user) { FactoryGirl.create :user } - let!(:anonymous) { FactoryGirl.create(:anonymous) } + let!(:user) { FactoryBot.create :user } + let!(:anonymous) { FactoryBot.create(:anonymous) } before do allow(view).to receive(:current_menu_item).and_return('overview') @@ -180,7 +180,7 @@ describe 'layouts/base', type: :view do context "EE is active and styles are present" do let(:custom_style) { CustomStyle.new } - let(:primary_color) { FactoryGirl.create :"design_color_primary-color" } + let(:primary_color) { FactoryBot.create :"design_color_primary-color" } before do allow(EnterpriseToken).to receive(:allows_to?).with(:define_custom_style).and_return(true) diff --git a/spec/views/my/page.html.erb_spec.rb b/spec/views/my/page.html.erb_spec.rb index 751a7c5a60..6fd15dfdf4 100644 --- a/spec/views/my/page.html.erb_spec.rb +++ b/spec/views/my/page.html.erb_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe 'my/page', type: :view do - let(:project) { FactoryGirl.create :valid_project } - let(:user) { FactoryGirl.create :admin, member_in_project: project } - let(:issue) { FactoryGirl.create :work_package, project: project, author: user } + let(:project) { FactoryBot.create :valid_project } + let(:user) { FactoryBot.create :admin, member_in_project: project } + let(:issue) { FactoryBot.create :work_package, project: project, author: user } let(:time_entry) { - FactoryGirl.create :time_entry, + FactoryBot.create :time_entry, project: project, user: user, work_package: issue, diff --git a/spec/views/projects/level_list_api_json_spec.rb b/spec/views/projects/level_list_api_json_spec.rb index 420f9ed60e..9119e494e9 100644 --- a/spec/views/projects/level_list_api_json_spec.rb +++ b/spec/views/projects/level_list_api_json_spec.rb @@ -46,14 +46,14 @@ describe '/projects/level_list.api.rabl', type: :view do describe 'with some projects available' do let(:projects) do - p1 = FactoryGirl.build(:project, name: 'P1') + p1 = FactoryBot.build(:project, name: 'P1') # a result from Project.project_level_list [{ project: p1, level: 0 }, - { project: FactoryGirl.build(:project, name: 'P2', parent: p1), + { project: FactoryBot.build(:project, name: 'P2', parent: p1), level: 1 }, - { project: FactoryGirl.build(:project, name: 'P3'), + { project: FactoryBot.build(:project, name: 'P3'), level: 0 }] end diff --git a/spec/views/projects/settings.html.erb_spec.rb b/spec/views/projects/settings.html.erb_spec.rb index c6349f0438..19898e09b9 100644 --- a/spec/views/projects/settings.html.erb_spec.rb +++ b/spec/views/projects/settings.html.erb_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'project_settings/show', type: :view do - let(:project) { FactoryGirl.build_stubbed(:project) } + let(:project) { FactoryBot.build_stubbed(:project) } describe 'project copy permission' do before do @@ -61,7 +61,7 @@ describe 'project_settings/show', type: :view do end context 'User.current is admin' do - let(:admin) { FactoryGirl.build_stubbed :admin } + let(:admin) { FactoryBot.build_stubbed :admin } before do assign(:project, project) @@ -78,7 +78,7 @@ describe 'project_settings/show', type: :view do end context 'User.current is non-admin' do - let(:non_admin) { FactoryGirl.build_stubbed :user } + let(:non_admin) { FactoryBot.build_stubbed :user } before do assign(:project, project) diff --git a/spec/views/repositories/stats.html.erb_spec.rb b/spec/views/repositories/stats.html.erb_spec.rb index 8eeb9d4c2a..41be44745e 100644 --- a/spec/views/repositories/stats.html.erb_spec.rb +++ b/spec/views/repositories/stats.html.erb_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'repositories/stats', type: :view do - let(:project) { FactoryGirl.create(:project) } + let(:project) { FactoryBot.create(:project) } before do assign(:project, project) diff --git a/spec/views/search/index.html.erb_spec.rb b/spec/views/search/index.html.erb_spec.rb index 8105c1ab62..eb5252c68c 100644 --- a/spec/views/search/index.html.erb_spec.rb +++ b/spec/views/search/index.html.erb_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' describe 'search/index', type: :view do - let(:project) { FactoryGirl.create :project } - let(:user) { FactoryGirl.create :admin, member_in_project: project } - let(:work_package) { FactoryGirl.create :work_package, project: project } + let(:project) { FactoryBot.create :project } + let(:user) { FactoryBot.create :admin, member_in_project: project } + let(:work_package) { FactoryBot.create :work_package, project: project } before do assign :project, project diff --git a/spec/views/users/edit.html.erb_spec.rb b/spec/views/users/edit.html.erb_spec.rb index 777ff0c611..1c91f45613 100644 --- a/spec/views/users/edit.html.erb_spec.rb +++ b/spec/views/users/edit.html.erb_spec.rb @@ -29,7 +29,7 @@ require 'spec_helper' describe 'users/edit', type: :view do - let(:admin) { FactoryGirl.build :admin } + let(:admin) { FactoryBot.build :admin } before do # The url_for is missing the users id that is usually taken @@ -39,7 +39,7 @@ describe 'users/edit', type: :view do context 'authentication provider' do let(:user) do - FactoryGirl.build :user, id: 1, # id is required to create route to edit + FactoryBot.build :user, id: 1, # id is required to create route to edit identity_url: 'test_provider:veryuniqueid' end @@ -65,7 +65,7 @@ describe 'users/edit', type: :view do end context 'with an invited user' do - let(:user) { FactoryGirl.build_stubbed :invited_user } + let(:user) { FactoryBot.build_stubbed :invited_user } before do assign(:user, user) @@ -84,7 +84,7 @@ describe 'users/edit', type: :view do end context 'for a non-admin' do - let(:non_admin) { FactoryGirl.create :user } + let(:non_admin) { FactoryBot.create :user } before do allow(view).to receive(:current_user).and_return(non_admin) @@ -98,7 +98,7 @@ describe 'users/edit', type: :view do end context 'with a normal (not invited) user' do - let(:user) { FactoryGirl.create :user } + let(:user) { FactoryBot.create :user } before do assign(:user, user) @@ -114,7 +114,7 @@ describe 'users/edit', type: :view do end context 'with password-based login' do - let(:user) { FactoryGirl.build :user, id: 42 } + let(:user) { FactoryBot.build :user, id: 42 } before do assign :user, user @@ -135,7 +135,7 @@ describe 'users/edit', type: :view do end context 'with auth sources' do - let(:auth_sources) { [FactoryGirl.create(:auth_source)] } + let(:auth_sources) { [FactoryBot.create(:auth_source)] } before do assign :auth_sources, auth_sources @@ -161,7 +161,7 @@ describe 'users/edit', type: :view do end context 'with auth sources' do - let(:auth_sources) { [FactoryGirl.create(:auth_source)] } + let(:auth_sources) { [FactoryBot.create(:auth_source)] } before do assign :auth_sources, auth_sources diff --git a/spec/views/users/show.html.erb_spec.rb b/spec/views/users/show.html.erb_spec.rb index eeec65e51e..0cac4bb42a 100644 --- a/spec/views/users/show.html.erb_spec.rb +++ b/spec/views/users/show.html.erb_spec.rb @@ -29,11 +29,11 @@ require 'spec_helper' describe 'users/show', type: :view do - let(:project) { FactoryGirl.create :valid_project } - let(:user) { FactoryGirl.create :admin, member_in_project: project } - let(:custom_field) { FactoryGirl.create :text_user_custom_field } + let(:project) { FactoryBot.create :valid_project } + let(:user) { FactoryBot.create :admin, member_in_project: project } + let(:custom_field) { FactoryBot.create :text_user_custom_field } let(:visibility_custom_value) { - FactoryGirl.create(:principal_custom_value, + FactoryBot.create(:principal_custom_value, customized: user, custom_field: custom_field, value: 'TextUserCustomFieldValue') diff --git a/spec/views/work_package/auto_complete/index_spec.rb b/spec/views/work_package/auto_complete/index_spec.rb index ae99c5b519..1f1eab94a6 100644 --- a/spec/views/work_package/auto_complete/index_spec.rb +++ b/spec/views/work_package/auto_complete/index_spec.rb @@ -30,7 +30,7 @@ require 'spec_helper' describe 'work_packages/auto_completes/index.html.erb', type: :view do let(:work_package) { - FactoryGirl.build(:work_package, + FactoryBot.build(:work_package, subject: '') } diff --git a/spec/workers/extract_fulltext_job_spec.rb b/spec/workers/extract_fulltext_job_spec.rb index 7a4ca8653a..110ffeea89 100644 --- a/spec/workers/extract_fulltext_job_spec.rb +++ b/spec/workers/extract_fulltext_job_spec.rb @@ -34,7 +34,7 @@ describe ExtractFulltextJob, type: :job do # These jobs only get created when TSVector is supported by the DB. if OpenProject::Database.allows_tsv? let(:text) { 'lorem ipsum' } - let(:attachment) { FactoryGirl.create(:attachment) } + let(:attachment) { FactoryBot.create(:attachment) } context "with successful text extraction" do before do diff --git a/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb b/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb index dbf7020368..ab84e03639 100644 --- a/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb +++ b/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' describe DeliverWatcherNotificationJob, type: :model do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } - let(:watcher_setter) { FactoryGirl.create(:user) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } + let(:watcher_setter) { FactoryBot.create(:user) } let(:watcher_user) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) end - let(:work_package) { FactoryGirl.build(:work_package, project: project) } - let(:watcher) { FactoryGirl.create(:watcher, watchable: work_package, user: watcher_user) } + let(:work_package) { FactoryBot.build(:work_package, project: project) } + let(:watcher) { FactoryBot.create(:watcher, watchable: work_package, user: watcher_user) } subject { described_class.new(watcher.id, watcher_user.id, watcher_setter.id) } diff --git a/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb b/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb index 15e29da498..95cc4945ac 100644 --- a/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb +++ b/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' describe DeliverWorkPackageNotificationJob, type: :model do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:recipient) { - FactoryGirl.create(:user, member_in_project: project, member_through_role: role) + FactoryBot.create(:user, member_in_project: project, member_through_role: role) } - let(:author) { FactoryGirl.create(:user) } + let(:author) { FactoryBot.create(:user) } let(:work_package) { - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: author) } @@ -103,7 +103,7 @@ describe DeliverWorkPackageNotificationJob, type: :model do let(:journal) { work_package.journals.last } before do - work_package.add_journal(FactoryGirl.create(:user), 'a comment') + work_package.add_journal(FactoryBot.create(:user), 'a comment') work_package.save! end @@ -137,7 +137,7 @@ describe DeliverWorkPackageNotificationJob, type: :model do end context 'for a known current user' do - let(:current_user) { FactoryGirl.create(:user) } + let(:current_user) { FactoryBot.create(:user) } it 'resets to the previous current user after running' do User.current = current_user diff --git a/spec/workers/mail_notification_jobs/enqueue_work_package_notification_job_spec.rb b/spec/workers/mail_notification_jobs/enqueue_work_package_notification_job_spec.rb index ef022ed975..1c27c3c288 100644 --- a/spec/workers/mail_notification_jobs/enqueue_work_package_notification_job_spec.rb +++ b/spec/workers/mail_notification_jobs/enqueue_work_package_notification_job_spec.rb @@ -30,14 +30,14 @@ require 'spec_helper' describe EnqueueWorkPackageNotificationJob, type: :model do - let(:project) { FactoryGirl.create(:project) } - let(:role) { FactoryGirl.create(:role, permissions: [:view_work_packages]) } + let(:project) { FactoryBot.create(:project) } + let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) } let(:recipient) do - FactoryGirl.create(:user, member_in_project: project, member_through_role: role, login: "johndoe") + FactoryBot.create(:user, member_in_project: project, member_through_role: role, login: "johndoe") end - let(:author) { FactoryGirl.create(:user, login: "marktwain") } + let(:author) { FactoryBot.create(:user, login: "marktwain") } let(:work_package) do - FactoryGirl.create(:work_package, + FactoryBot.create(:work_package, project: project, author: author, assigned_to: recipient) @@ -278,7 +278,7 @@ describe EnqueueWorkPackageNotificationJob, type: :model do context "that is an email address" do let(:recipient) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role, login: "foo@bar.com") @@ -302,7 +302,7 @@ describe EnqueueWorkPackageNotificationJob, type: :model do context "the recipient turned off all mail notifications" do let(:recipient) do - FactoryGirl.create(:user, + FactoryBot.create(:user, member_in_project: project, member_through_role: role, mail_notification: 'none') @@ -321,7 +321,7 @@ describe EnqueueWorkPackageNotificationJob, type: :model do context "mentioned user is not allowed to view the work package" do let(:recipient) do - FactoryGirl.create(:user, + FactoryBot.create(:user, login: "foo@bar.com") end let(:added_text) do @@ -336,13 +336,13 @@ describe EnqueueWorkPackageNotificationJob, type: :model do end context 'for groups' do - let(:group_member) { FactoryGirl.create(:user) } + let(:group_member) { FactoryBot.create(:user) } let(:group) do - FactoryGirl.create(:group) do |group| + FactoryBot.create(:group) do |group| group.users << group_member - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: group, roles: [role]) @@ -362,7 +362,7 @@ describe EnqueueWorkPackageNotificationJob, type: :model do end context 'user disabled notifications' do - let(:group_member) { FactoryGirl.create(:user, mail_notification: User::USER_MAIL_OPTION_NON.first) } + let(:group_member) { FactoryBot.create(:user, mail_notification: User::USER_MAIL_OPTION_NON.first) } it "group member is ignored" do is_expected @@ -372,7 +372,7 @@ describe EnqueueWorkPackageNotificationJob, type: :model do end context 'group is not allowed to view the work package' do - let(:role) { FactoryGirl.create(:role, permissions: []) } + let(:role) { FactoryBot.create(:role, permissions: []) } it "group member is ignored" do is_expected @@ -381,10 +381,10 @@ describe EnqueueWorkPackageNotificationJob, type: :model do context 'but group member is allowed individually' do before do - FactoryGirl.create(:member, + FactoryBot.create(:member, project: project, principal: group_member, - roles: [FactoryGirl.create(:role, permissions: [:view_work_packages])]) + roles: [FactoryBot.create(:role, permissions: [:view_work_packages])]) end it "group member gets detected" do diff --git a/spec/workers/scm/create_local_repository_job_spec.rb b/spec/workers/scm/create_local_repository_job_spec.rb index 3d1c151dca..a887dedd0e 100644 --- a/spec/workers/scm/create_local_repository_job_spec.rb +++ b/spec/workers/scm/create_local_repository_job_spec.rb @@ -47,7 +47,7 @@ describe Scm::CreateLocalRepositoryJob do describe 'with a managed repository' do include_context 'with tmpdir' - let(:project) { FactoryGirl.build(:project) } + let(:project) { FactoryBot.build(:project) } let(:repository) { repo = Repository::Subversion.new(scm_type: :managed) repo.project = project diff --git a/spec_legacy/functional/activities_controller_spec.rb b/spec_legacy/functional/activities_controller_spec.rb index 57e82af0f3..cadabd116b 100644 --- a/spec_legacy/functional/activities_controller_spec.rb +++ b/spec_legacy/functional/activities_controller_spec.rb @@ -37,8 +37,8 @@ describe ActivitiesController, type: :controller do it 'project index' do Journal.delete_all - public_project = FactoryGirl.create :public_project - issue = FactoryGirl.create :work_package, + public_project = FactoryBot.create :public_project + issue = FactoryBot.create :work_package, project: public_project, status_id: 2, priority_id: 4, @@ -46,17 +46,17 @@ describe ActivitiesController, type: :controller do start_date: 1.day.ago.to_date.to_s(:db), due_date: 10.day.from_now.to_date.to_s(:db) - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: issue.id, created_at: 3.days.ago.to_date.to_s(:db), - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, project_id: issue.project_id, status_id: 1) - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: issue.id, notes: 'Some notes with Redmine links: #2, r2.', created_at: 1.days.ago.to_date.to_s(:db), - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: issue.subject, status_id: 2, type_id: issue.type_id, @@ -84,10 +84,10 @@ describe ActivitiesController, type: :controller do it 'previous project index' do issue = WorkPackage.find(1) - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: issue.id, created_at: 3.days.ago.to_date.to_s(:db), - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: issue.subject, status_id: issue.status_id, type_id: issue.type_id, @@ -115,11 +115,11 @@ describe ActivitiesController, type: :controller do it 'user index' do issue = WorkPackage.find(1) - FactoryGirl.create :work_package_journal, + FactoryBot.create :work_package_journal, journable_id: issue.id, user_id: 2, created_at: 3.days.ago.to_date.to_s(:db), - data: FactoryGirl.build(:journal_work_package_journal, + data: FactoryBot.build(:journal_work_package_journal, subject: issue.subject, status_id: issue.status_id, type_id: issue.type_id, diff --git a/spec_legacy/functional/user_mailer_spec.rb b/spec_legacy/functional/user_mailer_spec.rb index cb3bd8ef06..24586e4220 100644 --- a/spec_legacy/functional/user_mailer_spec.rb +++ b/spec_legacy/functional/user_mailer_spec.rb @@ -45,9 +45,9 @@ describe UserMailer, type: :mailer do end it 'should test mail sends a simple greeting' do - user = FactoryGirl.create(:admin, mail: 'foo@bar.de') + user = FactoryBot.create(:admin, mail: 'foo@bar.de') - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) mail = UserMailer.test_mail(user) assert mail.deliver_now @@ -148,8 +148,8 @@ describe UserMailer, type: :mailer do end it 'should email headers' do - user = FactoryGirl.create(:user) - issue = FactoryGirl.create(:work_package) + user = FactoryBot.create(:user) + issue = FactoryBot.create(:work_package) mail = UserMailer.work_package_added(user, issue.journals.first, user) assert mail.deliver_now refute_nil mail @@ -159,9 +159,9 @@ describe UserMailer, type: :mailer do it 'sends plain text mail' do Setting.plain_text_mail = 1 - user = FactoryGirl.create(:user) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) - issue = FactoryGirl.create(:work_package) + user = FactoryBot.create(:user) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) + issue = FactoryBot.create(:work_package) UserMailer.work_package_added(user, issue.journals.first, user).deliver_now mail = ActionMailer::Base.deliveries.last assert_match /text\/plain/, mail.content_type @@ -171,9 +171,9 @@ describe UserMailer, type: :mailer do it 'sends html mail' do Setting.plain_text_mail = 0 - user = FactoryGirl.create(:user) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) - issue = FactoryGirl.create(:work_package) + user = FactoryBot.create(:user) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) + issue = FactoryBot.create(:work_package) UserMailer.work_package_added(user, issue.journals.first, user).deliver_now mail = ActionMailer::Base.deliveries.last assert_match /multipart\/alternative/, mail.content_type @@ -183,8 +183,8 @@ describe UserMailer, type: :mailer do context 'with mail_from set', with_settings: { mail_from: 'Redmine app ' } do it 'should mail from with phrase' do - user = FactoryGirl.create(:user) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + user = FactoryBot.create(:user) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) UserMailer.test_mail(user).deliver_now mail = ActionMailer::Base.deliveries.last refute_nil mail @@ -193,8 +193,8 @@ describe UserMailer, type: :mailer do end it 'should not send email without recipient' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) # notify him user.pref[:no_self_notified] = false @@ -212,8 +212,8 @@ describe UserMailer, type: :mailer do end it 'should issue add message id' do - user = FactoryGirl.create(:user) - issue = FactoryGirl.create(:work_package) + user = FactoryBot.create(:user) + issue = FactoryBot.create(:work_package) mail = UserMailer.work_package_added(user, issue.journals.first, user) mail.deliver_now refute_nil mail @@ -222,8 +222,8 @@ describe UserMailer, type: :mailer do end it 'should work package updated message id' do - user = FactoryGirl.create(:user) - issue = FactoryGirl.create(:work_package) + user = FactoryBot.create(:user) + issue = FactoryBot.create(:work_package) journal = issue.journals.first UserMailer.work_package_updated(user, journal).deliver_now mail = ActionMailer::Base.deliveries.last @@ -233,9 +233,9 @@ describe UserMailer, type: :mailer do end it 'should message posted message id' do - user = FactoryGirl.create(:user) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) - message = FactoryGirl.create(:message) + user = FactoryBot.create(:user) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) + message = FactoryBot.create(:message) UserMailer.message_posted(user, message, user).deliver_now mail = ActionMailer::Base.deliveries.last refute_nil mail @@ -248,10 +248,10 @@ describe UserMailer, type: :mailer do end it 'should reply posted message id' do - user = FactoryGirl.create(:user) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) - parent = FactoryGirl.create(:message) - message = FactoryGirl.create(:message, parent: parent) + user = FactoryBot.create(:user) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) + parent = FactoryBot.create(:message) + message = FactoryBot.create(:message, parent: parent) UserMailer.message_posted(user, message, user).deliver_now mail = ActionMailer::Base.deliveries.last refute_nil mail @@ -266,9 +266,9 @@ describe UserMailer, type: :mailer do context '#issue_add', with_settings: { available_languages: ['en', 'de'], default_language: 'de' } do it 'should change mail language depending on recipient language' do - issue = FactoryGirl.create(:work_package) - user = FactoryGirl.create(:user, mail: 'foo@bar.de', language: 'de') - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + issue = FactoryBot.create(:work_package) + user = FactoryBot.create(:user, mail: 'foo@bar.de', language: 'de') + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) I18n.locale = 'en' assert UserMailer.work_package_added(user, issue.journals.first, user).deliver_now @@ -284,9 +284,9 @@ describe UserMailer, type: :mailer do # 1. user's language # 2. Setting.default_language # 3. I18n.default_locale - issue = FactoryGirl.create(:work_package) - user = FactoryGirl.create(:user, mail: 'foo@bar.de', language: '') # (auto) - FactoryGirl.create(:user_preference, user: user, others: { no_self_notified: false }) + issue = FactoryBot.create(:work_package) + user = FactoryBot.create(:user, mail: 'foo@bar.de', language: '') # (auto) + FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false }) I18n.locale = 'de' assert UserMailer.work_package_added(user, issue.journals.first, user).deliver_now @@ -300,38 +300,38 @@ describe UserMailer, type: :mailer do end it 'should news added' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) assert UserMailer.news_added(user, news, user).deliver_now end it 'should news comment added' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) - comment = FactoryGirl.create(:comment, commented: news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) + comment = FactoryBot.create(:comment, commented: news) assert UserMailer.news_comment_added(user, comment, user).deliver_now end it 'should message posted' do - user = FactoryGirl.create(:user) - message = FactoryGirl.create(:message) + user = FactoryBot.create(:user) + message = FactoryBot.create(:message) assert UserMailer.message_posted(user, message, user).deliver_now end it 'should account information' do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) assert UserMailer.account_information(user, 'pAsswORd').deliver_now end it 'should lost password' do - user = FactoryGirl.create(:user) - token = FactoryGirl.create(:recovery_token, user: user) + user = FactoryBot.create(:user) + token = FactoryBot.create(:recovery_token, user: user) assert UserMailer.password_lost(token).deliver_now end it 'should register' do - user = FactoryGirl.create(:user) - token = FactoryGirl.create(:invitation_token, user: user) + user = FactoryBot.create(:user) + token = FactoryBot.create(:invitation_token, user: user) Setting.host_name = 'redmine.foo' Setting.protocol = 'https' @@ -341,8 +341,8 @@ describe UserMailer, type: :mailer do end it 'should reminders' do - user = FactoryGirl.create(:user, mail: 'foo@bar.de') - issue = FactoryGirl.create(:work_package, due_date: Date.tomorrow, assigned_to: user, subject: 'some issue') + user = FactoryBot.create(:user, mail: 'foo@bar.de') + issue = FactoryBot.create(:work_package, due_date: Date.tomorrow, assigned_to: user, subject: 'some issue') DueIssuesReminder.new(42).remind_users assert_equal 1, ActionMailer::Base.deliveries.size @@ -353,9 +353,9 @@ describe UserMailer, type: :mailer do end it 'should reminders for users' do - user1 = FactoryGirl.create(:user, mail: 'foo1@bar.de') - user2 = FactoryGirl.create(:user, mail: 'foo2@bar.de') - issue = FactoryGirl.create(:work_package, due_date: Date.tomorrow, assigned_to: user1, subject: 'some issue') + user1 = FactoryBot.create(:user, mail: 'foo1@bar.de') + user2 = FactoryBot.create(:user, mail: 'foo2@bar.de') + issue = FactoryBot.create(:work_package, due_date: Date.tomorrow, assigned_to: user1, subject: 'some issue') DueIssuesReminder.new(42, nil, nil, [user2.id]).remind_users assert_equal 0, ActionMailer::Base.deliveries.size @@ -375,7 +375,7 @@ describe UserMailer, type: :mailer do # Set current language to english I18n.locale = :en # Send an email to a german user - user = FactoryGirl.create(:user, language: 'de') + user = FactoryBot.create(:user, language: 'de') UserMailer.account_activated(user).deliver_now mail = ActionMailer::Base.deliveries.last assert mail.body.encoded.include?('aktiviert') @@ -384,7 +384,7 @@ describe UserMailer, type: :mailer do end it 'should with deliveries off' do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) UserMailer.with_deliveries(false) do UserMailer.test_mail(user).deliver_now end @@ -399,7 +399,7 @@ describe UserMailer, type: :mailer do localized_emails_header: 'deutscher header' } do it 'should include the emails_header depeding on the locale' do - user = FactoryGirl.create(:user, language: :de) + user = FactoryBot.create(:user, language: :de) assert UserMailer.test_mail(user).deliver_now mail = ActionMailer::Base.deliveries.last assert mail.body.encoded.include?('deutscher header') @@ -415,18 +415,18 @@ describe UserMailer, type: :mailer do end def setup_complex_issue_update - project = FactoryGirl.create(:valid_project) - user = FactoryGirl.create(:admin, member_in_project: project) - type = FactoryGirl.create(:type, name: 'My Type') + project = FactoryBot.create(:valid_project) + user = FactoryBot.create(:admin, member_in_project: project) + type = FactoryBot.create(:type, name: 'My Type') project.types << type project.save - related_issue = FactoryGirl.create(:work_package, + related_issue = FactoryBot.create(:work_package, subject: 'My related Ticket', type: type, project: project) - issue = FactoryGirl.create(:work_package, + issue = FactoryBot.create(:work_package, subject: 'My awesome Ticket', type: type, project: project, @@ -435,16 +435,16 @@ describe UserMailer, type: :mailer do # now change the issue, to get a nice journal issue.description = "This is related to issue ##{related_issue.id}\n" - repository = FactoryGirl.create(:repository_subversion, + repository = FactoryBot.create(:repository_subversion, project: project) - changeset = FactoryGirl.create :changeset, + changeset = FactoryBot.create :changeset, repository: repository, comments: 'This commit fixes #1, #2 and references #1 and #3' issue.description += " A reference to a changeset r#{changeset.revision}\n" if changeset - attachment = FactoryGirl.build(:attachment, + attachment = FactoryBot.build(:attachment, author: issue.author) issue.attachments << attachment diff --git a/spec_legacy/functional/wiki_controller_spec.rb b/spec_legacy/functional/wiki_controller_spec.rb index a1d84e327c..a8b1369f03 100644 --- a/spec_legacy/functional/wiki_controller_spec.rb +++ b/spec_legacy/functional/wiki_controller_spec.rb @@ -166,10 +166,10 @@ describe WikiController, type: :controller do # because running whole suite is fine, but running only this test # results in failure it 'should update stale page should not raise an error' do - journal = FactoryGirl.create :wiki_content_journal, + journal = FactoryBot.create :wiki_content_journal, journable_id: 2, version: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. Another page\n\n\nthis is a link to ticket: #2") session[:user_id] = 2 c = Wiki.find(1).find_page('Another page').content @@ -207,17 +207,17 @@ describe WikiController, type: :controller do end it 'should history' do - FactoryGirl.create :wiki_content_journal, + FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: 'h1. CookBook documentation') - FactoryGirl.create :wiki_content_journal, + FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...") - FactoryGirl.create :wiki_content_journal, + FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\nSome updated [[documentation]] here...") get :history, params: { project_id: 1, id: 'CookBook documentation' } @@ -229,9 +229,9 @@ describe WikiController, type: :controller do end it 'should history with one version' do - FactoryGirl.create :wiki_content_journal, + FactoryBot.create :wiki_content_journal, journable_id: 2, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. Another page\n\n\nthis is a link to ticket: #2") get :history, params: { project_id: 1, id: 'Another page' } assert_response :success @@ -242,13 +242,13 @@ describe WikiController, type: :controller do end it 'should diff' do - journal_from = FactoryGirl.create :wiki_content_journal, + journal_from = FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: 'h1. CookBook documentation') - journal_to = FactoryGirl.create :wiki_content_journal, + journal_to = FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...") get :diff, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version } @@ -259,13 +259,13 @@ describe WikiController, type: :controller do end it 'should annotate' do - FactoryGirl.create :wiki_content_journal, + FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: 'h1. CookBook documentation') - journal_to = FactoryGirl.create :wiki_content_journal, + journal_to = FactoryBot.create :wiki_content_journal, journable_id: 1, - data: FactoryGirl.build(:journal_wiki_content_journal, + data: FactoryBot.build(:journal_wiki_content_journal, text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...") get :annotate, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version } diff --git a/spec_legacy/integration/layout_spec.rb b/spec_legacy/integration/layout_spec.rb index 8eae81cd58..46418b1065 100644 --- a/spec_legacy/integration/layout_spec.rb +++ b/spec_legacy/integration/layout_spec.rb @@ -61,7 +61,7 @@ describe 'Layout' do specify 'page titles should be properly escaped', with_settings: { app_title: '<3' } do - project = FactoryGirl.create(:project, name: 'C&A', is_public: true) + project = FactoryBot.create(:project, name: 'C&A', is_public: true) get "/projects/#{project.to_param}" def title_html diff --git a/spec_legacy/legacy_spec_helper.rb b/spec_legacy/legacy_spec_helper.rb index 87a66f336e..d4f650d640 100644 --- a/spec_legacy/legacy_spec_helper.rb +++ b/spec_legacy/legacy_spec_helper.rb @@ -33,7 +33,7 @@ require File.expand_path('../../config/environment', __FILE__) require 'fileutils' require 'rspec/mocks' -require 'factory_girl_rails' +require 'factory_bot_rails' require_relative './support/legacy_file_helpers' require_relative './support/legacy_assertions' diff --git a/spec_legacy/support/legacy_assertions.rb b/spec_legacy/support/legacy_assertions.rb index 6cffb5e161..bfbbb754dd 100644 --- a/spec_legacy/support/legacy_assertions.rb +++ b/spec_legacy/support/legacy_assertions.rb @@ -143,17 +143,17 @@ module LegacyAssertionsAndHelpers def should_show_the_old_and_new_values_for(prop_key, model, &block) context '' do before do - FactoryGirl.create :issue if WorkPackage.count == 0 # some tests use WorkPackage.last + FactoryBot.create :issue if WorkPackage.count == 0 # some tests use WorkPackage.last if block_given? instance_eval &block else - @old_value = FactoryGirl.create(model.to_sym) - @new_value = FactoryGirl.create(model.to_sym) + @old_value = FactoryBot.create(model.to_sym) + @new_value = FactoryBot.create(model.to_sym) end end it "use the new value's name" do - journal = FactoryGirl.build :work_package_journal + journal = FactoryBot.build :work_package_journal journal.stub(:journable).and_return(WorkPackage.last) journal.stub(:details).and_return(prop_key => [@old_value.id, @new_value.id]) @@ -162,7 +162,7 @@ module LegacyAssertionsAndHelpers end it "use the old value's name" do - journal = FactoryGirl.build :work_package_journal + journal = FactoryBot.build :work_package_journal journal.stub(:journable).and_return(WorkPackage.last) journal.stub(:details).and_return(prop_key => [@old_value.id, @new_value.id]) @@ -289,7 +289,7 @@ module LegacyAssertionsAndHelpers context "should allow http basic auth using a username and password for #{http_method} #{url}" do context 'with a valid HTTP authentication' do before do - @user = FactoryGirl.create(:user, password: 'adminADMIN!', password_confirmation: 'adminADMIN!', admin: true) # Admin so they can access the project + @user = FactoryBot.create(:user, password: 'adminADMIN!', password_confirmation: 'adminADMIN!', admin: true) # Admin so they can access the project send(http_method, url, params: parameters, headers: credentials(@user.login, 'adminADMIN!')) end @@ -302,7 +302,7 @@ module LegacyAssertionsAndHelpers context 'with an invalid HTTP authentication' do before do - @user = FactoryGirl.create(:user) + @user = FactoryBot.create(:user) send(http_method, url, params: parameters, headers: credentials(@user.login, 'wrong_password')) end @@ -341,8 +341,8 @@ module LegacyAssertionsAndHelpers context "should allow http basic auth with a key for #{http_method} #{url}" do context 'with a valid HTTP authentication using the API token' do before do - @user = FactoryGirl.create(:user, admin: true) - @token = FactoryGirl.create(:api_token, user: @user) + @user = FactoryBot.create(:user, admin: true) + @token = FactoryBot.create(:api_token, user: @user) send(http_method, url, params: parameters, headers: credentials(@token.plain_value, 'X')) end @@ -356,8 +356,8 @@ module LegacyAssertionsAndHelpers context 'with an invalid HTTP authentication' do before do - @user = FactoryGirl.create(:user) - @token = FactoryGirl.create(:rss_token, user: @user) + @user = FactoryBot.create(:user) + @token = FactoryBot.create(:rss_token, user: @user) send(http_method, url, params: parameters, headers: credentials(@token.value, 'X')) end @@ -385,8 +385,8 @@ module LegacyAssertionsAndHelpers context "should allow key based auth using key=X for #{http_method} #{url}" do context 'with a valid api token' do before do - @user = FactoryGirl.create(:user, admin: true) - @token = FactoryGirl.create(:api_token, user: @user) + @user = FactoryBot.create(:user, admin: true) + @token = FactoryBot.create(:api_token, user: @user) # Simple url parse to add on ?key= or &key= request_url = if url.match(/\?/) url + "&key=#{@token.plain_value}" @@ -405,8 +405,8 @@ module LegacyAssertionsAndHelpers context 'with an invalid api token' do before do - @user = FactoryGirl.create(:user) - @token = FactoryGirl.create(:rss_token, user: @user) + @user = FactoryBot.create(:user) + @token = FactoryBot.create(:rss_token, user: @user) # Simple url parse to add on ?key= or &key= request_url = if url.match(/\?/) url + "&key=#{@token.value}" @@ -425,8 +425,8 @@ module LegacyAssertionsAndHelpers context "should allow key based auth using X-OpenProject-API-Key header for #{http_method} #{url}" do before do - @user = FactoryGirl.create(:user, admin: true) - @token = FactoryGirl.create(:api_token, user: @user) + @user = FactoryBot.create(:user, admin: true) + @token = FactoryBot.create(:api_token, user: @user) send(http_method, url, params: {}, headers: { 'X-OpenProject-API-Key' => @token.plain_value.to_s }) end it { should respond_with success_code } diff --git a/spec_legacy/unit/category_spec.rb b/spec_legacy/unit/category_spec.rb index 33ea80168c..95d71c1880 100644 --- a/spec_legacy/unit/category_spec.rb +++ b/spec_legacy/unit/category_spec.rb @@ -30,9 +30,9 @@ require 'legacy_spec_helper' describe Category, type: :model do before do - @project = FactoryGirl.create :project - @category = FactoryGirl.create :category, project: @project - @issue = FactoryGirl.create :work_package, project: @project, category: @category + @project = FactoryBot.create :project + @category = FactoryBot.create :category, project: @project + @issue = FactoryBot.create :work_package, project: @project, category: @category assert_equal @issue.category, @category assert_equal @category.work_packages, [@issue] end @@ -45,8 +45,8 @@ describe Category, type: :model do end it 'should create with group assignment' do - group = FactoryGirl.create :group - role = FactoryGirl.create :role + group = FactoryBot.create :group + role = FactoryBot.create :role (Member.new.tap do |m| m.attributes = { principal: group, project: @project, role_ids: [role.id] } end).save! @@ -65,7 +65,7 @@ describe Category, type: :model do # both issue categories must be in the same project it 'should destroy with reassign' do - reassign_to = FactoryGirl.create :category, project: @project + reassign_to = FactoryBot.create :category, project: @project @category.destroy(reassign_to) # Make sure the issue was reassigned assert_equal reassign_to, @issue.reload.category diff --git a/spec_legacy/unit/changeset_spec.rb b/spec_legacy/unit/changeset_spec.rb index 9bb33b61fb..08ff3fc886 100644 --- a/spec_legacy/unit/changeset_spec.rb +++ b/spec_legacy/unit/changeset_spec.rb @@ -240,7 +240,7 @@ describe Changeset, type: :model do context 'enabled scm', with_settings: { enabled_scm: ['subversion'] } do it 'should comments empty' do - r = FactoryGirl.create(:repository_subversion) + r = FactoryBot.create(:repository_subversion) assert r c = Changeset.new(repository: r, @@ -256,7 +256,7 @@ describe Changeset, type: :model do end it 'should comments nil' do - r = FactoryGirl.create(:repository_subversion) + r = FactoryBot.create(:repository_subversion) assert r c = Changeset.new(repository: r, diff --git a/spec_legacy/unit/comment_spec.rb b/spec_legacy/unit/comment_spec.rb index 2e8d7b6264..c66ac6b504 100644 --- a/spec_legacy/unit/comment_spec.rb +++ b/spec_legacy/unit/comment_spec.rb @@ -33,52 +33,52 @@ describe Comment, type: :model do it 'should validations' do # factory valid - assert FactoryGirl.build(:comment).valid? + assert FactoryBot.build(:comment).valid? # comment text required - refute FactoryGirl.build(:comment, comments: '').valid? + refute FactoryBot.build(:comment, comments: '').valid? # object that is commented required - refute FactoryGirl.build(:comment, commented: nil).valid? + refute FactoryBot.build(:comment, commented: nil).valid? # author required - refute FactoryGirl.build(:comment, author: nil).valid? + refute FactoryBot.build(:comment, author: nil).valid? end it 'should create' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) comment = Comment.new(commented: news, author: user, comments: 'some important words') assert comment.save assert_equal 1, news.reload.comments_count end it 'should create through news' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) comment = news.new_comment(author: user, comments: 'some important words') assert comment.save assert_equal 1, news.reload.comments_count end it 'should create comment through news' do - user = FactoryGirl.create(:user) - news = FactoryGirl.create(:news) + user = FactoryBot.create(:user) + news = FactoryBot.create(:news) news.post_comment!(author: user, comments: 'some important words') assert_equal 1, news.reload.comments_count end it 'should text' do - comment = FactoryGirl.build(:comment, comments: 'something useful') + comment = FactoryBot.build(:comment, comments: 'something useful') assert_equal 'something useful', comment.text end it 'should create should send notification with settings' do # news needs a project in order to be notified # see Redmine::Acts::Journalized::Deprecated#recipients - project = FactoryGirl.create(:project) - user = FactoryGirl.create(:user, member_in_project: project) + project = FactoryBot.create(:project) + user = FactoryBot.create(:user, member_in_project: project) # author is automatically added as watcher # this makes #user to receive a notification - news = FactoryGirl.create(:news, project: project, author: user) + news = FactoryBot.create(:news, project: project, author: user) # with notifications for that event turned on allow(Setting).to receive(:notified_events).and_return(['news_comment_added']) @@ -96,8 +96,8 @@ describe Comment, type: :model do # TODO: testing #destroy really needed? it 'should destroy' do # just setup - news = FactoryGirl.create(:news) - comment = FactoryGirl.build(:comment) + news = FactoryBot.create(:news) + comment = FactoryBot.build(:comment) news.comments << comment assert comment.persisted? diff --git a/spec_legacy/unit/custom_field_spec.rb b/spec_legacy/unit/custom_field_spec.rb index 414ed2a130..927303b17e 100644 --- a/spec_legacy/unit/custom_field_spec.rb +++ b/spec_legacy/unit/custom_field_spec.rb @@ -53,7 +53,7 @@ describe CustomField, type: :model do end it 'should destroy' do - field = FactoryGirl.create :custom_field + field = FactoryBot.create :custom_field assert field.destroy end end diff --git a/spec_legacy/unit/custom_value_spec.rb b/spec_legacy/unit/custom_value_spec.rb index bafe6fb2aa..923a2dc254 100644 --- a/spec_legacy/unit/custom_value_spec.rb +++ b/spec_legacy/unit/custom_value_spec.rb @@ -102,11 +102,11 @@ describe CustomValue, type: :model do end it 'should float field validation' do - user = FactoryGirl.create :user + user = FactoryBot.create :user # There are cases, where the custom-value-table is not cleared completely, # therefore making double sure, that we have a clean slate before we start CustomField.destroy_all - FactoryGirl.create :float_user_custom_field, name: 'Money' + FactoryBot.create :float_user_custom_field, name: 'Money' v = CustomValue.new(customized: user, custom_field: UserCustomField.find_by(name: 'Money')) v.value = '11.2' assert v.save @@ -120,9 +120,9 @@ describe CustomValue, type: :model do it 'should sti polymorphic association' do # Rails uses top level sti class for polymorphic association. See #3978. - user = FactoryGirl.create :user - custom_field = FactoryGirl.create :user_custom_field, field_format: 'string' - custom_value = FactoryGirl.create :principal_custom_value, + user = FactoryBot.create :user + custom_field = FactoryBot.create :user_custom_field, field_format: 'string' + custom_value = FactoryBot.create :principal_custom_value, custom_field: custom_field, customized: user, value: '01 23 45 67 89' diff --git a/spec_legacy/unit/enumeration_spec.rb b/spec_legacy/unit/enumeration_spec.rb index ce00468e40..f3debb03ce 100644 --- a/spec_legacy/unit/enumeration_spec.rb +++ b/spec_legacy/unit/enumeration_spec.rb @@ -31,14 +31,14 @@ require 'legacy_spec_helper' describe Enumeration, type: :model do before do WorkPackage.delete_all - @low_priority = FactoryGirl.create :priority_low - @issues = FactoryGirl.create_list :work_package, 6, priority: @low_priority - @default_enumeration = FactoryGirl.create :default_enumeration + @low_priority = FactoryBot.create :priority_low + @issues = FactoryBot.create_list :work_package, 6, priority: @low_priority + @default_enumeration = FactoryBot.create :default_enumeration end it 'should in use' do assert @low_priority.in_use? - assert !FactoryGirl.create(:priority).in_use? + assert !FactoryBot.create(:priority).in_use? end it 'should default' do @@ -79,7 +79,7 @@ describe Enumeration, type: :model do end it 'should destroy with reassign' do - new_priority = FactoryGirl.create :priority + new_priority = FactoryBot.create :priority Enumeration.find(@low_priority.id).destroy(new_priority) assert_nil WorkPackage.find_by(priority_id: @low_priority.id) assert_equal @issues.size, new_priority.objects_count diff --git a/spec_legacy/unit/group_spec.rb b/spec_legacy/unit/group_spec.rb index ca0fff05b2..00eb775410 100644 --- a/spec_legacy/unit/group_spec.rb +++ b/spec_legacy/unit/group_spec.rb @@ -30,14 +30,14 @@ require 'legacy_spec_helper' describe Group, type: :model do before do - @group = FactoryGirl.create :group - @member = FactoryGirl.build :member - @work_package = FactoryGirl.create :work_package - @roles = FactoryGirl.create_list :role, 2 + @group = FactoryBot.create :group + @member = FactoryBot.build :member + @work_package = FactoryBot.create :work_package + @roles = FactoryBot.create_list :role, 2 @member.attributes = { principal: @group, role_ids: @roles.map(&:id) } @member.save! @project = @member.project - @user = FactoryGirl.create :user + @user = FactoryBot.create :user @group.users << @user @group.save! end @@ -48,7 +48,7 @@ describe Group, type: :model do end it 'should roles given to new user' do - user = FactoryGirl.build :user + user = FactoryBot.build :user @group.users << user assert user.member_of? @project @@ -59,13 +59,13 @@ describe Group, type: :model do end it 'should roles updated' do - group = FactoryGirl.create :group - member = FactoryGirl.build :member - roles = FactoryGirl.create_list :role, 2 + group = FactoryBot.create :group + member = FactoryBot.build :member + roles = FactoryBot.create_list :role, 2 role_ids = roles.map(&:id) member.attributes = { principal: group, role_ids: role_ids } member.save! - user = FactoryGirl.create :user + user = FactoryBot.create :user group.users << user group.save! diff --git a/spec_legacy/unit/helpers/application_helper_spec.rb b/spec_legacy/unit/helpers/application_helper_spec.rb index f74e6d25bf..c097576826 100644 --- a/spec_legacy/unit/helpers/application_helper_spec.rb +++ b/spec_legacy/unit/helpers/application_helper_spec.rb @@ -34,25 +34,25 @@ describe ApplicationHelper, type: :helper do before do # @project variable is used by helper - @project = FactoryGirl.create :valid_project + @project = FactoryBot.create :valid_project @project.reload # reload references to indirectly created entities (e.g. wiki) - @admin = FactoryGirl.create :admin - @anonymous = FactoryGirl.create :anonymous - @non_member = FactoryGirl.create :user - @project_member = FactoryGirl.create :user, + @admin = FactoryBot.create :admin + @anonymous = FactoryBot.create :anonymous + @non_member = FactoryBot.create :user + @project_member = FactoryBot.create :user, member_in_project: @project, - member_through_role: FactoryGirl.create(:role, + member_through_role: FactoryBot.create(:role, permissions: [:view_work_packages, :edit_work_packages, :browse_repository, :view_changesets, :view_wiki_pages]) - @issue = FactoryGirl.create :work_package, project: @project, author: @project_member, type: @project.types.first + @issue = FactoryBot.create :work_package, project: @project, author: @project_member, type: @project.types.first file = LegacyFileHelpers.mock_uploaded_file name: 'logo.gif', content_type: 'image/gif', content: 'not actually a gif', binary: true - @attachment = FactoryGirl.create :attachment, + @attachment = FactoryBot.create :attachment, author: @project_member, file: file, content_type: 'image/gif', @@ -184,7 +184,7 @@ RAW end it 'should cross project redmine links' do - version = FactoryGirl.create :version, + version = FactoryBot.create :version, name: '1.0', project: @project @@ -195,10 +195,10 @@ RAW 'invalid:version:"1.0"' => 'invalid:version:"1.0"' } - repository = FactoryGirl.create :repository_subversion, + repository = FactoryBot.create :repository_subversion, project: @project - changeset = FactoryGirl.create :changeset, + changeset = FactoryBot.create :changeset, repository: repository, comments: 'This commit fixes #1, #2 and references #1 & #3' identifier = @project.identifier @@ -229,7 +229,7 @@ RAW ) # helper.format_text "sees" the text is parses from the_other_project (and not @project) - the_other_project = FactoryGirl.create :valid_project + the_other_project = FactoryBot.create :valid_project to_test.each do |text, result| assert_dom_equal "

#{result}

", @@ -343,8 +343,8 @@ EXPECTED it 'should wiki links in tables' do @project.wiki.start_page = 'Page' @project.wiki.save! - FactoryGirl.create :wiki_page_with_content, wiki: @project.wiki, title: 'Other page' - FactoryGirl.create :wiki_page_with_content, wiki: @project.wiki, title: 'Last page' + FactoryBot.create :wiki_page_with_content, wiki: @project.wiki, title: 'Other page' + FactoryBot.create :wiki_page_with_content, wiki: @project.wiki, title: 'Last page' to_test = { "|[[Page|Link title]]|[[Other Page|Other title]]|\n|Cell 21|[[Last page]]|" => "Link title" + @@ -395,8 +395,8 @@ EXPECTED it 'should table of content' do @project.wiki.start_page = 'Wiki' @project.wiki.save! - FactoryGirl.create :wiki_page_with_content, wiki: @project.wiki, title: 'Wiki' - FactoryGirl.create :wiki_page_with_content, wiki: @project.wiki, title: 'another Wiki' + FactoryBot.create :wiki_page_with_content, wiki: @project.wiki, title: 'Wiki' + FactoryBot.create :wiki_page_with_content, wiki: @project.wiki, title: 'another Wiki' raw = <<-RAW {{toc}} @@ -457,9 +457,9 @@ RAW it 'should table of content should contain included page headings' do @project.wiki.start_page = 'Wiki' @project.save! - page = FactoryGirl.create :wiki_page_with_content, wiki: @project.wiki, title: 'Wiki' - child = FactoryGirl.create :wiki_page, wiki: @project.wiki, title: 'Child_1', parent: page - child.content = FactoryGirl.create :wiki_content, page: child, text: "h1. Child page 1\n\nThis is a child page" + page = FactoryBot.create :wiki_page_with_content, wiki: @project.wiki, title: 'Wiki' + child = FactoryBot.create :wiki_page, wiki: @project.wiki, title: 'Child_1', parent: page + child.content = FactoryBot.create :wiki_content, page: child, text: "h1. Child page 1\n\nThis is a child page" child.save! raw = <<-RAW @@ -506,7 +506,7 @@ RAW end it 'should link to user should not link to locked user' do - user = FactoryGirl.build :user + user = FactoryBot.build :user user.lock! assert user.locked? t = link_to_user(user) diff --git a/spec_legacy/unit/helpers/timelog_helper_spec.rb b/spec_legacy/unit/helpers/timelog_helper_spec.rb index 7d4047e101..554a043e6d 100644 --- a/spec_legacy/unit/helpers/timelog_helper_spec.rb +++ b/spec_legacy/unit/helpers/timelog_helper_spec.rb @@ -34,22 +34,22 @@ describe TimelogHelper, type: :helper do include ActionView::Helpers::DateHelper it 'should activities collection for select options should return array of activity names and ids' do - design = TimeEntryActivity.find_by(name: 'Design') || FactoryGirl.create(:activity, name: 'Design') - development = TimeEntryActivity.find_by(name: 'Development') || FactoryGirl.create(:activity, name: 'Development') + design = TimeEntryActivity.find_by(name: 'Design') || FactoryBot.create(:activity, name: 'Design') + development = TimeEntryActivity.find_by(name: 'Development') || FactoryBot.create(:activity, name: 'Development') activities = activity_collection_for_select_options assert activities.include?(['Design', design.id]) assert activities.include?(['Development', development.id]) end it 'should activities collection for select options should not include inactive activities' do - inactive = TimeEntryActivity.find_by(name: 'Inactive Activity') || FactoryGirl.create(:inactive_activity, name: 'Inactive Activity') + inactive = TimeEntryActivity.find_by(name: 'Inactive Activity') || FactoryBot.create(:inactive_activity, name: 'Inactive Activity') activities = activity_collection_for_select_options assert !activities.include?(['Inactive Activity', inactive.id]) end it 'should activities collection for select options should use the projects override' do - project = FactoryGirl.create :valid_project - design = TimeEntryActivity.find_by(name: 'Design') || FactoryGirl.create(:activity, name: 'Design') + project = FactoryBot.create :valid_project + design = TimeEntryActivity.find_by(name: 'Design') || FactoryBot.create(:activity, name: 'Design') override_activity = TimeEntryActivity.create!(name: 'Design override', parent: TimeEntryActivity.find_by(name: 'Design'), project: project) activities = activity_collection_for_select_options(nil, project) diff --git a/spec_legacy/unit/journal_spec.rb b/spec_legacy/unit/journal_spec.rb index e349fbaf0d..220728b6e5 100644 --- a/spec_legacy/unit/journal_spec.rb +++ b/spec_legacy/unit/journal_spec.rb @@ -59,9 +59,9 @@ describe Journal, end specify 'creating a journal should update the updated_on value of the parent record (touch)' do - @user = FactoryGirl.create(:user) - @project = FactoryGirl.create(:project) - @issue = FactoryGirl.create(:work_package, project: @project) + @user = FactoryBot.create(:user) + @project = FactoryBot.create(:project) + @issue = FactoryBot.create(:work_package, project: @project) start = @issue.updated_at sleep(1) # TODO: massive hack to make sure the timestamps are different. switch to timecop later @@ -81,7 +81,7 @@ describe Journal, end specify 'setting journal fields through the journaled object for creation' do - @issue = FactoryGirl.create(:work_package) + @issue = FactoryBot.create(:work_package) @issue.add_journal @issue.author, 'Test setting fields on Journal from Issue' assert_difference('Journal.count') do diff --git a/spec_legacy/unit/lib/redmine/ciphering_spec.rb b/spec_legacy/unit/lib/redmine/ciphering_spec.rb index 4c5a90bb6c..618838d729 100644 --- a/spec_legacy/unit/lib/redmine/ciphering_spec.rb +++ b/spec_legacy/unit/lib/redmine/ciphering_spec.rb @@ -32,7 +32,7 @@ require_relative '../../../legacy_spec_helper' describe Redmine::Ciphering do it 'should password should be encrypted' do OpenProject::Configuration.with 'database_cipher_key' => 'secret' do - r = FactoryGirl.create(:repository_subversion, password: 'foo') + r = FactoryBot.create(:repository_subversion, password: 'foo') assert_equal 'foo', r.password assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/) end @@ -40,7 +40,7 @@ describe Redmine::Ciphering do it 'should password should be clear with blank key' do OpenProject::Configuration.with 'database_cipher_key' => '' do - r = FactoryGirl.create(:repository_subversion, password: 'foo') + r = FactoryBot.create(:repository_subversion, password: 'foo') assert_equal 'foo', r.password assert_equal 'foo', r.read_attribute(:password) end @@ -48,7 +48,7 @@ describe Redmine::Ciphering do it 'should password should be clear with nil key' do OpenProject::Configuration.with 'database_cipher_key' => nil do - r = FactoryGirl.create(:repository_subversion, password: 'foo') + r = FactoryBot.create(:repository_subversion, password: 'foo') assert_equal 'foo', r.password assert_equal 'foo', r.read_attribute(:password) end @@ -56,7 +56,7 @@ describe Redmine::Ciphering do it 'should unciphered password should be readable' do OpenProject::Configuration.with 'database_cipher_key' => nil do - FactoryGirl.create(:repository_subversion, password: 'clear') + FactoryBot.create(:repository_subversion, password: 'clear') end OpenProject::Configuration.with 'database_cipher_key' => 'secret' do @@ -68,8 +68,8 @@ describe Redmine::Ciphering do it 'should encrypt all' do Repository.delete_all OpenProject::Configuration.with 'database_cipher_key' => nil do - FactoryGirl.create(:repository_subversion, password: 'foo') - FactoryGirl.create(:repository_subversion, password: 'bar') + FactoryBot.create(:repository_subversion, password: 'foo') + FactoryBot.create(:repository_subversion, password: 'bar') end OpenProject::Configuration.with 'database_cipher_key' => 'secret' do @@ -83,8 +83,8 @@ describe Redmine::Ciphering do it 'should decrypt all' do Repository.delete_all OpenProject::Configuration.with 'database_cipher_key' => 'secret' do - FactoryGirl.create(:repository_subversion, password: 'foo') - FactoryGirl.create(:repository_subversion, password: 'bar') + FactoryBot.create(:repository_subversion, password: 'foo') + FactoryBot.create(:repository_subversion, password: 'bar') assert Repository.decrypt_all(:password) r = Repository.order('id DESC').first diff --git a/spec_legacy/unit/lib/redmine/hook_spec.rb b/spec_legacy/unit/lib/redmine/hook_spec.rb index c674ce3a2f..659f41eff2 100644 --- a/spec_legacy/unit/lib/redmine/hook_spec.rb +++ b/spec_legacy/unit/lib/redmine/hook_spec.rb @@ -156,7 +156,7 @@ describe 'Redmine::Hook::Manager' do # FIXME: naming (RSpec-port) it 'should call_hook_should_not_change_the_default_url_for_email_notifications' do user = User.find(1) - issue = FactoryGirl.create(:work_package) + issue = FactoryBot.create(:work_package) UserMailer.work_package_added(user, issue.journals.first, user).deliver_now mail = ActionMailer::Base.deliveries.last diff --git a/spec_legacy/unit/mail_handler_spec.rb b/spec_legacy/unit/mail_handler_spec.rb index e1f989bfd8..f8b80d55f5 100644 --- a/spec_legacy/unit/mail_handler_spec.rb +++ b/spec_legacy/unit/mail_handler_spec.rb @@ -168,9 +168,9 @@ describe MailHandler, type: :model do end it 'should add work package should match assignee on display name' do # added from redmine - not sure if it is ok here - user = FactoryGirl.create(:user, firstname: 'Foo', lastname: 'Bar') - role = FactoryGirl.create(:role, name: 'Superhero') - FactoryGirl.create(:member, user: user, project: Project.find(2), role_ids: [role.id]) + user = FactoryBot.create(:user, firstname: 'Foo', lastname: 'Bar') + role = FactoryBot.create(:role, name: 'Superhero') + FactoryBot.create(:member, user: user, project: Project.find(2), role_ids: [role.id]) issue = submit_email('ticket_on_given_project.eml') do |email| email.sub!(/^Assigned to.*$/, 'Assigned to: Foo Bar') end @@ -357,7 +357,7 @@ describe MailHandler, type: :model do specify 'reply to issue update (Journal) by message_id' do Journal.delete_all issue = WorkPackage.find(2) - j = FactoryGirl.create :work_package_journal, id: 3, journable_id: issue.id + j = FactoryBot.create :work_package_journal, id: 3, journable_id: issue.id journal = submit_email('ticket_reply_by_message_id.eml') assert journal.data.is_a?(Journal::WorkPackageJournal), "Email was a #{journal.data.class}" assert_equal User.find_by_login('jsmith'), journal.user diff --git a/spec_legacy/unit/member_spec.rb b/spec_legacy/unit/member_spec.rb index 83b92d8a82..1d018f2801 100644 --- a/spec_legacy/unit/member_spec.rb +++ b/spec_legacy/unit/member_spec.rb @@ -32,8 +32,8 @@ describe Member, type: :model do before do Role.non_member.add_permission! :view_work_packages # non_member users may be watchers of work units Role.non_member.add_permission! :view_wiki_pages # non_member users may be watchers of wikis - @project = FactoryGirl.create :project_with_types - @user = FactoryGirl.create :user, member_in_project: @project + @project = FactoryBot.create :project_with_types + @user = FactoryBot.create :user, member_in_project: @project @member = @project.members.first @role = @member.roles.first @role.add_permission! :view_wiki_pages @@ -42,7 +42,7 @@ describe Member, type: :model do it 'should create' do member = Member.new.tap do |m| m.attributes = { project_id: @project.id, - user_id: FactoryGirl.create(:user).id, + user_id: FactoryBot.create(:user).id, role_ids: [@role.id] } end assert member.save @@ -63,14 +63,14 @@ describe Member, type: :model do it 'should update roles' do assert_equal 1, @member.roles.size - @member.role_ids = [@role.id, FactoryGirl.create(:role).id] + @member.role_ids = [@role.id, FactoryBot.create(:role).id] assert @member.save assert_equal 2, @member.reload.roles.size end it 'should validate' do members = [] - user_id = FactoryGirl.create(:user).id + user_id = FactoryBot.create(:user).id 2.times do members << Member.new.tap do |m| m.attributes = { project_id: @project.id, @@ -85,7 +85,7 @@ describe Member, type: :model do member = Member.new.tap do |m| m.attributes = { project_id: @project, - user_id: FactoryGirl.create(:user).id, + user_id: FactoryBot.create(:user).id, role_ids: [] } end # must have one role at least @@ -104,25 +104,25 @@ describe Member, type: :model do context 'removing permissions' do before do - @private_project = FactoryGirl.create :project_with_types, + @private_project = FactoryBot.create :project_with_types, is_public: true # has to be public first to successfully create things. Will be set to private later - @watcher_user = FactoryGirl.create(:user) + @watcher_user = FactoryBot.create(:user) # watchers for public issue - public_issue = FactoryGirl.create :work_package + public_issue = FactoryBot.create :work_package public_issue.project.is_public = true public_issue.project.save! Watcher.create!(watchable: public_issue, user: @watcher_user) # watchers for private things - Watcher.create!(watchable: FactoryGirl.create(:work_package, project: @private_project), user: @watcher_user) - board = FactoryGirl.create :board, project: @private_project - @message = FactoryGirl.create :message, board: board + Watcher.create!(watchable: FactoryBot.create(:work_package, project: @private_project), user: @watcher_user) + board = FactoryBot.create :board, project: @private_project + @message = FactoryBot.create :message, board: board Watcher.create!(watchable: @message, user: @watcher_user) - Watcher.create!(watchable: FactoryGirl.create(:wiki, project: @private_project), user: @watcher_user) + Watcher.create!(watchable: FactoryBot.create(:wiki, project: @private_project), user: @watcher_user) @private_project.reload # to access @private_project.wiki - Watcher.create!(watchable: FactoryGirl.create(:wiki_page, wiki: @private_project.wiki), user: @watcher_user) - @private_role = FactoryGirl.create :role, permissions: [:view_wiki_pages, :view_work_packages] + Watcher.create!(watchable: FactoryBot.create(:wiki_page, wiki: @private_project.wiki), user: @watcher_user) + @private_role = FactoryBot.create :role, permissions: [:view_wiki_pages, :view_work_packages] @private_project.is_public = false @private_project.save @@ -133,7 +133,7 @@ describe Member, type: :model do (@member = Member.new.tap do |m| m.attributes = { project_id: @private_project.id, user_id: @watcher_user.id, - role_ids: [@private_role.id, FactoryGirl.create(:role).id] } + role_ids: [@private_role.id, FactoryBot.create(:role).id] } end).save! end @@ -159,11 +159,11 @@ describe Member, type: :model do context 'of group' do before do - @group = FactoryGirl.create :group + @group = FactoryBot.create :group @member = (Member.new.tap do |m| m.attributes = { project_id: @private_project.id, user_id: @group.id, - role_ids: [@private_role.id, FactoryGirl.create(:role).id] } + role_ids: [@private_role.id, FactoryBot.create(:role).id] } end) @group.members << @member diff --git a/spec_legacy/unit/principal_spec.rb b/spec_legacy/unit/principal_spec.rb index 7704b866c8..4d6a88975c 100644 --- a/spec_legacy/unit/principal_spec.rb +++ b/spec_legacy/unit/principal_spec.rb @@ -31,17 +31,17 @@ require 'legacy_spec_helper' describe Principal, type: :model do context '#like' do before do - FactoryGirl.create(:principal, login: 'login') - FactoryGirl.create(:principal, login: 'login2') + FactoryBot.create(:principal, login: 'login') + FactoryBot.create(:principal, login: 'login2') - FactoryGirl.create(:principal, firstname: 'firstname') - FactoryGirl.create(:principal, firstname: 'firstname2') + FactoryBot.create(:principal, firstname: 'firstname') + FactoryBot.create(:principal, firstname: 'firstname2') - FactoryGirl.create(:principal, lastname: 'lastname') - FactoryGirl.create(:principal, lastname: 'lastname2') + FactoryBot.create(:principal, lastname: 'lastname') + FactoryBot.create(:principal, lastname: 'lastname2') - FactoryGirl.create(:principal, mail: 'mail@example.com') - FactoryGirl.create(:principal, mail: 'mail2@example.com') + FactoryBot.create(:principal, mail: 'mail@example.com') + FactoryBot.create(:principal, mail: 'mail2@example.com') end it 'should search login' do diff --git a/spec_legacy/unit/project_nested_set_spec.rb b/spec_legacy/unit/project_nested_set_spec.rb index e48d9d72e0..1198d10fc3 100644 --- a/spec_legacy/unit/project_nested_set_spec.rb +++ b/spec_legacy/unit/project_nested_set_spec.rb @@ -31,7 +31,7 @@ require 'legacy_spec_helper' describe 'ProjectNestedSet', type: :model do context 'nested set' do before do - FactoryGirl.create(:type_standard) + FactoryBot.create(:type_standard) Project.delete_all @a = Project.create!(name: 'Project A', identifier: 'projecta') diff --git a/spec_legacy/unit/project_spec.rb b/spec_legacy/unit/project_spec.rb index f6b3f71905..5c6fdf010c 100644 --- a/spec_legacy/unit/project_spec.rb +++ b/spec_legacy/unit/project_spec.rb @@ -33,7 +33,7 @@ describe Project, type: :model do fixtures :all before do - FactoryGirl.create(:type_standard) + FactoryBot.create(:type_standard) @ecookbook = Project.find(1) @ecookbook_sub1 = Project.find(3) User.current = nil @@ -450,7 +450,7 @@ describe Project, type: :model do end it 'should short description returns shortened description' do - @project = FactoryGirl.create(:project) + @project = FactoryBot.create(:project) @project.description = ('Abcd ' * 5 + "\n") * 11 assert_equal (('Abcd ' * 5 + "\n") * 10)[0..-2] + '...', @project.short_description end @@ -458,9 +458,9 @@ describe Project, type: :model do context '#rolled_up_versions' do before do - @project = FactoryGirl.create(:project) - @parent_version_1 = FactoryGirl.create(:version, project: @project) - @parent_version_2 = FactoryGirl.create(:version, project: @project) + @project = FactoryBot.create(:project) + @parent_version_1 = FactoryBot.create(:version, project: @project) + @parent_version_2 = FactoryBot.create(:version, project: @project) end it 'should include the versions for the current project' do @@ -468,9 +468,9 @@ describe Project, type: :model do end it 'should include versions for a subproject' do - @subproject = FactoryGirl.create(:project) + @subproject = FactoryBot.create(:project) @subproject.set_parent!(@project) - @subproject_version = FactoryGirl.create(:version, project: @subproject) + @subproject_version = FactoryBot.create(:version, project: @subproject) assert_same_elements [ @parent_version_1, @@ -480,11 +480,11 @@ describe Project, type: :model do end it 'should include versions for a sub-subproject' do - @subproject = FactoryGirl.create(:project) + @subproject = FactoryBot.create(:project) @subproject.set_parent!(@project) - @sub_subproject = FactoryGirl.create(:project) + @sub_subproject = FactoryBot.create(:project) @sub_subproject.set_parent!(@subproject) - @sub_subproject_version = FactoryGirl.create(:version, project: @sub_subproject) + @sub_subproject_version = FactoryBot.create(:version, project: @sub_subproject) @project.reload @@ -496,9 +496,9 @@ describe Project, type: :model do end it 'should only check active projects' do - @subproject = FactoryGirl.create(:project) + @subproject = FactoryBot.create(:project) @subproject.set_parent!(@project) - @subproject_version = FactoryGirl.create(:version, project: @subproject) + @subproject_version = FactoryBot.create(:version, project: @subproject) assert @subproject.archive @project.reload @@ -723,7 +723,7 @@ describe Project, type: :model do project = Project.find(1) system_activity = TimeEntryActivity.find_by(name: 'Design') assert system_activity.active? - overridden_activity = FactoryGirl.create(:time_entry_activity, project: project, parent: system_activity, active: false) + overridden_activity = FactoryBot.create(:time_entry_activity, project: project, parent: system_activity, active: false) assert overridden_activity.save! assert !project.activities.include?(overridden_activity), 'Inactive Project specific Activity not found' @@ -757,7 +757,7 @@ describe Project, type: :model do end it 'should copy work units' do - work_package = FactoryGirl.create(:work_package, + work_package = FactoryBot.create(:work_package, status: Status.find_by_name('Closed'), subject: 'copy issue status', type_id: 1, @@ -784,10 +784,10 @@ describe Project, type: :model do it 'should change the new issues to use the copied version' do User.current = User.find(1) - assigned_version = FactoryGirl.create(:version, name: 'Assigned Issues', status: 'open') + assigned_version = FactoryBot.create(:version, name: 'Assigned Issues', status: 'open') @source_project.versions << assigned_version assert_equal 3, @source_project.versions.size - FactoryGirl.create(:work_package, project: @source_project, + FactoryBot.create(:work_package, project: @source_project, fixed_version_id: assigned_version.id, subject: 'change the new issues to use the copied version', type_id: 1, @@ -805,10 +805,10 @@ describe Project, type: :model do it 'should change the new issues to use the copied closed version' do User.current = User.find(1) - assigned_version = FactoryGirl.create(:version, name: 'Assigned Issues', status: 'open') + assigned_version = FactoryBot.create(:version, name: 'Assigned Issues', status: 'open') @source_project.versions << assigned_version assert_equal 3, @source_project.versions.size - FactoryGirl.create(:work_package, project: @source_project, + FactoryBot.create(:work_package, project: @source_project, fixed_version_id: assigned_version.id, subject: 'change the new issues to use the copied version', type_id: 1, @@ -828,15 +828,15 @@ describe Project, type: :model do it 'should copy issue relations' do Setting.cross_project_work_package_relations = '1' - second_issue = FactoryGirl.create(:work_package, status_id: 5, + second_issue = FactoryBot.create(:work_package, status_id: 5, subject: 'copy issue relation', type_id: 1, assigned_to_id: 2, project_id: @source_project.id) - source_relation = FactoryGirl.create(:relation, from: WorkPackage.find(4), + source_relation = FactoryBot.create(:relation, from: WorkPackage.find(4), to: second_issue, relation_type: 'relates') - source_relation_cross_project = FactoryGirl.create(:relation, from: WorkPackage.find(1), + source_relation_cross_project = FactoryBot.create(:relation, from: WorkPackage.find(1), to: second_issue, relation_type: 'duplicates') @@ -910,8 +910,8 @@ describe Project, type: :model do end it 'should copy versions' do - @source_project.versions << FactoryGirl.create(:version) - @source_project.versions << FactoryGirl.create(:version) + @source_project.versions << FactoryBot.create(:version) + @source_project.versions << FactoryBot.create(:version) assert @project.versions.empty? assert @project.copy(@source_project) @@ -1000,8 +1000,8 @@ describe Project, type: :model do context '#start_date' do before do ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests - @project = FactoryGirl.create(:project, identifier: 'test0') - @project.types << FactoryGirl.create(:type) + @project = FactoryBot.create(:project, identifier: 'test0') + @project.types << FactoryBot.create(:type) end it 'should be nil if there are no issues on the project' do @@ -1010,8 +1010,8 @@ describe Project, type: :model do it "should be the earliest start date of it's issues" do early = 7.days.ago.to_date - FactoryGirl.create(:work_package, project: @project, start_date: Date.today) - FactoryGirl.create(:work_package, project: @project, start_date: early) + FactoryBot.create(:work_package, project: @project, start_date: Date.today) + FactoryBot.create(:work_package, project: @project, start_date: early) assert_equal early, @project.start_date end @@ -1020,8 +1020,8 @@ describe Project, type: :model do context '#due_date' do before do ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests - @project = FactoryGirl.create(:project, identifier: 'test0') - @project.types << FactoryGirl.create(:type) + @project = FactoryBot.create(:project, identifier: 'test0') + @project.types << FactoryBot.create(:type) end it 'should be nil if there are no issues on the project' do @@ -1030,16 +1030,16 @@ describe Project, type: :model do it "should be the latest due date of it's issues" do future = 7.days.from_now.to_date - FactoryGirl.create(:work_package, project: @project, due_date: future) - FactoryGirl.create(:work_package, project: @project, due_date: Date.today) + FactoryBot.create(:work_package, project: @project, due_date: future) + FactoryBot.create(:work_package, project: @project, due_date: Date.today) assert_equal future, @project.due_date end it "should be the latest due date of it's versions" do future = 7.days.from_now.to_date - @project.versions << FactoryGirl.create(:version, effective_date: future) - @project.versions << FactoryGirl.create(:version, effective_date: Date.today) + @project.versions << FactoryBot.create(:version, effective_date: future) + @project.versions << FactoryBot.create(:version, effective_date: Date.today) assert_equal future, @project.due_date end @@ -1047,8 +1047,8 @@ describe Project, type: :model do it "should pick the latest date from it's issues and versions" do future = 7.days.from_now.to_date far_future = 14.days.from_now.to_date - FactoryGirl.create(:work_package, project: @project, due_date: far_future) - @project.versions << FactoryGirl.create(:version, effective_date: future) + FactoryBot.create(:work_package, project: @project, due_date: far_future) + @project.versions << FactoryBot.create(:version, effective_date: future) assert_equal far_future, @project.due_date end @@ -1057,8 +1057,8 @@ describe Project, type: :model do context 'Project#completed_percent' do before do ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests - @project = FactoryGirl.create(:project, identifier: 'test0') - @project.types << FactoryGirl.create(:type) + @project = FactoryBot.create(:project, identifier: 'test0') + @project.types << FactoryBot.create(:type) end context 'no versions' do @@ -1069,26 +1069,26 @@ describe Project, type: :model do context 'with versions' do it 'should return 0 if the versions have no issues' do - FactoryGirl.create(:version, project: @project) - FactoryGirl.create(:version, project: @project) + FactoryBot.create(:version, project: @project) + FactoryBot.create(:version, project: @project) assert_equal 0, @project.completed_percent end it 'should return 100 if the version has only closed issues' do - v1 = FactoryGirl.create(:version, project: @project) - v2 = FactoryGirl.create(:version, project: @project) - FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v1) - FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v2) + v1 = FactoryBot.create(:version, project: @project) + v2 = FactoryBot.create(:version, project: @project) + FactoryBot.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v1) + FactoryBot.create(:work_package, project: @project, status: Status.find_by_name('Closed'), fixed_version: v2) assert_equal 100, @project.completed_percent end it 'should return the averaged completed percent of the versions (not weighted)' do - v1 = FactoryGirl.create(:version, project: @project) - v2 = FactoryGirl.create(:version, project: @project) - FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v1) - FactoryGirl.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v2) + v1 = FactoryBot.create(:version, project: @project) + v2 = FactoryBot.create(:version, project: @project) + FactoryBot.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v1) + FactoryBot.create(:work_package, project: @project, status: Status.find_by_name('New'), estimated_hours: 10, done_ratio: 50, fixed_version: v2) assert_equal 50, @project.completed_percent end @@ -1097,35 +1097,35 @@ describe Project, type: :model do context '#notified_users' do before do - @project = FactoryGirl.create(:project) - @role = FactoryGirl.create(:role) + @project = FactoryBot.create(:project) + @role = FactoryBot.create(:role) - @user_with_membership_notification = FactoryGirl.create(:user, mail_notification: 'selected') + @user_with_membership_notification = FactoryBot.create(:user, mail_notification: 'selected') Member.create!(project: @project, principal: @user_with_membership_notification, mail_notification: true) do |member| member.role_ids = [@role.id] end - @all_events_user = FactoryGirl.create(:user, mail_notification: 'all') + @all_events_user = FactoryBot.create(:user, mail_notification: 'all') Member.create!(project: @project, principal: @all_events_user) do |member| member.role_ids = [@role.id] end - @no_events_user = FactoryGirl.create(:user, mail_notification: 'none') + @no_events_user = FactoryBot.create(:user, mail_notification: 'none') Member.create!(project: @project, principal: @no_events_user) do |member| member.role_ids = [@role.id] end - @only_my_events_user = FactoryGirl.create(:user, mail_notification: 'only_my_events') + @only_my_events_user = FactoryBot.create(:user, mail_notification: 'only_my_events') Member.create!(project: @project, principal: @only_my_events_user) do |member| member.role_ids = [@role.id] end - @only_assigned_user = FactoryGirl.create(:user, mail_notification: 'only_assigned') + @only_assigned_user = FactoryBot.create(:user, mail_notification: 'only_assigned') Member.create!(project: @project, principal: @only_assigned_user) do |member| member.role_ids = [@role.id] end - @only_owned_user = FactoryGirl.create(:user, mail_notification: 'only_owner') + @only_owned_user = FactoryBot.create(:user, mail_notification: 'only_owner') Member.create!(project: @project, principal: @only_owned_user) do |member| member.role_ids = [@role.id] end diff --git a/spec_legacy/unit/query_spec.rb b/spec_legacy/unit/query_spec.rb index 69df475210..39e13d2f9b 100644 --- a/spec_legacy/unit/query_spec.rb +++ b/spec_legacy/unit/query_spec.rb @@ -209,9 +209,9 @@ describe Query, type: :model do group = Group.find(10) project = Project.find(1) User.current = user - i1 = FactoryGirl.create(:work_package, project: project, type: project.types.first, assigned_to: user) - i2 = FactoryGirl.create(:work_package, project: project, type: project.types.first, assigned_to: group) - i3 = FactoryGirl.create(:work_package, project: project, type: project.types.first, assigned_to: Group.find(11)) + i1 = FactoryBot.create(:work_package, project: project, type: project.types.first, assigned_to: user) + i2 = FactoryBot.create(:work_package, project: project, type: project.types.first, assigned_to: group) + i3 = FactoryBot.create(:work_package, project: project, type: project.types.first, assigned_to: Group.find(11)) group.users << user query = Query.new(name: '_', filters: [{ assigned_to_id: { operator: '=', values: ['me'] } }]) @@ -419,8 +419,8 @@ describe Query, type: :model do it 'should have a list of the groups as values' do Group.destroy_all # No fixtures - group1 = FactoryGirl.create(:group).reload - group2 = FactoryGirl.create(:group).reload + group1 = FactoryBot.create(:group).reload + group2 = FactoryBot.create(:group).reload expected_group_list = [ [group1.name, group1.id.to_s], @@ -536,19 +536,19 @@ describe Query, type: :model do context "with 'member_of_group' filter" do before do Group.destroy_all # No fixtures - @user_in_group = FactoryGirl.create(:user) - @second_user_in_group = FactoryGirl.create(:user) - @user_in_group2 = FactoryGirl.create(:user) - @user_not_in_group = FactoryGirl.create(:user) + @user_in_group = FactoryBot.create(:user) + @second_user_in_group = FactoryBot.create(:user) + @user_in_group2 = FactoryBot.create(:user) + @user_not_in_group = FactoryBot.create(:user) - @group = FactoryGirl.create(:group).reload + @group = FactoryBot.create(:group).reload @group.users << @user_in_group @group.users << @second_user_in_group - @group2 = FactoryGirl.create(:group).reload + @group2 = FactoryBot.create(:group).reload @group2.users << @user_in_group2 - @empty_group = FactoryGirl.create(:group).reload + @empty_group = FactoryBot.create(:group).reload end it 'should search assigned to for users in the group' do @@ -601,17 +601,17 @@ describe Query, type: :model do Member.delete_all Role.delete_all - @manager_role = FactoryGirl.create(:role, name: 'Manager') - @developer_role = FactoryGirl.create(:role, name: 'Developer') - @empty_role = FactoryGirl.create(:role, name: 'Empty') - - @project = FactoryGirl.create(:project) - @manager = FactoryGirl.create(:user) - @developer = FactoryGirl.create(:user) - @boss = FactoryGirl.create(:user) - FactoryGirl.create(:member, user: @manager, project: @project, role_ids: [@manager_role.id]) - FactoryGirl.create(:member, user: @developer, project: @project, role_ids: [@developer_role.id]) - FactoryGirl.create(:member, user: @boss, project: @project, role_ids: [@manager_role, @developer_role].map(&:id)) + @manager_role = FactoryBot.create(:role, name: 'Manager') + @developer_role = FactoryBot.create(:role, name: 'Developer') + @empty_role = FactoryBot.create(:role, name: 'Empty') + + @project = FactoryBot.create(:project) + @manager = FactoryBot.create(:user) + @developer = FactoryBot.create(:user) + @boss = FactoryBot.create(:user) + FactoryBot.create(:member, user: @manager, project: @project, role_ids: [@manager_role.id]) + FactoryBot.create(:member, user: @developer, project: @project, role_ids: [@developer_role.id]) + FactoryBot.create(:member, user: @boss, project: @project, role_ids: [@manager_role, @developer_role].map(&:id)) end it 'should search assigned to for users with the Role' do diff --git a/spec_legacy/unit/time_entry_spec.rb b/spec_legacy/unit/time_entry_spec.rb index bff033665b..b08658ef2d 100644 --- a/spec_legacy/unit/time_entry_spec.rb +++ b/spec_legacy/unit/time_entry_spec.rb @@ -99,9 +99,9 @@ describe TimeEntry, type: :model do context '#earliest_date_for_project' do before do User.current = nil - @public_project = FactoryGirl.create(:project, is_public: true) - @issue = FactoryGirl.create(:work_package, project: @public_project) - FactoryGirl.create(:time_entry, spent_on: '2010-01-01', + @public_project = FactoryBot.create(:project, is_public: true) + @issue = FactoryBot.create(:work_package, project: @public_project) + FactoryBot.create(:time_entry, spent_on: '2010-01-01', work_package: @issue, project: @public_project) end @@ -122,9 +122,9 @@ describe TimeEntry, type: :model do context '#latest_date_for_project' do before do User.current = nil - @public_project = FactoryGirl.create(:project, is_public: true) - @issue = FactoryGirl.create(:work_package, project: @public_project) - FactoryGirl.create(:time_entry, spent_on: '2010-01-01', + @public_project = FactoryBot.create(:project, is_public: true) + @issue = FactoryBot.create(:work_package, project: @public_project) + FactoryBot.create(:time_entry, spent_on: '2010-01-01', work_package: @issue, project: @public_project) end diff --git a/spec_legacy/unit/user_preference_spec.rb b/spec_legacy/unit/user_preference_spec.rb index 9690b1a975..cc39ce9d11 100644 --- a/spec_legacy/unit/user_preference_spec.rb +++ b/spec_legacy/unit/user_preference_spec.rb @@ -33,14 +33,14 @@ describe UserPreference do it 'should validations' do # factory valid - assert FactoryGirl.build(:user_preference).valid? + assert FactoryBot.build(:user_preference).valid? # user required - refute FactoryGirl.build(:user_preference, user: nil).valid? + refute FactoryBot.build(:user_preference, user: nil).valid? end it 'should create' do - user = FactoryGirl.create :user + user = FactoryBot.create :user assert_kind_of UserPreference, user.pref assert_kind_of Hash, user.pref.others @@ -48,8 +48,8 @@ describe UserPreference do end it 'should update' do - user = FactoryGirl.create :user - pref = FactoryGirl.create :user_preference, user: user, hide_mail: true + user = FactoryBot.create :user + pref = FactoryBot.create :user_preference, user: user, hide_mail: true assert_equal true, user.pref.hide_mail user.pref['preftest'] = 'value' @@ -60,7 +60,7 @@ describe UserPreference do end it 'should update_with_method' do - user = FactoryGirl.create :user + user = FactoryBot.create :user assert_equal OpenProject::Configuration.default_comment_sort_order, user.pref.comments_sorting user.pref.comments_sorting = 'value' assert user.pref.save diff --git a/spec_legacy/unit/user_spec.rb b/spec_legacy/unit/user_spec.rb index 6326342d15..f10f7d7e20 100644 --- a/spec_legacy/unit/user_spec.rb +++ b/spec_legacy/unit/user_spec.rb @@ -40,8 +40,8 @@ describe User, type: :model do end specify 'object_daddy creation' do - FactoryGirl.create(:user, firstname: 'Testing connection') - FactoryGirl.create(:user, firstname: 'Testing connection') + FactoryBot.create(:user, firstname: 'Testing connection') + FactoryBot.create(:user, firstname: 'Testing connection') assert_equal 2, User.where(firstname: 'Testing connection').count end @@ -79,11 +79,11 @@ describe User, type: :model do context 'User#before_create' do it 'should set the mail_notification to the default Setting' do - @user1 = FactoryGirl.create(:user, mail_notification: nil) + @user1 = FactoryBot.create(:user, mail_notification: nil) assert_equal 'only_my_events', @user1.mail_notification Setting.default_notification_option = 'all' - @user2 = FactoryGirl.create(:user) + @user2 = FactoryBot.create(:user) assert_equal 'all', @user2.mail_notification end end @@ -155,7 +155,7 @@ describe User, type: :model do end it 'should select the exact matching user first' do - case_sensitive_user = FactoryGirl.create(:user, login: 'changed', password: 'adminADMIN!', password_confirmation: 'adminADMIN!') + case_sensitive_user = FactoryBot.create(:user, login: 'changed', password: 'adminADMIN!', password_confirmation: 'adminADMIN!') # bypass validations to make it appear like existing data case_sensitive_user.update_attribute(:login, 'ADMIN') @@ -286,8 +286,8 @@ describe User, type: :model do end it 'should return nil if the key is found for an inactive user' do - user = FactoryGirl.create(:user, status: User::STATUSES[:locked]) - token = FactoryGirl.build(:api_token, user: user) + user = FactoryBot.create(:user, status: User::STATUSES[:locked]) + token = FactoryBot.build(:api_token, user: user) user.api_token = token user.save @@ -295,8 +295,8 @@ describe User, type: :model do end it 'should return the user if the key is found for an active user' do - user = FactoryGirl.create(:user, status: User::STATUSES[:active]) - token = FactoryGirl.build(:api_token, user: user) + user = FactoryBot.create(:user, status: User::STATUSES[:active]) + token = FactoryBot.build(:api_token, user: user) user.api_token = token user.save @@ -323,7 +323,7 @@ describe User, type: :model do end it 'should projects by role for user with no role' do - user = FactoryGirl.create(:user) + user = FactoryBot.create(:user) assert_equal({}, user.projects_by_role) end diff --git a/spec_legacy/unit/version_spec.rb b/spec_legacy/unit/version_spec.rb index 6b69ead57c..04581333e2 100644 --- a/spec_legacy/unit/version_spec.rb +++ b/spec_legacy/unit/version_spec.rb @@ -56,7 +56,7 @@ describe Version, type: :model do v.attributes = { project: project, name: 'Progress' } end).save! add_work_package(v, estimated_hours: 10, start_date: '2010-03-01') - FactoryGirl.create(:work_package, project: project, subject: 'not assigned', start_date: '2010-01-01') + FactoryBot.create(:work_package, project: project, subject: 'not assigned', start_date: '2010-01-01') assert_equal '2010-03-01', v.start_date.to_s end @@ -163,8 +163,8 @@ describe Version, type: :model do context '#behind_schedule?' do before do ProjectCustomField.destroy_all # Custom values are a mess to isolate in tests - @project = FactoryGirl.create(:project, identifier: 'test0') - @project.types << FactoryGirl.create(:type) + @project = FactoryBot.create(:project, identifier: 'test0') + @project.types << FactoryBot.create(:type) (@version = Version.new.tap do |v| v.attributes = { project: @project, effective_date: nil, name: 'test' } @@ -183,8 +183,8 @@ describe Version, type: :model do it 'should be false if all of the issues are ahead of schedule' do @version.update_attribute(:effective_date, 7.days.from_now.to_date) @version.fixed_issues = [ - FactoryGirl.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left - FactoryGirl.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60) # 14 day span, 60% done, 50% time left + FactoryBot.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left + FactoryBot.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60) # 14 day span, 60% done, 50% time left ] assert_equal 60, @version.completed_percent assert_equal false, @version.behind_schedule? @@ -193,8 +193,8 @@ describe Version, type: :model do it 'should be true if any of the issues are behind schedule' do @version.update_attribute(:effective_date, 7.days.from_now.to_date) @version.fixed_issues = [ - FactoryGirl.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left - FactoryGirl.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 20) # 14 day span, 20% done, 50% time left + FactoryBot.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 60), # 14 day span, 60% done, 50% time left + FactoryBot.create(:work_package, project: @project, start_date: 7.days.ago, done_ratio: 20) # 14 day span, 20% done, 50% time left ] assert_equal 40, @version.completed_percent assert_equal true, @version.behind_schedule? @@ -203,8 +203,8 @@ describe Version, type: :model do it 'should be false if all of the issues are complete' do @version.update_attribute(:effective_date, 7.days.from_now.to_date) @version.fixed_issues = [ - FactoryGirl.create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)), # 7 day span - FactoryGirl.create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)) # 7 day span + FactoryBot.create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)), # 7 day span + FactoryBot.create(:work_package, project: @project, start_date: 14.days.ago, done_ratio: 100, status: Status.find(5)) # 7 day span ] assert_equal 100, @version.completed_percent assert_equal false, @version.behind_schedule? diff --git a/spec_legacy/unit/watcher_spec.rb b/spec_legacy/unit/watcher_spec.rb index 111e78c002..775b32af91 100644 --- a/spec_legacy/unit/watcher_spec.rb +++ b/spec_legacy/unit/watcher_spec.rb @@ -30,9 +30,9 @@ require 'legacy_spec_helper' describe Watcher do before do - @user = FactoryGirl.create :user - @issue = FactoryGirl.create :work_package - @role = FactoryGirl.create :role, permissions: [:view_work_packages] + @user = FactoryBot.create :user + @issue = FactoryBot.create :work_package + @role = FactoryBot.create :role, permissions: [:view_work_packages] @issue.project.add_member! @user, @role end diff --git a/spec_legacy/unit/wiki_content_spec.rb b/spec_legacy/unit/wiki_content_spec.rb index bc6823811c..1721198a4e 100644 --- a/spec_legacy/unit/wiki_content_spec.rb +++ b/spec_legacy/unit/wiki_content_spec.rb @@ -83,7 +83,7 @@ describe WikiContent, type: :model do end it 'should fetch history' do - wiki_content_journal = FactoryGirl.build(:wiki_content_journal, + wiki_content_journal = FactoryBot.build(:wiki_content_journal, journable_id: @page.content.id) wiki_content_journal.data.page_id = @page.id wiki_content_journal.data.text = '' diff --git a/spec_legacy/unit/wiki_spec.rb b/spec_legacy/unit/wiki_spec.rb index 7129313460..ea7d941227 100644 --- a/spec_legacy/unit/wiki_spec.rb +++ b/spec_legacy/unit/wiki_spec.rb @@ -58,7 +58,7 @@ describe Wiki, type: :model do page = WikiPage.find(10) assert_equal page, wiki.find_page('Этика менеджмента') - page = FactoryGirl.create(:wiki_page, wiki: wiki, title: '2009\\02\\09') + page = FactoryBot.create(:wiki_page, wiki: wiki, title: '2009\\02\\09') assert_equal page, wiki.find_page('2009\\02\\09') end end