Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
FactoryGirl => FactoryBot (opf/openproject#6304)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed May 7, 2018
1 parent a118ace commit fa75d24
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
16 changes: 8 additions & 8 deletions spec/lib/custom_field_xls_export_spec.rb
Expand Up @@ -2,11 +2,11 @@
require 'spreadsheet'

describe "WorkPackageXlsExport Custom Fields" 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,
Expand All @@ -23,7 +23,7 @@ def custom_values_for(*values)
end

let(:work_package1) do
wp = FactoryGirl.create :work_package, project: project, type: type
wp = FactoryBot.create :work_package, project: project, type: type
wp.custom_field_values = {
custom_field.id => custom_values_for('ham', 'onions')
}
Expand All @@ -32,20 +32,20 @@ def custom_values_for(*values)
end

let(:work_package2) do
wp = FactoryGirl.create :work_package, project: project, type: type
wp = FactoryBot.create :work_package, project: project, type: type
wp.custom_field_values = {
custom_field.id => custom_values_for('pineapple')
}
wp.save
wp
end

let(:work_package3) { FactoryGirl.create :work_package, project: project, type: type }
let(:work_package3) { FactoryBot.create :work_package, project: project, type: type }
let(:work_packages) { [work_package1, work_package2, work_package3] }
let(:current_user) { FactoryGirl.create :admin }
let(:current_user) { FactoryBot.create :admin }

let!(:query) do
query = FactoryGirl.build(:query, user: current_user, project: project)
query = FactoryBot.build(:query, user: current_user, project: project)
query.column_names = ['subject', "cf_#{custom_field.id}"]
query.sort_criteria = [%w[id asc]]

Expand Down
20 changes: 10 additions & 10 deletions spec/lib/work_package_xls_export_spec.rb
Expand Up @@ -2,21 +2,21 @@
require 'spreadsheet'

describe "WorkPackageXlsExport" do
let(:project) { FactoryGirl.create :project }
let(:project) { FactoryBot.create :project }

let(:parent) { FactoryGirl.create :work_package, project: project, subject: 'Parent' }
let(:parent) { FactoryBot.create :work_package, project: project, subject: 'Parent' }
let(:child_1) do
FactoryGirl.create :work_package, parent: parent, project: project, subject: 'Child 1'
FactoryBot.create :work_package, parent: parent, project: project, subject: 'Child 1'
end
let(:child_2) do
FactoryGirl.create :work_package, parent: parent, project: project, subject: 'Child 2'
FactoryBot.create :work_package, parent: parent, project: project, subject: 'Child 2'
end

let(:single) { FactoryGirl.create :work_package, project: project, subject: 'Single' }
let(:followed) { FactoryGirl.create :work_package, project: project, subject: 'Followed' }
let(:single) { FactoryBot.create :work_package, project: project, subject: 'Single' }
let(:followed) { FactoryBot.create :work_package, project: project, subject: 'Followed' }

let(:child_2_child) do
FactoryGirl.create :work_package, parent: child_2, project: project, subject: "Child 2's child"
FactoryBot.create :work_package, parent: child_2, project: project, subject: "Child 2's child"
end

let(:relation) do
Expand All @@ -36,10 +36,10 @@
work_packages
end

let(:current_user) { FactoryGirl.create :admin } # may export relations
let(:current_user) { FactoryBot.create :admin } # may export relations

let(:query) do
query = FactoryGirl.build(:query, user: current_user, project: project)
query = FactoryBot.build(:query, user: current_user, project: project)

query.filters.clear
query.sort_criteria = [['id', 'asc']]
Expand Down Expand Up @@ -158,7 +158,7 @@ def load_sheet(export)
end

context 'with someone who may not see related work packages' do
let(:current_user) { FactoryGirl.create :user }
let(:current_user) { FactoryBot.create :user }

it 'exports no information without visibility' do
expect(sheet.rows.length).to eq(2)
Expand Down
12 changes: 6 additions & 6 deletions spec/patches/work_packages_controller_patch_spec.rb
@@ -1,9 +1,9 @@
require 'spec_helper'

describe WorkPackagesController, 'rendering to xls', type: :controller do
let(:current_user) { FactoryGirl.create(:admin) }
let(:current_user) { FactoryBot.create(:admin) }
let!(:work_package) do
FactoryGirl.create(:work_package,
FactoryBot.create(:work_package,
subject: '!SUBJECT!',
description: '!DESCRIPTION!')
end
Expand Down Expand Up @@ -43,11 +43,11 @@
# a custom field called 'costs' to emulate it.

let(:custom_field) do
FactoryGirl.create(:float_wp_custom_field,
FactoryBot.create(:float_wp_custom_field,
name: 'unit costs')
end
let(:custom_value) do
FactoryGirl.create(:custom_value,
FactoryBot.create(:custom_value,
custom_field: custom_field)
end
let(:type) do
Expand All @@ -56,11 +56,11 @@
type
end
let(:project) do
FactoryGirl.create(:project,
FactoryBot.create(:project,
work_package_custom_fields: [custom_field])
end
let(:work_packages) do
wps = FactoryGirl.create_list(:work_package, 4,
wps = FactoryBot.create_list(:work_package, 4,
project: project,
type: type)
wps[0].estimated_hours = 27.5
Expand Down

0 comments on commit fa75d24

Please sign in to comment.