stabilize flickering request spec

pull/7913/head
ulferts 5 years ago
parent c2311df6f5
commit 273402e20c
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 12
      spec/requests/api/v3/work_packages/form/work_package_form_resource_spec.rb
  2. 4
      spec/services/relations/update_service_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

@ -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

Loading…
Cancel
Save