Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

avoid fixtures in seeding spec

ulferts7d82fea80e76
diff --git a/modules/bim/spec/seeders/demo_data_seeder_spec.rb b/modules/bim/spec/seeders/demo_data_seeder_spec.rb
index f1659334cf9..d49e177ab3e 100644
--- a/modules/bim/spec/seeders/demo_data_seeder_spec.rb
+++ b/modules/bim/spec/seeders/demo_data_seeder_spec.rb
@@ -30,7 +30,7 @@
require 'spec_helper'
-describe 'seeds' do
+describe 'seeds', :with_clean_fixture do
context 'BIM edition', with_config: { edition: 'bim' } do
it 'create the demo data' do
expect { ::Bim::BasicDataSeeder.new.seed! }.not_to raise_error
diff --git a/spec/lib/api/v3/relations/relation_representer_spec.rb b/spec/lib/api/v3/relations/relation_representer_spec.rb
index a4efdea530d..c67e99a0783 100644
--- a/spec/lib/api/v3/relations/relation_representer_spec.rb
+++ b/spec/lib/api/v3/relations/relation_representer_spec.rb
@@ -29,23 +29,22 @@
require 'spec_helper'
describe ::API::V3::Relations::RelationRepresenter do
- using_shared_fixtures :admin
- let(:user) { admin }
+ let(:user) { FactoryBot.build_stubbed(:admin) }
- let(:from) { FactoryBot.create :work_package }
- let(:to) { FactoryBot.create :work_package }
+ let(:from) { FactoryBot.build_stubbed :work_package }
+ let(:to) { FactoryBot.build_stubbed :work_package }
let(:type) { "follows" }
let(:description) { "This first" }
let(:delay) { 3 }
let(:relation) do
- FactoryBot.create :relation,
- from: from,
- to: to,
- relation_type: type,
- description: description,
- delay: delay
+ FactoryBot.build_stubbed :relation,
+ from: from,
+ to: to,
+ relation_type: type,
+ description: description,
+ delay: delay
end
let(:representer) { described_class.new relation, current_user: user }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 3cd06765554..c76fde65eaa 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -567,7 +567,7 @@ describe User, type: :model do
it "is false for a user with :only_my_events who has no relation to the work package" do
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] }
+ m.attributes = { principal: user, project: project, role_ids: [role.id] }
end)
expect(user.notify_about?(work_package)).to be_falsey
end
@@ -625,7 +625,7 @@ describe User, type: :model do
it "is false for a user with :only_my_events who has no relation to the work package" do
user = FactoryBot.build(:user, mail_notification: 'selected')
(Member.new.tap do |m|
- m.attributes = { user: user, project: project, role_ids: [role.id] }
+ m.attributes = { principal: user, project: project, role_ids: [role.id] }
end)
expect(user.notify_about?(work_package)).to be_falsey
end
diff --git a/spec/seeders/demo_data_seeder_spec.rb b/spec/seeders/demo_data_seeder_spec.rb
index a9d33e5decc..955e22521de 100644
--- a/spec/seeders/demo_data_seeder_spec.rb
+++ b/spec/seeders/demo_data_seeder_spec.rb
@@ -30,7 +30,7 @@
require 'spec_helper'
-describe 'seeds' do
+describe 'seeds', :with_clean_fixture do
context 'standard edition', with_config: { edition: 'standard' } do
it 'create the demo data' do
expect { StandardSeeder::BasicDataSeeder.new.seed! }.not_to raise_error
diff --git a/spec/support/shared_fixtures/shared_fixture.rb b/spec/support/shared_fixtures/shared_fixture.rb
index b4b63ad40c8..0ef212c387e 100644
--- a/spec/support/shared_fixtures/shared_fixture.rb
+++ b/spec/support/shared_fixtures/shared_fixture.rb
@@ -6,7 +6,6 @@ require 'test_prof/ext/active_record_refind'
# This will allow to lazily define fixtures through FactoryBot calls
# that are created once and reloaded (instead of recreated) for each example.
class SharedFixture
-
# Keep a registry of fixture to instantiate
# them lazily.
cattr_accessor :fixtures