Skip to content

Commit

Permalink
Make spec slightly faster
Browse files Browse the repository at this point in the history
  • Loading branch information
cbliard committed Mar 22, 2024
1 parent 8c4a540 commit e0fe75a
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions spec/services/work_packages/copy_service_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,28 @@
require "spec_helper"

RSpec.describe WorkPackages::CopyService, "integration", type: :model do
let(:user) do
create(:user, member_with_roles: { project => role })
shared_let(:custom_field) { create(:work_package_custom_field) }
shared_let(:type) do
create(:type_standard,
custom_fields: [custom_field])
end
let(:role) do
create(:project_role,
permissions:)
shared_let(:project) { create(:project, types: [type]) }
shared_let(:user) do
create(:user, member_with_permissions: { project => %i[view_work_packages add_work_packages manage_subtasks] })
end

let(:permissions) do
%i(view_work_packages add_work_packages manage_subtasks)
before_all do
set_factory_default(:project, project)
set_factory_default(:project_with_types, project)
set_factory_default(:type, type)
set_factory_default(:user, user)
end

let(:type) do
create(:type_standard,
custom_fields: [custom_field])
end
let(:project) { create(:project, types: [type]) }
let(:work_package) do
create(:work_package,
project:,
type:)
shared_let(:work_package) do
create(:work_package, author: user, project:, type:)
end

let(:instance) { described_class.new(work_package:, user:) }
let(:custom_field) { create(:work_package_custom_field) }
let(:custom_value) do
create(:work_package_custom_value,
custom_field:,
Expand Down Expand Up @@ -151,15 +149,15 @@
end

context "required custom field in the target project" do
let(:custom_field) do
create(
:work_package_custom_field,
let(:target_custom_fields) { [custom_field] }

before do
custom_field.update(
field_format: "text",
is_required: true,
is_for_all: false
)
end
let(:target_custom_fields) { [custom_field] }

it "does not copy the work package" do
expect(service_result).to be_failure
Expand Down

0 comments on commit e0fe75a

Please sign in to comment.