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

stabilize flickering request spec

ulferts273402e20c86
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 226e37bb099..7bd0aa203ff 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
@@ -29,7 +29,7 @@
require 'spec_helper'
require 'rack/test'
-describe 'API v3 Work package form resource', type: :request do
+describe 'API v3 Work package form resource', type: :request, with_mail: false do
include Rack::Test::Methods
include Capybara::RSpecMatchers
include API::V3::Utilities::PathHelper
@@ -37,7 +37,13 @@ describe 'API v3 Work package form resource', type: :request do
shared_let(:all_allowed_permissions) { %i[view_work_packages edit_work_packages assign_versions] }
shared_let(:assign_permissions) { %i[view_work_packages assign_versions] }
shared_let(:project) { FactoryBot.create(:project, public: false) }
- shared_let(:work_package) { FactoryBot.create(:work_package, project: project) }
+ shared_let(:work_package) do
+ # Prevent executing as potentially unsaved AnyonymousUser which would
+ # lead to the creation failing as the journal cannot be written with user_id = nil.
+ User.execute_as authorized_user do
+ FactoryBot.create(:work_package, project: project)
+ end
+ end
shared_let(:authorized_user) do
FactoryBot.create(:user, member_in_project: project, member_with_permissions: all_allowed_permissions)
end
@@ -59,7 +65,7 @@ describe 'API v3 Work package form resource', type: :request do
shared_context 'post request' do
before(:each) do
- allow(User).to receive(:current).and_return current_user
+ login_as(current_user)
post post_path, (params ? params.to_json : nil), 'CONTENT_TYPE' => 'application/json'
end
end
diff --git a/spec/services/relations/update_service_spec.rb b/spec/services/relations/update_service_spec.rb
index 544288fa171..23a1a1e832d 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
- FactoryBot.build_stubbed(:work_package,
+ FactoryBot.build_stubbed(:stubbed_work_package,
due_date: work_package1_due_date,
start_date: work_package1_start_date)
end
let(:work_package2) do
- FactoryBot.build_stubbed(:work_package,
+ FactoryBot.build_stubbed(:stubbed_work_package,
due_date: work_package2_due_date,
start_date: work_package2_start_date)
end