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

Fix create service with flag

Oliver Günther19e22ca57c7b
diff --git a/modules/meeting/spec/services/meetings/create_service_spec.rb b/modules/meeting/spec/services/meetings/create_service_spec.rb
index 06f59dbafc6..e3442e8797f 100644
--- a/modules/meeting/spec/services/meetings/create_service_spec.rb
+++ b/modules/meeting/spec/services/meetings/create_service_spec.rb
@@ -30,18 +30,30 @@
require "spec_helper"
require "services/base_services/behaves_like_create_service"
-RSpec.describe Meetings::CreateService, type: :model do
- describe "The creation of backlogs in the service breaks these. Need new ones" do
- it_behaves_like "BaseServices create service" do
- let(:factory) { :meeting }
+RSpec.describe Meetings::CreateService,
+ type: :model,
+ with_flag: { meeting_backlogs: true } do
+ let(:section_double) { instance_double(MeetingSections::CreateService) }
- context "when system user creates the meeting" do
- let(:user) { User.system }
+ before do
+ allow(MeetingSections::CreateService)
+ .to receive(:new)
+ .and_return(section_double)
- it "does not get assigned as the creator" do
- expect(subject).to be_success
- expect(subject.result.participants).to be_empty
- end
+ allow(section_double)
+ .to receive(:call)
+ .and_return(ServiceResult.success)
+ end
+
+ it_behaves_like "BaseServices create service" do
+ let(:factory) { :meeting }
+
+ context "when system user creates the meeting" do
+ let(:user) { User.system }
+
+ it "does not get assigned as the creator" do
+ expect(subject).to be_success
+ expect(subject.result.participants).to be_empty
end
end
end
diff --git a/spec/services/base_services/behaves_like_create_service.rb b/spec/services/base_services/behaves_like_create_service.rb
index b2fbfac1408..84d6d7e234e 100644
--- a/spec/services/base_services/behaves_like_create_service.rb
+++ b/spec/services/base_services/behaves_like_create_service.rb
@@ -46,15 +46,15 @@ RSpec.shared_examples "BaseServices create service" do
let(:set_attributes_success) do
true
end
+ let!(:model_instance) { build_stubbed(factory) }
let(:set_attributes_errors) do
- double("set_attributes_errors")
+ ActiveModel::Errors.new(model_instance)
end
let(:set_attributes_result) do
ServiceResult.new result: model_instance,
success: set_attributes_success,
errors: set_attributes_errors
end
- let!(:model_instance) { build_stubbed(factory) }
let!(:set_attributes_service) do
# Do not stub the SetAttributesService when the model is not stubbed
next unless stub_model_instance