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 type expectations in specs

ulferts7eab2c4a69bb
diff --git a/modules/my_page/spec/features/my/assigned_to_me_spec.rb b/modules/my_page/spec/features/my/assigned_to_me_spec.rb
index 0ea9a92a550..f21cc8a3139 100644
--- a/modules/my_page/spec/features/my/assigned_to_me_spec.rb
+++ b/modules/my_page/spec/features/my/assigned_to_me_spec.rb
@@ -159,17 +159,6 @@ describe 'Assigned to me embedded query on my page', type: :feature, js: true do
project_field.openSelectField
project_field.set_value project.name
- embedded_table.expect_toast(
- message: 'Type is not set to one of the allowed values.',
- type: :error
- )
-
- # Set type
- type_field = embedded_table.edit_field(nil, :type)
- type_field.expect_active!
- type_field.openSelectField
- type_field.set_value type.name
-
embedded_table.expect_toast(
message: 'Successful creation. Click here to open this work package in fullscreen view.'
)
diff --git a/spec/factories/work_package_factory.rb b/spec/factories/work_package_factory.rb
index e08e32515f4..6cd50c18a3d 100644
--- a/spec/factories/work_package_factory.rb
+++ b/spec/factories/work_package_factory.rb
@@ -74,7 +74,9 @@ FactoryBot.define do
end
callback(:after_stub) do |wp, arguments|
- wp.type = wp.project.types.first unless wp.type_id || arguments.instance_variable_get(:@overrides).has_key?(:type)
+ unless wp.type_id || arguments.instance_variable_get(:@overrides).has_key?(:type) || wp.project.nil?
+ wp.type = wp.project.types.first
+ end
end
end
end
diff --git a/spec/factories/workflow_factory.rb b/spec/factories/workflow_factory.rb
index e00b0a1031c..ded70ab4901 100644
--- a/spec/factories/workflow_factory.rb
+++ b/spec/factories/workflow_factory.rb
@@ -31,6 +31,7 @@ FactoryBot.define do
old_status factory: :status
new_status factory: :status
role
+ type
factory :workflow_with_default_status do
old_status factory: :default_status
diff --git a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
index b3bbe2ca7e8..f0ea15998bc 100644
--- a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
+++ b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
@@ -152,21 +152,12 @@ describe 'inline create work package', js: true do
it_behaves_like 'inline create work package' do
let(:callback) do
-> {
- # Set project
+ # Set project which will also select the type (first one in the selected project)
project_field = wp_table.edit_field(nil, :project)
project_field.expect_active!
project_field.openSelectField
project_field.set_value project.name
-
- sleep 1
-
- # Set type
- type_field = wp_table.edit_field(nil, :type)
- type_field.expect_active!
-
- type_field.openSelectField
- type_field.set_value type.name
}
end
end
diff --git a/spec/helpers/work_packages_helper_spec.rb b/spec/helpers/work_packages_helper_spec.rb
index d4db7497ea4..e67277369c2 100644
--- a/spec/helpers/work_packages_helper_spec.rb
+++ b/spec/helpers/work_packages_helper_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
describe WorkPackagesHelper, type: :helper do
- let(:stub_work_package) { build_stubbed(:work_package) }
+ let(:stub_work_package) { build_stubbed(:work_package, type: stub_type) }
let(:stub_project) { build_stubbed(:project) }
let(:stub_type) { build_stubbed(:type) }
let(:stub_user) { build_stubbed(:user) }
@@ -42,16 +42,7 @@ describe WorkPackagesHelper, type: :helper do
end
describe 'without parameters' do
- it 'returns a link to the work package with the id as the text' do
- link_text = Regexp.new("^##{stub_work_package.id}$")
- expect(helper.link_to_work_package(stub_work_package)).to have_selector(
- "a[href='#{work_package_path(stub_work_package)}']", text: link_text
- )
- end
-
it 'returns a link to the work package with type and id as the text if type is set' do
- stub_work_package.type = stub_type
-
link_text = Regexp.new("^#{stub_type.name} ##{stub_work_package.id}$")
expect(helper.link_to_work_package(stub_work_package)).to have_selector(
"a[href='#{work_package_path(stub_work_package)}']", text: link_text
@@ -79,8 +70,6 @@ describe WorkPackagesHelper, type: :helper do
describe 'with the all_link option provided' do
it 'returns a link to the work package with the type, id, and subject as the text' do
- stub_work_package.type = stub_type
-
link_text = Regexp.new("^#{stub_type} ##{stub_work_package.id}: #{stub_work_package.subject}$")
expect(helper.link_to_work_package(stub_work_package,
all_link: true)).to have_selector(
@@ -113,8 +102,6 @@ describe WorkPackagesHelper, type: :helper do
describe 'when omitting the type' do
it 'omits the type' do
- stub_work_package.type = stub_type
-
link_text = Regexp.new("^##{stub_work_package.id}$")
expect(helper.link_to_work_package(stub_work_package,
type: false)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
@@ -139,9 +126,7 @@ describe WorkPackagesHelper, type: :helper do
end
describe 'when only wanting the id' do
- it 'returns a link with the id as text only even if the work package has a type' do
- stub_work_package.type = stub_type
-
+ it 'returns a link with the id as text only' do
link_text = Regexp.new("^##{stub_work_package.id}$")
expect(helper.link_to_work_package(stub_work_package,
id_only: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
@@ -165,8 +150,6 @@ describe WorkPackagesHelper, type: :helper do
describe 'with the status displayed' do
it 'returns a link with the status name contained in the text' do
- stub_work_package.type = stub_type
-
link_text = Regexp.new("^#{stub_type.name} ##{stub_work_package.id} #{stub_work_package.status}$")
expect(helper.link_to_work_package(stub_work_package,
status: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
diff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rb
index c29cdd1dd25..73c621c2398 100644
--- a/spec/services/work_packages/set_attributes_service_spec.rb
+++ b/spec/services/work_packages/set_attributes_service_spec.rb
@@ -232,7 +232,7 @@ describe WorkPackages::SetAttributesService,
subject
expect(work_package.changed_by_system['author_id'])
- .to eql [0, user.id]
+ .to eql [nil, user.id]
end
end
end