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

Switch to double quotes for files modified on this branch

Christophe Bliard03d9ff74a80f
diff --git a/app/contracts/work_packages/base_contract.rb b/app/contracts/work_packages/base_contract.rb
index c3d7e94eb6d..65342ddf316 100644
--- a/app/contracts/work_packages/base_contract.rb
+++ b/app/contracts/work_packages/base_contract.rb
@@ -74,7 +74,7 @@ module WorkPackages
next unless model.project
validate_people_visible :assigned_to,
- 'assigned_to_id',
+ "assigned_to_id",
assignable_assignees
end
@@ -82,7 +82,7 @@ module WorkPackages
next unless model.project
validate_people_visible :responsible,
- 'responsible_id',
+ "responsible_id",
assignable_responsibles
end
@@ -223,7 +223,7 @@ module WorkPackages
def validate_after_soonest_start(date_attribute)
if !model.schedule_manually? && before_soonest_start?(date_attribute)
- message = I18n.t('activerecord.errors.models.work_package.attributes.start_date.violates_relationships',
+ message = I18n.t("activerecord.errors.models.work_package.attributes.start_date.violates_relationships",
soonest_start: model.soonest_start)
errors.add date_attribute, message, error_symbol: :violates_relationships
@@ -353,7 +353,7 @@ module WorkPackages
unless principal_visible?(id, list)
errors.add attribute,
- I18n.t('api_v3.errors.validation.invalid_user_assigned_to_work_package',
+ I18n.t("api_v3.errors.validation.invalid_user_assigned_to_work_package",
property: I18n.t("attributes.#{attribute}"))
end
end
diff --git a/app/models/mail_handler.rb b/app/models/mail_handler.rb
index 8e3290ad2b2..24b2c994849 100644
--- a/app/models/mail_handler.rb
+++ b/app/models/mail_handler.rb
@@ -47,7 +47,7 @@ class MailHandler < ActionMailer::Base
# Code copied from base class and extended with optional options parameter
# as well as force_encoding support.
def self.receive(raw_mail, options = {})
- raw_mail.force_encoding('ASCII-8BIT') if raw_mail.respond_to?(:force_encoding)
+ raw_mail.force_encoding("ASCII-8BIT") if raw_mail.respond_to?(:force_encoding)
ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
mail = Mail.new(raw_mail)
@@ -66,8 +66,8 @@ class MailHandler < ActionMailer::Base
cattr_accessor :ignored_emails_headers
@@ignored_emails_headers = {
- 'X-Auto-Response-Suppress' => 'oof',
- 'Auto-Submitted' => /\Aauto-/
+ "X-Auto-Response-Suppress" => "oof",
+ "Auto-Submitted" => /\Aauto-/
}
# Processes incoming emails
@@ -102,9 +102,9 @@ class MailHandler < ActionMailer::Base
if @user.nil?
# Email was submitted by an unknown user
case options[:unknown_user]
- when 'accept'
+ when "accept"
@user = User.anonymous
- when 'create'
+ when "create"
@user, password = MailHandler::UserCreator.create_user_from_email(email)
if @user
log "[#{@user.login}] account created"
@@ -140,7 +140,7 @@ class MailHandler < ActionMailer::Base
options[:allow_override] << :type unless options[:issue].has_key?(:type)
# Priority overridable by default
options[:allow_override] << :priority unless options[:issue].has_key?(:priority)
- options[:no_permission_check] = options[:no_permission_check].to_s == '1'
+ options[:no_permission_check] = options[:no_permission_check].to_s == "1"
end
private
@@ -255,7 +255,7 @@ class MailHandler < ActionMailer::Base
if message.locked?
log "ignoring reply from [#{sender_email}] to a locked topic"
else
- reply = Message.new(subject: email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
+ reply = Message.new(subject: email.subject.gsub(%r{^.*msg\d+\]}, "").strip,
content: cleaned_up_text_body)
reply.author = user
reply.forum = message.forum
@@ -303,7 +303,7 @@ class MailHandler < ActionMailer::Base
unless addresses.empty?
User
.active
- .where(['LOWER(mail) IN (?)', addresses])
+ .where(["LOWER(mail) IN (?)", addresses])
.find_each do |user|
Services::CreateWatcher
.new(obj, user)
@@ -348,7 +348,7 @@ class MailHandler < ActionMailer::Base
text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(?<value>#{format || '.+'})\s*$/i) do |_|
value = Regexp.last_match[:value]&.strip
- ''
+ ""
end
value
@@ -369,7 +369,7 @@ class MailHandler < ActionMailer::Base
# * parse the email To field
# * specific project (eg. Setting.mail_handler_target_project)
target = Project.find_by(identifier: get_keyword(:project))
- raise MissingInformation.new('Unable to determine target project') if target.nil?
+ raise MissingInformation.new("Unable to determine target project") if target.nil?
target
end
@@ -377,17 +377,17 @@ class MailHandler < ActionMailer::Base
# Returns a Hash of issue attributes extracted from keywords in the email body
def wp_attributes_from_keywords(work_package)
{
- 'type_id' => wp_type_from_keywords(work_package),
- 'status_id' => wp_status_from_keywords,
- 'parent_id' => wp_parent_from_keywords,
- 'priority_id' => wp_priority_from_keywords,
- 'category_id' => wp_category_from_keywords(work_package),
- 'assigned_to_id' => wp_assignee_from_keywords(work_package),
- 'version_id' => wp_version_from_keywords(work_package),
- 'start_date' => wp_start_date_from_keywords,
- 'due_date' => wp_due_date_from_keywords,
- 'estimated_hours' => wp_estimated_hours_from_keywords,
- 'remaining_hours' => wp_remaining_hours_from_keywords
+ "type_id" => wp_type_from_keywords(work_package),
+ "status_id" => wp_status_from_keywords,
+ "parent_id" => wp_parent_from_keywords,
+ "priority_id" => wp_priority_from_keywords,
+ "category_id" => wp_category_from_keywords(work_package),
+ "assigned_to_id" => wp_assignee_from_keywords(work_package),
+ "version_id" => wp_version_from_keywords(work_package),
+ "start_date" => wp_start_date_from_keywords,
+ "due_date" => wp_due_date_from_keywords,
+ "estimated_hours" => wp_estimated_hours_from_keywords,
+ "remaining_hours" => wp_remaining_hours_from_keywords
}.compact_blank!
end
@@ -401,7 +401,7 @@ class MailHandler < ActionMailer::Base
end
end
- def lookup_case_insensitive_key(scope, attribute, column_name = Arel.sql('name'))
+ def lookup_case_insensitive_key(scope, attribute, column_name = Arel.sql("name"))
if k = get_keyword(attribute)
scope.find_by("lower(#{column_name}) = ?", k.downcase).try(:id)
end
@@ -420,7 +420,7 @@ class MailHandler < ActionMailer::Base
@plain_text_body = strip_tags(@plain_text_body.strip)
@plain_text_body = CGI.unescapeHTML(@plain_text_body)
- @plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
+ @plain_text_body.sub! %r{^<!DOCTYPE .*$}, ""
@plain_text_body
end
@@ -434,7 +434,7 @@ class MailHandler < ActionMailer::Base
def allow_override_option(options)
if options[:allow_override].is_a?(String)
- options[:allow_override].split(',').map(&:strip)
+ options[:allow_override].split(",").map(&:strip)
else
options[:allow_override] || []
end
@@ -445,13 +445,13 @@ class MailHandler < ActionMailer::Base
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).compact_blank.map { |s| Regexp.escape(s) }
unless delimiters.empty?
regex = Regexp.new("^[> ]*(#{delimiters.join('|')})\s*[\r\n].*", Regexp::MULTILINE)
- body = body.gsub(regex, '')
+ body = body.gsub(regex, "")
end
regex_delimiter = Setting.mail_handler_body_delimiter_regex
if regex_delimiter.present?
regex = Regexp.new(regex_delimiter, Regexp::MULTILINE)
- body = body.gsub(regex, '')
+ body = body.gsub(regex, "")
end
body.strip
@@ -491,9 +491,9 @@ class MailHandler < ActionMailer::Base
def collect_wp_attributes_from_email_on_create(work_package)
attributes = wp_attributes_from_keywords(work_package)
attributes
- .merge('custom_field_values' => custom_field_values_from_keywords(work_package),
- 'subject' => email.subject.to_s.chomp[0, 255] || '(no subject)',
- 'description' => cleaned_up_text_body)
+ .merge("custom_field_values" => custom_field_values_from_keywords(work_package),
+ "subject" => email.subject.to_s.chomp[0, 255] || "(no subject)",
+ "description" => cleaned_up_text_body)
end
def update_work_package(work_package)
@@ -516,8 +516,8 @@ class MailHandler < ActionMailer::Base
def collect_wp_attributes_from_email_on_update(work_package)
attributes = wp_attributes_from_keywords(work_package)
attributes
- .merge('custom_field_values' => custom_field_values_from_keywords(work_package),
- 'journal_notes' => cleaned_up_text_body)
+ .merge("custom_field_values" => custom_field_values_from_keywords(work_package),
+ "journal_notes" => cleaned_up_text_body)
end
def wp_type_from_keywords(work_package)
@@ -586,7 +586,7 @@ class MailHandler < ActionMailer::Base
{
message_id: email.message_id,
subject: email.subject,
- from: email.from&.first || '(unknown from address)',
+ from: email.from&.first || "(unknown from address)",
quote: incoming_email_quote(email),
text: plain_text_body || incoming_email_text(email)
}
diff --git a/app/services/work_packages/set_attributes_service.rb b/app/services/work_packages/set_attributes_service.rb
index 36871f2fe4a..874a98792e5 100644
--- a/app/services/work_packages/set_attributes_service.rb
+++ b/app/services/work_packages/set_attributes_service.rb
@@ -222,7 +222,7 @@ class WorkPackages::SetAttributesService < BaseServices::SetAttributes
end
def normalize_whitespace(string)
- string.gsub(/\s/, ' ').squeeze(' ')
+ string.gsub(/\s/, " ").squeeze(" ")
end
def set_custom_attributes(attributes)
diff --git a/app/services/work_packages/update_ancestors_service.rb b/app/services/work_packages/update_ancestors_service.rb
index 8211a9d6996..22f730f442a 100644
--- a/app/services/work_packages/update_ancestors_service.rb
+++ b/app/services/work_packages/update_ancestors_service.rb
@@ -112,7 +112,7 @@ class WorkPackages::UpdateAncestorsService
def set_journal_note(work_packages)
work_packages.each do |wp|
- wp.journal_notes = I18n.t('work_package.updated_automatically_by_child_changes', child: "##{initiator_work_package.id}")
+ wp.journal_notes = I18n.t("work_package.updated_automatically_by_child_changes", child: "##{initiator_work_package.id}")
end
end
diff --git a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
index e17074c1d76..ec0e5136457 100644
--- a/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
+++ b/lib/api/v3/work_packages/schema/work_package_schema_representer.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'roar/decorator'
-require 'roar/json/hal'
+require "roar/decorator"
+require "roar/json/hal"
module API
module V3
@@ -101,84 +101,84 @@ module API
uncacheable: true
schema :lock_version,
- type: 'Integer',
- name_source: ->(*) { I18n.t('api_v3.attributes.lock_version') },
+ type: "Integer",
+ name_source: ->(*) { I18n.t("api_v3.attributes.lock_version") },
show_if: ->(*) { @show_lock_version }
schema :id,
- type: 'Integer'
+ type: "Integer"
schema :subject,
- type: 'String',
+ type: "String",
min_length: 1,
max_length: 255
schema :description,
- type: 'Formattable',
+ type: "Formattable",
required: false
schema :duration,
- type: 'Duration',
+ type: "Duration",
required: false,
show_if: ->(*) { !represented.milestone? }
schema :schedule_manually,
- type: 'Boolean',
+ type: "Boolean",
required: false,
has_default: true
schema :ignore_non_working_days,
- type: 'Boolean',
+ type: "Boolean",
required: false
schema :start_date,
- type: 'Date',
+ type: "Date",
required: false,
show_if: ->(*) { !represented.milestone? }
schema :due_date,
- type: 'Date',
+ type: "Date",
required: false,
show_if: ->(*) { !represented.milestone? }
schema :derived_start_date,
- type: 'Date',
+ type: "Date",
required: false,
show_if: ->(*) { !represented.milestone? }
schema :derived_due_date,
- type: 'Date',
+ type: "Date",
required: false,
show_if: ->(*) { !represented.milestone? }
schema :date,
- type: 'Date',
+ type: "Date",
required: false,
show_if: ->(*) { represented.milestone? }
schema :estimated_time,
- type: 'Duration',
+ type: "Duration",
required: false
schema :derived_estimated_time,
- name_source: ->(*) { I18n.t('attributes.derived_estimated_hours') },
- type: 'Duration',
+ name_source: ->(*) { I18n.t("attributes.derived_estimated_hours") },
+ type: "Duration",
required: false
schema :remaining_time,
name_source: :remaining_hours,
- type: 'Duration',
+ type: "Duration",
required: false,
writable: ->(*) { !WorkPackage.use_status_for_done_ratio? }
schema :derived_remaining_time,
name_source: :derived_remaining_hours,
- type: 'Duration',
+ type: "Duration",
required: false,
writable: false
schema :spent_time,
- type: 'Duration',
+ type: "Duration",
required: false,
show_if: ->(*) {
current_user.allowed_in_project?(:view_time_entries, represented.project) ||
@@ -186,36 +186,36 @@ module API
}
schema :percentage_done,
- type: 'Integer',
+ type: "Integer",
name_source: :done_ratio,
- show_if: ->(*) { Setting.work_package_done_ratio != 'disabled' },
+ show_if: ->(*) { Setting.work_package_done_ratio != "disabled" },
required: false
schema :derived_percentage_done,
- type: 'Integer',
+ type: "Integer",
name_source: :derived_done_ratio,
- show_if: ->(*) { Setting.work_package_done_ratio != 'disabled' },
+ show_if: ->(*) { Setting.work_package_done_ratio != "disabled" },
required: false
schema :readonly,
- type: 'Boolean',
+ type: "Boolean",
show_if: ->(*) { Status.can_readonly? },
required: false,
has_default: true
schema :created_at,
- type: 'DateTime'
+ type: "DateTime"
schema :updated_at,
- type: 'DateTime'
+ type: "DateTime"
schema :author,
- type: 'User',
+ type: "User",
location: :link,
writable: false
schema_with_allowed_link :project,
- type: 'Project',
+ type: "Project",
required: true,
href_callback: ->(*) {
work_package = represented.work_package
@@ -227,7 +227,7 @@ module API
}
schema_with_allowed_link :parent,
- type: 'WorkPackage',
+ type: "WorkPackage",
required: false,
writable: true,
href_callback: ->(*) {
@@ -238,7 +238,7 @@ module API
}
schema_with_allowed_link :assignee,
- type: 'User',
+ type: "User",
required: false,
href_callback: ->(*) {
work_package = represented.work_package
@@ -251,7 +251,7 @@ module API
}
schema_with_allowed_link :responsible,
- type: 'User',
+ type: "User",
required: false,
href_callback: ->(*) {
if represented.project
@@ -311,7 +311,7 @@ module API
has_default: true
schema_with_allowed_collection :budget,
- type: 'Budget',
+ type: "Budget",
required: false,
value_representer: ::API::V3::Budgets::BudgetRepresenter,
link_factory: ->(budget) {
@@ -381,7 +381,7 @@ module API
end
def form_config_attribute_cache_key(group)
- ['wp_schema_attribute_group',
+ ["wp_schema_attribute_group",
group.key,
I18n.locale,
represented.project,
diff --git a/lib/api/v3/work_packages/work_package_representer.rb b/lib/api/v3/work_packages/work_package_representer.rb
index face30dda14..3f2adbd163a 100644
--- a/lib/api/v3/work_packages/work_package_representer.rb
+++ b/lib/api/v3/work_packages/work_package_representer.rb
@@ -106,7 +106,7 @@ module API
{
href: new_work_package_move_path(represented),
- type: 'text/html',
+ type: "text/html",
title: "Move #{represented.subject}"
}
end
@@ -116,7 +116,7 @@ module API
next if represented.new_record?
{
- href: work_package_path(represented, 'copy'),
+ href: work_package_path(represented, "copy"),
title: "Copy #{represented.subject}"
}
end
@@ -127,8 +127,8 @@ module API
{
href: work_package_path(id: represented.id, format: :pdf),
- type: 'application/pdf',
- title: 'Export as PDF'
+ type: "application/pdf",
+ title: "Export as PDF"
}
end
@@ -138,8 +138,8 @@ module API
{
href: work_package_path(id: represented.id, format: :atom),
- type: 'application/rss+xml',
- title: 'Atom feed'
+ type: "application/rss+xml",
+ title: "Atom feed"
}
end
@@ -158,7 +158,7 @@ module API
{
href: project_settings_custom_fields_path(represented.project.identifier),
- type: 'text/html',
+ type: "text/html",
title: "Custom fields"
}
end
@@ -168,8 +168,8 @@ module API
next unless represented.type_id
{
- href: edit_type_path(represented.type_id, tab: 'form_configuration'),
- type: 'text/html',
+ href: edit_type_path(represented.type_id, tab: "form_configuration"),
+ type: "text/html",
title: "Configure form"
}
end
@@ -233,7 +233,7 @@ module API
{
href: api_v3_paths.work_package_watchers(represented.id),
method: :post,
- payload: { user: { href: api_v3_paths.user('{user_id}') } },
+ payload: { user: { href: api_v3_paths.user("{user_id}") } },
templated: true
}
end
@@ -241,7 +241,7 @@ module API
link :removeWatcher,
cache_if: -> { current_user.allowed_in_project?(:delete_work_package_watchers, represented.project) } do
{
- href: api_v3_paths.watcher('{user_id}', represented.id),
+ href: api_v3_paths.watcher("{user_id}", represented.id),
method: :delete,
templated: true
}
@@ -252,7 +252,7 @@ module API
{
href: api_v3_paths.work_package_relations(represented.id),
method: :post,
- title: 'Add relation'
+ title: "Add relation"
}
end
@@ -281,7 +281,7 @@ module API
{
href: api_v3_paths.work_package_activities(represented.id),
method: :post,
- title: 'Add comment'
+ title: "Add comment"
}
end
@@ -300,7 +300,7 @@ module API
{
href: api_v3_paths.path_for(:time_entries, filters:),
- title: 'Time entries'
+ title: "Time entries"
}
end
@@ -361,11 +361,11 @@ module API
# handled in reader
},
reader: ->(decorator:, doc:, **) {
- next unless doc.key?('date')
+ next unless doc.key?("date")
date = decorator
.datetime_formatter
- .parse_date(doc['date'],
+ .parse_date(doc["date"],
name.to_s.camelize(:lower),
allow_nil: true)
@@ -445,12 +445,12 @@ module API
property :done_ratio,
as: :percentageDone,
render_nil: true,
- if: ->(*) { Setting.work_package_done_ratio != 'disabled' }
+ if: ->(*) { Setting.work_package_done_ratio != "disabled" }
property :derived_done_ratio,
as: :derivedPercentageDone,
render_nil: true,
- if: ->(*) { Setting.work_package_done_ratio != 'disabled' }
+ if: ->(*) { Setting.work_package_done_ratio != "disabled" }
date_time_property :created_at
@@ -526,15 +526,15 @@ module API
setter: ->(fragment:, **) do
next if fragment.empty?
- href = fragment['href']
+ href = fragment["href"]
new_parent =
if href
id = ::API::Utilities::ResourceLinkParser
.parse_id href,
- property: 'parent',
- expected_version: '3',
- expected_namespace: 'work_packages'
+ property: "parent",
+ expected_version: "3",
+ expected_namespace: "work_packages"
WorkPackage.find_by(id:) ||
::WorkPackage::InexistentWorkPackage.new(id:)
@@ -570,7 +570,7 @@ module API
end
def _type
- 'WorkPackage'
+ "WorkPackage"
end
def to_hash(*args)
@@ -648,22 +648,22 @@ module API
def estimated_time=(value)
represented.estimated_hours =
- datetime_formatter.parse_duration_to_hours(value, 'estimatedTime', allow_nil: true)
+ datetime_formatter.parse_duration_to_hours(value, "estimatedTime", allow_nil: true)
end
def derived_estimated_time=(value)
represented.derived_estimated_hours =
- datetime_formatter.parse_duration_to_hours(value, 'derivedEstimatedTime', allow_nil: true)
+ datetime_formatter.parse_duration_to_hours(value, "derivedEstimatedTime", allow_nil: true)
end
def remaining_time=(value)
represented.remaining_hours =
- datetime_formatter.parse_duration_to_hours(value, 'remainingTime', allow_nil: true)
+ datetime_formatter.parse_duration_to_hours(value, "remainingTime", allow_nil: true)
end
def derived_remaining_time=(value)
represented.derived_remaining_hours =
- datetime_formatter.parse_duration_to_hours(value, 'derivedRemainingTime', allow_nil: true)
+ datetime_formatter.parse_duration_to_hours(value, "derivedRemainingTime", allow_nil: true)
end
def spent_time=(value)
@@ -672,7 +672,7 @@ module API
def duration=(value)
represented.duration = datetime_formatter.parse_duration_to_days(value,
- 'duration',
+ "duration",
allow_nil: true)
end
@@ -691,11 +691,11 @@ module API
# The dynamic class generation introduced because of the custom fields interferes with
# the class naming as well as prevents calls to super
def json_cache_key
- ['API',
- 'V3',
- 'WorkPackages',
- 'WorkPackageRepresenter',
- 'json',
+ ["API",
+ "V3",
+ "WorkPackages",
+ "WorkPackageRepresenter",
+ "json",
I18n.locale,
json_key_representer_parts,
represented.cache_checksum,
diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rb
index 2e589a117f3..daac840a8b0 100644
--- a/spec/contracts/work_packages/base_contract_spec.rb
+++ b/spec/contracts/work_packages/base_contract_spec.rb
@@ -26,8 +26,8 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require 'contracts/shared/model_contract_shared_context'
+require "spec_helper"
+require "contracts/shared/model_contract_shared_context"
RSpec.describe WorkPackages::BaseContract do
let(:work_package) do
@@ -65,9 +65,9 @@ RSpec.describe WorkPackages::BaseContract do
subject(:contract) { described_class.new(work_package, current_user) }
- include_context 'ModelContract shared context'
+ include_context "ModelContract shared context"
- shared_examples_for 'invalid if changed' do |attribute|
+ shared_examples_for "invalid if changed" do |attribute|
before do
allow(work_package).to receive(:changed).and_return(changed_values.map(&:to_s))
end
@@ -76,27 +76,27 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- context 'when has changed' do
+ context "when has changed" do
let(:changed_values) { [attribute] }
- it('is invalid') do
+ it("is invalid") do
expect(contract.errors.symbols_for(attribute)).to contain_exactly(:error_readonly)
end
end
- context 'when not changed' do
+ context "when not changed" do
let(:changed_values) { [] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
end
- shared_examples 'a parent unwritable property' do |attribute, schedule_sensitive: false|
+ shared_examples "a parent unwritable property" do |attribute, schedule_sensitive: false|
before do
allow(work_package).to receive(:changed).and_return(changed_values.map(&:to_s))
end
- context 'when no parent' do
+ context "when no parent" do
before do
allow(work_package)
.to receive(:leaf?)
@@ -105,20 +105,20 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- context 'when not changed' do
+ context "when not changed" do
let(:changed_values) { [] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
- context 'when has changed' do
+ context "when has changed" do
let(:changed_values) { [attribute] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
end
- context 'when is a parent' do
+ context "when is a parent" do
let(:schedule_manually) { false }
before do
@@ -130,50 +130,50 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- context 'when not changed' do
+ context "when not changed" do
let(:changed_values) { [] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
- context 'when has changed' do
+ context "when has changed" do
let(:changed_values) { [attribute] }
- it('is invalid (read only)') do
+ it("is invalid (read only)") do
expect(contract.errors.symbols_for(attribute)).to contain_exactly(:error_readonly)
end
end
if schedule_sensitive
- context 'when is scheduled manually' do
+ context "when is scheduled manually" do
let(:schedule_manually) { true }
- context 'when has changed' do
+ context "when has changed" do
let(:changed_values) { [attribute] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
end
end
end
end
- describe 'status' do
- context 'for readonly status' do
+ describe "status" do
+ context "for readonly status" do
before do
allow(work_package)
.to receive(:readonly_status?)
.and_return true
end
- it 'only sets status to allowed' do
+ it "only sets status to allowed" do
expect(contract.writable_attributes).to eq(%w[status status_id])
end
end
- context 'when work_package has a closed version and status' do
+ context "when work_package has a closed version and status" do
before do
- version = build_stubbed(:version, status: 'closed')
+ version = build_stubbed(:version, status: "closed")
work_package.version = version
allow(work_package.status)
@@ -181,29 +181,29 @@ RSpec.describe WorkPackages::BaseContract do
.and_return(true)
end
- it 'is not writable' do
+ it "is not writable" do
expect(contract).not_to be_writable(:status)
end
- context 'when we only switched into that status now' do
+ context "when we only switched into that status now" do
before do
allow(work_package)
.to receive(:status_id_change)
.and_return [1, 2]
end
- it 'is writable' do
+ it "is writable" do
expect(contract).to be_writable(:status)
end
end
end
- context 'when status is inexistent' do
+ context "when status is inexistent" do
before do
work_package.status = Status::InexistentStatus.new
end
- it 'is invalid' do
+ it "is invalid" do
contract.validate
expect(subject.errors.symbols_for(:status))
@@ -211,7 +211,7 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'transitions' do
+ describe "transitions" do
let(:roles) { [build_stubbed(:project_role)] }
let(:valid_transition_result) { true }
let(:new_status) { build_stubbed(:status) }
@@ -220,7 +220,7 @@ RSpec.describe WorkPackages::BaseContract do
let(:status_change) { work_package.status = new_status }
before do
- new_statuses_scope = double('new statuses scope')
+ new_statuses_scope = double("new statuses scope") # rubocop:disable RSpec/VerifiedDoubles
allow(Status)
.to receive(:find_by)
@@ -249,39 +249,39 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- context 'when valid transition' do
- it 'is valid' do
+ context "when valid transition" do
+ it "is valid" do
expect(subject.errors.symbols_for(:status_id))
.to be_empty
end
end
- context 'when invalid transition' do
+ context "when invalid transition" do
let(:valid_transition_result) { false }
- it 'is invalid' do
+ it "is invalid" do
expect(subject.errors.symbols_for(:status_id))
.to contain_exactly(:status_transition_invalid)
end
end
- context 'when status is nil' do
+ context "when status is nil" do
let(:status_change) { work_package.status = nil }
- it 'is invalid' do
+ it "is invalid" do
expect(subject.errors.symbols_for(:status))
.to contain_exactly(:blank)
end
end
- context 'when invalid transition but the type changed as well' do
+ context "when invalid transition but the type changed as well" do
let(:valid_transition_result) { false }
let(:status_change) do
work_package.status = new_status
work_package.type = build_stubbed(:type)
end
- it 'is valid' do
+ it "is valid" do
expect(subject.errors.symbols_for(:status_id))
.to be_empty
end
@@ -289,17 +289,17 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'estimated hours' do
+ describe "estimated hours" do
let(:estimated_hours) { 1 }
before do
work_package.estimated_hours = estimated_hours
end
- context 'when > 0' do
+ context "when > 0" do
let(:estimated_hours) { 1 }
- it 'is valid' do
+ it "is valid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -307,10 +307,10 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when 0' do
+ context "when 0" do
let(:estimated_hours) { 0 }
- it 'is valid' do
+ it "is valid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -318,10 +318,10 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when nil' do
+ context "when nil" do
let(:estimated_hours) { nil }
- it 'is valid' do
+ it "is valid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -329,10 +329,10 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when < 0' do
+ context "when < 0" do
let(:estimated_hours) { -1 }
- it 'is invalid' do
+ it "is invalid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -340,7 +340,7 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when inferior to remaining_hours' do
+ context "when inferior to remaining_hours" do
let(:estimated_hours) { 5.0 }
before do
@@ -348,7 +348,7 @@ RSpec.describe WorkPackages::BaseContract do
allow(work_package).to receive(:changed).and_return(%w[estimated_hours])
end
- it 'is invalid' do
+ it "is invalid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -357,7 +357,7 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'derived estimated hours' do
+ describe "derived estimated hours" do
let(:changed_values) { [] }
let(:attribute) { :derived_estimated_hours }
@@ -367,22 +367,22 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- context 'when has not changed' do
+ context "when has not changed" do
let(:changed_values) { [] }
- it('is valid') { expect(contract.errors).to be_empty }
+ it("is valid") { expect(contract.errors).to be_empty }
end
- context 'when has changed' do
+ context "when has changed" do
let(:changed_values) { [attribute] }
- it('is invalid (read only)') do
+ it("is invalid (read only)") do
expect(contract.errors.symbols_for(attribute)).to contain_exactly(:error_readonly)
end
end
end
- describe 'remaining hours' do
+ describe "remaining hours" do
before do
work_package.estimated_hours = 5.0
work_package.remaining_hours = remaining_hours
@@ -393,7 +393,7 @@ RSpec.describe WorkPackages::BaseContract do
context "when it's the same as estimated_hours" do
let(:remaining_hours) { 5.0 }
- it 'is valid' do
+ it "is valid" do
contract.validate
expect(subject.errors.symbols_for(:remaining_hours))
@@ -404,7 +404,7 @@ RSpec.describe WorkPackages::BaseContract do
context "when it's less than estimated_hours" do
let(:remaining_hours) { 4.0 }
- it 'is valid' do
+ it "is valid" do
contract.validate
expect(subject.errors.symbols_for(:remaining_hours))
@@ -415,7 +415,7 @@ RSpec.describe WorkPackages::BaseContract do
context "when it's greater than estimated_hours" do
let(:remaining_hours) { 6.0 }
- it 'is invalid' do
+ it "is invalid" do
contract.validate
expect(subject.errors.symbols_for(:remaining_hours))
@@ -424,14 +424,14 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'estimated_hours and remaining_hours' do
- context 'when changing both and remaining_hours exceeds estimated_hours' do
+ describe "estimated_hours and remaining_hours" do
+ context "when changing both and remaining_hours exceeds estimated_hours" do
before do
work_package.estimated_hours = 5.0
work_package.remaining_hours = 6.0
end
- it 'is invalid' do
+ it "is invalid" do
contract.validate
expect(subject.errors.symbols_for(:estimated_hours))
@@ -442,49 +442,49 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- shared_examples_for 'a date attribute' do |attribute|
- context 'for a date' do
+ shared_examples_for "a date attribute" do |attribute|
+ context "for a date" do
before do
work_package.send(:"#{attribute}=", Time.zone.today)
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(subject.errors.symbols_for(attribute))
.to be_empty
end
end
- context 'for a string representing a date' do
+ context "for a string representing a date" do
before do
- work_package.send(:"#{attribute}=", '01/01/17')
+ work_package.send(:"#{attribute}=", "01/01/17")
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(subject.errors.symbols_for(attribute))
.to be_empty
end
end
- context 'for a non-date' do
+ context "for a non-date" do
before do
- work_package.send(:"#{attribute}=", 'not a date')
+ work_package.send(:"#{attribute}=", "not a date")
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(subject.errors.symbols_for(attribute))
.to contain_exactly(:not_a_date)
end
end
end
- describe 'start date' do
- it_behaves_like 'a parent unwritable property', :start_date, schedule_sensitive: true
- it_behaves_like 'a date attribute', :start_date
+ describe "start date" do
+ it_behaves_like "a parent unwritable property", :start_date, schedule_sensitive: true
+ it_behaves_like "a date attribute", :start_date
- context 'as before soonest start date of parent' do
+ context "as before soonest start date of parent" do
let(:schedule_manually) { false }
before do
@@ -499,11 +499,11 @@ RSpec.describe WorkPackages::BaseContract do
work_package.start_date = Time.zone.today + 2.days
end
- context 'when scheduled automatically' do
- it 'notes the error' do
+ context "when scheduled automatically" do
+ it "notes the error" do
contract.validate
- message = I18n.t('activerecord.errors.models.work_package.attributes.start_date.violates_relationships',
+ message = I18n.t("activerecord.errors.models.work_package.attributes.start_date.violates_relationships",
soonest_start: Time.zone.today + 4.days)
expect(contract.errors[:start_date])
@@ -511,41 +511,41 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when scheduled manually' do
+ context "when scheduled manually" do
let(:schedule_manually) { true }
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
end
- context 'when setting due date and duration without start date' do
+ context "when setting due date and duration without start date" do
before do
work_package.duration = 1
work_package.start_date = nil
work_package.due_date = Time.zone.today
end
- it_behaves_like 'contract is invalid', start_date: :cannot_be_null
+ it_behaves_like "contract is invalid", start_date: :cannot_be_null
end
end
- describe 'due date' do
- it_behaves_like 'a parent unwritable property', :due_date, schedule_sensitive: true
- it_behaves_like 'a date attribute', :due_date
+ describe "due date" do
+ it_behaves_like "a parent unwritable property", :due_date, schedule_sensitive: true
+ it_behaves_like "a date attribute", :due_date
- it 'returns an error when trying to set it before the start date' do
+ it "returns an error when trying to set it before the start date" do
work_package.start_date = Time.zone.today + 2.days
work_package.due_date = Time.zone.today
contract.validate
- message = I18n.t('activerecord.errors.messages.greater_than_or_equal_to_start_date')
+ message = I18n.t("activerecord.errors.messages.greater_than_or_equal_to_start_date")
expect(contract.errors[:due_date])
.to include message
end
- context 'when start date is not set and due date is before soonest start date of parent' do
+ context "when start date is not set and due date is before soonest start date of parent" do
let(:schedule_manually) { false }
before do
@@ -561,11 +561,11 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = Time.zone.today + 2.days
end
- context 'when scheduled automatically' do
- it 'notes the error' do
+ context "when scheduled automatically" do
+ it "notes the error" do
contract.validate
- message = I18n.t('activerecord.errors.models.work_package.attributes.start_date.violates_relationships',
+ message = I18n.t("activerecord.errors.models.work_package.attributes.start_date.violates_relationships",
soonest_start: Time.zone.today + 4.days)
expect(contract.errors[:due_date])
@@ -573,88 +573,88 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when scheduled manually' do
+ context "when scheduled manually" do
let(:schedule_manually) { true }
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
end
- context 'when setting start date and duration without due date' do
+ context "when setting start date and duration without due date" do
before do
work_package.duration = 1
work_package.start_date = Time.zone.today
work_package.due_date = nil
end
- it_behaves_like 'contract is invalid', due_date: :cannot_be_null
+ it_behaves_like "contract is invalid", due_date: :cannot_be_null
end
end
- describe 'duration' do
- context 'when setting duration' do
+ describe "duration" do
+ context "when setting duration" do
before do
work_package.duration = 5
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
- context 'when setting duration for a milestone type work package' do
+ context "when setting duration for a milestone type work package" do
let(:is_milestone) { true }
before do
work_package.duration = 5
end
- it_behaves_like 'contract is invalid', duration: :not_available_for_milestones
+ it_behaves_like "contract is invalid", duration: :not_available_for_milestones
end
- context 'when setting duration to nil for a milestone type work package' do
+ context "when setting duration to nil for a milestone type work package" do
let(:is_milestone) { true }
before do
work_package.duration = nil
end
- it_behaves_like 'contract is invalid'
+ it_behaves_like "contract is invalid"
end
- context 'when setting duration to 1 for a milestone type work package' do
+ context "when setting duration to 1 for a milestone type work package" do
let(:is_milestone) { true }
before do
work_package.duration = 1
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
- context 'when setting duration to 0' do
+ context "when setting duration to 0" do
before do
work_package.duration = 0
end
- it_behaves_like 'contract is invalid', duration: :greater_than
+ it_behaves_like "contract is invalid", duration: :greater_than
end
- context 'when setting duration to a floating point' do
+ context "when setting duration to a floating point" do
before do
work_package.duration = 4.5
end
- it_behaves_like 'contract is invalid', duration: :not_an_integer
+ it_behaves_like "contract is invalid", duration: :not_an_integer
end
- context 'when setting duration to a negative value' do
+ context "when setting duration to a negative value" do
before do
work_package.duration = -5
end
- it_behaves_like 'contract is invalid', duration: :greater_than
+ it_behaves_like "contract is invalid", duration: :greater_than
end
- context 'when setting duration and dates' do
+ context "when setting duration and dates" do
before do
work_package.ignore_non_working_days = true
work_package.duration = 6
@@ -662,10 +662,10 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = Time.zone.today + 1.day
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
- context 'when setting duration and dates while covering non-working days' do
+ context "when setting duration and dates while covering non-working days" do
before do
week_with_saturday_and_sunday_as_weekend
work_package.ignore_non_working_days = false
@@ -674,10 +674,10 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = "2022-08-29"
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
- context 'when setting duration and dates and duration is too small' do
+ context "when setting duration and dates and duration is too small" do
before do
work_package.ignore_non_working_days = true
work_package.duration = 5
@@ -685,10 +685,10 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = Time.zone.today + 1.day
end
- it_behaves_like 'contract is invalid', duration: :smaller_than_dates
+ it_behaves_like "contract is invalid", duration: :smaller_than_dates
end
- context 'when setting duration and dates while covering non-working days and duration is too small' do
+ context "when setting duration and dates while covering non-working days and duration is too small" do
before do
week_with_saturday_and_sunday_as_weekend
work_package.ignore_non_working_days = false
@@ -697,10 +697,10 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = "2022-08-29"
end
- it_behaves_like 'contract is invalid', duration: :smaller_than_dates
+ it_behaves_like "contract is invalid", duration: :smaller_than_dates
end
- context 'when setting duration and dates and duration is too big' do
+ context "when setting duration and dates and duration is too big" do
before do
work_package.ignore_non_working_days = true
work_package.duration = 7
@@ -708,10 +708,10 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = Time.zone.today + 1.day
end
- it_behaves_like 'contract is invalid', duration: :larger_than_dates
+ it_behaves_like "contract is invalid", duration: :larger_than_dates
end
- context 'when setting duration and dates while covering non-working days and duration is too big' do
+ context "when setting duration and dates while covering non-working days and duration is too big" do
before do
week_with_saturday_and_sunday_as_weekend
work_package.ignore_non_working_days = false
@@ -720,53 +720,53 @@ RSpec.describe WorkPackages::BaseContract do
work_package.due_date = "2022-08-29"
end
- it_behaves_like 'contract is invalid', duration: :larger_than_dates
+ it_behaves_like "contract is invalid", duration: :larger_than_dates
end
- context 'when setting start date and due date without duration' do
+ context "when setting start date and due date without duration" do
before do
work_package.duration = nil
work_package.start_date = Time.zone.today
work_package.due_date = Time.zone.today
end
- it_behaves_like 'contract is invalid', duration: :cannot_be_null
+ it_behaves_like "contract is invalid", duration: :cannot_be_null
end
end
- describe 'ignore_non_working_days' do
- context 'when setting the value to true' do
+ describe "ignore_non_working_days" do
+ context "when setting the value to true" do
before do
work_package.ignore_non_working_days = true
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
- context 'when setting the value to false' do
+ context "when setting the value to false" do
before do
work_package.ignore_non_working_days = false
end
- it_behaves_like 'contract is valid'
+ it_behaves_like "contract is valid"
end
end
- describe 'percentage done' do
- context 'when % Complete inferred by status',
- with_settings: { work_package_done_ratio: 'status' } do
- it_behaves_like 'invalid if changed', :done_ratio
+ describe "percentage done" do
+ context "when % Complete inferred by status",
+ with_settings: { work_package_done_ratio: "status" } do
+ it_behaves_like "invalid if changed", :done_ratio
end
- context 'when % Complete disabled',
- with_settings: { work_package_done_ratio: 'disabled' } do
+ context "when % Complete disabled",
+ with_settings: { work_package_done_ratio: "disabled" } do
let(:changed_values) { [:done_ratio] }
- it_behaves_like 'invalid if changed', :done_ratio
+ it_behaves_like "invalid if changed", :done_ratio
end
end
- describe 'version' do
+ describe "version" do
subject(:contract) { described_class.new(work_package, current_user) }
let(:assignable_version) { build_stubbed(:version) }
@@ -776,32 +776,32 @@ RSpec.describe WorkPackages::BaseContract do
allow(work_package).to receive(:assignable_versions).and_return [assignable_version]
end
- context 'for assignable version' do
+ context "for assignable version" do
before do
work_package.version = assignable_version
subject.validate
end
- it 'is valid' do
+ it "is valid" do
expect(subject.errors).to be_empty
end
end
- context 'for non assignable version' do
+ context "for non assignable version" do
before do
work_package.version = invalid_version
subject.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(subject.errors.symbols_for(:version_id)).to eql [:inclusion]
end
end
- context 'for a closed version' do
- let(:assignable_version) { build_stubbed(:version, status: 'closed') }
+ context "for a closed version" do
+ let(:assignable_version) { build_stubbed(:version, status: "closed") }
- context 'when reopening a work package' do
+ context "when reopening a work package" do
before do
allow(work_package)
.to receive(:reopened?)
@@ -811,25 +811,25 @@ RSpec.describe WorkPackages::BaseContract do
subject.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(subject.errors[:base]).to eql [I18n.t(:error_can_not_reopen_work_package_on_closed_version)]
end
end
- context 'when not reopening the work package' do
+ context "when not reopening the work package" do
before do
work_package.version = assignable_version
subject.validate
end
- it 'is valid' do
+ it "is valid" do
expect(subject.errors).to be_empty
end
end
end
end
- describe 'parent' do
+ describe "parent" do
let(:parent) { build_stubbed(:work_package) }
before do
@@ -844,16 +844,16 @@ RSpec.describe WorkPackages::BaseContract do
contract.errors.symbols_for(:parent)
end
- context 'when self assigning' do
+ context "when self assigning" do
let(:parent) { work_package }
- it 'returns an error for the parent' do
+ it "returns an error for the parent" do
expect(subject)
.to eq [:cannot_be_self_assigned]
end
end
- context 'when the intended parent is not relatable' do
+ context "when the intended parent is not relatable" do
before do
scope = instance_double(ActiveRecord::Relation)
@@ -868,35 +868,35 @@ RSpec.describe WorkPackages::BaseContract do
.and_return([])
end
- it 'is invalid' do
+ it "is invalid" do
expect(subject)
.to include(:cant_link_a_work_package_with_a_descendant)
end
end
- context 'when an invalid parent_id is set' do
+ context "when an invalid parent_id is set" do
before do
work_package.parent = nil
work_package.parent_id = -1
end
- it 'is invalid' do
+ it "is invalid" do
expect(subject)
.to include(:does_not_exist)
end
end
end
- describe 'type' do
- context 'for disabled type' do
+ describe "type" do
+ context "for disabled type" do
before do
allow(project)
.to receive(:types)
.and_return([])
end
- describe 'not changing the type' do
- it 'is valid' do
+ describe "not changing the type" do
+ it "is valid" do
subject.validate
expect(subject)
@@ -904,10 +904,10 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'changing the type' do
+ describe "changing the type" do
let(:other_type) { build_stubbed(:type) }
- it 'is invalid' do
+ it "is invalid" do
work_package.type = other_type
subject.validate
@@ -917,10 +917,10 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe 'changing the project (and that one not having the type)' do
+ describe "changing the project (and that one not having the type)" do
let(:other_project) { build_stubbed(:project) }
- it 'is invalid' do
+ it "is invalid" do
work_package.project = other_project
subject.validate
@@ -931,36 +931,36 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'for inexistent type' do
+ context "for inexistent type" do
before do
work_package.type = Type::InexistentType.new
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:type))
.to contain_exactly(:does_not_exist)
end
end
end
- describe 'assigned_to' do
- context 'for inexistent user' do
+ describe "assigned_to" do
+ context "for inexistent user" do
before do
work_package.assigned_to = Users::InexistentUser.new
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:assigned_to))
.to contain_exactly(:does_not_exist)
end
end
end
- describe 'category' do
+ describe "category" do
let(:category) { build_stubbed(:category) }
context "for one of the project's categories" do
@@ -974,39 +974,39 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(contract.errors.symbols_for(:category))
.to be_empty
end
end
- context 'when empty' do
+ context "when empty" do
before do
work_package.category = nil
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(contract.errors.symbols_for(:category))
.to be_empty
end
end
- context 'for inexistent category (e.g. removed)' do
+ context "for inexistent category (e.g. removed)" do
before do
work_package.category_id = 5
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:category))
.to contain_exactly(:does_not_exist)
end
end
- context 'when not of the project' do
+ context "when not of the project" do
before do
allow(project)
.to receive(:categories)
@@ -1017,44 +1017,44 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:category))
.to contain_exactly(:only_same_project_categories_allowed)
end
end
end
- describe 'priority' do
+ describe "priority" do
let (:active_priority) { build_stubbed(:priority) }
let (:inactive_priority) { build_stubbed(:priority, active: false) }
- context 'as active priority' do
+ context "as active priority" do
before do
work_package.priority = active_priority
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(contract.errors.symbols_for(:priority_id))
.to be_empty
end
end
- context 'as inactive priority' do
+ context "as inactive priority" do
before do
work_package.priority = inactive_priority
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:priority_id))
.to contain_exactly(:only_active_priorities_allowed)
end
end
- context 'as inactive priority but priority not changed' do
+ context "as inactive priority but priority not changed" do
before do
work_package.priority = inactive_priority
work_package.clear_changes_information
@@ -1062,27 +1062,27 @@ RSpec.describe WorkPackages::BaseContract do
contract.validate
end
- it 'is valid' do
+ it "is valid" do
expect(contract.errors.symbols_for(:priority_id))
.to be_empty
end
end
- context 'as inexistent priority' do
+ context "as inexistent priority" do
before do
work_package.priority = Priority::InexistentPriority.new
contract.validate
end
- it 'is invalid' do
+ it "is invalid" do
expect(contract.errors.symbols_for(:priority))
.to contain_exactly(:does_not_exist)
end
end
end
- describe '#assignable_statuses' do
+ describe "#assignable_statuses" do
let(:role) { build_stubbed(:project_role) }
let(:type) { build_stubbed(:type) }
let(:assignee_user) { build_stubbed(:user) }
@@ -1116,7 +1116,7 @@ RSpec.describe WorkPackages::BaseContract do
.and_return(roles)
end
- shared_examples_for 'new_statuses_allowed_to' do
+ shared_examples_for "new_statuses_allowed_to" do
let(:base_scope) do
from_workflows = Workflow
.from_status(current_status.id, type.id, [role.id], author, assignee)
@@ -1126,12 +1126,12 @@ RSpec.describe WorkPackages::BaseContract do
.or(Status.where(id: current_status.id))
end
- it 'returns a scope that returns current_status and those available by workflow' do
+ it "returns a scope that returns current_status and those available by workflow" do
expect(contract.assignable_statuses.to_sql)
.to eql base_scope.order_by_position.to_sql
end
- it 'removes closed statuses if blocked' do
+ it "removes closed statuses if blocked" do
allow(work_package)
.to receive(:blocked?)
.and_return(true)
@@ -1142,55 +1142,55 @@ RSpec.describe WorkPackages::BaseContract do
.to eql expected.to_sql
end
- context 'if the current status is closed and the version is closed as well' do
- let(:version) { build_stubbed(:version, status: 'closed') }
+ context "if the current status is closed and the version is closed as well" do
+ let(:version) { build_stubbed(:version, status: "closed") }
let(:current_status) { build_stubbed(:status, is_closed: true) }
- it 'only allows the current status' do
+ it "only allows the current status" do
expect(contract.assignable_statuses.to_sql)
.to eql Status.where(id: current_status.id).to_sql
end
end
end
- context 'with somebody else asking' do
- it_behaves_like 'new_statuses_allowed_to' do
+ context "with somebody else asking" do
+ it_behaves_like "new_statuses_allowed_to" do
let(:author) { false }
let(:assignee) { false }
end
end
- context 'with the author asking' do
+ context "with the author asking" do
let(:current_user) { author_user }
- it_behaves_like 'new_statuses_allowed_to' do
+ it_behaves_like "new_statuses_allowed_to" do
let(:author) { true }
let(:assignee) { false }
end
end
- context 'with the assignee asking' do
+ context "with the assignee asking" do
let(:current_user) { assignee_user }
- it_behaves_like 'new_statuses_allowed_to' do
+ it_behaves_like "new_statuses_allowed_to" do
let(:author) { false }
let(:assignee) { true }
end
end
- context 'with the assignee changing and asking as new assignee' do
+ context "with the assignee changing and asking as new assignee" do
before do
work_package.assigned_to = current_user
end
# is using the former assignee
- it_behaves_like 'new_statuses_allowed_to' do
+ it_behaves_like "new_statuses_allowed_to" do
let(:author) { false }
let(:assignee) { false }
end
end
- context 'with the status having changed' do
+ context "with the status having changed" do
let(:new_status) { build_stubbed(:status) }
before do
@@ -1205,14 +1205,14 @@ RSpec.describe WorkPackages::BaseContract do
work_package.status = new_status
end
- it_behaves_like 'new_statuses_allowed_to' do
+ it_behaves_like "new_statuses_allowed_to" do
let(:author) { false }
let(:assignee) { false }
end
end
end
- describe '#assignable_types' do
+ describe "#assignable_types" do
let(:scope) do
instance_double(ActiveRecord::Querying).tap do |s|
allow(s)
@@ -1221,12 +1221,12 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when project nil' do
+ context "when project nil" do
before do
work_package.project = nil
end
- it 'is all types' do
+ it "is all types" do
allow(Type)
.to receive(:includes)
.and_return(scope)
@@ -1236,8 +1236,8 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- context 'when project defined' do
- it 'is all types of the project' do
+ context "when project defined" do
+ it "is all types of the project" do
allow(work_package.project)
.to receive(:types)
.and_return(scope)
@@ -1248,17 +1248,17 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe '#assignable_versions' do
+ describe "#assignable_versions" do
let(:result) { double }
- it 'calls through to the work package' do
+ it "calls through to the work package" do
allow(work_package).to receive(:assignable_versions).and_return(result)
expect(subject.assignable_values(:version, current_user)).to eql(result)
expect(work_package).to have_received(:assignable_versions)
end
end
- describe '#assignable_priorities' do
+ describe "#assignable_priorities" do
let(:active_priority) { build(:priority, active: true) }
let(:inactive_priority) { build(:priority, active: false) }
@@ -1267,7 +1267,7 @@ RSpec.describe WorkPackages::BaseContract do
inactive_priority.save!
end
- it 'returns only active priorities' do
+ it "returns only active priorities" do
expect(subject.assignable_values(:priority, current_user).size).to be >= 1
subject.assignable_values(:priority, current_user).each do |priority|
expect(priority.active).to be_truthy
@@ -1275,17 +1275,17 @@ RSpec.describe WorkPackages::BaseContract do
end
end
- describe '#assignable_categories' do
+ describe "#assignable_categories" do
let(:category) { instance_double(Category) }
before do
allow(project).to receive(:categories).and_return([category])
end
- it 'returns all categories of the project' do
+ it "returns all categories of the project" do
expect(subject.assignable_values(:category, current_user)).to contain_exactly(category)
end
end
- include_examples 'contract reuses the model errors'
+ include_examples "contract reuses the model errors"
end
diff --git a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
index a1d9745370c..f1ca08142ee 100644
--- a/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/specific_work_package_schema_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
let(:project) { build_stubbed(:project) }
@@ -45,19 +45,19 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
subject { described_class.new(work_package:) }
- it 'has the project set' do
+ it "has the project set" do
expect(subject.project).to eql(project)
end
- it 'has the type set' do
+ it "has the type set" do
expect(subject.type).to eql(type)
end
- it 'has an id' do
+ it "has an id" do
expect(subject.id).to eql(work_package.id)
end
- describe '#milestone?' do
+ describe "#milestone?" do
it "shows the work_package's value" do
allow(work_package)
.to receive(:milestone?)
@@ -73,15 +73,15 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
end
- describe '#readonly?' do
+ describe "#readonly?" do
it "modifies the writable attributes" do
allow(work_package)
.to receive(:readonly_status?)
.and_return(true)
expect(subject).to be_readonly
- expect(subject).to be_writable('status')
- expect(subject).not_to be_writable('subject')
+ expect(subject).to be_writable("status")
+ expect(subject).not_to be_writable("subject")
allow(work_package)
.to receive(:readonly_status?)
@@ -90,13 +90,13 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
# As the writability is memoized we need to have a new schema
new_schema = described_class.new(work_package:)
expect(new_schema).not_to be_readonly
- expect(new_schema).to be_writable('status')
- expect(new_schema).to be_writable('subject')
+ expect(new_schema).to be_writable("status")
+ expect(new_schema).to be_writable("subject")
end
end
- describe '#available_custom_fields' do
- it 'delegates to work_package' do
+ describe "#available_custom_fields" do
+ it "delegates to work_package" do
expect(work_package)
.to receive(:available_custom_fields)
@@ -104,29 +104,29 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
end
- describe '#assignable_types' do
+ describe "#assignable_types" do
let(:result) do
result = double
allow(result).to receive(:includes).and_return(result)
result
end
- it 'calls through to the project' do
+ it "calls through to the project" do
expect(project).to receive(:types).and_return(result)
expect(subject.assignable_values(:type, current_user)).to eql(result)
end
end
- describe '#assignable_versions' do
+ describe "#assignable_versions" do
let(:result) { double }
- it 'calls through to the work package' do
+ it "calls through to the work package" do
expect(work_package).to receive(:assignable_versions).and_return(result)
expect(subject.assignable_values(:version, current_user)).to eql(result)
end
end
- describe '#assignable_priorities' do
+ describe "#assignable_priorities" do
let(:active_priority) { build(:priority, active: true) }
let(:inactive_priority) { build(:priority, active: false) }
@@ -135,7 +135,7 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
inactive_priority.save!
end
- it 'returns only active priorities' do
+ it "returns only active priorities" do
expect(subject.assignable_values(:priority, current_user).size).to be >= 1
subject.assignable_values(:priority, current_user).each do |priority|
expect(priority.active).to be_truthy
@@ -143,159 +143,159 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
end
- describe '#assignable_categories' do
- let(:category) { double('category') }
+ describe "#assignable_categories" do
+ let(:category) { instance_double(Category) }
before do
allow(project).to receive(:categories).and_return([category])
end
- it 'returns all categories of the project' do
+ it "returns all categories of the project" do
expect(subject.assignable_values(:category, current_user)).to contain_exactly(category)
end
end
- describe '#assignable_budgets' do
+ describe "#assignable_budgets" do
subject { described_class.new(work_package:) }
before do
- allow(project).to receive(:budgets).and_return(double('Budgets'))
+ allow(project).to receive(:budgets).and_return([instance_double(Budget)])
end
- it 'returns project.budgets' do
+ it "returns project.budgets" do
expect(subject.assignable_values(:budget, nil)).to eql(project.budgets)
end
end
- describe '#writable?' do
- describe '% Complete' do
- it 'is not writable' do
+ describe "#writable?" do
+ describe "% Complete" do
+ it "is not writable" do
expect(subject).not_to be_writable(:done_ratio)
end
end
- describe 'work' do
- it 'is writable when the work package is a parent' do
+ describe "work" do
+ it "is writable when the work package is a parent" do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject).to be_writable(:estimated_hours)
end
- it 'is writable when the work package is a leaf' do
+ it "is writable when the work package is a leaf" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:estimated_hours)
end
end
- describe 'derived work' do
- it 'is not writable when the work package is a parent' do
+ describe "derived work" do
+ it "is not writable when the work package is a parent" do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject).not_to be_writable(:derived_estimated_time)
end
- it 'is not writable when the work package is a leaf' do
+ it "is not writable when the work package is a leaf" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).not_to be_writable(:derived_estimated_time)
end
end
- describe 'start date' do
- context 'when work package is parent' do
+ describe "start date" do
+ context "when work package is parent" do
before do
allow(work_package)
.to receive(:leaf?)
.and_return(false)
end
- context 'when scheduled automatically' do
- it 'is not writable' do
+ context "when scheduled automatically" do
+ it "is not writable" do
expect(subject).not_to be_writable(:start_date)
end
end
- context 'when scheduled manually' do
+ context "when scheduled manually" do
before do
work_package.schedule_manually = true
end
- it 'is writable' do
+ it "is writable" do
expect(subject).to be_writable(:start_date)
end
end
end
- context 'when work package is a leaf' do
- it 'is writable' do
+ context "when work package is a leaf" do
+ it "is writable" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:start_date)
end
end
end
- describe 'due date' do
- context 'when work package is parent' do
+ describe "due date" do
+ context "when work package is parent" do
before do
allow(work_package)
.to receive(:leaf?)
.and_return(false)
end
- context 'when scheduled automatically' do
- it 'is not writable' do
+ context "when scheduled automatically" do
+ it "is not writable" do
expect(subject).not_to be_writable(:due_date)
end
end
- context 'when scheduled manually' do
+ context "when scheduled manually" do
before do
work_package.schedule_manually = true
end
- it 'is writable' do
+ it "is writable" do
expect(subject).to be_writable(:due_date)
end
end
end
- context 'when work package is a leaf' do
- it 'is writable' do
+ context "when work package is a leaf" do
+ it "is writable" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:due_date)
end
end
end
- describe 'date' do
+ describe "date" do
# As a date only exists on milestones, which can have no children
# we do not need to check for differences caused by scheduling modes.
before do
allow(work_package.type).to receive(:is_milestone?).and_return(true)
end
- it 'is not writable when the work package is a parent' do
+ it "is not writable when the work package is a parent" do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject).not_to be_writable(:date)
end
- it 'is writable when the work package is a leaf' do
+ it "is writable when the work package is a leaf" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:date)
end
end
- describe 'priority' do
- it 'is writable when the work package is a parent' do
+ describe "priority" do
+ it "is writable when the work package is a parent" do
allow(work_package).to receive(:leaf?).and_return(false)
expect(subject).to be_writable(:priority)
end
- it 'is writable when the work package is a leaf' do
+ it "is writable when the work package is a leaf" do
allow(work_package).to receive(:leaf?).and_return(true)
expect(subject).to be_writable(:priority)
end
end
end
- describe '#assignable_custom_field_values' do
+ describe "#assignable_custom_field_values" do
let(:list_cf) { create(:list_wp_custom_field) }
let(:version_cf) { build_stubbed(:version_wp_custom_field) }
@@ -305,7 +305,7 @@ RSpec.describe API::V3::WorkPackages::Schema::SpecificWorkPackageSchema do
end
it "is a version custom fields' project values" do
- result = double('versions')
+ result = [instance_double(Version)]
allow(work_package)
.to receive(:assignable_versions)
diff --git a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
index e7bcac679f8..3b753605674 100644
--- a/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/typed_work_package_schema_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
let(:project) { build(:project) }
@@ -41,48 +41,48 @@ RSpec.describe API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
mock_permissions_for(current_user, &:allow_everything)
end
- it 'has the project set' do
+ it "has the project set" do
expect(subject.project).to eql(project)
end
- it 'has the type set' do
+ it "has the type set" do
expect(subject.type).to eql(type)
end
- it 'does not know assignable statuses' do
+ it "does not know assignable statuses" do
expect(subject.assignable_values(:status, current_user)).to be_nil
end
- it 'does not know assignable versions' do
+ it "does not know assignable versions" do
expect(subject.assignable_values(:version, current_user)).to be_nil
end
- describe '#writable?' do
- it 'percentage done is not writable' do
+ describe "#writable?" do
+ it "percentage done is not writable" do
expect(subject).not_to be_writable(:done_ratio)
end
- it 'work is writable' do
+ it "work is writable" do
expect(subject).to be_writable(:estimated_hours)
end
- it 'start date is writable' do
+ it "start date is writable" do
expect(subject).to be_writable(:start_date)
end
- it 'finish date is writable' do
+ it "finish date is writable" do
expect(subject).to be_writable(:due_date)
end
end
- describe '#milestone?' do
+ describe "#milestone?" do
before do
allow(type)
.to receive(:is_milestone?)
.and_return(true)
end
- it 'is the value the type has' do
+ it "is the value the type has" do
expect(subject).to be_milestone
allow(type)
@@ -92,20 +92,20 @@ RSpec.describe API::V3::WorkPackages::Schema::TypedWorkPackageSchema do
expect(subject).not_to be_milestone
end
- it 'has a writable date' do
+ it "has a writable date" do
expect(subject).to be_writable(:date)
end
end
- describe '#assignable_custom_field_values' do
+ describe "#assignable_custom_field_values" do
let(:list_cf) { build_stubbed(:list_wp_custom_field) }
let(:version_cf) { build_stubbed(:version_wp_custom_field) }
- it 'is nil for a list cf' do
+ it "is nil for a list cf" do
expect(subject.assignable_custom_field_values(list_cf)).to be_nil
end
- it 'is nil for a version cf' do
+ it "is nil for a version cf" do
expect(subject.assignable_custom_field_values(version_cf)).to be_nil
end
end
diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
index 6210b75d02a..a650da8814a 100644
--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
include API::V3::Utilities::PathHelper
@@ -36,7 +36,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:attribute_query) do
build_stubbed(:query).tap do |query|
query.filters.clear
- query.add_filter('parent', '=', ['{id}'])
+ query.add_filter("parent", "=", ["{id}"])
end
end
let(:attribute_groups) do
@@ -58,7 +58,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return([])
end
end
- let(:self_link) { '/a/self/link' }
+ let(:self_link) { "/a/self/link" }
let(:base_schema_link) { nil }
let(:hide_self_link) { false }
let(:embedded) { true }
@@ -94,84 +94,84 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
allow(schema).to receive(:writable?).and_call_original
end
- context 'for generation' do
+ context "for generation" do
subject(:generated) { representer.to_json }
- shared_examples_for 'has a collection of allowed values' do
+ shared_examples_for "has a collection of allowed values" do
let(:embedded) { true }
before do
allow(schema).to receive(:assignable_values).and_return(nil)
end
- context 'when no values are allowed' do
+ context "when no values are allowed" do
before do
allow(schema).to receive(:assignable_values).with(factory, anything).and_return([])
end
- it_behaves_like 'links to and embeds allowed values directly' do
+ it_behaves_like "links to and embeds allowed values directly" do
let(:path) { json_path }
let(:hrefs) { [] }
end
end
- context 'when values are allowed' do
+ context "when values are allowed" do
let(:values) { build_stubbed_list(factory, 3) }
before do
allow(schema).to receive(:assignable_values).with(factory, anything).and_return(values)
end
- it_behaves_like 'links to and embeds allowed values directly' do
+ it_behaves_like "links to and embeds allowed values directly" do
let(:path) { json_path }
let(:hrefs) { values.map { |value| "/api/v3/#{href_path}/#{value.id}" } }
end
end
- context 'when not embedded' do
+ context "when not embedded" do
before do
allow(schema).to receive(:assignable_values).with(factory, anything).and_return(nil)
end
- it_behaves_like 'does not link to allowed values' do
+ it_behaves_like "does not link to allowed values" do
let(:path) { json_path }
end
end
end
- describe 'self link' do
- it_behaves_like 'has an untitled link' do
- let(:link) { 'self' }
+ describe "self link" do
+ it_behaves_like "has an untitled link" do
+ let(:link) { "self" }
let(:href) { self_link }
end
- it_behaves_like 'has no link' do
- let(:link) { 'baseSchema' }
+ it_behaves_like "has no link" do
+ let(:link) { "baseSchema" }
end
- context 'when embedded in a form' do
+ context "when embedded in a form" do
let(:self_link) { nil }
- let(:base_schema_link) { '/a/schema/link' }
+ let(:base_schema_link) { "/a/schema/link" }
- it_behaves_like 'has no link' do
- let(:link) { 'self' }
+ it_behaves_like "has no link" do
+ let(:link) { "self" }
end
- it_behaves_like 'has an untitled link' do
- let(:link) { 'baseSchema' }
+ it_behaves_like "has an untitled link" do
+ let(:link) { "baseSchema" }
let(:href) { base_schema_link }
end
end
end
- describe '_type' do
- it 'is indicated as Schema' do
- expect(subject).to be_json_eql('Schema'.to_json).at_path('_type')
+ describe "_type" do
+ it "is indicated as Schema" do
+ expect(subject).to be_json_eql("Schema".to_json).at_path("_type")
end
end
- describe '_attributeGroups' do
- it 'renders form attribute group elements of the schema' do
+ describe "_attributeGroups" do
+ it "renders form attribute group elements of the schema" do
expect(subject)
.to be_json_eql(
{
@@ -180,7 +180,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
attributes: %w(assignee responsible)
}.to_json
)
- .at_path('_attributeGroups/0')
+ .at_path("_attributeGroups/0")
expect(subject)
.to be_json_eql(
@@ -190,57 +190,57 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
attributes: %w(estimatedTime spentTime)
}.to_json
)
- .at_path('_attributeGroups/1')
+ .at_path("_attributeGroups/1")
end
- it 'renders form children query group elements of the schema' do
+ it "renders form children query group elements of the schema" do
expect(subject)
.to be_json_eql("WorkPackageFormChildrenQueryGroup".to_json)
- .at_path('_attributeGroups/2/_type')
+ .at_path("_attributeGroups/2/_type")
expect(subject)
.to be_json_eql(api_v3_paths.query(attribute_query.id).to_json)
- .at_path('_attributeGroups/2/_links/query/href')
+ .at_path("_attributeGroups/2/_links/query/href")
expect(subject)
- .to be_json_eql('Query'.to_json)
- .at_path('_attributeGroups/2/_embedded/query/_type')
+ .to be_json_eql("Query".to_json)
+ .at_path("_attributeGroups/2/_embedded/query/_type")
end
- context 'with relation query group' do
+ context "with relation query group" do
let(:attribute_query) do
build_stubbed(:query).tap do |query|
query.filters.clear
- query.add_filter('follows', '=', ['{id}'])
+ query.add_filter("follows", "=", ["{id}"])
end
end
- it 'renders form relation query group elements of the schema' do
+ it "renders form relation query group elements of the schema" do
expect(subject)
.to be_json_eql("WorkPackageFormRelationQueryGroup".to_json)
- .at_path('_attributeGroups/2/_type')
+ .at_path("_attributeGroups/2/_type")
expect(subject)
.to be_json_eql(api_v3_paths.query(attribute_query.id).to_json)
- .at_path('_attributeGroups/2/_links/query/href')
+ .at_path("_attributeGroups/2/_links/query/href")
expect(subject)
- .to be_json_eql('Query'.to_json)
- .at_path('_attributeGroups/2/_embedded/query/_type')
+ .to be_json_eql("Query".to_json)
+ .at_path("_attributeGroups/2/_embedded/query/_type")
end
end
end
- describe 'lock version' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'lockVersion' }
- let(:type) { 'Integer' }
- let(:name) { I18n.t('api_v3.attributes.lock_version') }
+ describe "lock version" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "lockVersion" }
+ let(:type) { "Integer" }
+ let(:name) { I18n.t("api_v3.attributes.lock_version") }
let(:required) { true }
let(:writable) { true }
end
- context 'when lockVersion disabled' do
+ context "when lockVersion disabled" do
let(:representer) do
described_class.create(schema,
self_link: nil,
@@ -248,49 +248,49 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
hide_lock_version: true)
end
- it 'is hidden' do
- expect(subject).not_to have_json_path('lockVersion')
+ it "is hidden" do
+ expect(subject).not_to have_json_path("lockVersion")
end
end
end
- describe 'id' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'id' }
- let(:type) { 'Integer' }
- let(:name) { I18n.t('attributes.id') }
+ describe "id" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "id" }
+ let(:type) { "Integer" }
+ let(:name) { I18n.t("attributes.id") }
let(:required) { true }
let(:writable) { false }
end
end
- describe 'subject' do
- let(:path) { 'subject' }
+ describe "subject" do
+ let(:path) { "subject" }
- it_behaves_like 'has basic schema properties' do
- let(:type) { 'String' }
- let(:name) { I18n.t('attributes.subject') }
+ it_behaves_like "has basic schema properties" do
+ let(:type) { "String" }
+ let(:name) { I18n.t("attributes.subject") }
let(:required) { true }
let(:writable) { true }
end
- it_behaves_like 'indicates length requirements' do
+ it_behaves_like "indicates length requirements" do
let(:min_length) { 1 }
let(:max_length) { 255 }
end
end
- describe 'description' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'description' }
- let(:type) { 'Formattable' }
- let(:name) { I18n.t('attributes.description') }
+ describe "description" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "description" }
+ let(:type) { "Formattable" }
+ let(:name) { I18n.t("attributes.description") }
let(:required) { false }
let(:writable) { true }
end
end
- describe 'duration' do
+ describe "duration" do
let(:milestone?) { false }
before do
@@ -299,72 +299,72 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(milestone?)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'duration' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.duration') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "duration" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.duration") }
let(:required) { false }
let(:writable) { true }
end
- context 'when the work package is a milestone' do
+ context "when the work package is a milestone" do
let(:milestone?) { true }
- it 'has no duration attribute' do
- expect(subject).not_to have_json_path('duration')
+ it "has no duration attribute" do
+ expect(subject).not_to have_json_path("duration")
end
end
end
- describe 'scheduleManually' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'scheduleManually' }
- let(:type) { 'Boolean' }
- let(:name) { I18n.t('activerecord.attributes.work_package.schedule_manually') }
+ describe "scheduleManually" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "scheduleManually" }
+ let(:type) { "Boolean" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.schedule_manually") }
let(:required) { false }
let(:has_default) { true }
let(:writable) { true }
end
end
- describe 'ignoreNonWorkingDays' do
+ describe "ignoreNonWorkingDays" do
before do
allow(schema)
.to receive(:writable?)
- .with('ignore_non_working_days')
+ .with("ignore_non_working_days")
.and_return writable
end
- context 'when writable' do
+ context "when writable" do
let(:writable) { true }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'ignoreNonWorkingDays' }
- let(:type) { 'Boolean' }
- let(:name) { I18n.t('activerecord.attributes.work_package.ignore_non_working_days') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "ignoreNonWorkingDays" }
+ let(:type) { "Boolean" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.ignore_non_working_days") }
let(:required) { false }
let(:writable) { true }
end
end
- context 'when not writable' do
+ context "when not writable" do
let(:writable) { false }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'ignoreNonWorkingDays' }
- let(:type) { 'Boolean' }
- let(:name) { I18n.t('activerecord.attributes.work_package.ignore_non_working_days') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "ignoreNonWorkingDays" }
+ let(:type) { "Boolean" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.ignore_non_working_days") }
let(:required) { false }
let(:writable) { false }
end
end
end
- describe 'date' do
+ describe "date" do
before do
allow(schema)
.to receive(:writable?)
- .with('date')
+ .with("date")
.and_return true
allow(schema)
@@ -372,49 +372,49 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(true)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'date' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "date" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.date") }
let(:required) { false }
let(:writable) { true }
end
- context 'when not writable' do
+ context "when not writable" do
before do
allow(schema)
.to receive(:writable?)
- .with('date')
+ .with("date")
.and_return false
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'date' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "date" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.date") }
let(:required) { false }
let(:writable) { false }
end
end
- context 'when the work package is no milestone' do
+ context "when the work package is no milestone" do
before do
allow(schema)
.to receive(:milestone?)
.and_return(false)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('date')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("date")
end
end
end
- describe 'startDate' do
+ describe "startDate" do
before do
allow(schema)
.to receive(:writable?)
- .with('start_date')
+ .with("start_date")
.and_return true
allow(schema)
@@ -422,49 +422,49 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(false)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'startDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.start_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "startDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.start_date") }
let(:required) { false }
let(:writable) { true }
end
- context 'when not writable' do
+ context "when not writable" do
before do
allow(schema)
.to receive(:writable?)
- .with('start_date')
+ .with("start_date")
.and_return false
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'startDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.start_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "startDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.start_date") }
let(:required) { false }
let(:writable) { false }
end
end
- context 'when the work package is a milestone' do
+ context "when the work package is a milestone" do
before do
allow(schema)
.to receive(:milestone?)
.and_return(true)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('startDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("startDate")
end
end
end
- describe 'dueDate' do
+ describe "dueDate" do
before do
allow(schema)
.to receive(:writable?)
- .with('due_date')
+ .with("due_date")
.and_return true
allow(schema)
@@ -472,42 +472,42 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(false)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'dueDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.due_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "dueDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.due_date") }
let(:required) { false }
let(:writable) { true }
end
- context 'when not writable' do
+ context "when not writable" do
before do
- allow(schema).to receive(:writable?).with('due_date').and_return false
+ allow(schema).to receive(:writable?).with("due_date").and_return false
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'dueDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.due_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "dueDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.due_date") }
let(:required) { false }
let(:writable) { false }
end
end
- context 'when the work package is a milestone' do
+ context "when the work package is a milestone" do
before do
allow(schema)
.to receive(:milestone?)
.and_return(true)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('dueDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("dueDate")
end
end
end
- describe 'derivedStartDate' do
+ describe "derivedStartDate" do
let(:is_milestone) { false }
before do
@@ -516,24 +516,24 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(is_milestone)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'derivedStartDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.derived_start_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "derivedStartDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.derived_start_date") }
let(:required) { false }
let(:writable) { false }
end
- context 'when the work package is a milestone' do
+ context "when the work package is a milestone" do
let(:is_milestone) { true }
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('derivedStartDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("derivedStartDate")
end
end
end
- describe 'derivedDueDate' do
+ describe "derivedDueDate" do
let(:is_milestone) { false }
before do
@@ -542,255 +542,255 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(is_milestone)
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'derivedDueDate' }
- let(:type) { 'Date' }
- let(:name) { I18n.t('attributes.derived_due_date') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "derivedDueDate" }
+ let(:type) { "Date" }
+ let(:name) { I18n.t("attributes.derived_due_date") }
let(:required) { false }
let(:writable) { false }
end
- context 'when the work package is a milestone' do
+ context "when the work package is a milestone" do
let(:is_milestone) { true }
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('derivedDueDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("derivedDueDate")
end
end
end
- describe 'estimatedTime' do
+ describe "estimatedTime" do
before do
allow(schema)
.to receive(:writable?)
- .with('estimated_hours')
+ .with("estimated_hours")
.and_return true
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'estimatedTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('attributes.estimated_time') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "estimatedTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("attributes.estimated_time") }
let(:required) { false }
let(:writable) { true }
end
- context 'when not writable' do
+ context "when not writable" do
before do
allow(schema)
.to receive(:writable?)
- .with('estimated_hours')
+ .with("estimated_hours")
.and_return false
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'estimatedTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('attributes.estimated_time') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "estimatedTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("attributes.estimated_time") }
let(:required) { false }
let(:writable) { false }
end
end
end
- describe 'derivedEstimatedTime' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'derivedEstimatedTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('attributes.derived_estimated_hours') }
+ describe "derivedEstimatedTime" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "derivedEstimatedTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("attributes.derived_estimated_hours") }
let(:required) { false }
let(:writable) { false }
end
end
- describe 'remainingTime' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'remainingTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.remaining_hours') }
+ describe "remainingTime" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "remainingTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.remaining_hours") }
let(:required) { false }
let(:writable) { true }
end
context 'when on the "status-based" % complete mode',
- with_settings: { work_package_done_ratio: 'status' } do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'remainingTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.remaining_hours') }
+ with_settings: { work_package_done_ratio: "status" } do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "remainingTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.remaining_hours") }
let(:required) { false }
let(:writable) { false }
end
end
end
- describe 'derivedRemainingTime' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'derivedRemainingTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.derived_remaining_hours') }
+ describe "derivedRemainingTime" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "derivedRemainingTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.derived_remaining_hours") }
let(:required) { false }
let(:writable) { false }
end
end
- describe 'spentTime' do
- context 'with the view_time_entries permission' do
+ describe "spentTime" do
+ context "with the view_time_entries permission" do
let(:permissions) { %i[edit_work_packages view_time_entries] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'spentTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.spent_time') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "spentTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.spent_time") }
let(:required) { false }
let(:writable) { false }
end
end
- context 'with the view_own_time_entries permission' do
+ context "with the view_own_time_entries permission" do
let(:permissions) { %i[edit_work_packages view_own_time_entries] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'spentTime' }
- let(:type) { 'Duration' }
- let(:name) { I18n.t('activerecord.attributes.work_package.spent_time') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "spentTime" }
+ let(:type) { "Duration" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.spent_time") }
let(:required) { false }
let(:writable) { false }
end
end
- context 'without any view time_entries permission' do
- it 'has no spentTime attribute' do
- expect(subject).not_to have_json_path('spentTime')
+ context "without any view time_entries permission" do
+ it "has no spentTime attribute" do
+ expect(subject).not_to have_json_path("spentTime")
end
end
end
- describe 'percentageDone' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'percentageDone' }
- let(:type) { 'Integer' }
- let(:name) { I18n.t('activerecord.attributes.work_package.done_ratio') }
+ describe "percentageDone" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "percentageDone" }
+ let(:type) { "Integer" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.done_ratio") }
let(:required) { false }
let(:writable) { false }
end
- context 'as disabled' do
+ context "as disabled" do
before do
- allow(Setting).to receive(:work_package_done_ratio).and_return('disabled')
+ allow(Setting).to receive(:work_package_done_ratio).and_return("disabled")
end
- it 'is hidden' do
- expect(subject).not_to have_json_path('percentageDone')
+ it "is hidden" do
+ expect(subject).not_to have_json_path("percentageDone")
end
end
end
- describe 'derivedPercentageDone' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'derivedPercentageDone' }
- let(:type) { 'Integer' }
- let(:name) { I18n.t('activerecord.attributes.work_package.derived_done_ratio') }
+ describe "derivedPercentageDone" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "derivedPercentageDone" }
+ let(:type) { "Integer" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.derived_done_ratio") }
let(:required) { false }
let(:writable) { false }
end
- context 'as disabled' do
+ context "as disabled" do
before do
- allow(Setting).to receive(:work_package_done_ratio).and_return('disabled')
+ allow(Setting).to receive(:work_package_done_ratio).and_return("disabled")
end
- it 'is hidden' do
- expect(subject).not_to have_json_path('derivedPercentageDone')
+ it "is hidden" do
+ expect(subject).not_to have_json_path("derivedPercentageDone")
end
end
end
- describe 'readonly' do
- context 'with the enterprise add-on enabled', with_ee: %i[readonly_work_packages] do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'readonly' }
- let(:type) { 'Boolean' }
- let(:name) { I18n.t('activerecord.attributes.work_package.readonly') }
+ describe "readonly" do
+ context "with the enterprise add-on enabled", with_ee: %i[readonly_work_packages] do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "readonly" }
+ let(:type) { "Boolean" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.readonly") }
let(:required) { false }
let(:has_default) { true }
let(:writable) { false }
end
end
- context 'without the enterprise add-on' do
- it 'has no such property' do
- expect(subject).not_to have_json_path('readonly')
+ context "without the enterprise add-on" do
+ it "has no such property" do
+ expect(subject).not_to have_json_path("readonly")
end
end
end
- describe 'createdAt' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'createdAt' }
- let(:type) { 'DateTime' }
- let(:name) { I18n.t('attributes.created_at') }
+ describe "createdAt" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "createdAt" }
+ let(:type) { "DateTime" }
+ let(:name) { I18n.t("attributes.created_at") }
let(:required) { true }
let(:writable) { false }
end
end
- describe 'updatedAt' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'updatedAt' }
- let(:type) { 'DateTime' }
- let(:name) { I18n.t('attributes.updated_at') }
+ describe "updatedAt" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "updatedAt" }
+ let(:type) { "DateTime" }
+ let(:name) { I18n.t("attributes.updated_at") }
let(:required) { true }
let(:writable) { false }
end
end
- describe 'author' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'author' }
- let(:type) { 'User' }
- let(:name) { I18n.t('attributes.author') }
+ describe "author" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "author" }
+ let(:type) { "User" }
+ let(:name) { I18n.t("attributes.author") }
let(:required) { true }
let(:writable) { false }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
- describe 'project' do
- context 'if having the move_work_packages permission' do
+ describe "project" do
+ context "if having the move_work_packages permission" do
let(:permissions) { [:move_work_packages] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'project' }
- let(:type) { 'Project' }
- let(:name) { I18n.t('attributes.project') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "project" }
+ let(:type) { "Project" }
+ let(:name) { I18n.t("attributes.project") }
let(:required) { true }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
- context 'if having the edit_work_packages permission' do
+ context "if having the edit_work_packages permission" do
let(:permissions) { [:edit_work_packages] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'project' }
- let(:type) { 'Project' }
- let(:name) { I18n.t('attributes.project') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "project" }
+ let(:type) { "Project" }
+ let(:name) { I18n.t("attributes.project") }
let(:required) { true }
let(:writable) { false }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
- context 'when updating' do
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'project' }
+ context "when updating" do
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "project" }
let(:href) { api_v3_paths.available_projects_on_edit(work_package.id) }
end
end
- context 'when creating (new_record)' do
+ context "when creating (new_record)" do
let(:work_package) do
build(:work_package, project:, type: wp_type) do |wp|
allow(wp)
@@ -799,13 +799,13 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'project' }
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "project" }
let(:href) { api_v3_paths.available_projects_on_create }
end
end
- context 'when creating (new_record with empty type)' do
+ context "when creating (new_record with empty type)" do
let(:work_package) do
build(:work_package, project:, type: nil) do |wp|
allow(wp)
@@ -814,37 +814,37 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'project' }
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "project" }
let(:href) { api_v3_paths.available_projects_on_create }
end
end
- context 'when not embedded' do
+ context "when not embedded" do
let(:embedded) { false }
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'project' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "project" }
end
end
end
- describe 'parent' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'parent' }
- let(:type) { 'WorkPackage' }
- let(:name) { I18n.t('activerecord.attributes.work_package.parent') }
+ describe "parent" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "parent" }
+ let(:type) { "WorkPackage" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.parent") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'parent' }
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "parent" }
let(:href) { api_v3_paths.work_package_available_relation_candidates(work_package.id, type: :parent) }
end
- context 'when creating' do
+ context "when creating" do
let(:work_package) do
build(:work_package, project:) do |wp|
allow(wp)
@@ -853,183 +853,183 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'parent' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "parent" }
end
end
end
- describe 'type' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'type' }
- let(:type) { 'Type' }
- let(:name) { I18n.t('activerecord.attributes.work_package.type') }
+ describe "type" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "type" }
+ let(:type) { "Type" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.type") }
let(:required) { true }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'type' }
- let(:href_path) { 'types' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "type" }
+ let(:href_path) { "types" }
let(:factory) { :type }
end
end
- describe 'status' do
- context 'if having the change_work_package_status permission' do
+ describe "status" do
+ context "if having the change_work_package_status permission" do
let(:permissions) { [:change_work_package_status] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'status' }
- let(:type) { 'Status' }
- let(:name) { I18n.t('attributes.status') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "status" }
+ let(:type) { "Status" }
+ let(:name) { I18n.t("attributes.status") }
let(:required) { true }
let(:writable) { true }
let(:has_default) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'status' }
- let(:href_path) { 'statuses' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "status" }
+ let(:href_path) { "statuses" }
let(:factory) { :status }
end
end
# Just edit_work_packages without change_work_package_status still makes status writable:
- context 'if having the edit_work_packages permission' do
+ context "if having the edit_work_packages permission" do
let(:permissions) { [:edit_work_packages] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'status' }
- let(:type) { 'Status' }
- let(:name) { I18n.t('attributes.status') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "status" }
+ let(:type) { "Status" }
+ let(:name) { I18n.t("attributes.status") }
let(:required) { true }
let(:writable) { true }
let(:has_default) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
end
- describe 'categories' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'category' }
- let(:type) { 'Category' }
- let(:name) { I18n.t('attributes.category') }
+ describe "categories" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "category" }
+ let(:type) { "Category" }
+ let(:name) { I18n.t("attributes.category") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'category' }
- let(:href_path) { 'categories' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "category" }
+ let(:href_path) { "categories" }
let(:factory) { :category }
end
end
- describe 'versions' do
- context 'if having the assign_versions permission' do
+ describe "versions" do
+ context "if having the assign_versions permission" do
let(:permissions) { [:assign_versions] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'version' }
- let(:type) { 'Version' }
- let(:name) { I18n.t('activerecord.attributes.work_package.version') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "version" }
+ let(:type) { "Version" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.version") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'version' }
- let(:href_path) { 'versions' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "version" }
+ let(:href_path) { "versions" }
let(:factory) { :version }
end
end
- context 'if having the edit_work_packages permission' do
+ context "if having the edit_work_packages permission" do
let(:permissions) { [:edit_work_packages] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'version' }
- let(:type) { 'Version' }
- let(:name) { I18n.t('activerecord.attributes.work_package.version') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "version" }
+ let(:type) { "Version" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.version") }
let(:required) { false }
let(:writable) { false }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
end
- describe 'priorities' do
+ describe "priorities" do
before do
- allow(schema).to receive(:writable?).with('priority').and_return true
+ allow(schema).to receive(:writable?).with("priority").and_return true
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'priority' }
- let(:type) { 'Priority' }
- let(:name) { I18n.t('activerecord.attributes.work_package.priority') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "priority" }
+ let(:type) { "Priority" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.priority") }
let(:required) { true }
let(:writable) { true }
let(:has_default) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'priority' }
- let(:href_path) { 'priorities' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "priority" }
+ let(:href_path) { "priorities" }
let(:factory) { :priority }
end
- context 'when not writable' do
+ context "when not writable" do
before do
- allow(schema).to receive(:writable?).with('priority').and_return false
+ allow(schema).to receive(:writable?).with("priority").and_return false
end
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'priority' }
- let(:type) { 'Priority' }
- let(:name) { I18n.t('activerecord.attributes.work_package.priority') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "priority" }
+ let(:type) { "Priority" }
+ let(:name) { I18n.t("activerecord.attributes.work_package.priority") }
let(:required) { true }
let(:writable) { false }
let(:has_default) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
end
end
- describe 'responsible and assignee' do
+ describe "responsible and assignee" do
let(:base_href) { "/api/v3/projects/#{work_package.project.id}" }
- describe 'assignee' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'assignee' }
- let(:type) { 'User' }
- let(:name) { I18n.t('attributes.assigned_to') }
+ describe "assignee" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "assignee" }
+ let(:type) { "User" }
+ let(:name) { I18n.t("attributes.assigned_to") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'assignee' }
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "assignee" }
let(:base_href) { "/api/v3/work_packages/#{work_package.id}" }
let(:href) { "#{base_href}/available_assignees" }
end
- context 'when not embedded' do
+ context "when not embedded" do
let(:embedded) { false }
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'assignee' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "assignee" }
end
end
- context 'when not having a project (yet) and not yet persisted' do
+ context "when not having a project (yet) and not yet persisted" do
before do
work_package.project = nil
@@ -1038,78 +1038,78 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.and_return(false)
end
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'assignee' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "assignee" }
end
end
end
- describe 'responsible' do
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'responsible' }
- let(:type) { 'User' }
- let(:name) { I18n.t('attributes.responsible') }
+ describe "responsible" do
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "responsible" }
+ let(:type) { "User" }
+ let(:name) { I18n.t("attributes.responsible") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'links to allowed values via collection link' do
- let(:path) { 'responsible' }
+ it_behaves_like "links to allowed values via collection link" do
+ let(:path) { "responsible" }
let(:href) { "#{base_href}/available_responsibles" }
end
- context 'when not embedded' do
+ context "when not embedded" do
let(:embedded) { false }
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'responsible' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "responsible" }
end
end
- context 'when not having a project (yet)' do
+ context "when not having a project (yet)" do
before do
work_package.project = nil
end
- it_behaves_like 'does not link to allowed values' do
- let(:path) { 'responsible' }
+ it_behaves_like "does not link to allowed values" do
+ let(:path) { "responsible" }
end
end
end
end
- describe 'budget' do
- context 'when user allowed to view_budgets' do
+ describe "budget" do
+ context "when user allowed to view_budgets" do
let(:permissions) { %i[edit_work_packages view_budgets] }
- it_behaves_like 'has basic schema properties' do
- let(:path) { 'budget' }
- let(:type) { 'Budget' }
- let(:name) { I18n.t('attributes.budget') }
+ it_behaves_like "has basic schema properties" do
+ let(:path) { "budget" }
+ let(:type) { "Budget" }
+ let(:name) { I18n.t("attributes.budget") }
let(:required) { false }
let(:writable) { true }
- let(:location) { '_links' }
+ let(:location) { "_links" }
end
- it_behaves_like 'has a collection of allowed values' do
- let(:json_path) { 'budget' }
- let(:href_path) { 'budgets' }
+ it_behaves_like "has a collection of allowed values" do
+ let(:json_path) { "budget" }
+ let(:href_path) { "budgets" }
let(:factory) { :budget }
end
end
- context 'when user not allowed to view_budgets' do
- it 'has no schema for budget' do
- expect(subject).not_to have_json_path('budget')
+ context "when user not allowed to view_budgets" do
+ it "has no schema for budget" do
+ expect(subject).not_to have_json_path("budget")
end
end
end
- describe 'custom fields' do
+ describe "custom fields" do
let(:available_custom_fields) { [build_stubbed(:integer_wp_custom_field)] }
- it 'uses a CustomFieldInjector' do
+ it "uses a CustomFieldInjector" do
allow(API::V3::Utilities::CustomFieldInjector).to receive(:create_schema_representer)
.and_return(described_class)
representer.to_json
@@ -1119,12 +1119,12 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- describe 'caching' do
- context 'for a SpecificWorkPackageSchema' do
+ describe "caching" do
+ context "for a SpecificWorkPackageSchema" do
# do not interfere with the representer cache fetching
let(:attribute_groups) { [] }
- it 'is disabled' do
+ it "is disabled" do
allow(OpenProject::Cache).to receive(:fetch)
representer.to_json
@@ -1134,7 +1134,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- context 'for a TypedWorkPackageSchema' do
+ context "for a TypedWorkPackageSchema" do
# do not interfere with the representer cache fetching
let(:attribute_groups) { [] }
@@ -1156,7 +1156,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- it 'is based on the representer\'s cache_key' do
+ it "is based on the representer's cache_key" do
allow(OpenProject::Cache)
.to receive(:fetch)
.with(representer.json_cache_key)
@@ -1169,7 +1169,7 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
.with(representer.json_cache_key)
end
- it 'does not cache the attribute_groups' do
+ it "does not cache the attribute_groups" do
call_count = 0
allow(work_package.type)
.to receive(:attribute_groups) do
@@ -1185,9 +1185,9 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- describe '#json_cache_key' do
+ describe "#json_cache_key" do
def joined_cache_key
- representer.json_cache_key.join('/')
+ representer.json_cache_key.join("/")
end
before do
@@ -1205,48 +1205,48 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:setup) { nil }
let(:original_cache_key) { joined_cache_key }
- shared_examples_for 'changes' do
+ shared_examples_for "changes" do
before do
change
end
- it 'the cache key' do
+ it "the cache key" do
expect(joined_cache_key).not_to eql(original_cache_key)
end
end
- context 'for a different project' do
- it_behaves_like 'changes' do
+ context "for a different project" do
+ it_behaves_like "changes" do
let(:change) { work_package.project = build_stubbed(:project) }
end
end
- context 'if the project is updated' do
- it_behaves_like 'changes' do
+ context "if the project is updated" do
+ it_behaves_like "changes" do
let(:change) { work_package.project.updated_at += 1.hour }
end
end
- context 'for a different type' do
- it_behaves_like 'changes' do
+ context "for a different type" do
+ it_behaves_like "changes" do
let(:change) { work_package.type = build_stubbed(:type) }
end
end
- context 'if the type is updated' do
- it_behaves_like 'changes' do
+ context "if the type is updated" do
+ it_behaves_like "changes" do
let(:change) { work_package.type.updated_at += 1.hour }
end
end
- context 'if the type is switches' do
- it_behaves_like 'changes' do
+ context "if the type is switches" do
+ it_behaves_like "changes" do
let(:change) { allow(I18n).to receive(:locale).and_return(:de) }
end
end
- context 'if the custom_fields change' do
- it_behaves_like 'changes' do
+ context "if the custom_fields change" do
+ it_behaves_like "changes" do
let(:change) do
allow(work_package)
.to receive(:available_custom_fields)
@@ -1255,24 +1255,24 @@ RSpec.describe API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- context 'if the work_package_done_ratio setting changes' do
- it_behaves_like 'changes' do
+ context "if the work_package_done_ratio setting changes" do
+ it_behaves_like "changes" do
let(:setup) do
allow(Setting)
.to receive(:work_package_done_ratio)
- .and_return('something')
+ .and_return("something")
end
let(:change) do
allow(Setting)
.to receive(:work_package_done_ratio)
- .and_return('else')
+ .and_return("else")
end
end
end
- context 'if the users permissions change' do
- it_behaves_like 'changes' do
+ context "if the users permissions change" do
+ it_behaves_like "changes" do
let(:cache_perms) { %i[view_work_packages edit_work_packages] }
let(:setup) do
allow(representer).to receive(:all_permissions_granted_to_user_under_project).and_return(cache_perms)
diff --git a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
index 4a7e2827a05..31897bbade1 100644
--- a/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_payload_representer_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
include API::V3::Utilities::PathHelper
@@ -57,95 +57,95 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
allow(work_package).to receive(:lock_version).and_return(1)
end
- context 'for generation' do
+ context "for generation" do
subject(:generated) { representer.to_json }
- describe 'work_package' do
- it { is_expected.to have_json_path('subject') }
+ describe "work_package" do
+ it { is_expected.to have_json_path("subject") }
- it_behaves_like 'API V3 formattable', 'description' do
- let(:format) { 'markdown' }
+ it_behaves_like "API V3 formattable", "description" do
+ let(:format) { "markdown" }
let(:raw) { work_package.description }
let(:html) { "<p class=\"op-uc-p\">#{work_package.description}</p>" }
end
- describe 'lock version' do
- it { is_expected.to have_json_path('lockVersion') }
+ describe "lock version" do
+ it { is_expected.to have_json_path("lockVersion") }
- it { is_expected.to have_json_type(Integer).at_path('lockVersion') }
+ it { is_expected.to have_json_type(Integer).at_path("lockVersion") }
- it { is_expected.to be_json_eql(work_package.lock_version.to_json).at_path('lockVersion') }
+ it { is_expected.to be_json_eql(work_package.lock_version.to_json).at_path("lockVersion") }
- context 'with only change_work_package_status permission' do
+ context "with only change_work_package_status permission" do
before do
mock_permissions_for(user) do |mock|
mock.allow_in_project :change_work_package_status, project: work_package.project
end
end
- it { is_expected.to have_json_path('lockVersion') }
+ it { is_expected.to have_json_path("lockVersion") }
end
- context 'with a lock version of nil (new work package)' do
+ context "with a lock version of nil (new work package)" do
before do
allow(work_package)
.to receive(:lock_version)
.and_return(nil)
end
- it 'has a lockVersion of 0' do
+ it "has a lockVersion of 0" do
expect(subject)
.to be_json_eql(0)
- .at_path('lockVersion')
+ .at_path("lockVersion")
end
end
end
- describe 'estimated hours' do
+ describe "estimated hours" do
before do
allow(work_package)
.to receive(:leaf?)
.and_return(true)
end
- it { is_expected.to have_json_path('estimatedTime') }
+ it { is_expected.to have_json_path("estimatedTime") }
it do
expect(subject).to be_json_eql(work_package.estimated_hours.to_json)
- .at_path('estimatedTime')
+ .at_path("estimatedTime")
end
- context 'when not set' do
- it { is_expected.to have_json_type(NilClass).at_path('estimatedTime') }
+ context "when not set" do
+ it { is_expected.to have_json_type(NilClass).at_path("estimatedTime") }
end
- context 'when set' do
+ context "when set" do
let(:work_package) { build(:work_package, estimated_hours: 0) }
- it { is_expected.to have_json_type(String).at_path('estimatedTime') }
+ it { is_expected.to have_json_type(String).at_path("estimatedTime") }
end
end
- describe 'remaining hours' do
- it { is_expected.to have_json_path('remainingTime') }
+ describe "remaining hours" do
+ it { is_expected.to have_json_path("remainingTime") }
it do
expect(subject).to be_json_eql(work_package.estimated_hours.to_json)
- .at_path('estimatedTime')
+ .at_path("estimatedTime")
end
- context 'when not set' do
- it { is_expected.to have_json_type(NilClass).at_path('estimatedTime') }
+ context "when not set" do
+ it { is_expected.to have_json_type(NilClass).at_path("estimatedTime") }
end
- context 'when set' do
+ context "when set" do
let(:work_package) { build(:work_package, estimated_hours: 7, remaining_hours: 5) }
- it { is_expected.to have_json_type(String).at_path('estimatedTime') }
+ it { is_expected.to have_json_type(String).at_path("estimatedTime") }
end
end
- describe 'startDate' do
+ describe "startDate" do
before do
allow(work_package)
.to receive(:milestone?)
@@ -156,33 +156,33 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
.and_return(true)
end
- it_behaves_like 'has ISO 8601 date only' do
+ it_behaves_like "has ISO 8601 date only" do
let(:date) { work_package.start_date }
- let(:json_path) { 'startDate' }
+ let(:json_path) { "startDate" }
end
- context 'with no start date' do
+ context "with no start date" do
let(:work_package) { build(:work_package, start_date: nil) }
- it 'renders as null' do
- expect(subject).to be_json_eql(nil.to_json).at_path('startDate')
+ it "renders as null" do
+ expect(subject).to be_json_eql(nil.to_json).at_path("startDate")
end
end
- context 'when the work_package is a milestone' do
+ context "when the work_package is a milestone" do
before do
allow(work_package)
.to receive(:milestone?)
.and_return(true)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('startDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("startDate")
end
end
end
- describe 'dueDate' do
+ describe "dueDate" do
before do
allow(work_package)
.to receive(:milestone?)
@@ -193,33 +193,33 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
.and_return(true)
end
- it_behaves_like 'has ISO 8601 date only' do
+ it_behaves_like "has ISO 8601 date only" do
let(:date) { work_package.due_date }
- let(:json_path) { 'dueDate' }
+ let(:json_path) { "dueDate" }
end
- context 'when no finish date' do
+ context "when no finish date" do
let(:work_package) { build(:work_package, due_date: nil) }
- it 'renders as null' do
- expect(subject).to be_json_eql(nil.to_json).at_path('dueDate')
+ it "renders as null" do
+ expect(subject).to be_json_eql(nil.to_json).at_path("dueDate")
end
end
- context 'when the work_package is a milestone' do
+ context "when the work_package is a milestone" do
before do
allow(work_package)
.to receive(:milestone?)
.and_return(true)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('dueDate')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("dueDate")
end
end
end
- describe 'date' do
+ describe "date" do
before do
allow(work_package)
.to receive(:milestone?)
@@ -230,43 +230,43 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
.and_return(true)
end
- it_behaves_like 'has ISO 8601 date only' do
+ it_behaves_like "has ISO 8601 date only" do
let(:date) { work_package.due_date }
- let(:json_path) { 'date' }
+ let(:json_path) { "date" }
end
- context 'when no finish date' do
+ context "when no finish date" do
let(:work_package) do
build_stubbed(:work_package,
type: build_stubbed(:type),
due_date: nil)
end
- it 'renders as null' do
- expect(subject).to be_json_eql(nil.to_json).at_path('date')
+ it "renders as null" do
+ expect(subject).to be_json_eql(nil.to_json).at_path("date")
end
end
- context 'when the work_package is no milestone' do
+ context "when the work_package is no milestone" do
before do
allow(work_package)
.to receive(:milestone?)
.and_return(false)
end
- it 'has no date attribute' do
- expect(subject).not_to have_json_path('date')
+ it "has no date attribute" do
+ expect(subject).not_to have_json_path("date")
end
end
end
end
- describe '_links' do
+ describe "_links" do
let(:path) { "_links/#{property}/href" }
- it { is_expected.to have_json_path('_links') }
+ it { is_expected.to have_json_path("_links") }
- shared_examples_for 'linked property' do
+ shared_examples_for "linked property" do
before do
unless defined?(link) && defined?(property)
raise "Requires to have 'property' and 'link' defined"
@@ -276,110 +276,110 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
it { expect(subject).to be_json_eql(link.to_json).at_path(path) }
end
- shared_examples_for 'linked property with 0 value' do |attribute, association = attribute|
+ shared_examples_for "linked property with 0 value" do |attribute, association = attribute|
context "with a 0 for #{attribute}_id" do
before do
work_package.send(:"#{association}_id=", 0)
end
- it_behaves_like 'linked property' do
+ it_behaves_like "linked property" do
let(:property) { attribute }
let(:link) { nil }
end
end
end
- describe 'status' do
+ describe "status" do
let(:status) { build_stubbed(:status) }
before do
work_package.status = status
end
- it_behaves_like 'linked property' do
- let(:property) { 'status' }
+ it_behaves_like "linked property" do
+ let(:property) { "status" }
let(:link) { "/api/v3/statuses/#{status.id}" }
end
- it_behaves_like 'linked property with 0 value', :status
+ it_behaves_like "linked property with 0 value", :status
end
- describe 'assignee and responsible' do
+ describe "assignee and responsible" do
let(:other_user) { build_stubbed(:user) }
let(:link) { "/api/v3/users/#{other_user.id}" }
- describe 'assignee' do
+ describe "assignee" do
before do
work_package.assigned_to = other_user
end
- it_behaves_like 'linked property' do
- let(:property) { 'assignee' }
+ it_behaves_like "linked property" do
+ let(:property) { "assignee" }
end
- it_behaves_like 'linked property with 0 value', :assignee, :assigned_to
+ it_behaves_like "linked property with 0 value", :assignee, :assigned_to
end
- describe 'responsible' do
+ describe "responsible" do
before do
work_package.responsible = other_user
end
- it_behaves_like 'linked property' do
- let(:property) { 'responsible' }
+ it_behaves_like "linked property" do
+ let(:property) { "responsible" }
end
- it_behaves_like 'linked property with 0 value', :responsible
+ it_behaves_like "linked property with 0 value", :responsible
end
end
- describe 'version' do
+ describe "version" do
let(:version) { build_stubbed(:version) }
before do
work_package.version = version
end
- it_behaves_like 'linked property' do
- let(:property) { 'version' }
+ it_behaves_like "linked property" do
+ let(:property) { "version" }
let(:link) { "/api/v3/versions/#{version.id}" }
end
- it_behaves_like 'linked property with 0 value', :version, :version
+ it_behaves_like "linked property with 0 value", :version, :version
end
- describe 'category' do
+ describe "category" do
let(:category) { build_stubbed(:category) }
before do
work_package.category = category
end
- it_behaves_like 'linked property' do
- let(:property) { 'category' }
+ it_behaves_like "linked property" do
+ let(:property) { "category" }
let(:link) { "/api/v3/categories/#{category.id}" }
end
- it_behaves_like 'linked property with 0 value', :category
+ it_behaves_like "linked property with 0 value", :category
end
- describe 'priority' do
+ describe "priority" do
let(:priority) { build_stubbed(:priority) }
before do
work_package.priority = priority
end
- it_behaves_like 'linked property' do
- let(:property) { 'priority' }
+ it_behaves_like "linked property" do
+ let(:property) { "priority" }
let(:link) { "/api/v3/priorities/#{priority.id}" }
end
- it_behaves_like 'linked property with 0 value', :priority
+ it_behaves_like "linked property with 0 value", :priority
end
- describe 'parent' do
- context 'with a parent' do
+ describe "parent" do
+ context "with a parent" do
let(:parent) { build_stubbed(:work_package) }
before do
@@ -389,54 +389,54 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
.and_return(true)
end
- it_behaves_like 'linked property' do
- let(:property) { 'parent' }
+ it_behaves_like "linked property" do
+ let(:property) { "parent" }
let(:link) { "/api/v3/work_packages/#{parent.id}" }
end
end
- context 'without a parent' do
- it_behaves_like 'linked property' do
+ context "without a parent" do
+ it_behaves_like "linked property" do
let(:property) { :parent }
let(:link) { nil }
end
end
end
- describe 'budgets' do
- context 'without a cost object assigned' do
+ describe "budgets" do
+ context "without a cost object assigned" do
let(:budget) { nil }
- it_behaves_like 'linked property' do
+ it_behaves_like "linked property" do
let(:property) { :budget }
let(:link) { nil }
end
end
- context 'with a cost object assigned' do
- it_behaves_like 'linked property' do
+ context "with a cost object assigned" do
+ it_behaves_like "linked property" do
let(:property) { :budget }
let(:link) { api_v3_paths.budget(budget.id) }
end
end
- context 'without necessary permissions' do
+ context "without necessary permissions" do
before do
mock_permissions_for(user, &:forbid_everything)
end
- it 'has no href' do
+ it "has no href" do
expect(subject)
- .not_to have_json_path('_links/budget')
+ .not_to have_json_path("_links/budget")
end
end
end
end
- describe 'custom fields' do
+ describe "custom fields" do
let(:available_custom_fields) { [build_stubbed(:integer_wp_custom_field)] }
- it 'uses a CustomFieldInjector' do
+ it "uses a CustomFieldInjector" do
allow(API::V3::Utilities::CustomFieldInjector).to receive(:create_value_representer)
.and_call_original
representer.to_json
@@ -444,8 +444,8 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
end
- describe 'caching' do
- it 'does not cache' do
+ describe "caching" do
+ it "does not cache" do
representer.to_json
allow(Rails.cache)
@@ -459,7 +459,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
end
- describe 'parsing' do
+ describe "parsing" do
let(:attributes) { {} }
let(:links) { {} }
let(:json) do
@@ -471,83 +471,83 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
subject { representer.from_json(json) }
- shared_examples_for 'settable ISO 8601 date only' do
+ shared_examples_for "settable ISO 8601 date only" do
let(:attributes) do
{
property => date_string
}
end
- context 'with an ISO formatted date' do
- let(:date_string) { '2015-01-31' }
+ context "with an ISO formatted date" do
+ let(:date_string) { "2015-01-31" }
- it 'sets the date' do
+ it "sets the date" do
expect(subject.send(method)).to eql(Date.new(2015, 1, 31))
end
end
- context 'with null' do
+ context "with null" do
let(:date_string) { nil }
- it 'sets the date to nil' do
+ it "sets the date to nil" do
expect(subject.send(method)).to be_nil
end
end
- context 'with a non ISO formatted date' do
- let(:date_string) { '31.01.2015' }
+ context "with a non ISO formatted date" do
+ let(:date_string) { "31.01.2015" }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(API::Errors::PropertyFormatError)
end
end
- context 'with an ISO formatted date and time' do
- let(:date_string) { '2015-01-31T13:37:00Z' }
+ context "with an ISO formatted date and time" do
+ let(:date_string) { "2015-01-31T13:37:00Z" }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(API::Errors::PropertyFormatError)
end
end
end
- describe 'scheduleManually' do
+ describe "scheduleManually" do
let(:value) { raise "define value" }
let(:attributes) { { scheduleManually: value } }
- context 'with true' do
+ context "with true" do
let(:value) { true }
- it 'reads true' do
+ it "reads true" do
expect(subject.schedule_manually).to be true
end
end
- context 'with false' do
+ context "with false" do
let(:value) { false }
- it 'reads false' do
+ it "reads false" do
expect(subject.schedule_manually).to be false
end
end
end
- describe 'startDate' do
- it_behaves_like 'settable ISO 8601 date only' do
+ describe "startDate" do
+ it_behaves_like "settable ISO 8601 date only" do
let(:property) { :startDate }
let(:method) { :start_date }
end
end
- describe 'dueDate' do
- it_behaves_like 'settable ISO 8601 date only' do
+ describe "dueDate" do
+ it_behaves_like "settable ISO 8601 date only" do
let(:property) { :dueDate }
let(:method) { :due_date }
end
end
- describe 'date' do
+ describe "date" do
before do
allow(work_package)
.to receive(:milestone?)
@@ -557,14 +557,14 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
work_package.start_date = work_package.due_date = Time.zone.today
end
- it_behaves_like 'settable ISO 8601 date only' do
+ it_behaves_like "settable ISO 8601 date only" do
let(:property) { :date }
let(:method) { :due_date }
- context 'with an ISO formatted date' do
- let(:date_string) { '2015-01-31' }
+ context "with an ISO formatted date" do
+ let(:date_string) { "2015-01-31" }
- it 'sets the start and the due_date' do
+ it "sets the start and the due_date" do
expect(subject.start_date).to eql(Date.new(2015, 1, 31))
expect(subject.due_date).to eql(Date.new(2015, 1, 31))
end
@@ -572,7 +572,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
end
- shared_examples_for 'linked resource' do
+ shared_examples_for "linked resource" do
let(:path) { api_v3_paths.send(attribute_name, id) }
let(:association_name) { "#{attribute_name}_id" }
let(:id) { work_package.send(association_name).to_i + 1 }
@@ -581,115 +581,115 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
end
let(:representer_attribute) { subject.send(association_name) }
- describe 'with a valid href' do
+ describe "with a valid href" do
let(:href) { { href: path } }
- it 'sets attribute to the specified id' do
+ it "sets attribute to the specified id" do
expect(representer_attribute.to_i).to eql(id)
end
end
- describe 'with a null href' do
+ describe "with a null href" do
let(:href) { { href: nil } }
- it 'sets attribute to nil' do
+ it "sets attribute to nil" do
expect(representer_attribute).to be_nil
end
end
- describe 'with an invalid link' do
+ describe "with an invalid link" do
let(:href) { {} }
!let(:old_id) { work_package.send(association_name) }
- it 'leaves attribute unchanged' do
+ it "leaves attribute unchanged" do
expect(representer_attribute).to eql(old_id)
end
end
end
- describe 'project' do
- it_behaves_like 'linked resource' do
- let(:attribute_name) { 'project' }
+ describe "project" do
+ it_behaves_like "linked resource" do
+ let(:attribute_name) { "project" }
end
end
- describe 'version' do
+ describe "version" do
before do
work_package.version_id = 1
end
- it_behaves_like 'linked resource' do
- let(:attribute_name) { 'version' }
- let(:association_name) { 'version_id' }
+ it_behaves_like "linked resource" do
+ let(:attribute_name) { "version" }
+ let(:association_name) { "version_id" }
end
end
- describe 'type' do
- it_behaves_like 'linked resource' do
- let(:attribute_name) { 'type' }
+ describe "type" do
+ it_behaves_like "linked resource" do
+ let(:attribute_name) { "type" }
end
end
- describe 'status' do
- it_behaves_like 'linked resource' do
- let(:attribute_name) { 'status' }
+ describe "status" do
+ it_behaves_like "linked resource" do
+ let(:attribute_name) { "status" }
end
end
- describe 'assignee' do
- let(:attribute_name) { 'assignee' }
+ describe "assignee" do
+ let(:attribute_name) { "assignee" }
before do
work_package.assigned_to_id = 1
end
- context 'with a user' do
- it_behaves_like 'linked resource' do
+ context "with a user" do
+ it_behaves_like "linked resource" do
let(:path) { api_v3_paths.user(id) }
- let(:association_name) { 'assigned_to_id' }
+ let(:association_name) { "assigned_to_id" }
end
end
- context 'with a group' do
- it_behaves_like 'linked resource' do
+ context "with a group" do
+ it_behaves_like "linked resource" do
let(:path) { api_v3_paths.group(id) }
- let(:association_name) { 'assigned_to_id' }
+ let(:association_name) { "assigned_to_id" }
end
end
end
- describe 'responsible' do
- let(:attribute_name) { 'responsible' }
+ describe "responsible" do
+ let(:attribute_name) { "responsible" }
before do
work_package.responsible_id = 1
end
- context 'with a user' do
- it_behaves_like 'linked resource' do
+ context "with a user" do
+ it_behaves_like "linked resource" do
let(:path) { api_v3_paths.user(id) }
end
end
- context 'with a group' do
- it_behaves_like 'linked resource' do
+ context "with a group" do
+ it_behaves_like "linked resource" do
let(:path) { api_v3_paths.group(id) }
end
end
end
- describe 'category' do
+ describe "category" do
before do
work_package.category_id = 1
end
- it_behaves_like 'linked resource' do
- let(:attribute_name) { 'category' }
+ it_behaves_like "linked resource" do
+ let(:attribute_name) { "category" }
end
end
- describe 'parent' do
+ describe "parent" do
let(:parent) { build_stubbed(:work_package) }
let(:new_parent) do
wp = build_stubbed(:work_package)
@@ -708,26 +708,26 @@ RSpec.describe API::V3::WorkPackages::WorkPackagePayloadRepresenter do
work_package.parent = parent
end
- describe 'with a valid href' do
+ describe "with a valid href" do
let(:href) { { href: path } }
- it 'sets attribute to the specified id' do
+ it "sets attribute to the specified id" do
expect(subject.parent).to eql(new_parent)
end
end
- describe 'with a null href' do
+ describe "with a null href" do
let(:href) { { href: nil } }
- it 'sets attribute to nil' do
+ it "sets attribute to nil" do
expect(subject.parent).to be_nil
end
end
- describe 'with an invalid link' do
+ describe "with an invalid link" do
let(:href) { {} }
- it 'leaves attribute unchanged' do
+ it "leaves attribute unchanged" do
expect(subject.parent).to eql(parent)
end
end
diff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rb
index 48b0ef90156..fd32c8f14b2 100644
--- a/spec/models/mail_handler_spec.rb
+++ b/spec/models/mail_handler_spec.rb
@@ -26,16 +26,16 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe MailHandler do
# we need these run first so the anonymous and system users are created and
# there is a default work package priority to save any work packages
shared_let(:anno_user) { User.anonymous }
shared_let(:system_user) { User.system }
- shared_let(:priority_low) { create(:priority_low, name: 'Low', is_default: true) }
+ shared_let(:priority_low) { create(:priority_low, name: "Low", is_default: true) }
- shared_let(:project) { create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', public: false) }
+ shared_let(:project) { create(:valid_project, identifier: "onlinestore", name: "OnlineStore", public: false) }
before do
allow(UserMailer)
@@ -45,67 +45,67 @@ RSpec.describe MailHandler do
after do
User.current = nil
- allow(Setting).to receive(:default_language).and_return('en')
+ allow(Setting).to receive(:default_language).and_return("en")
end
- shared_context 'for wp_on_given_project' do
+ shared_context "for wp_on_given_project" do
let(:permissions) { %i[add_work_packages assign_versions work_package_assigned] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_on_given_project.eml', **submit_options)
+ submit_email("wp_on_given_project.eml", **submit_options)
end
end
- shared_context 'for wp_on_given_project_case_insensitive' do
+ shared_context "for wp_on_given_project_case_insensitive" do
let(:permissions) { %i[add_work_packages assign_versions] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
- let(:submit_options) { { allow_override: 'version' } }
+ let(:submit_options) { { allow_override: "version" } }
subject do
- submit_email('wp_on_given_project_case_insensitive.eml', **submit_options)
+ submit_email("wp_on_given_project_case_insensitive.eml", **submit_options)
end
end
- shared_context 'for wp on given project group assignment' do
+ shared_context "for wp on given project group assignment" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:group) do
create(:group,
- lastname: 'A-Team',
+ lastname: "A-Team",
member_with_permissions: { project => [:work_package_assigned] })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_on_given_project_group_assignment.eml', **submit_options)
+ submit_email("wp_on_given_project_group_assignment.eml", **submit_options)
end
end
- shared_context 'with a reply to a wp mention with quotes above' do
+ shared_context "with a reply to a wp mention with quotes above" do
let(:permissions) { %i[edit_work_packages view_work_packages] }
let!(:user) do
create(:user,
member_with_permissions: { project => permissions })
end
@@ -118,44 +118,44 @@ RSpec.describe MailHandler do
end
subject do
- submit_email('wp_reply_with_quoted_reply_above.eml')
+ submit_email("wp_reply_with_quoted_reply_above.eml")
end
end
- shared_context 'with wp create with cc' do
+ shared_context "with wp create with cc" do
let(:permissions) { %i[add_work_packages view_work_packages add_work_package_watchers] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:cc_user) do
create(:user,
- firstname: 'D',
- lastname: 'Lopper',
+ firstname: "D",
+ lastname: "Lopper",
member_with_permissions: { project => permissions })
end
let(:submit_options) { { issue: { project: project.identifier } } }
subject do
- submit_email('ticket_with_cc.eml', **submit_options)
+ submit_email("ticket_with_cc.eml", **submit_options)
end
end
- shared_context 'with a reply to a wp mention' do
+ shared_context "with a reply to a wp mention" do
let(:permissions) { %i[add_work_package_notes view_work_packages] }
let!(:user) do
create(:user,
member_with_permissions: { project => permissions })
end
let!(:work_package) do
create(:work_package,
- subject: 'Some subject of the bug',
+ subject: "Some subject of the bug",
id: 39733,
project:) do |wp|
wp.journals.last.update_column(:id, 99999999)
@@ -163,24 +163,24 @@ RSpec.describe MailHandler do
end
subject do
- submit_email('wp_mention_reply.eml')
+ submit_email("wp_mention_reply.eml")
end
end
- shared_context 'with a reply to a wp mention with attributes' do
+ shared_context "with a reply to a wp mention with attributes" do
let(:permissions) { %i[add_work_package_notes view_work_packages edit_work_packages work_package_assigned] }
let(:role) do
create(:project_role, permissions:)
end
let!(:user) do
create(:user,
member_with_roles: { project => role })
end
let!(:work_package) do
create(:work_package,
- subject: 'Some subject of the bug',
+ subject: "Some subject of the bug",
id: 39733,
project:,
status: original_status) do |wp|
@@ -192,7 +192,7 @@ RSpec.describe MailHandler do
end
let!(:resolved_status) do
create(:status,
- name: 'Resolved') do |status|
+ name: "Resolved") do |status|
create(:workflow,
old_status: original_status,
new_status: status,
@@ -202,27 +202,27 @@ RSpec.describe MailHandler do
end
let!(:other_user) do
create(:user,
member_with_roles: { project => [role] })
end
let!(:float_cf) do
create(:float_wp_custom_field,
- name: 'float field') do |cf|
+ name: "float field") do |cf|
project.work_package_custom_fields << cf
work_package.type.custom_fields << cf
end
end
subject do
- submit_email('wp_mention_reply_with_attributes.eml')
+ submit_email("wp_mention_reply_with_attributes.eml")
end
end
- shared_context 'with a reply to a message' do
+ shared_context "with a reply to a message" do
let(:permissions) { %i[view_messages add_messages] }
let!(:user) do
create(:user,
member_with_permissions: { project => permissions })
end
@@ -235,27 +235,27 @@ RSpec.describe MailHandler do
end
subject do
- submit_email('message_reply.eml')
+ submit_email("message_reply.eml")
end
end
- shared_context 'with a new work package with attributes' do
+ shared_context "with a new work package with attributes" do
let(:permissions) { %i[add_work_packages assign_versions work_package_assigned] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:feature_type) do
create(:type,
- name: 'Feature request') do |type|
+ name: "Feature request") do |type|
project.types << type
end
end
let!(:stock_category) do
- project.categories.create(name: 'Stock management')
+ project.categories.create(name: "Stock management")
end
let!(:urgent_priority) do
create(:priority_urgent)
@@ -266,27 +266,27 @@ RSpec.describe MailHandler do
let(:submit_options) { {} }
subject do
- submit_email('wp_with_attributes.eml', **submit_options)
+ submit_email("wp_with_attributes.eml", **submit_options)
end
end
- shared_context 'with a new work package with attributes with additional spaces' do
+ shared_context "with a new work package with attributes with additional spaces" do
let(:permissions) { %i[add_work_packages assign_versions work_package_assigned] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:feature_type) do
create(:type,
- name: 'Feature request') do |type|
+ name: "Feature request") do |type|
project.types << type
end
end
let!(:stock_category) do
- project.categories.create(name: 'Stock management')
+ project.categories.create(name: "Stock management")
end
let!(:urgent_priority) do
create(:priority_urgent)
@@ -297,77 +297,77 @@ RSpec.describe MailHandler do
let(:submit_options) { {} }
subject do
- submit_email('wp_with_spaces_between_attribute_and_separator.eml', **submit_options)
+ submit_email("wp_with_spaces_between_attribute_and_separator.eml", **submit_options)
end
end
- shared_context 'with a new work package with attributes in japanese' do
+ shared_context "with a new work package with attributes in japanese" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:japanese_type) do
create(:type,
- name: '開発') do |type|
+ name: "開発") do |type|
project.types << type
end
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_attributes_japanese.eml', **submit_options)
+ submit_email("wp_with_attributes_japanese.eml", **submit_options)
end
end
- shared_context 'with a new work package with attachment' do
+ shared_context "with a new work package with attachment" do
# The work package is created first and only then the attachment is added.
let(:permissions) { %i[add_work_packages add_work_package_attachments] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_attachment.eml', **submit_options)
+ submit_email("wp_with_attachment.eml", **submit_options)
end
end
- shared_context 'with a new work package with attachment in apple format' do
+ shared_context "with a new work package with attachment in apple format" do
# The work package is created first and only then the attachment is added.
let(:permissions) { %i[add_work_packages add_work_package_attachments] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_attachment_apple.eml', **submit_options)
+ submit_email("wp_with_attachment_apple.eml", **submit_options)
end
end
- shared_context 'with a new work package with a custom field' do
+ shared_context "with a new work package with a custom field" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let!(:custom_field) do
- create(:string_wp_custom_field, name: 'Searchable field') do |cf|
+ create(:string_wp_custom_field, name: "Searchable field") do |cf|
project.work_package_custom_fields << cf
project.types.first.custom_fields << cf
end
@@ -375,108 +375,108 @@ RSpec.describe MailHandler do
let(:submit_options) { {} }
subject do
- submit_email('wp_with_custom_field.eml', **submit_options)
+ submit_email("wp_with_custom_field.eml", **submit_options)
end
end
- shared_context 'with a new work package with invalid attributes' do
+ shared_context "with a new work package with invalid attributes" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
+ firstname: "John",
+ lastname: "Smith",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_invalid_attributes.eml', **submit_options)
+ submit_email("wp_with_invalid_attributes.eml", **submit_options)
end
end
- shared_context 'with a new work package with localized attributes' do
+ shared_context "with a new work package with localized attributes" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
- language: 'de',
+ firstname: "John",
+ lastname: "Smith",
+ language: "de",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
let!(:feature_type) do
create(:type,
- name: 'Feature request') do |type|
+ name: "Feature request") do |type|
project.types << type
end
end
let!(:stock_category) do
- project.categories.create(name: 'Stock management')
+ project.categories.create(name: "Stock management")
end
let!(:urgent_priority) do
create(:priority_urgent)
end
subject do
- submit_email('wp_with_localized_attributes.eml', **submit_options)
+ submit_email("wp_with_localized_attributes.eml", **submit_options)
end
end
- shared_context 'with a new work package with iso 8859 1 subject' do
+ shared_context "with a new work package with iso 8859 1 subject" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
- language: 'de',
+ firstname: "John",
+ lastname: "Smith",
+ language: "de",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_iso_8859_1_subject.eml', **submit_options)
+ submit_email("wp_with_iso_8859_1_subject.eml", **submit_options)
end
end
- shared_context 'with a new work package with long subject' do
+ shared_context "with a new work package with long subject" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
- language: 'de',
+ firstname: "John",
+ lastname: "Smith",
+ language: "de",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_long_subject.eml', **submit_options)
+ submit_email("wp_with_long_subject.eml", **submit_options)
end
end
- shared_context 'with a new work package with html only description' do
+ shared_context "with a new work package with html only description" do
let(:permissions) { %i[add_work_packages] }
let!(:user) do
create(:user,
- firstname: 'John',
- lastname: 'Smith',
- language: 'de',
+ firstname: "John",
+ lastname: "Smith",
+ language: "de",
member_with_permissions: { project => permissions })
end
let(:submit_options) { {} }
subject do
- submit_email('wp_with_html_only_description.eml', **submit_options)
+ submit_email("wp_with_html_only_description.eml", **submit_options)
end
end
- shared_context 'with a new work package with the sender fullname in utf-8' do
+ shared_context "with a new work package with the sender fullname in utf-8" do
let(:submit_options) { {} }
before do
@@ -485,13 +485,13 @@ RSpec.describe MailHandler do
end
subject do
- submit_email('wp_with_utf8_fullname_of_sender.eml', **submit_options)
+ submit_email("wp_with_utf8_fullname_of_sender.eml", **submit_options)
end
end
- describe '#receive' do
- shared_examples_for 'work package created' do
- it 'creates the work package' do
+ describe "#receive" do
+ shared_examples_for "work package created" do
+ it "creates the work package" do
expect(subject)
.to be_a(WorkPackage)
@@ -500,8 +500,8 @@ RSpec.describe MailHandler do
end
end
- shared_examples_for 'journal created' do
- it 'creates the journal' do
+ shared_examples_for "journal created" do
+ it "creates the journal" do
expect(subject)
.to be_a(Journal)
@@ -510,79 +510,79 @@ RSpec.describe MailHandler do
end
end
- context 'when sending a mail not as a reply' do
- context 'for a given project' do
+ context "when sending a mail not as a reply" do
+ context "for a given project" do
let(:type) { project.types.first }
- let!(:status) { create(:status, name: 'Resolved', workflow_for_type: type) }
- let!(:version) { create(:version, name: 'alpha', project:) }
+ let!(:status) { create(:status, name: "Resolved", workflow_for_type: type) }
+ let!(:version) { create(:version, name: "alpha", project:) }
- include_context 'for wp_on_given_project' do
- let(:submit_options) { { allow_override: 'version' } }
+ include_context "for wp_on_given_project" do
+ let(:submit_options) { { allow_override: "version" } }
end
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the referenced project' do
+ it "sets the referenced project" do
expect(subject.project)
.to eql(project)
end
- it 'sets the first type in the project' do
+ it "sets the first type in the project" do
expect(subject.type)
.to eql(type)
end
- it 'sets the subject' do
+ it "sets the subject" do
expect(subject.subject)
- .to eql('New ticket on a given project')
+ .to eql("New ticket on a given project")
end
- it 'sets the sender as the author' do
+ it "sets the sender as the author" do
expect(subject.author)
.to eql(user)
end
- it 'set the description' do
+ it "set the description" do
expect(subject.description)
- .to include('Lorem ipsum dolor sit amet, consectetuer adipiscing elit.')
+ .to include("Lorem ipsum dolor sit amet, consectetuer adipiscing elit.")
end
- it 'sets the start date' do
+ it "sets the start date" do
expect(subject.start_date.to_s)
- .to eql('2010-01-01')
+ .to eql("2010-01-01")
end
- it 'sets the due date' do
+ it "sets the due date" do
expect(subject.due_date.to_s)
- .to eql('2010-12-31')
+ .to eql("2010-12-31")
end
- it 'sets the assignee' do
+ it "sets the assignee" do
expect(subject.assigned_to)
.to eql(user)
end
- it 'sets the status' do
+ it "sets the status" do
expect(subject.status)
.to eql(status)
end
- it 'sets the version' do
+ it "sets the version" do
expect(subject.version)
.to eql(version)
end
- it 'sets the estimated_hours' do
+ it "sets the estimated_hours" do
expect(subject.estimated_hours)
.to be(2.5)
end
- it 'sets the done_ratio' do
+ it "sets the done_ratio" do
expect(subject.done_ratio)
.to be(30)
end
- it 'removes keywords' do
+ it "removes keywords" do
expect(subject.description)
.not_to match(/^Project:/i)
@@ -593,7 +593,7 @@ RSpec.describe MailHandler do
.not_to match(/^Start Date:/i)
end
- it 'sends notifications to watching users' do
+ it "sends notifications to watching users" do
# User gets all updates
user = create(:user,
member_with_permissions: { project => %i(view_work_packages) },
@@ -606,77 +606,77 @@ RSpec.describe MailHandler do
end.to change(Notification.where(recipient: user), :count).by(1)
end
- it 'does not send an error reply email' do
+ it "does not send an error reply email" do
subject # send mail
expect(UserMailer).not_to have_received(:incoming_email_error)
end
end
- context 'for a given project with a default type' do
+ context "for a given project with a default type" do
let(:default_type) do
create(:type, is_default: true) do |t|
project.types << t
end
end
- include_context 'for wp_on_given_project' do
+ include_context "for wp_on_given_project" do
let(:submit_options) { { issue: { type: default_type.name } } }
end
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the default type' do
+ it "sets the default type" do
expect(subject.type.name)
.to eql(default_type.name)
end
end
- context 'for a given project with a locked user' do
- let!(:status) { create(:status, name: 'Resolved') }
+ context "for a given project with a locked user" do
+ let!(:status) { create(:status, name: "Resolved") }
before do
user.locked!
end
- include_context 'for wp_on_given_project'
+ include_context "for wp_on_given_project"
- it 'does not create the work package' do
+ it "does not create the work package" do
expect { subject }
.not_to change(WorkPackage, :count)
end
end
- context 'for a given project with group assignment' do
- include_context 'for wp on given project group assignment'
+ context "for a given project with group assignment" do
+ include_context "for wp on given project group assignment"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the assignee to the group' do
+ it "sets the assignee to the group" do
expect(subject.assigned_to)
.to eql(group)
end
end
- context 'for an email by unknown user' do
- context 'with unknown_user: \'create\'' do
- it 'adds a work_package by create user on public project' do
+ context "for an email by unknown user" do
+ context "with unknown_user: 'create'" do
+ it "adds a work_package by create user on public project" do
ProjectRole.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :public, true
expect do
- work_package = submit_email('ticket_by_unknown_user.eml', issue: { project: 'onlinestore' }, unknown_user: 'create')
+ work_package = submit_email("ticket_by_unknown_user.eml", issue: { project: "onlinestore" }, unknown_user: "create")
work_package_created(work_package)
expect(work_package.author).to be_active
- expect(work_package.author.mail).to eq('[email protected]')
- expect(work_package.author.firstname).to eq('John')
- expect(work_package.author.lastname).to eq('Doe')
+ expect(work_package.author.mail).to eq("[email protected]")
+ expect(work_package.author.firstname).to eq("John")
+ expect(work_package.author.lastname).to eq("Doe")
# account information
perform_enqueued_jobs
email = ActionMailer::Base.deliveries.first
expect(email).not_to be_nil
- expect(email.subject).to eq(I18n.t('mail_subject_register', value: Setting.app_title))
+ expect(email.subject).to eq(I18n.t("mail_subject_register", value: Setting.app_title))
login = email.body.encoded.match(/\* Username: (\S+)\s?$/)[1]
password = email.body.encoded.match(/\* Password: (\S+)\s?$/)[1]
@@ -688,28 +688,28 @@ RSpec.describe MailHandler do
end
end
- context 'with unknown_user: \'create\' and an utf8 encoded fullname' do
- include_context 'with a new work package with the sender fullname in utf-8'
- let(:submit_options) { { issue: { project: 'onlinestore' }, unknown_user: 'create' } }
+ context "with unknown_user: 'create' and an utf8 encoded fullname" do
+ include_context "with a new work package with the sender fullname in utf-8"
+ let(:submit_options) { { issue: { project: "onlinestore" }, unknown_user: "create" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'adds the user with decoded fullname' do
+ it "adds the user with decoded fullname" do
expect do
expect(subject.author).to be_active
- expect(subject.author.mail).to eq('[email protected]')
- expect(subject.author.firstname).to eq("\xc3\x84\xc3\xa4".force_encoding('UTF-8'))
- expect(subject.author.lastname).to eq("\xc3\x96\xc3\xb6".force_encoding('UTF-8'))
+ expect(subject.author.mail).to eq("[email protected]")
+ expect(subject.author.firstname).to eq("\xc3\x84\xc3\xa4".force_encoding("UTF-8"))
+ expect(subject.author.lastname).to eq("\xc3\x96\xc3\xb6".force_encoding("UTF-8"))
end.to change(User, :count).by(1)
end
end
- context 'with unknown_user: nil (default)' do
+ context "with unknown_user: nil (default)" do
let(:results) { [] }
before do
results << submit_email(
- 'ticket_by_unknown_user.eml',
+ "ticket_by_unknown_user.eml",
issue: { project: project.identifier },
unknown_user: nil
)
@@ -724,9 +724,9 @@ RSpec.describe MailHandler do
end
end
- context 'with unknown_user: \'accept\' and permission check present' do
+ context "with unknown_user: 'accept' and permission check present" do
let(:expected) do
- 'MailHandler: work_package could not be created by Anonymous due to ' \
+ "MailHandler: work_package could not be created by Anonymous due to " \
'#["Type was attempted to be written but is not writable.", ' \
'"Project was attempted to be written but is not writable.", ' \
'"Subject was attempted to be written but is not writable.", ' \
@@ -737,9 +737,9 @@ RSpec.describe MailHandler do
subject(:work_package) do
submit_email(
- 'ticket_by_unknown_user.eml',
+ "ticket_by_unknown_user.eml",
issue: { project: project.identifier },
- unknown_user: 'accept'
+ unknown_user: "accept"
)
end
@@ -748,21 +748,21 @@ RSpec.describe MailHandler do
ProjectRole.anonymous.add_permission!(permission) if permission
end
- context 'with anonymous lacking permissions' do
+ context "with anonymous lacking permissions" do
before do
work_package
end
- it 'rejects the email' do
+ it "rejects the email" do
expect(work_package).to be false
end
- it 'logs the error' do
+ it "logs the error" do
expect(Rails.logger).to have_received(:error).with(expected)
end
- context 'with report_incoming_email_errors true (default)' do
- it 'responds with an error email' do
+ context "with report_incoming_email_errors true (default)" do
+ it "responds with an error email" do
expect(UserMailer).to have_received(:incoming_email_error) do |user, mail, logs|
expect(user).to eq anno_user
expect(mail[:subject]).to eq "Ticket by unknown user"
@@ -771,181 +771,181 @@ RSpec.describe MailHandler do
end
end
- context 'with report_incoming_email_errors false', with_settings: { report_incoming_email_errors: false } do
- it 'does not respond with an error email' do
+ context "with report_incoming_email_errors false", with_settings: { report_incoming_email_errors: false } do
+ it "does not respond with an error email" do
expect(UserMailer).not_to have_received(:incoming_email_error)
end
end
end
- context 'with anonymous having permissions in a public project' do
+ context "with anonymous having permissions in a public project" do
let(:permission) { :add_work_packages }
before do
project.update_attribute(:public, true)
end
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the author to anonymous' do
+ it "sets the author to anonymous" do
expect(work_package.author)
.to eql User.anonymous
end
- it 'creates no user' do
+ it "creates no user" do
expect { work_package }
.not_to change(User, :count)
end
end
- context 'with anonymous having permissions in a private project' do
+ context "with anonymous having permissions in a private project" do
let(:permission) { :add_work_packages }
before do
project.update_attribute(:public, false)
end
- it 'creates no work package' do
+ it "creates no work package" do
expect { work_package }
.not_to change(WorkPackage, :count)
end
- it 'creates no user' do
+ it "creates no user" do
expect { work_package }
.not_to change(User, :count)
end
end
end
- context 'for unknown_user: \'accept\' and no_permission_check' do
+ context "for unknown_user: 'accept' and no_permission_check" do
subject(:work_package) do
- submit_email 'ticket_by_unknown_user.eml',
+ submit_email "ticket_by_unknown_user.eml",
issue: { project: project.identifier },
- unknown_user: 'accept',
+ unknown_user: "accept",
no_permission_check: 1
end
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the author to anonymous' do
+ it "sets the author to anonymous" do
expect(work_package.author).to eq(User.anonymous)
end
end
- context 'for unknown_user: \'accept\' and without from header' do
+ context "for unknown_user: 'accept' and without from header" do
subject(:work_package) do
ProjectRole.anonymous.add_permission!(:add_work_packages)
- submit_email 'wp_without_from_header.eml',
+ submit_email "wp_without_from_header.eml",
issue: { project: project.identifier },
- unknown_user: 'accept'
+ unknown_user: "accept"
end
- it 'creates no work package' do
+ it "creates no work package" do
expect { work_package }
.not_to change(WorkPackage, :count)
end
end
- context 'for unknown_user: \'accept\' and without permission checks and without from header' do
+ context "for unknown_user: 'accept' and without permission checks and without from header" do
subject(:work_package) do
- submit_email 'wp_without_from_header.eml',
+ submit_email "wp_without_from_header.eml",
issue: { project: project.identifier },
- unknown_user: 'accept',
+ unknown_user: "accept",
no_permission_check: 1
end
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the author to anonymous' do
+ it "sets the author to anonymous" do
expect(work_package.author).to eq(User.anonymous)
end
end
end
- context 'for email from emission address', with_settings: { mail_from: '[email protected]' } do
+ context "for email from emission address", with_settings: { mail_from: "[email protected]" } do
before do
ProjectRole.non_member.add_permission!(:add_work_packages)
end
subject do
project.update(public: true)
- submit_email('ticket_from_emission_address.eml',
+ submit_email("ticket_from_emission_address.eml",
issue: { project: project.identifier },
- unknown_user: 'create')
+ unknown_user: "create")
end
- it 'returns false' do
+ it "returns false" do
expect(subject).to be_falsey
end
- it 'does not create the user' do
+ it "does not create the user" do
expect { subject }
.not_to(change(User, :count))
end
- it 'does not create the work_package' do
+ it "does not create the work_package" do
expect { subject }
.not_to(change(WorkPackage, :count))
end
- it 'does not result in an error email response' do
+ it "does not result in an error email response" do
subject # send email
expect(UserMailer).not_to have_received(:incoming_email_error)
end
end
- context 'for wp with status' do
+ context "for wp with status" do
let(:type) { project.types.first }
- let!(:status) { create(:status, name: 'Resolved', workflow_for_type: type) }
+ let!(:status) { create(:status, name: "Resolved", workflow_for_type: type) }
# This email contains: 'Project: onlinestore' and 'Status: Resolved'
- include_context 'for wp_on_given_project'
+ include_context "for wp_on_given_project"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'assigns the status to the created work package' do
+ it "assigns the status to the created work package" do
expect(subject.status)
.to eql(status)
end
end
- context 'for wp with status case insensitive' do
+ context "for wp with status case insensitive" do
let(:type) { project.types.first }
- let!(:status) { create(:status, name: 'Resolved', workflow_for_type: type) }
- let!(:version) { create(:version, name: 'alpha', project:) }
+ let!(:status) { create(:status, name: "Resolved", workflow_for_type: type) }
+ let!(:version) { create(:version, name: "alpha", project:) }
# This email contains: 'Project: onlinestore' and 'Status: resolved'
- include_context 'for wp_on_given_project_case_insensitive'
+ include_context "for wp_on_given_project_case_insensitive"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'assigns the status to the created work package' do
+ it "assigns the status to the created work package" do
expect(subject.status).to eq(status)
expect(subject.version).to eq(version)
expect(subject.priority).to eq priority_low
end
end
- context 'for wp with cc' do
- include_context 'with wp create with cc'
+ context "for wp with cc" do
+ include_context "with wp create with cc"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'assigns cc and author as watcher' do
+ it "assigns cc and author as watcher" do
expect(subject.watcher_users)
.to contain_exactly(user, cc_user)
end
end
- context 'for a wp overriding attributes' do
- include_context 'with a new work package with attributes'
- let(:submit_options) { { allow_override: 'type,category,priority' } }
+ context "for a wp overriding attributes" do
+ include_context "with a new work package with attributes"
+ let(:submit_options) { { allow_override: "type,category,priority" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the provided attributes' do
+ it "sets the provided attributes" do
expect(subject.project)
.to eql project
@@ -960,13 +960,13 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp overriding attributes partially' do
- include_context 'with a new work package with attributes'
- let(:submit_options) { { issue: { priority: 'High' }, allow_override: ['type'] } }
+ context "for a wp overriding attributes partially" do
+ include_context "with a new work package with attributes"
+ let(:submit_options) { { issue: { priority: "High" }, allow_override: ["type"] } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the provided attributes only to the extend allowed and uses default' do
+ it "sets the provided attributes only to the extend allowed and uses default" do
expect(subject.project)
.to eql project
@@ -981,13 +981,13 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp overriding attributes with spaces between attribute and separator' do
- include_context 'with a new work package with attributes with additional spaces'
- let(:submit_options) { { allow_override: 'type,category,priority' } }
+ context "for a wp overriding attributes with spaces between attribute and separator" do
+ include_context "with a new work package with attributes with additional spaces"
+ let(:submit_options) { { allow_override: "type,category,priority" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the provided attributes' do
+ it "sets the provided attributes" do
expect(subject.project)
.to eql project
@@ -1002,82 +1002,82 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp overriding attributes in japanese' do
- include_context 'with a new work package with attributes in japanese'
- let(:submit_options) { { issue: { project: 'onlinestore' }, allow_override: 'type' } }
+ context "for a wp overriding attributes in japanese" do
+ include_context "with a new work package with attributes in japanese"
+ let(:submit_options) { { issue: { project: "onlinestore" }, allow_override: "type" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the provided attributes' do
+ it "sets the provided attributes" do
expect(subject.type)
.to eql japanese_type
end
end
- context 'for a wp with attachment' do
- include_context 'with a new work package with attachment'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with attachment" do
+ include_context "with a new work package with attachment"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'adds the attachment' do
+ it "adds the attachment" do
expect(subject.attachments.count)
.to be 1
expect(subject.attachments.first.filename)
- .to eql 'Paella.jpg'
+ .to eql "Paella.jpg"
expect(subject.attachments.first.content_type)
- .to eql 'image/jpeg'
+ .to eql "image/jpeg"
expect(subject.attachments.first.filesize)
.to be 10790
end
end
- context 'for a wp with attachment in apple format' do
- include_context 'with a new work package with attachment in apple format'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with attachment in apple format" do
+ include_context "with a new work package with attachment in apple format"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'adds the attachment' do
+ it "adds the attachment" do
expect(subject.attachments.count)
.to be 1
expect(subject.attachments.first.filename)
- .to eql 'paella.jpg'
+ .to eql "paella.jpg"
expect(subject.attachments.first.content_type)
- .to eql 'image/jpeg'
+ .to eql "image/jpeg"
expect(subject.attachments.first.filesize)
.to be 10790
end
end
- context 'for a wp with a custom field value' do
- include_context 'with a new work package with a custom field'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with a custom field value" do
+ include_context "with a new work package with a custom field"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the custom field value and removes it from the text' do
+ it "sets the custom field value and removes it from the text" do
expect(subject.custom_value_attributes)
- .to eql(custom_field.id => 'Value for a custom field')
+ .to eql(custom_field.id => "Value for a custom field")
expect(subject.description)
- .not_to include 'searchable field'
+ .not_to include "searchable field"
end
end
- context 'for a wp with invalid attributes' do
- include_context 'with a new work package with invalid attributes'
- let(:submit_options) { { issue: { project: 'onlinestore' }, allow_override: 'type,category,priority' } }
+ context "for a wp with invalid attributes" do
+ include_context "with a new work package with invalid attributes"
+ let(:submit_options) { { issue: { project: "onlinestore" }, allow_override: "type,category,priority" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'ignores the invalid attributes and set default ones where possible' do
+ it "ignores the invalid attributes and set default ones where possible" do
expect(subject.assigned_to)
.to be_nil
@@ -1095,13 +1095,13 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp with localized attributes' do
- include_context 'with a new work package with localized attributes'
- let(:submit_options) { { allow_override: 'type,category,priority' } }
+ context "for a wp with localized attributes" do
+ include_context "with a new work package with localized attributes"
+ let(:submit_options) { { allow_override: "type,category,priority" } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the provided attributes' do
+ it "sets the provided attributes" do
expect(subject.project)
.to eql project
@@ -1116,25 +1116,25 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp with iso 8859 1 subject' do
- include_context 'with a new work package with iso 8859 1 subject'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with iso 8859 1 subject" do
+ include_context "with a new work package with iso 8859 1 subject"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the subject' do
+ it "sets the subject" do
expect(subject.subject)
- .to eql 'Testmail from Webmail: ä ö ü...'
+ .to eql "Testmail from Webmail: ä ö ü..."
end
end
- context 'for a wp with long subject' do
- include_context 'with a new work package with long subject'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with long subject" do
+ include_context "with a new work package with long subject"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the subject' do
+ it "sets the subject" do
original_subject = <<~MSG.squish
New ticket on a given project with a very long subject line
which exceeds 255 chars and should not be ignored but chopped off.
@@ -1147,21 +1147,21 @@ RSpec.describe MailHandler do
end
end
- context 'for a wp with html only description' do
- include_context 'with a new work package with html only description'
- let(:submit_options) { { issue: { project: 'onlinestore' } } }
+ context "for a wp with html only description" do
+ include_context "with a new work package with html only description"
+ let(:submit_options) { { issue: { project: "onlinestore" } } }
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'sets the description' do
+ it "sets the description" do
expect(subject.description)
- .to eql 'This is a html-only email.'
+ .to eql "This is a html-only email."
end
end
end
- context 'when sending a reply to work package mail' do
- let!(:mail_user) { create(:admin, mail: '[email protected]') }
+ context "when sending a reply to work package mail" do
+ let!(:mail_user) { create(:admin, mail: "[email protected]") }
let!(:work_package) { create(:work_package, project:) }
before do
@@ -1169,45 +1169,45 @@ RSpec.describe MailHandler do
allow(OpenProject::Database).to receive(:allows_tsv?).and_return false
end
- context 'with attachments to be added' do
- it 'updates a work package with attachment' do
+ context "with attachments to be added" do
+ it "updates a work package with attachment" do
allow(WorkPackage).to receive(:find_by).with(id: 123).and_return(work_package)
# Mail with two attachments, one of which is skipped by signature.asc filename match
- submit_email 'update_ticket_with_attachment_and_sig.eml', issue: { project: 'onlinestore' }
+ submit_email "update_ticket_with_attachment_and_sig.eml", issue: { project: "onlinestore" }
work_package.reload
# Expect comment
- expect(work_package.journals.last.notes).to eq 'Reply to work package #123'
+ expect(work_package.journals.last.notes).to eq "Reply to work package #123"
expect(work_package.journals.last.user).to eq mail_user
# Expect filename without signature to be saved
expect(work_package.attachments.count).to eq(1)
- expect(work_package.attachments.first.filename).to eq('Photo25.jpg')
+ expect(work_package.attachments.first.filename).to eq("Photo25.jpg")
end
end
- context 'with existing attachment' do
+ context "with existing attachment" do
let!(:attachment) { create(:attachment, container: work_package) }
- it 'does not replace it (Regression #29722)' do
+ it "does not replace it (Regression #29722)" do
work_package.reload
allow(WorkPackage).to receive(:find_by).with(id: 123).and_return(work_package)
# Mail with two attachments, one of which is skipped by signature.asc filename match
- submit_email 'update_ticket_with_attachment_and_sig.eml', issue: { project: 'onlinestore' }
+ submit_email "update_ticket_with_attachment_and_sig.eml", issue: { project: "onlinestore" }
expect(work_package.attachments.length).to eq 2
end
end
- context 'with reply text' do
- include_context 'with a reply to a wp mention with quotes above'
+ context "with reply text" do
+ include_context "with a reply to a wp mention with quotes above"
- it_behaves_like 'journal created'
+ it_behaves_like "journal created"
- it 'sends notifications' do
+ it "sends notifications" do
assignee = create(:user,
member_with_permissions: { project => %i(view_work_packages) },
notification_settings: [build(:notification_setting, assignee: true, responsible: true)])
@@ -1223,26 +1223,26 @@ RSpec.describe MailHandler do
end
end
- context 'when replying to mention mail with only text' do
- include_context 'with a reply to a wp mention'
+ context "when replying to mention mail with only text" do
+ include_context "with a reply to a wp mention"
- it_behaves_like 'journal created'
+ it_behaves_like "journal created"
- it 'adds the content to the last journal' do
+ it "adds the content to the last journal" do
subject
expect(work_package.journals.reload.last.notes)
- .to include 'The text of the reply.'
+ .to include "The text of the reply."
end
- it 'does not alter any attributes' do
+ it "does not alter any attributes" do
subject
expect(work_package.journals.reload.last.details)
.to be_empty
end
- it 'performs the changes in the name of the sender' do
+ it "performs the changes in the name of the sender" do
subject
expect(work_package.journals.reload.last.user)
@@ -1250,19 +1250,19 @@ RSpec.describe MailHandler do
end
end
- context 'when replying to mention mail with text and attributes' do
- include_context 'with a reply to a wp mention with attributes'
+ context "when replying to mention mail with text and attributes" do
+ include_context "with a reply to a wp mention with attributes"
- it_behaves_like 'journal created'
+ it_behaves_like "journal created"
- it 'adds the content to the last journal' do
+ it "adds the content to the last journal" do
subject
expect(work_package.journals.reload.last.notes)
- .to include 'The text of the reply.'
+ .to include "The text of the reply."
end
- it 'alters the attributes' do
+ it "alters the attributes" do
subject
expect(work_package.journals.reload.last.details)
@@ -1276,7 +1276,7 @@ RSpec.describe MailHandler do
)
end
- it 'performs the changes in the name of the sender' do
+ it "performs the changes in the name of the sender" do
subject
expect(work_package.journals.reload.last.user)
@@ -1284,7 +1284,7 @@ RSpec.describe MailHandler do
end
end
- context 'with a custom field' do
+ context "with a custom field" do
let(:work_package) { create(:work_package, project:) }
let(:type) { create(:type) }
@@ -1298,11 +1298,11 @@ RSpec.describe MailHandler do
allow(User).to receive(:find_by_mail).with("[email protected]").and_return(mail_user)
end
- context 'as type text' do
+ context "as type text" do
let(:custom_field) { create(:text_wp_custom_field, name: "Notes") }
before do
- submit_email 'wp_reply_with_text_custom_field.eml', issue: { project: project.identifier }
+ submit_email "wp_reply_with_text_custom_field.eml", issue: { project: project.identifier }
work_package.reload
end
@@ -1314,11 +1314,11 @@ RSpec.describe MailHandler do
end
end
- context 'as type list' do
+ context "as type list" do
let(:custom_field) { create(:list_wp_custom_field, name: "Letters", possible_values: %w(A B C)) }
before do
- submit_email 'wp_reply_with_list_custom_field.eml', issue: { project: project.identifier }
+ submit_email "wp_reply_with_list_custom_field.eml", issue: { project: project.identifier }
work_package.reload
end
@@ -1332,23 +1332,23 @@ RSpec.describe MailHandler do
end
end
- context 'when receiving an auto reply' do
- include_context 'with a reply to a wp mention with quotes above' do
+ context "when receiving an auto reply" do
+ include_context "with a reply to a wp mention with quotes above" do
[
- 'X-Auto-Response-Suppress: OOF',
- 'Auto-Submitted: auto-replied',
- 'Auto-Submitted: Auto-Replied',
- 'Auto-Submitted: auto-generated'
+ "X-Auto-Response-Suppress: OOF",
+ "Auto-Submitted: auto-replied",
+ "Auto-Submitted: Auto-Replied",
+ "Auto-Submitted: auto-generated"
].each do |header|
subject do
raw = File.read(File.join("#{File.dirname(__FILE__)}/../fixtures/mail_handler",
- 'wp_reply_with_quoted_reply_above.eml'))
+ "wp_reply_with_quoted_reply_above.eml"))
raw = "#{header}\n#{raw}"
described_class.receive(raw)
end
- it 'does not update the work package' do
+ it "does not update the work package" do
expect { subject }
.not_to change(Journal, :count)
end
@@ -1357,18 +1357,18 @@ RSpec.describe MailHandler do
end
end
- context 'when sending a reply to a message mail' do
- include_context 'with a reply to a message'
+ context "when sending a reply to a message mail" do
+ include_context "with a reply to a message"
- it 'creates a new message in the name of the sender', :aggregate_failures do
+ it "creates a new message in the name of the sender", :aggregate_failures do
expect(subject)
.to be_a Message
expect(subject.subject)
- .to eql('Response to the original message')
+ .to eql("Response to the original message")
expect(subject.content)
- .to include('Test message')
+ .to include("Test message")
expect(subject.author)
.to eql user
@@ -1381,117 +1381,117 @@ RSpec.describe MailHandler do
end
end
- describe 'truncate emails based on the Setting' do
- context 'with no setting', with_settings: { mail_handler_body_delimiters: '' } do
- include_context 'for wp_on_given_project'
+ describe "truncate emails based on the Setting" do
+ context "with no setting", with_settings: { mail_handler_body_delimiters: "" } do
+ include_context "for wp_on_given_project"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'adds the entire email into the work_package' do
+ it "adds the entire email into the work_package" do
expect(subject.description)
- .to include('---')
+ .to include("---")
expect(subject.description)
- .to include('This paragraph is after the delimiter')
+ .to include("This paragraph is after the delimiter")
end
end
- context 'with a single string', with_settings: { mail_handler_body_delimiters: '---' } do
- include_context 'for wp_on_given_project'
+ context "with a single string", with_settings: { mail_handler_body_delimiters: "---" } do
+ include_context "for wp_on_given_project"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'truncates the email at the delimiter for the work package' do
+ it "truncates the email at the delimiter for the work package" do
expect(subject.description)
- .to include('This paragraph is before delimiters')
+ .to include("This paragraph is before delimiters")
expect(subject.description)
- .to include('--- This line starts with a delimiter')
+ .to include("--- This line starts with a delimiter")
expect(subject.description)
.not_to match(/^---$/)
expect(subject.description)
- .not_to include('This paragraph is after the delimiter')
+ .not_to include("This paragraph is after the delimiter")
end
end
- context 'with a single quoted reply (e.g. reply to a OpenProject email notification)',
- with_settings: { mail_handler_body_delimiters: '--- Reply above. Do not remove this line. ---' } do
- include_context 'with a reply to a wp mention with quotes above'
+ context "with a single quoted reply (e.g. reply to a OpenProject email notification)",
+ with_settings: { mail_handler_body_delimiters: "--- Reply above. Do not remove this line. ---" } do
+ include_context "with a reply to a wp mention with quotes above"
- it_behaves_like 'journal created'
+ it_behaves_like "journal created"
- it 'truncates the email at the delimiter with the quoted reply symbols (>)' do
+ it "truncates the email at the delimiter with the quoted reply symbols (>)" do
expect(subject.notes)
- .to include('An update to the issue by the sender.')
+ .to include("An update to the issue by the sender.")
expect(subject.notes)
- .not_to match(Regexp.escape('--- Reply above. Do not remove this line. ---'))
+ .not_to match(Regexp.escape("--- Reply above. Do not remove this line. ---"))
expect(subject.notes)
- .not_to include('Looks like the JSON api for projects was missed.')
+ .not_to include("Looks like the JSON api for projects was missed.")
end
end
- context 'with multiple strings',
+ context "with multiple strings",
with_settings: { mail_handler_body_delimiters: "---\nBREAK" } do
- include_context 'for wp_on_given_project'
+ include_context "for wp_on_given_project"
- it_behaves_like 'work package created'
+ it_behaves_like "work package created"
- it 'truncates the email at the first delimiter found (BREAK)' do
+ it "truncates the email at the first delimiter found (BREAK)" do
expect(subject.description)
- .to include('This paragraph is before delimiters')
+ .to include("This paragraph is before delimiters")
expect(subject.description)
- .not_to include('BREAK')
+ .not_to include("BREAK")
expect(subject.description)
- .not_to include('This paragraph is between delimiters')
+ .not_to include("This paragraph is between delimiters")
expect(subject.description)
.not_to match(/^---$/)
expect(subject.description)
- .not_to include('This paragraph is after the delimiter')
+ .not_to include("This paragraph is after the delimiter")
end
end
end
- describe 'category' do
- let!(:category) { create(:category, project:, name: 'Foobar') }
+ describe "category" do
+ let!(:category) { create(:category, project:, name: "Foobar") }
- it 'adds a work_package with category' do
- allow(Setting).to receive(:default_language).and_return('en')
+ it "adds a work_package with category" do
+ allow(Setting).to receive(:default_language).and_return("en")
ProjectRole.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :public, true
- work_package = submit_email 'ticket_with_category.eml',
- issue: { project: 'onlinestore' },
- allow_override: ['category'],
- unknown_user: 'create'
+ work_package = submit_email "ticket_with_category.eml",
+ issue: { project: "onlinestore" },
+ allow_override: ["category"],
+ unknown_user: "create"
work_package_created(work_package)
expect(work_package.category).to eq(category)
end
end
end
- describe '#cleanup_body' do
+ describe "#cleanup_body" do
let(:input) do
"Subject:foo\nDescription:bar\n" \
">>> myserver.example.org 2016-01-27 15:56 >>>\n... (Email-Body) ..."
end
let(:handler) { described_class.send :new }
- context 'with regex delimiter' do
+ context "with regex delimiter" do
before do
- allow(Setting).to receive(:mail_handler_body_delimiter_regex).and_return('>>>.+?>>>.*')
+ allow(Setting).to receive(:mail_handler_body_delimiter_regex).and_return(">>>.+?>>>.*")
allow(handler).to receive(:plain_text_body).and_return(input)
allow(handler).to receive(:cleaned_up_text_body).and_call_original
end
- it 'removes the irrelevant lines' do
+ it "removes the irrelevant lines" do
expect(handler.send(:cleaned_up_text_body)).to eq("Subject:foo\nDescription:bar")
expect(handler).to have_received(:cleaned_up_text_body)
end
diff --git a/spec/models/query/results_sums_integration_spec.rb b/spec/models/query/results_sums_integration_spec.rb
index 19c978eb391..8f659f0574c 100644
--- a/spec/models/query/results_sums_integration_spec.rb
+++ b/spec/models/query/results_sums_integration_spec.rb
@@ -26,16 +26,16 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe Query::Results, 'sums' do
+RSpec.describe Query::Results, "sums" do
let(:project) do
create(:project) do |p|
p.work_package_custom_fields << int_cf
p.work_package_custom_fields << float_cf
end
end
- let(:estimated_hours_column) { query.displayable_columns.detect { |c| c.name.to_s == 'estimated_hours' } }
+ let(:estimated_hours_column) { query.displayable_columns.detect { |c| c.name.to_s == "estimated_hours" } }
let(:int_cf_column) { query.displayable_columns.detect { |c| c.name.to_s == int_cf.column_name } }
let(:float_cf_column) { query.displayable_columns.detect { |c| c.name.to_s == float_cf.column_name } }
let(:material_costs_column) { query.displayable_columns.detect { |c| c.name.to_s == "material_costs" } }
@@ -152,8 +152,8 @@ RSpec.describe Query::Results, 'sums' do
login_as(current_user)
end
- describe '#all_total_sums' do
- it 'is a hash of all summable columns' do
+ describe "#all_total_sums" do
+ it "is a hash of all summable columns" do
expect(query_results.all_total_sums)
.to eql(estimated_hours_column => 20.0,
int_cf_column => 30,
@@ -165,12 +165,12 @@ RSpec.describe Query::Results, 'sums' do
story_points_column => 21)
end
- context 'when filtering' do
+ context "when filtering" do
before do
- query.add_filter('assigned_to_id', '=', [current_user.id.to_s])
+ query.add_filter("assigned_to_id", "=", [current_user.id.to_s])
end
- it 'is a hash of all summable columns and includes only the work packages matching the filter' do
+ it "is a hash of all summable columns and includes only the work packages matching the filter" do
expect(query_results.all_total_sums)
.to eql(estimated_hours_column => 10.0,
int_cf_column => 20,
@@ -184,11 +184,11 @@ RSpec.describe Query::Results, 'sums' do
end
end
- describe '#all_sums_for_group' do
- context 'when grouped by assigned_to' do
+ describe "#all_sums_for_group" do
+ context "when grouped by assigned_to" do
let(:group_by) { :assigned_to }
- it 'is a hash of sums grouped by user values (and nil) and grouped columns' do
+ it "is a hash of sums grouped by user values (and nil) and grouped columns" do
expect(query_results.all_group_sums)
.to eql(current_user => { estimated_hours_column => 10.0,
int_cf_column => 20,
@@ -208,12 +208,12 @@ RSpec.describe Query::Results, 'sums' do
story_points_column => 7 })
end
- context 'when filtering' do
+ context "when filtering" do
before do
- query.add_filter('responsible_id', '=', [current_user.id.to_s])
+ query.add_filter("responsible_id", "=", [current_user.id.to_s])
end
- it 'is a hash of sums grouped by user values and grouped columns' do
+ it "is a hash of sums grouped by user values and grouped columns" do
expect(query_results.all_group_sums)
.to eql(current_user => { estimated_hours_column => 5.0,
int_cf_column => 10,
@@ -227,10 +227,10 @@ RSpec.describe Query::Results, 'sums' do
end
end
- context 'when grouped by done_ratio' do
+ context "when grouped by done_ratio" do
let(:group_by) { :done_ratio }
- it 'is a hash of sums grouped by done_ratio values and grouped columns' do
+ it "is a hash of sums grouped by done_ratio values and grouped columns" do
expect(query_results.all_group_sums)
.to eql(50 => { estimated_hours_column => 10.0,
int_cf_column => 20,
@@ -250,12 +250,12 @@ RSpec.describe Query::Results, 'sums' do
story_points_column => 7 })
end
- context 'when filtering' do
+ context "when filtering" do
before do
- query.add_filter('responsible_id', '=', [current_user.id.to_s])
+ query.add_filter("responsible_id", "=", [current_user.id.to_s])
end
- it 'is a hash of sums grouped by done_ratio values and grouped columns' do
+ it "is a hash of sums grouped by done_ratio values and grouped columns" do
expect(query_results.all_group_sums)
.to eql(50 => { estimated_hours_column => 5.0,
int_cf_column => 10,
diff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rb
index 233fb9a7e03..65e48f508d2 100644
--- a/spec/services/work_packages/set_attributes_service_spec.rb
+++ b/spec/services/work_packages/set_attributes_service_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe WorkPackages::SetAttributesService,
type: :model do
@@ -72,7 +72,7 @@ RSpec.describe WorkPackages::SetAttributesService,
contract_class: mock_contract)
end
- shared_examples_for 'service call' do
+ shared_examples_for "service call" do
subject do
allow(work_package)
.to receive(:save)
@@ -80,11 +80,11 @@ RSpec.describe WorkPackages::SetAttributesService,
instance.call(call_attributes)
end
- it 'is successful' do
+ it "is successful" do
expect(subject).to be_success
end
- it 'sets the value' do
+ it "sets the value" do
next if !defined?(expected_attributes) || expected_attributes.blank?
subject
@@ -94,25 +94,25 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- it 'does not persist the work_package' do
+ it "does not persist the work_package" do
subject
expect(work_package)
.not_to have_received(:save)
end
- it 'has no errors' do
+ it "has no errors" do
expect(subject.errors).to be_empty
end
- context 'when the contract does not validate' do
+ context "when the contract does not validate" do
let(:contract_valid) { false }
- it 'is unsuccessful' do
+ it "is unsuccessful" do
expect(subject).not_to be_success
end
- it 'does not persist the changes' do
+ it "does not persist the changes" do
subject
expect(work_package)
@@ -127,28 +127,28 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when updating subject before calling the service' do
+ context "when updating subject before calling the service" do
let(:call_attributes) { {} }
- let(:expected_attributes) { { subject: 'blubs blubs' } }
+ let(:expected_attributes) { { subject: "blubs blubs" } }
before do
work_package.attributes = expected_attributes
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when updating subject via attributes' do
+ context "when updating subject via attributes" do
let(:call_attributes) { expected_attributes }
- let(:expected_attributes) { { subject: 'blubs blubs' } }
+ let(:expected_attributes) { { subject: "blubs blubs" } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'for estimated_hours' do
- context 'with the status being used for done_ratio computations',
- with_settings: { work_package_done_ratio: 'status' } do
- context 'when the work package has estimated hours and remaining hours set along with a done ratio' do
+ context "for estimated_hours" do
+ context "with the status being used for done_ratio computations",
+ with_settings: { work_package_done_ratio: "status" } do
+ context "when the work package has estimated hours and remaining hours set along with a done ratio" do
let!(:status) { create(:status, default_done_ratio: 50) }
before do
@@ -158,21 +158,21 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.send(:clear_changes_information)
end
- context 'and estimated_hours are subsequently unset' do
+ context "and estimated_hours are subsequently unset" do
let(:call_attributes) { { estimated_hours: nil } }
let(:expected_attributes) { { estimated_hours: nil, remaining_hours: nil, done_ratio: 50 } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'and estimated_hours are subsequently modified' do
+ context "and estimated_hours are subsequently modified" do
let(:call_attributes) { { estimated_hours: 5.0 } }
let(:expected_attributes) { { estimated_hours: 5.0, remaining_hours: 2.5, done_ratio: 50 } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'and the status is subsequently changed' do
+ context "and the status is subsequently changed" do
let!(:other_status) { create(:status, default_done_ratio: 70) }
let(:call_attributes) { {} }
let(:expected_attributes) { { estimated_hours: 10.0, remaining_hours: 3.0 } }
@@ -181,15 +181,15 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.status = other_status
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
end
end
- context 'for done_ratio' do
- context 'with the status being used for done_ratio computations',
- with_settings: { work_package_done_ratio: 'status' } do
+ context "for done_ratio" do
+ context "with the status being used for done_ratio computations",
+ with_settings: { work_package_done_ratio: "status" } do
let!(:status) { create(:status, default_done_ratio: 50) }
let(:call_attributes) { { estimated_hours: 10.0 } }
# remaining hours computed from estimated hours and the status's default done ratio
@@ -199,49 +199,49 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.status = status
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
describe 'is "unset"' do
- context 'when estimated_hours is unset' do
+ context "when estimated_hours is unset" do
let(:call_attributes) { { estimated_hours: nil } }
let(:expected_attributes) do
{ estimated_hours: nil, done_ratio: 0 }
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when remaining_hours is unset' do
+ context "when remaining_hours is unset" do
let(:call_attributes) { { remaining_hours: nil } }
let(:expected_attributes) do
{ remaining_hours: nil, done_ratio: 0 }
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when both estimated_hours and remaining_hours are unset' do
+ context "when both estimated_hours and remaining_hours are unset" do
let(:call_attributes) { { estimated_hours: nil, remaining_hours: nil } }
let(:expected_attributes) do
{ estimated_hours: nil, remaining_hours: nil, done_ratio: 0 }
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
- context 'when both estimated_hours and remaining_hours are set' do
+ context "when both estimated_hours and remaining_hours are set" do
let(:call_attributes) { { estimated_hours: 10.0, remaining_hours: 5.0 } }
let(:expected_attributes) do
{ estimated_hours: 10.0, remaining_hours: 5.0, done_ratio: 50 }
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
- context 'for status' do
+ context "for status" do
let(:default_status) { build_stubbed(:default_status) }
let(:other_status) { build_stubbed(:status) }
let(:new_statuses) { [other_status, default_status] }
@@ -252,7 +252,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return(default_status)
end
- context 'with no value set before for a new work package' do
+ context "with no value set before for a new work package" do
let(:call_attributes) { {} }
let(:expected_attributes) { { status: default_status } }
let(:work_package) { new_work_package }
@@ -261,39 +261,39 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.status = nil
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'with an invalid value that is not part of the type.statuses for a new work package' do
+ context "with an invalid value that is not part of the type.statuses for a new work package" do
let(:invalid_status) { create(:status) }
let(:type) { create(:type) }
let(:call_attributes) { { status: invalid_status, type: } }
let(:expected_attributes) { { status: default_status, type: } }
let(:work_package) { new_work_package }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'with valid value and without a type present for a new work package' do
+ context "with valid value and without a type present for a new work package" do
let(:status) { create(:status) }
let(:call_attributes) { { status:, type: nil } }
let(:expected_attributes) { { status: } }
let(:work_package) { new_work_package }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'with a valid value that is part of the type.statuses for a new work package' do
+ context "with a valid value that is part of the type.statuses for a new work package" do
let(:type) { create(:type) }
let(:status) { create(:status, workflow_for_type: type) }
let(:call_attributes) { { status:, type: } }
let(:expected_attributes) { { status:, type: } }
let(:work_package) { new_work_package }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'with no value set on existing work package' do
+ context "with no value set on existing work package" do
let(:call_attributes) { {} }
let(:expected_attributes) { {} }
@@ -301,8 +301,8 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.status = nil
end
- it_behaves_like 'service call' do
- it 'stays nil' do
+ it_behaves_like "service call" do
+ it "stays nil" do
subject
expect(work_package.status)
@@ -311,7 +311,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when updating status before calling the service' do
+ context "when updating status before calling the service" do
let(:call_attributes) { {} }
let(:expected_attributes) { { status: other_status } }
@@ -319,26 +319,26 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.attributes = expected_attributes
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when updating status via attributes' do
+ context "when updating status via attributes" do
let(:call_attributes) { expected_attributes }
let(:expected_attributes) { { status: other_status } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
- context 'for author' do
+ context "for author" do
let(:other_user) { build_stubbed(:user) }
- context 'with no value set before for a new work package' do
+ context "with no value set before for a new work package" do
let(:call_attributes) { {} }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the service's author" do
subject
@@ -346,16 +346,16 @@ RSpec.describe WorkPackages::SetAttributesService,
.to eql user
end
- it 'notes the author to be system changed' do
+ it "notes the author to be system changed" do
subject
- expect(work_package.changed_by_system['author_id'])
+ expect(work_package.changed_by_system["author_id"])
.to eql [nil, user.id]
end
end
end
- context 'with no value set on existing work package' do
+ context "with no value set on existing work package" do
let(:call_attributes) { {} }
let(:expected_attributes) { {} }
@@ -363,8 +363,8 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.author = nil
end
- it_behaves_like 'service call' do
- it 'stays nil' do
+ it_behaves_like "service call" do
+ it "stays nil" do
subject
expect(work_package.author)
@@ -373,7 +373,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when updating author before calling the service' do
+ context "when updating author before calling the service" do
let(:call_attributes) { {} }
let(:expected_attributes) { { author: other_user } }
@@ -381,20 +381,20 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.attributes = expected_attributes
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when updating author via attributes' do
+ context "when updating author via attributes" do
let(:call_attributes) { expected_attributes }
let(:expected_attributes) { { author: other_user } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
- context 'with the actual contract' do
+ context "with the actual contract" do
let(:invalid_wp) do
- build(:work_package, subject: '').tap do |wp|
+ build(:work_package, subject: "").tap do |wp|
wp.save!(validate: false)
end
end
@@ -405,22 +405,22 @@ RSpec.describe WorkPackages::SetAttributesService,
contract_class:)
end
- context 'with a currently invalid subject' do
+ context "with a currently invalid subject" do
let(:call_attributes) { expected_attributes }
- let(:expected_attributes) { { subject: 'ABC' } }
+ let(:expected_attributes) { { subject: "ABC" } }
let(:contract_valid) { true }
subject { instance.call(call_attributes) }
- it 'is successful' do
+ it "is successful" do
expect(subject).to be_success
expect(subject.errors).to be_empty
end
end
end
- context 'for start_date & due_date & duration' do
- context 'with a parent' do
+ context "for start_date & due_date & duration" do
+ context "with a parent" do
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
let(:parent) do
@@ -431,10 +431,10 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:parent_start_date) { Time.zone.today - 5.days }
let(:parent_due_date) { Time.zone.today + 10.days }
- context 'with the parent having dates and not providing own dates' do
+ context "with the parent having dates and not providing own dates" do
let(:call_attributes) { { parent: } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent`s start_date" do
subject
@@ -451,8 +451,8 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates and not providing own dates and with the parent`s' \
- 'soonest_start being before the start_date (e.g. because the parent is manually scheduled)' do
+ context "with the parent having dates and not providing own dates and with the parent`s" \
+ "soonest_start being before the start_date (e.g. because the parent is manually scheduled)" do
let(:call_attributes) { { parent: } }
before do
@@ -461,7 +461,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return(parent_start_date + 3.days)
end
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent`s start_date" do
subject
@@ -478,11 +478,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having start date (no due) and not providing own dates' do
+ context "with the parent having start date (no due) and not providing own dates" do
let(:call_attributes) { { parent: } }
let(:parent_due_date) { nil }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent`s start_date" do
subject
@@ -499,11 +499,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having due date (no start) and not providing own dates' do
+ context "with the parent having due date (no start) and not providing own dates" do
let(:call_attributes) { { parent: } }
let(:parent_start_date) { nil }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to nil" do
subject
@@ -520,10 +520,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing own dates' do
+ context "with the parent having dates but providing own dates" do
let(:call_attributes) { { parent:, start_date: Time.zone.today, due_date: Time.zone.today + 1.day } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the provided date" do
subject
@@ -540,10 +540,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing own start_date' do
+ context "with the parent having dates but providing own start_date" do
let(:call_attributes) { { parent:, start_date: Time.zone.today } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the provided date" do
subject
@@ -560,10 +560,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing own due_date' do
+ context "with the parent having dates but providing own due_date" do
let(:call_attributes) { { parent:, due_date: Time.zone.today + 4.days } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent's start date" do
subject
@@ -580,10 +580,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing own empty start_date' do
+ context "with the parent having dates but providing own empty start_date" do
let(:call_attributes) { { parent:, start_date: nil } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to nil" do
subject
@@ -600,10 +600,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing own empty due_date' do
+ context "with the parent having dates but providing own empty due_date" do
let(:call_attributes) { { parent:, due_date: nil } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent's start date" do
subject
@@ -620,10 +620,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing a start date that is before parent`s due date`' do
+ context "with the parent having dates but providing a start date that is before parent`s due date`" do
let(:call_attributes) { { parent:, start_date: parent_due_date - 4.days } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the provided date" do
subject
@@ -640,10 +640,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing a start date that is after the parent`s due date`' do
+ context "with the parent having dates but providing a start date that is after the parent`s due date`" do
let(:call_attributes) { { parent:, start_date: parent_due_date + 1.day } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the provided date" do
subject
@@ -660,10 +660,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with the parent having dates but providing a due date that is before the parent`s start date`' do
+ context "with the parent having dates but providing a due date that is before the parent`s start date`" do
let(:call_attributes) { { parent:, due_date: parent_start_date - 3.days } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "leaves the start date empty" do
subject
@@ -680,11 +680,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with providing a parent_id that is invalid' do
+ context "with providing a parent_id that is invalid" do
let(:call_attributes) { { parent_id: -1 } }
let(:work_package) { build_stubbed(:work_package, start_date: Time.zone.today, due_date: Time.zone.today + 2.days) }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start_date to the parent`s start_date" do
subject
@@ -702,13 +702,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with no value set for a new work package and with default setting active',
+ context "with no value set for a new work package and with default setting active",
with_settings: { work_package_startdate_is_adddate: true } do
let(:call_attributes) { {} }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the start date to today" do
subject
@@ -723,7 +723,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.to be_nil
end
- context 'when the work package type is milestone' do
+ context "when the work package type is milestone" do
before do
work_package.type = milestone_type
end
@@ -738,14 +738,14 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with a value set for a new work package and with default setting active',
+ context "with a value set for a new work package and with default setting active",
with_settings: { work_package_startdate_is_adddate: true } do
let(:call_attributes) { { start_date: Time.zone.today + 1.day } }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
- it_behaves_like 'service call' do
- it 'stays that value' do
+ it_behaves_like "service call" do
+ it "stays that value" do
subject
expect(work_package.start_date)
@@ -759,7 +759,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.to be_nil
end
- context 'when the work package type is milestone' do
+ context "when the work package type is milestone" do
before do
work_package.type = milestone_type
end
@@ -774,20 +774,20 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with date values set to the same date on a new work package' do
+ context "with date values set to the same date on a new work package" do
let(:call_attributes) { { start_date: Time.zone.today, due_date: Time.zone.today } }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
- it_behaves_like 'service call' do
- it 'sets the start date value' do
+ it_behaves_like "service call" do
+ it "sets the start date value" do
subject
expect(work_package.start_date)
.to eq(Time.zone.today)
end
- it 'sets the due date value' do
+ it "sets the due date value" do
subject
expect(work_package.due_date)
@@ -803,20 +803,20 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with date values set on a new work package' do
+ context "with date values set on a new work package" do
let(:call_attributes) { { start_date: Time.zone.today, due_date: Time.zone.today + 5.days } }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
- it_behaves_like 'service call' do
- it 'sets the start date value' do
+ it_behaves_like "service call" do
+ it "sets the start date value" do
subject
expect(work_package.start_date)
.to eq(Time.zone.today)
end
- it 'sets the due date value' do
+ it "sets the due date value" do
subject
expect(work_package.due_date)
@@ -832,20 +832,20 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with start date changed' do
+ context "with start date changed" do
let(:work_package) { build_stubbed(:work_package, start_date: Time.zone.today, due_date: Time.zone.today + 5.days) }
let(:call_attributes) { { start_date: Time.zone.today + 1.day } }
let(:expected_attributes) { {} }
- it_behaves_like 'service call' do
- it 'sets the start date value' do
+ it_behaves_like "service call" do
+ it "sets the start date value" do
subject
expect(work_package.start_date)
.to eq(Time.zone.today + 1.day)
end
- it 'keeps the due date value' do
+ it "keeps the due date value" do
subject
expect(work_package.due_date)
@@ -861,20 +861,20 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with due date changed' do
+ context "with due date changed" do
let(:work_package) { build_stubbed(:work_package, start_date: Time.zone.today, due_date: Time.zone.today + 5.days) }
let(:call_attributes) { { due_date: Time.zone.today + 1.day } }
let(:expected_attributes) { {} }
- it_behaves_like 'service call' do
- it 'keeps the start date value' do
+ it_behaves_like "service call" do
+ it "keeps the start date value" do
subject
expect(work_package.start_date)
.to eq(Time.zone.today)
end
- it 'sets the due date value' do
+ it "sets the due date value" do
subject
expect(work_package.due_date)
@@ -890,7 +890,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with start date nilled' do
+ context "with start date nilled" do
let(:traits) { [] }
let(:work_package) do
build_stubbed(:work_package, *traits, start_date: Time.zone.today, due_date: Time.zone.today + 5.days)
@@ -898,15 +898,15 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:call_attributes) { { start_date: nil } }
let(:expected_attributes) { {} }
- it_behaves_like 'service call' do
- it 'sets the start date to nil' do
+ it_behaves_like "service call" do
+ it "sets the start date to nil" do
subject
expect(work_package.start_date)
.to be_nil
end
- it 'keeps the due date value' do
+ it "keeps the due date value" do
subject
expect(work_package.due_date)
@@ -920,7 +920,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.to be_nil
end
- context 'when the work package type is milestone' do
+ context "when the work package type is milestone" do
let(:traits) { [:is_milestone] }
it "sets the duration to 1" do
@@ -933,7 +933,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with due date nilled' do
+ context "with due date nilled" do
let(:traits) { [] }
let(:work_package) do
build_stubbed(:work_package, *traits, start_date: Time.zone.today, due_date: Time.zone.today + 5.days)
@@ -941,15 +941,15 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:call_attributes) { { due_date: nil } }
let(:expected_attributes) { {} }
- it_behaves_like 'service call' do
- it 'keeps the start date' do
+ it_behaves_like "service call" do
+ it "keeps the start date" do
subject
expect(work_package.start_date)
.to eq(Time.zone.today)
end
- it 'nils the due date' do
+ it "nils the due date" do
subject
expect(work_package.due_date)
@@ -963,7 +963,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.to be_nil
end
- context 'when the work package type is milestone' do
+ context "when the work package type is milestone" do
let(:traits) { [:is_milestone] }
it "sets the duration to 1" do
@@ -976,7 +976,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when deriving one value from the two others' do
+ context "when deriving one value from the two others" do
# rubocop:disable Layout/ExtraSpacing, Layout/SpaceInsideArrayPercentLiteral, Layout/SpaceInsidePercentLiteralDelimiters, Layout/LineLength
all_possible_scenarios = [
{ initial: %i[start_date due_date duration], set: %i[], expected: {} },
@@ -1127,7 +1127,7 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:work_package) { build_stubbed(:work_package, work_package_attributes) }
let(:call_attributes) { nil_attributes.slice(*nilled).merge(set_attributes.slice(*set)) }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
if expected_change
it "changes #{expected_change.inspect}" do
expect { subject }
@@ -1153,7 +1153,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with non-working days' do
+ context "with non-working days" do
shared_let(:working_days) { week_with_saturday_and_sunday_as_weekend }
let(:monday) { Time.zone.today.beginning_of_week }
let(:tuesday) { monday + 1.day }
@@ -1163,13 +1163,13 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:next_monday) { monday + 7.days }
let(:next_tuesday) { monday + 8.days }
- context 'when start date changes' do
+ context "when start date changes" do
let(:work_package) do
build_stubbed(:work_package, start_date: monday, due_date: next_monday)
end
let(:call_attributes) { { start_date: wednesday } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the duration without including non-working days" do
expect { subject }
.to change(work_package, :duration)
@@ -1179,13 +1179,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when due date changes' do
+ context "when due date changes" do
let(:work_package) do
build_stubbed(:work_package, start_date: monday, due_date: next_monday)
end
let(:call_attributes) { { due_date: monday + 14.days } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the duration without including non-working days" do
expect { subject }
.to change(work_package, :duration)
@@ -1195,13 +1195,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when duration changes' do
+ context "when duration changes" do
let(:work_package) do
build_stubbed(:work_package, start_date: monday, due_date: next_monday)
end
let(:call_attributes) { { duration: "13" } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the due date from start date and duration and skips the non-working days" do
expect { subject }
.to change(work_package, :due_date)
@@ -1211,13 +1211,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when duration and end_date both change' do
+ context "when duration and end_date both change" do
let(:work_package) do
build_stubbed(:work_package, start_date: monday, due_date: next_monday)
end
let(:call_attributes) { { due_date: next_tuesday, duration: 4 } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the start date and skips the non-working days" do
expect { subject }
.to change(work_package, :start_date)
@@ -1233,7 +1233,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { ignore_non_working_days: true } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the due date from start date and duration to include the non-working days" do
# start_date and duration are checked too to ensure they did not change
expect { subject }
@@ -1250,7 +1250,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { ignore_non_working_days: false } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the due date from start date and duration to skip the non-working days" do
# start_date and duration are checked too to ensure they did not change
expect { subject }
@@ -1267,7 +1267,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { ignore_non_working_days: false } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the start date to be on next working day, and due date to accommodate duration" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1276,13 +1276,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with a new work package' do
+ context "with a new work package" do
let(:work_package) do
build(:work_package, start_date: monday - 1.day, due_date: friday, ignore_non_working_days: true)
end
let(:call_attributes) { { ignore_non_working_days: false, duration: 6 } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the start date to be on next working day, and due date to accommodate duration" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1299,7 +1299,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { ignore_non_working_days: false } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the finish date to be on next working day" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1315,7 +1315,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { ignore_non_working_days: false, due_date: nil } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "does not recompute the due date and nilifies the due date and the duration instead" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1331,7 +1331,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { due_date: wednesday, ignore_non_working_days: false } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the start date from due date and duration to skip the non-working days" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1347,7 +1347,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
let(:call_attributes) { { start_date: friday, due_date: next_tuesday, ignore_non_working_days: false } }
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "updates the duration from start date and due date" do
expect { subject }
.to change { work_package.slice(:start_date, :due_date, :duration) }
@@ -1359,7 +1359,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'for priority' do
+ context "for priority" do
let(:default_priority) { build_stubbed(:priority) }
let(:other_priority) { build_stubbed(:priority) }
@@ -1374,7 +1374,7 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return(default_priority)
end
- context 'with no value set before for a new work package' do
+ context "with no value set before for a new work package" do
let(:call_attributes) { {} }
let(:expected_attributes) { {} }
let(:work_package) { new_work_package }
@@ -1383,7 +1383,7 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.priority = nil
end
- it_behaves_like 'service call' do
+ it_behaves_like "service call" do
it "sets the default priority" do
subject
@@ -1393,7 +1393,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when updating priority before calling the service' do
+ context "when updating priority before calling the service" do
let(:call_attributes) { {} }
let(:expected_attributes) { { priority: other_priority } }
@@ -1401,94 +1401,94 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.attributes = expected_attributes
end
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
- context 'when updating priority via attributes' do
+ context "when updating priority via attributes" do
let(:call_attributes) { expected_attributes }
let(:expected_attributes) { { priority: other_priority } }
- it_behaves_like 'service call'
+ it_behaves_like "service call"
end
end
- context 'when switching the type' do
+ context "when switching the type" do
let(:target_type) { build_stubbed(:type, is_milestone:) }
let(:work_package) do
build_stubbed(:work_package, start_date: Time.zone.today - 6.days, due_date: Time.zone.today)
end
- context 'to a non-milestone type' do
+ context "to a non-milestone type" do
let(:is_milestone) { false }
- it 'keeps the start date' do
+ it "keeps the start date" do
instance.call(type: target_type)
expect(work_package.start_date)
.to eql Time.zone.today - 6.days
end
- it 'keeps the due date' do
+ it "keeps the due date" do
instance.call(type: target_type)
expect(work_package.due_date)
.to eql Time.zone.today
end
- it 'keeps duration' do
+ it "keeps duration" do
instance.call(type: target_type)
expect(work_package.duration).to be 7
end
end
- context 'to a milestone type' do
+ context "to a milestone type" do
let(:is_milestone) { true }
- context 'with both dates set' do
- it 'sets the start date to the due date' do
+ context "with both dates set" do
+ it "sets the start date to the due date" do
instance.call(type: target_type)
expect(work_package.start_date).to eq work_package.due_date
end
- it 'keeps the due date' do
+ it "keeps the due date" do
instance.call(type: target_type)
expect(work_package.due_date).to eql Time.zone.today
end
- it 'sets the duration to 1 (to be changed to 0 later on)' do
+ it "sets the duration to 1 (to be changed to 0 later on)" do
instance.call(type: target_type)
expect(work_package.duration).to eq 1
end
end
- context 'with only the start date set' do
+ context "with only the start date set" do
let(:work_package) do
build_stubbed(:work_package, start_date: Time.zone.today - 6.days)
end
- it 'keeps the start date' do
+ it "keeps the start date" do
instance.call(type: target_type)
expect(work_package.start_date).to eql Time.zone.today - 6.days
end
- it 'set the due date to the start date' do
+ it "set the due date to the start date" do
instance.call(type: target_type)
expect(work_package.due_date).to eql work_package.start_date
end
- it 'keeps the duration at 1 (to be changed to 0 later on)' do
+ it "keeps the duration at 1 (to be changed to 0 later on)" do
instance.call(type: target_type)
expect(work_package.duration).to eq 1
end
- context 'with a new work package' do
+ context "with a new work package" do
let(:work_package) do
build(:work_package, start_date: Time.zone.today - 6.days)
end
@@ -1498,15 +1498,15 @@ RSpec.describe WorkPackages::SetAttributesService,
instance.call(call_attributes)
end
- it 'keeps the start date' do
+ it "keeps the start date" do
expect(work_package.start_date).to eq Time.zone.today - 6.days
end
- it 'set the due date to the start date' do
+ it "set the due date to the start date" do
expect(work_package.due_date).to eq work_package.start_date
end
- it 'keeps the duration at 1 (to be changed to 0 later on)' do
+ it "keeps the duration at 1 (to be changed to 0 later on)" do
expect(work_package.duration).to eq 1
end
end
@@ -1514,7 +1514,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when switching the project' do
+ context "when switching the project" do
let(:new_project) { build_stubbed(:project) }
let(:version) { build_stubbed(:version) }
let(:category) { build_stubbed(:category) }
@@ -1553,14 +1553,14 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return(new_types)
end
- shared_examples_for 'updating the project' do
- context 'for version' do
+ shared_examples_for "updating the project" do
+ context "for version" do
before do
work_package.version = version
end
- context 'when not shared in new project' do
- it 'sets to nil' do
+ context "when not shared in new project" do
+ it "sets to nil" do
subject
expect(work_package.version)
@@ -1568,10 +1568,10 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when shared in the new project' do
+ context "when shared in the new project" do
let(:new_versions) { [version] }
- it 'keeps the version' do
+ it "keeps the version" do
subject
expect(work_package.version)
@@ -1580,13 +1580,13 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'for category' do
+ context "for category" do
before do
work_package.category = category
end
- context 'when no category of same name in new project' do
- it 'sets to nil' do
+ context "when no category of same name in new project" do
+ it "sets to nil" do
subject
expect(work_package.category)
@@ -1594,7 +1594,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when category of same name in new project' do
+ context "when category of same name in new project" do
before do
allow(new_project_categories)
.to receive(:find_by)
@@ -1602,25 +1602,25 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return new_category
end
- it 'uses the equally named category' do
+ it "uses the equally named category" do
subject
expect(work_package.category)
.to eql new_category
end
- it 'adds change to system changes' do
+ it "adds change to system changes" do
subject
- expect(work_package.changed_by_system['category_id'])
+ expect(work_package.changed_by_system["category_id"])
.to eql [nil, new_category.id]
end
end
end
- context 'for type' do
- context 'when current type exists in new project' do
- it 'leaves the type' do
+ context "for type" do
+ context "when current type exists in new project" do
+ it "leaves the type" do
subject
expect(work_package.type)
@@ -1628,69 +1628,69 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when a default type exists in new project' do
+ context "when a default type exists in new project" do
let(:new_types) { [other_type, default_type] }
- it 'uses the first type (by position)' do
+ it "uses the first type (by position)" do
subject
expect(work_package.type)
.to eql other_type
end
- it 'adds change to system changes' do
+ it "adds change to system changes" do
subject
- expect(work_package.changed_by_system['type_id'])
+ expect(work_package.changed_by_system["type_id"])
.to eql [initial_type.id, other_type.id]
end
end
- context 'when no default type exists in new project' do
+ context "when no default type exists in new project" do
let(:new_types) { [other_type, yet_another_type] }
- it 'uses the first type (by position)' do
+ it "uses the first type (by position)" do
subject
expect(work_package.type)
.to eql other_type
end
- it 'adds change to system changes' do
+ it "adds change to system changes" do
subject
- expect(work_package.changed_by_system['type_id'])
+ expect(work_package.changed_by_system["type_id"])
.to eql [initial_type.id, other_type.id]
end
end
- context 'when also setting a new type via attributes' do
+ context "when also setting a new type via attributes" do
let(:expected_attributes) { { project: new_project, type: yet_another_type } }
- it 'sets the desired type' do
+ it "sets the desired type" do
subject
expect(work_package.type)
.to eql yet_another_type
end
- it 'does not set the change to system changes' do
+ it "does not set the change to system changes" do
subject
expect(work_package.changed_by_system)
- .not_to include('type_id')
+ .not_to include("type_id")
end
end
end
- context 'for parent' do
+ context "for parent" do
let(:parent_work_package) { build_stubbed(:work_package, project:) }
let(:work_package) do
build_stubbed(:work_package, project:, type: initial_type, parent: parent_work_package)
end
- context 'with cross project relations allowed', with_settings: { cross_project_work_package_relations: true } do
- it 'keeps the parent' do
+ context "with cross project relations allowed", with_settings: { cross_project_work_package_relations: true } do
+ it "keeps the parent" do
expect(subject)
.to be_success
@@ -1699,8 +1699,8 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'with cross project relations disabled', with_settings: { cross_project_work_package_relations: false } do
- it 'deletes the parent' do
+ context "with cross project relations disabled", with_settings: { cross_project_work_package_relations: false } do
+ it "deletes the parent" do
expect(subject)
.to be_success
@@ -1711,7 +1711,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when updating project before calling the service' do
+ context "when updating project before calling the service" do
let(:call_attributes) { {} }
let(:expected_attributes) { { project: new_project } }
@@ -1719,38 +1719,38 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.attributes = expected_attributes
end
- it_behaves_like 'service call' do
- it_behaves_like 'updating the project'
+ it_behaves_like "service call" do
+ it_behaves_like "updating the project"
end
end
- context 'when updating project via attributes' do
+ context "when updating project via attributes" do
let(:call_attributes) { expected_attributes }
let(:expected_attributes) { { project: new_project } }
- it_behaves_like 'service call' do
- it_behaves_like 'updating the project'
+ it_behaves_like "service call" do
+ it_behaves_like "updating the project"
end
end
end
- context 'for custom fields' do
+ context "for custom fields" do
subject { instance.call(call_attributes) }
- context 'for non existing fields' do
- let(:call_attributes) { { custom_field_891: '1' } } # rubocop:disable Naming/VariableNumber
+ context "for non existing fields" do
+ let(:call_attributes) { { custom_field_891: "1" } } # rubocop:disable Naming/VariableNumber
before do
subject
end
- it 'is successful' do
+ it "is successful" do
expect(subject).to be_success
end
end
end
- context 'when switching back to automatic scheduling' do
+ context "when switching back to automatic scheduling" do
let(:work_package) do
wp = build_stubbed(:work_package,
project:,
@@ -1771,11 +1771,11 @@ RSpec.describe WorkPackages::SetAttributesService,
let(:expected_attributes) { {} }
let(:soonest_start) { Time.zone.today + 1.day }
- context 'when the soonest start date is later than the current start date' do
+ context "when the soonest start date is later than the current start date" do
let(:soonest_start) { Time.zone.today + 3.days }
- it_behaves_like 'service call' do
- it 'sets the start date to the soonest possible start date' do
+ it_behaves_like "service call" do
+ it "sets the start date to the soonest possible start date" do
subject
expect(work_package.start_date).to eql(Time.zone.today + 3.days)
@@ -1784,7 +1784,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when the soonest start date is a non-working day' do
+ context "when the soonest start date is a non-working day" do
shared_let(:working_days) { week_with_saturday_and_sunday_as_weekend }
let(:saturday) { Time.zone.today.beginning_of_week.next_occurring(:saturday) }
let(:next_monday) { saturday.next_occurring(:monday) }
@@ -1794,8 +1794,8 @@ RSpec.describe WorkPackages::SetAttributesService,
work_package.ignore_non_working_days = false
end
- it_behaves_like 'service call' do
- it 'sets the start date to the soonest possible start date being a working day' do
+ it_behaves_like "service call" do
+ it "sets the start date to the soonest possible start date being a working day" do
subject
expect(work_package).to have_attributes(
@@ -1806,11 +1806,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when the soonest start date is before the current start date' do
+ context "when the soonest start date is before the current start date" do
let(:soonest_start) { Time.zone.today - 3.days }
- it_behaves_like 'service call' do
- it 'sets the start date to the soonest possible start date' do
+ it_behaves_like "service call" do
+ it "sets the start date to the soonest possible start date" do
subject
expect(work_package.start_date).to eql(soonest_start)
@@ -1819,11 +1819,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when the soonest start date is nil' do
+ context "when the soonest start date is nil" do
let(:soonest_start) { nil }
- it_behaves_like 'service call' do
- it 'sets the start date to the soonest possible start date' do
+ it_behaves_like "service call" do
+ it "sets the start date to the soonest possible start date" do
subject
expect(work_package.start_date).to eql(Time.zone.today)
@@ -1832,7 +1832,7 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when the work package also has a child' do
+ context "when the work package also has a child" do
let(:child) do
build_stubbed(:work_package,
start_date: child_start_date,
@@ -1847,9 +1847,9 @@ RSpec.describe WorkPackages::SetAttributesService,
.and_return([child])
end
- context 'when the child`s start date is after soonest_start' do
- it_behaves_like 'service call' do
- it 'sets the dates to the child dates' do
+ context "when the child`s start date is after soonest_start" do
+ it_behaves_like "service call" do
+ it "sets the dates to the child dates" do
subject
expect(work_package.start_date).to eql(Time.zone.today + 2.days)
@@ -1858,11 +1858,11 @@ RSpec.describe WorkPackages::SetAttributesService,
end
end
- context 'when the child`s start date is before soonest_start' do
+ context "when the child`s start date is before soonest_start" do
let(:soonest_start) { Time.zone.today + 3.days }
- it_behaves_like 'service call' do
- it 'sets the dates to soonest date and to the duration of the child' do
+ it_behaves_like "service call" do
+ it "sets the dates to soonest date and to the duration of the child" do
subject
expect(work_package.start_date).to eql(Time.zone.today + 3.days)
diff --git a/spec/services/work_packages/update_ancestors_service_spec.rb b/spec/services/work_packages/update_ancestors_service_spec.rb
index 43cf0bb7d6a..040c67d2689 100644
--- a/spec/services/work_packages/update_ancestors_service_spec.rb
+++ b/spec/services/work_packages/update_ancestors_service_spec.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
shared_association_default(:author, factory_name: :user) { create(:user) }
@@ -54,16 +54,16 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(attributes)
end
- describe 'done_ratio/estimated_hours/remaining_hours propagation' do
- context 'when setting the status of a work package' do
+ describe "done_ratio/estimated_hours/remaining_hours propagation" do
+ context "when setting the status of a work package" do
shared_let(:open_status) { create(:status) }
shared_let(:new_status_with_done_ratio) { create(:status, default_done_ratio: 100) }
shared_let(:new_status_without_done_ratio) { create(:status) }
- shared_examples 'updates % complete of ancestors' do
- it 'considers the work package as the % complete ' \
- 'attached to the status and sets the ' \
- 'derived % complete value of the ancestors accordingly' do
+ shared_examples "updates % complete of ancestors" do
+ it "considers the work package as the % complete " \
+ "attached to the status and sets the " \
+ "derived % complete value of the ancestors accordingly" do
expect(child.done_ratio)
.to eq(new_status_with_done_ratio.default_done_ratio)
@@ -77,10 +77,10 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- shared_examples 'does not update % complete of ancestors' do
- it 'does not consider the closed status a special value and ' \
- 'does not set % complete of the work package or set the ' \
- 'derived % complete value of the ancestors accordingly' do
+ shared_examples "does not update % complete of ancestors" do
+ it "does not consider the closed status a special value and " \
+ "does not set % complete of the work package or set the " \
+ "derived % complete value of the ancestors accordingly" do
expect(child.done_ratio).to eq(0)
expect do
@@ -94,8 +94,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
context 'when using the "status-based" % complete mode',
- with_settings: { work_package_done_ratio: 'status' } do
- context 'with both parent and children having estimated hours set' do
+ with_settings: { work_package_done_ratio: "status" } do
+ context "with both parent and children having estimated hours set" do
shared_let(:parent) do
create(:work_package,
estimated_hours: 10.0,
@@ -112,78 +112,78 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
status: open_status)
end
- context 'when the new status has its default done ratio set' do
- context 'with the status field' do
+ context "when the new status has its default done ratio set" do
+ context "with the status field" do
before do
set_attributes_on(child, status: new_status_with_done_ratio)
end
- include_examples 'updates % complete of ancestors'
+ include_examples "updates % complete of ancestors"
end
- context 'with the status_id field' do
+ context "with the status_id field" do
before do
set_attributes_on(child, status_id: new_status_with_done_ratio.id)
end
- include_examples 'updates % complete of ancestors'
+ include_examples "updates % complete of ancestors"
end
end
- context 'when the closed status has no default done ratio set' do
- context 'with the status field' do
+ context "when the closed status has no default done ratio set" do
+ context "with the status field" do
before do
set_attributes_on(child, status: new_status_without_done_ratio)
end
- include_examples 'does not update % complete of ancestors'
+ include_examples "does not update % complete of ancestors"
end
- context 'with the status_id field' do
+ context "with the status_id field" do
before do
set_attributes_on(child, status_id: new_status_without_done_ratio.id)
end
- include_examples 'does not update % complete of ancestors'
+ include_examples "does not update % complete of ancestors"
end
end
end
end
end
- context 'for the new ancestor chain' do
- shared_examples 'attributes of parent having children' do
+ context "for the new ancestor chain" do
+ shared_examples "attributes of parent having children" do
before do
children
end
- it 'is a success' do
+ it "is a success" do
expect(subject)
.to be_success
end
- it 'updated one work package - the parent' do
+ it "updated one work package - the parent" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent)
end
- it 'has the expected derived done ratio' do
+ it "has the expected derived done ratio" do
expect(subject.dependent_results.first.result.derived_done_ratio)
.to eq aggregate_done_ratio
end
- it 'has the expected derived estimated_hours' do
+ it "has the expected derived estimated_hours" do
expect(subject.dependent_results.first.result.derived_estimated_hours)
.to eq aggregate_estimated_hours
end
- it 'has the expected derived remaining_hours' do
+ it "has the expected derived remaining_hours" do
expect(subject.dependent_results.first.result.derived_remaining_hours)
.to eq aggregate_remaining_hours
end
end
- context 'when on field-based mode for % complete' do
+ context "when on field-based mode for % complete" do
let(:children) do
(statuses.size - 1).downto(0).map do |i|
create(:work_package,
@@ -195,9 +195,9 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- shared_let(:parent) { create(:work_package, subject: 'parent', status: open_status) }
+ shared_let(:parent) { create(:work_package, subject: "parent", status: open_status) }
- context 'when estimated_hours is changed' do
+ context "when estimated_hours is changed" do
subject do
# On field-based mode, changing estimated_hours
# entails done_ratio also changing when going
@@ -208,23 +208,23 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(estimated_hours done_ratio))
end
- context 'with no estimated hours and no progress' do
+ context "with no estimated hours and no progress" do
let(:estimated_hours) { [nil, nil, nil] }
let(:remaining_hours) { [nil, nil, nil] }
- it 'is a success' do
+ it "is a success" do
expect(subject)
.to be_success
end
- it 'does not update the parent' do
+ it "does not update the parent" do
expect(subject.dependent_results)
.to be_empty
end
end
- context 'with all tasks having estimated hours and some having progress done already' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and some having progress done already" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 10.0, 10.0]
end
@@ -244,8 +244,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and all having progress done already' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and all having progress done already" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 10.0, 10.0]
end
@@ -265,8 +265,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and no tasks having any progress done yet' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and no tasks having any progress done yet" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 2.0, 3.0]
end
@@ -286,8 +286,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and no tasks having progress set' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and no tasks having progress set" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 2.0, 3.0]
end
@@ -307,8 +307,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with some tasks having estimated hours and none having progress set' do
- it_behaves_like 'attributes of parent having children' do
+ context "with some tasks having estimated hours and none having progress set" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -328,8 +328,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with some tasks having estimated hours and those that do also having progress done' do
- it_behaves_like 'attributes of parent having children' do
+ context "with some tasks having estimated hours and those that do also having progress done" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -349,16 +349,16 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with the parent having estimated hours and progress' do
+ context "with the parent having estimated hours and progress" do
shared_let(:parent) do
create(:work_package,
- subject: 'parent',
+ subject: "parent",
estimated_hours: 10.0,
remaining_hours: 5.0)
end
- context 'and some tasks having estimated hours and some progress' do
- it_behaves_like 'attributes of parent having children' do
+ context "and some tasks having estimated hours and some progress" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -379,8 +379,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'and no tasks having estimated hours or progress' do
- it_behaves_like 'attributes of parent having children' do
+ context "and no tasks having estimated hours or progress" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[nil, nil, nil]
end
@@ -403,7 +403,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'when remaining_hours is changed' do
+ context "when remaining_hours is changed" do
subject do
# On field-based mode, changing remaining_hours
# entails done_ratio also changing when going
@@ -414,24 +414,24 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(remaining_hours done_ratio))
end
- context 'with no estimated hours and no progress' do
+ context "with no estimated hours and no progress" do
let(:estimated_hours) { [nil, nil, nil] }
let(:remaining_hours) { [nil, nil, nil] }
# let(:statuses) { %i(open open open) }
- it 'is a success' do
+ it "is a success" do
expect(subject)
.to be_success
end
- it 'does not update the parent' do
+ it "does not update the parent" do
expect(subject.dependent_results)
.to be_empty
end
end
- context 'with all tasks having estimated hours and some having progress done already' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and some having progress done already" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 10.0, 10.0]
end
@@ -451,8 +451,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and all having progress done already' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and all having progress done already" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 10.0, 10.0]
end
@@ -472,8 +472,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and no tasks having any progress done yet' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and no tasks having any progress done yet" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 2.0, 3.0]
end
@@ -493,8 +493,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with all tasks having estimated hours and no tasks having progress set' do
- it_behaves_like 'attributes of parent having children' do
+ context "with all tasks having estimated hours and no tasks having progress set" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, 2.0, 3.0]
end
@@ -514,8 +514,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with some tasks having estimated hours and none having progress set' do
- it_behaves_like 'attributes of parent having children' do
+ context "with some tasks having estimated hours and none having progress set" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -535,8 +535,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with some tasks having estimated hours and those that do also having progress done' do
- it_behaves_like 'attributes of parent having children' do
+ context "with some tasks having estimated hours and those that do also having progress done" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -556,16 +556,16 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with the parent having estimated hours and progress' do
+ context "with the parent having estimated hours and progress" do
shared_let(:parent) do
create(:work_package,
- subject: 'parent',
+ subject: "parent",
estimated_hours: 10.0,
remaining_hours: 5.0)
end
- context 'and some tasks having estimated hours and some progress' do
- it_behaves_like 'attributes of parent having children' do
+ context "and some tasks having estimated hours and some progress" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[10.0, nil, nil]
end
@@ -586,8 +586,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'and no tasks having estimated hours or progress' do
- it_behaves_like 'attributes of parent having children' do
+ context "and no tasks having estimated hours or progress" do
+ it_behaves_like "attributes of parent having children" do
let(:estimated_hours) do
[nil, nil, nil]
end
@@ -612,7 +612,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for the previous ancestors' do
+ context "for the previous ancestors" do
shared_let(:sibling_estimated_hours) { 7.0 }
shared_let(:sibling_remaining_hours) { 3.5 }
shared_let(:parent_estimated_hours) { 3.0 }
@@ -621,19 +621,19 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
shared_let(:grandparent) do
create(:work_package,
- subject: 'grandparent',
+ subject: "grandparent",
estimated_hours: grandparent_estimated_hours,
remaining_hours: grandparent_remaining_hours)
end
shared_let(:parent) do
create(:work_package,
- subject: 'parent',
+ subject: "parent",
estimated_hours: parent_estimated_hours,
parent: grandparent)
end
shared_let(:sibling) do
create(:work_package,
- subject: 'sibling',
+ subject: "sibling",
parent:,
estimated_hours: sibling_estimated_hours,
remaining_hours: sibling_remaining_hours)
@@ -641,7 +641,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
shared_let(:work_package) do
create(:work_package,
- subject: 'subject - loses its parent',
+ subject: "subject - loses its parent",
parent:)
end
@@ -655,17 +655,17 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(parent))
end
- it 'is successful' do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns the former ancestors in the dependent results' do
+ it "returns the former ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent, grandparent)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the former parent' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the former parent" do
expect do
subject
parent.reload
@@ -675,7 +675,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.and change(parent, :derived_remaining_hours).to(sibling_remaining_hours)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the former grandparent' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the former grandparent" do
expect do
subject
grandparent.reload
@@ -689,7 +689,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for new ancestors' do
+ context "for new ancestors" do
shared_let(:estimated_hours) { 7.0 }
shared_let(:remaining_hours) { 3.5 }
shared_let(:parent_estimated_hours) { 3.0 }
@@ -697,34 +697,34 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
shared_let(:grandparent) do
create(:work_package,
- subject: 'grandparent')
+ subject: "grandparent")
end
shared_let(:parent) do
create(:work_package,
- subject: 'parent',
+ subject: "parent",
estimated_hours: parent_estimated_hours,
remaining_hours: parent_remaining_hours,
parent: grandparent)
end
shared_let(:work_package) do
create(:work_package,
- subject: 'subject - gains a new parent and grandparent',
+ subject: "subject - gains a new parent and grandparent",
estimated_hours:,
remaining_hours:)
end
- shared_examples_for 'updates the attributes within the new hierarchy' do
- it 'is successful' do
+ shared_examples_for "updates the attributes within the new hierarchy" do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns the new ancestors in the dependent results' do
+ it "returns the new ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent, grandparent)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the new parent' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the new parent" do
expect do
subject
parent.reload
@@ -734,8 +734,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.and change(parent, :derived_remaining_hours).to(parent_remaining_hours + remaining_hours)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours ' \
- 'of the new grandparent' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours " \
+ "of the new grandparent" do
expect do
subject
grandparent.reload
@@ -746,7 +746,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'if setting the parent' do
+ context "if setting the parent" do
subject do
work_package.parent = parent
work_package.save!
@@ -757,10 +757,10 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(parent))
end
- it_behaves_like 'updates the attributes within the new hierarchy'
+ it_behaves_like "updates the attributes within the new hierarchy"
end
- context 'if setting the parent_id' do
+ context "if setting the parent_id" do
subject do
work_package.parent_id = parent.id
work_package.save!
@@ -771,11 +771,11 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(parent_id))
end
- it_behaves_like 'updates the attributes within the new hierarchy'
+ it_behaves_like "updates the attributes within the new hierarchy"
end
end
- context 'with old and new parent having a common ancestor' do
+ context "with old and new parent having a common ancestor" do
shared_let(:estimated_hours) { 7.0 }
shared_let(:remaining_hours) { 3.5 }
shared_let(:new_estimated_hours) { 10.0 }
@@ -783,14 +783,14 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
shared_let(:grandparent) do
create(:work_package,
- subject: 'common grandparent',
+ subject: "common grandparent",
derived_done_ratio: 50, # two children having [done_ratio, 0]
derived_estimated_hours: estimated_hours,
derived_remaining_hours: remaining_hours)
end
shared_let(:old_parent) do
create(:work_package,
- subject: 'old parent',
+ subject: "old parent",
parent: grandparent,
derived_done_ratio: 50,
derived_estimated_hours: estimated_hours,
@@ -798,12 +798,12 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
shared_let(:new_parent) do
create(:work_package,
- subject: 'new parent',
+ subject: "new parent",
parent: grandparent)
end
shared_let(:work_package) do
create(:work_package,
- subject: 'subject - parent changes from old parent to new parent, same grandparent',
+ subject: "subject - parent changes from old parent to new parent, same grandparent",
parent: old_parent,
estimated_hours:,
remaining_hours:)
@@ -831,18 +831,18 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(parent))
end
- it 'is successful' do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns both the former and new ancestors in the dependent results without duplicates' do
+ it "returns both the former and new ancestors in the dependent results without duplicates" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(new_parent, grandparent, old_parent)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours ' \
- 'of the former parent to 0' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours " \
+ "of the former parent to 0" do
expect do
subject
old_parent.reload
@@ -852,7 +852,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.and change(old_parent, :derived_remaining_hours).to(nil)
end
- it 'updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the new parent' do
+ it "updates the derived_done_ratio, derived_estimated_hours, and derived_remaining_hours of the new parent" do
expect do
subject
new_parent.reload
@@ -862,7 +862,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.and change(new_parent, :derived_remaining_hours).to(new_remaining_hours)
end
- it 'updates the derived_done_ratio, erived_estimated_hours, and derived_remaining_hours of the grandparent' do
+ it "updates the derived_done_ratio, erived_estimated_hours, and derived_remaining_hours of the grandparent" do
expect do
subject
grandparent.reload
@@ -874,10 +874,10 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- describe 'estimated_hours propagation' do
- shared_let(:parent) { create(:work_package, subject: 'parent') }
+ describe "estimated_hours propagation" do
+ shared_let(:parent) { create(:work_package, subject: "parent") }
- context 'when setting estimated hours of a work package' do
+ context "when setting estimated hours of a work package" do
before do
parent.estimated_hours = 2.0
end
@@ -887,7 +887,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(estimated_hours))
end
- it 'sets its derived value to the same value' do
+ it "sets its derived value to the same value" do
expect { call_result }
.to change(parent, :derived_estimated_hours).from(nil).to(2.0)
expect(call_result).to be_success
@@ -895,8 +895,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for the new ancestors chain' do
- context 'with parent having no work' do
+ context "for the new ancestors chain" do
+ context "with parent having no work" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | |
@@ -910,7 +910,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(estimated_hours))
end
- it 'sets parent derived remaining work to the sum of children remaining work' do
+ it "sets parent derived remaining work to the sum of children remaining work" do
expect(call_result).to be_success
updated_work_packages = call_result.dependent_results.map(&:result)
expect_work_packages(updated_work_packages, <<~TABLE)
@@ -920,7 +920,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with parent having some remaining work' do
+ context "with parent having some remaining work" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | 5.25h |
@@ -934,7 +934,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(estimated_hours))
end
- it 'sets parent derived work to the sum of itself and children remaining work' do
+ it "sets parent derived work to the sum of itself and children remaining work" do
expect(call_result).to be_success
updated_work_packages = call_result.dependent_results.map(&:result)
expect_work_packages(updated_work_packages, <<~TABLE)
@@ -944,7 +944,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with parent and children having no work' do
+ context "with parent and children having no work" do
let_work_packages(<<~TABLE)
hierarchy | work |
parent | |
@@ -957,7 +957,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(estimated_hours))
end
- it 'does not update the parent derived work' do
+ it "does not update the parent derived work" do
expect(call_result).to be_success
expect(call_result.dependent_results).to be_empty
expect_work_packages([parent.reload], <<~TABLE)
@@ -969,10 +969,10 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- describe 'remaining_hours propagation' do
- shared_let(:parent) { create(:work_package, subject: 'parent') }
+ describe "remaining_hours propagation" do
+ shared_let(:parent) { create(:work_package, subject: "parent") }
- context 'when setting remaining hours of a work package' do
+ context "when setting remaining hours of a work package" do
before do
parent.remaining_hours = 2.0
end
@@ -982,7 +982,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(remaining_hours))
end
- it 'sets its derived value to the same value' do
+ it "sets its derived value to the same value" do
expect { call_result }
.to change(parent, :derived_remaining_hours).from(nil).to(2.0)
expect(call_result).to be_success
@@ -990,8 +990,8 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for the new ancestors chain' do
- context 'with parent having no remaining work' do
+ context "for the new ancestors chain" do
+ context "with parent having no remaining work" do
let_work_packages(<<~TABLE)
hierarchy | remaining work |
parent | |
@@ -1005,7 +1005,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(remaining_hours))
end
- it 'sets parent derived remaining work to the sum of children remaining work' do
+ it "sets parent derived remaining work to the sum of children remaining work" do
expect(call_result).to be_success
updated_work_packages = call_result.dependent_results.map(&:result)
expect_work_packages(updated_work_packages, <<~TABLE)
@@ -1015,7 +1015,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with parent having some remaining work' do
+ context "with parent having some remaining work" do
let_work_packages(<<~TABLE)
hierarchy | remaining work |
parent | 5.25h |
@@ -1029,7 +1029,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(remaining_hours))
end
- it 'sets parent derived remaining work to the sum of itself and children remaining work' do
+ it "sets parent derived remaining work to the sum of itself and children remaining work" do
expect(call_result).to be_success
updated_work_packages = call_result.dependent_results.map(&:result)
expect_work_packages(updated_work_packages, <<~TABLE)
@@ -1039,7 +1039,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'with parent and children having no remaining work' do
+ context "with parent and children having no remaining work" do
let_work_packages(<<~TABLE)
hierarchy | remaining work |
parent | |
@@ -1052,7 +1052,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
.call(%i(remaining_hours))
end
- it 'does not update the parent derived remaining work' do
+ it "does not update the parent derived remaining work" do
expect(call_result).to be_success
expect(call_result.dependent_results).to be_empty
expect_work_packages([parent.reload], <<~TABLE)
@@ -1064,24 +1064,24 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- describe 'ignore_non_working_days propagation' do
+ describe "ignore_non_working_days propagation" do
shared_let(:grandgrandparent) do
create(:work_package,
- subject: 'grandgrandparent')
+ subject: "grandgrandparent")
end
shared_let(:grandparent) do
create(:work_package,
- subject: 'grandparent',
+ subject: "grandparent",
parent: grandgrandparent)
end
shared_let(:parent) do
create(:work_package,
- subject: 'parent',
+ subject: "parent",
parent: grandparent)
end
shared_let(:sibling) do
create(:work_package,
- subject: 'sibling',
+ subject: "sibling",
parent:)
end
shared_let(:work_package) do
@@ -1100,7 +1100,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
let(:new_parent) { parent }
- context 'for the previous ancestors (parent removed)' do
+ context "for the previous ancestors (parent removed)" do
let(:new_parent) { nil }
before do
@@ -1116,12 +1116,12 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- it 'is successful' do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns the former ancestors in the dependent results' do
+ it "returns the former ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent, grandparent, grandgrandparent)
end
@@ -1144,7 +1144,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for the new ancestors where the grandparent is on manual scheduling' do
+ context "for the new ancestors where the grandparent is on manual scheduling" do
before do
[grandgrandparent, work_package].each do |wp|
wp.update_column(:ignore_non_working_days, true)
@@ -1159,17 +1159,17 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- it 'is successful' do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns the former ancestors in the dependent results' do
+ it "returns the former ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
.to contain_exactly(parent)
end
- it 'sets the ignore_non_working_days property of the new ancestors' do
+ it "sets the ignore_non_working_days property of the new ancestors" do
subject
expect(parent.reload.ignore_non_working_days)
@@ -1186,7 +1186,7 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- context 'for the new ancestors where the parent is on manual scheduling' do
+ context "for the new ancestors where the parent is on manual scheduling" do
before do
[grandgrandparent, grandparent, work_package].each do |wp|
wp.update_column(:ignore_non_working_days, true)
@@ -1201,17 +1201,17 @@ RSpec.describe WorkPackages::UpdateAncestorsService, type: :model do
end
end
- it 'is successful' do
+ it "is successful" do
expect(subject)
.to be_success
end
- it 'returns the former ancestors in the dependent results' do
+ it "returns the former ancestors in the dependent results" do
expect(subject.dependent_results.map(&:result))
.to be_empty
end
- it 'sets the ignore_non_working_days property of the new ancestors' do
+ it "sets the ignore_non_working_days property of the new ancestors" do
subject
expect(parent.reload.ignore_non_working_days)
diff --git a/spec/services/work_packages/update_service_integration_spec.rb b/spec/services/work_packages/update_service_integration_spec.rb
index 2bcbea1c1f8..9dd3dd36bfb 100644
--- a/spec/services/work_packages/update_service_integration_spec.rb
+++ b/spec/services/work_packages/update_service_integration_spec.rb
@@ -28,9 +28,9 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
+RSpec.describe WorkPackages::UpdateService, "integration", type: :model do
let(:user) do
create(:user, member_with_roles: { project => role })
end
@@ -105,10 +105,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
instance.call(**attributes.merge(send_notifications: false).symbolize_keys)
end
- describe 'updating subject' do
- let(:attributes) { { subject: 'New subject' } }
+ describe "updating subject" do
+ let(:attributes) { { subject: "New subject" } }
- it 'updates the subject' do
+ it "updates the subject" do
expect(subject)
.to be_success
@@ -117,7 +117,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'when updating the project' do
+ context "when updating the project" do
let(:target_project) do
p = create(:project,
types: target_types,
@@ -135,25 +135,25 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:target_parent) { nil }
let(:target_types) { [type] }
- it 'is is success and updates the project' do
+ it "is is success and updates the project" do
expect(subject).to be_success
expect(work_package.reload.project).to eql target_project
end
- context 'with missing permissions' do
+ context "with missing permissions" do
let(:target_permissions) { [] }
- it 'is failure' do
+ it "is failure" do
expect(subject).to be_failure
end
end
- describe 'time_entries' do
+ describe "time_entries" do
let!(:time_entries) do
create_list(:time_entry, 2, project:, work_package:)
end
- it 'moves the time entries along' do
+ it "moves the time entries along" do
expect(subject)
.to be_success
@@ -162,26 +162,26 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'memberships' do
+ describe "memberships" do
let(:wp_role) { create(:work_package_role, permissions: [:view_work_packages]) }
let(:other_user) { create(:user) }
let!(:membership) do
create(:member, project:, entity: work_package, principal: other_user, roles: [wp_role])
end
- it 'moves memberships for the entity to the new project' do
+ it "moves memberships for the entity to the new project" do
expect do
subject
membership.reload
end.to change(membership, :project).from(project).to(target_project)
end
- describe 'when the work package has descendents' do
+ describe "when the work package has descendents" do
let!(:child_membership) do
create(:member, project:, entity: child_work_package, principal: other_user, roles: [wp_role])
end
- it 'moves memberships for the entity and its descendents to the new project' do
+ it "moves memberships for the entity and its descendents to the new project" do
expect do
subject
membership.reload
@@ -192,7 +192,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'categories' do
+ describe "categories" do
let(:category) do
create(:category,
project:)
@@ -203,14 +203,14 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
work_package.save!
end
- context 'with equally named category' do
+ context "with equally named category" do
let!(:target_category) do
create(:category,
name: category.name,
project: target_project)
end
- it 'replaces the current category by the equally named one' do
+ it "replaces the current category by the equally named one" do
expect(subject)
.to be_success
@@ -219,13 +219,13 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'without a target category' do
+ context "without a target category" do
let!(:other_category) do
create(:category,
project: target_project)
end
- it 'removes the category' do
+ it "removes the category" do
expect(subject)
.to be_success
@@ -235,11 +235,11 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'version' do
- let(:sharing) { 'none' }
+ describe "version" do
+ let(:sharing) { "none" }
let(:version) do
create(:version,
- status: 'open',
+ status: "open",
project:,
sharing:)
end
@@ -249,8 +249,8 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
project:)
end
- context 'with an unshared version' do
- it 'removes the version' do
+ context "with an unshared version" do
+ it "removes the version" do
expect(subject)
.to be_success
@@ -259,10 +259,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with a system wide shared version' do
- let(:sharing) { 'system' }
+ context "with a system wide shared version" do
+ let(:sharing) { "system" }
- it 'keeps the version' do
+ it "keeps the version" do
expect(subject)
.to be_success
@@ -271,13 +271,13 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'when moving the work package in project hierarchy' do
+ context "when moving the work package in project hierarchy" do
let(:target_parent) do
project
end
- context 'with an unshared version' do
- it 'removes the version' do
+ context "with an unshared version" do
+ it "removes the version" do
expect(subject)
.to be_success
@@ -286,10 +286,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with a shared version' do
- let(:sharing) { 'tree' }
+ context "with a shared version" do
+ let(:sharing) { "tree" }
- it 'keeps the version' do
+ it "keeps the version" do
expect(subject)
.to be_success
@@ -300,7 +300,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'type' do
+ describe "type" do
let(:target_types) { [type, other_type] }
let(:other_type) { create(:type) }
let(:default_type) { type }
@@ -312,8 +312,8 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
create(:workflow, type: other_type, role:, old_status_id: status.id)
end
- context 'with the type existing in the target project' do
- it 'keeps the type' do
+ context "with the type existing in the target project" do
+ it "keeps the type" do
expect(subject)
.to be_success
@@ -322,10 +322,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with a default type existing in the target project' do
+ context "with a default type existing in the target project" do
let(:target_types) { [other_type, default_type] }
- it 'uses the default type' do
+ it "uses the default type" do
expect(subject)
.to be_success
@@ -334,10 +334,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with only non default types' do
+ context "with only non default types" do
let(:target_types) { [other_type] }
- it 'uses the first type' do
+ it "uses the first type" do
expect(subject)
.to be_success
@@ -346,7 +346,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with an invalid type being provided' do
+ context "with an invalid type being provided" do
let(:target_types) { [type] }
let(:attributes) do
@@ -354,14 +354,14 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
type: other_type }
end
- it 'is unsuccessful' do
+ it "is unsuccessful" do
expect(subject)
.to be_failure
end
end
end
- describe 'relations' do
+ describe "relations" do
let!(:relation) do
create(:follows_relation,
from: work_package,
@@ -369,8 +369,8 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
project:))
end
- context 'with cross project relations allowed', with_settings: { cross_project_work_package_relations: true } do
- it 'keeps the relation' do
+ context "with cross project relations allowed", with_settings: { cross_project_work_package_relations: true } do
+ it "keeps the relation" do
expect(subject)
.to be_success
@@ -379,8 +379,8 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- context 'with cross project relations disabled', with_settings: { cross_project_work_package_relations: false } do
- it 'deletes the relation' do
+ context "with cross project relations disabled", with_settings: { cross_project_work_package_relations: false } do
+ it "deletes the relation" do
expect(subject)
.to be_success
@@ -391,7 +391,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'inheriting dates' do
+ describe "inheriting dates" do
let(:attributes) { { start_date: Time.zone.today - 8.days, due_date: Time.zone.today + 12.days } }
let(:sibling1_attributes) do
work_package_attributes.merge(start_date: Time.zone.today - 5.days,
@@ -410,7 +410,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
sibling2_work_package
end
- it 'works and inherits' do
+ it "works and inherits" do
expect(subject)
.to be_success
@@ -444,7 +444,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'inheriting done_ratio' do
+ describe "inheriting done_ratio" do
let(:attributes) { { estimated_hours: 10.0, remaining_hours: 5.0 } }
let(:work_package_attributes) do
{ project_id: project.id,
@@ -470,7 +470,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
sibling2_work_package
end
- it 'works and inherits average done ratio of leaves weighted by work values' do
+ it "works and inherits average done ratio of leaves weighted by work values" do
expect(subject)
.to be_success
@@ -507,7 +507,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'inheriting estimated_hours' do
+ describe "inheriting estimated_hours" do
let(:attributes) { { estimated_hours: 7 } }
let(:sibling1_attributes) do
# no estimated hours
@@ -530,7 +530,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
child_work_package
end
- it 'works and inherits' do
+ it "works and inherits" do
expect(subject)
.to be_success
@@ -572,7 +572,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'inheriting ignore_non_working_days' do
+ describe "inheriting ignore_non_working_days" do
let(:attributes) { { ignore_non_working_days: true } }
before do
@@ -581,7 +581,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
sibling1_work_package
end
- it 'propagates the value up the ancestor chain' do
+ it "propagates the value up the ancestor chain" do
expect(subject)
.to be_success
@@ -601,7 +601,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'closing duplicates on closing status' do
+ describe "closing duplicates on closing status" do
let(:status_closed) do
create(:status,
is_closed: true).tap do |status_closed|
@@ -621,7 +621,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:attributes) { { status: status_closed } }
- it 'works and closes duplicates' do
+ it "works and closes duplicates" do
expect(subject)
.to be_success
@@ -634,7 +634,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'rescheduling work packages along follows/hierarchy relations' do
+ describe "rescheduling work packages along follows/hierarchy relations" do
# layout
# following_parent_work_package +-follows- following2_parent_work_package following3_parent_work_package
# | | / |
@@ -658,7 +658,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
let(:following_attributes) do
work_package_attributes.merge(parent: following_parent_work_package,
- subject: 'following',
+ subject: "following",
start_date: Time.zone.today + 6.days,
due_date: Time.zone.today + 20.days)
end
@@ -669,7 +669,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
let(:following_parent_attributes) do
- work_package_attributes.merge(subject: 'following_parent',
+ work_package_attributes.merge(subject: "following_parent",
start_date: Time.zone.today + 6.days,
due_date: Time.zone.today + 20.days)
end
@@ -679,7 +679,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
let(:following2_attributes) do
work_package_attributes.merge(parent: following2_parent_work_package,
- subject: 'following2',
+ subject: "following2",
start_date: Time.zone.today + 21.days,
due_date: Time.zone.today + 25.days)
end
@@ -688,7 +688,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
following2_attributes)
end
let(:following2_parent_attributes) do
- work_package_attributes.merge(subject: 'following2_parent',
+ work_package_attributes.merge(subject: "following2_parent",
start_date: Time.zone.today + 21.days,
due_date: Time.zone.today + 25.days)
end
@@ -699,7 +699,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
let(:following3_attributes) do
- work_package_attributes.merge(subject: 'following3',
+ work_package_attributes.merge(subject: "following3",
parent: following3_parent_work_package,
start_date: Time.zone.today + 26.days,
due_date: Time.zone.today + 30.days)
@@ -711,7 +711,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
let(:following3_parent_attributes) do
- work_package_attributes.merge(subject: 'following3_parent',
+ work_package_attributes.merge(subject: "following3_parent",
start_date: Time.zone.today + 26.days,
due_date: Time.zone.today + 36.days)
end
@@ -721,7 +721,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
let(:following3_sibling_attributes) do
work_package_attributes.merge(parent: following3_parent_work_package,
- subject: 'following3_sibling',
+ subject: "following3_sibling",
start_date: Time.zone.today + 32.days,
due_date: Time.zone.today + 36.days)
end
@@ -743,7 +743,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
# rubocop:disable RSpec/ExampleLength
# rubocop:disable RSpec/MultipleExpectations
- it 'propagates the changes to start/finish date along' do
+ it "propagates the changes to start/finish date along" do
expect(subject)
.to be_success
@@ -805,7 +805,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
# rubocop:enable RSpec/MultipleExpectations
end
- describe 'rescheduling work packages with a parent having a follows relation (Regression #43220)' do
+ describe "rescheduling work packages with a parent having a follows relation (Regression #43220)" do
let(:predecessor_work_package_attributes) do
work_package_attributes.merge(
start_date: Time.zone.today + 1.day,
@@ -839,7 +839,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:attributes) { { parent: parent_work_package } }
- it 'sets the parent and child dates correctly' do
+ it "sets the parent and child dates correctly" do
expect(subject)
.to be_success
@@ -854,10 +854,10 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'changing the parent' do
+ describe "changing the parent" do
let(:former_parent_attributes) do
{
- subject: 'former parent',
+ subject: "former parent",
project_id: project.id,
type_id: type.id,
author_id: user.id,
@@ -874,7 +874,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:former_sibling_attributes) do
work_package_attributes.merge(
- subject: 'former sibling',
+ subject: "former sibling",
parent: former_parent_work_package,
start_date: Time.zone.today + 3.days,
due_date: Time.zone.today + 6.days
@@ -897,7 +897,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:new_parent_attributes) do
work_package_attributes.merge(
- subject: 'new parent',
+ subject: "new parent",
parent: nil,
start_date: Time.zone.today + 10.days,
due_date: Time.zone.today + 12.days
@@ -909,7 +909,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:new_sibling_attributes) do
work_package_attributes.merge(
- subject: 'new sibling',
+ subject: "new sibling",
parent: new_parent_work_package,
start_date: Time.zone.today + 10.days,
due_date: Time.zone.today + 12.days
@@ -927,7 +927,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
new_sibling_work_package.reload
end
- it 'changes the parent reference and reschedules former and new parent' do
+ it "changes the parent reference and reschedules former and new parent" do
expect(subject)
.to be_success
@@ -959,11 +959,11 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'changing the parent with the parent being restricted in moving to an earlier date' do
+ describe "changing the parent with the parent being restricted in moving to an earlier date" do
# there is actually some time between the new parent and its predecessor
let(:new_parent_attributes) do
work_package_attributes.merge(
- subject: 'new parent',
+ subject: "new parent",
parent: nil,
start_date: Time.zone.today + 8.days,
due_date: Time.zone.today + 14.days
@@ -976,7 +976,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:new_parent_predecessor_attributes) do
work_package_attributes.merge(
- subject: 'new parent predecessor',
+ subject: "new parent predecessor",
parent: nil,
start_date: Time.zone.today + 1.day,
due_date: Time.zone.today + 4.days
@@ -1004,7 +1004,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
new_parent_predecessor_work_package.reload
end
- it 'reschedules the parent and the work package while adhering to the limitation imposed by the predecessor' do
+ it "reschedules the parent and the work package while adhering to the limitation imposed by the predecessor" do
expect(subject)
.to be_success
@@ -1039,7 +1039,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'removing the parent on a work package which precedes its sibling' do
+ describe "removing the parent on a work package which precedes its sibling" do
let(:work_package_attributes) do
{ project_id: project.id,
type_id: type.id,
@@ -1054,7 +1054,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:parent_attributes) do
{ project_id: project.id,
- subject: 'parent',
+ subject: "parent",
type_id: type.id,
author_id: user.id,
status_id: status.id,
@@ -1069,7 +1069,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:sibling_attributes) do
work_package_attributes.merge(
- subject: 'sibling',
+ subject: "sibling",
start_date: Time.zone.today + 4.days,
due_date: Time.zone.today + 10.days
)
@@ -1087,7 +1087,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
sibling_work_package.reload
end
- it 'removes the parent and reschedules it' do
+ it "removes the parent and reschedules it" do
expect(subject)
.to be_success
@@ -1111,7 +1111,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'replacing the attachments' do
+ describe "replacing the attachments" do
let!(:old_attachment) do
create(:attachment, container: work_package)
end
@@ -1123,7 +1123,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
# rubocop:disable RSpec/ExampleLength
- it 'reports on invalid attachments and replaces the existent with the new if everything is valid' do
+ it "reports on invalid attachments and replaces the existent with the new if everything is valid" do
work_package.attachments.reload
result = instance.call(attachment_ids: [other_users_attachment.id])
@@ -1175,7 +1175,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
# - Child2: C
#
# Trying to set parent of C to B failed because parent relation is requested before change is saved.
- describe 'Changing parent to a new one that has the same parent as the current element (Regression #27746)' do
+ describe "Changing parent to a new one that has the same parent as the current element (Regression #27746)" do
shared_let(:admin) { create(:admin) }
let(:user) { admin }
@@ -1188,34 +1188,34 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
let(:attributes) { { parent: wp_b } }
- it 'allows changing the parent' do
+ it "allows changing the parent" do
expect(subject).to be_success
end
end
- describe 'Changing type to one that does not have the current status (Regression #27780)' do
+ describe "Changing type to one that does not have the current status (Regression #27780)" do
let(:type) { create(:type_with_workflow) }
let(:new_type) { create(:type) }
let(:project_types) { [type, new_type] }
let(:attributes) { { type: new_type } }
- context 'when the work package does NOT have default status' do
+ context "when the work package does NOT have default status" do
let(:status) { create(:status) }
- it 'assigns the default status' do
+ it "assigns the default status" do
expect(subject).to be_success
expect(work_package.status).to eq(Status.default)
end
end
- context 'when the work package does have default status' do
+ context "when the work package does have default status" do
let(:status) { create(:default_status) }
let!(:workflow_type) do
create(:workflow, type: new_type, role:, old_status_id: status.id)
end
- it 'does not set the status' do
+ it "does not set the status" do
expect(subject).to be_success
expect(work_package)
@@ -1224,7 +1224,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'removing an invalid parent' do
+ describe "removing an invalid parent" do
# The parent does not have a required custom field set but will need to be touched since.
# the dates, inherited from its children (and then the only remaining child) will have to be updated.
let!(:parent) do
@@ -1262,7 +1262,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
}
end
- it 'removes the parent successfully and reschedules the parent' do
+ it "removes the parent successfully and reschedules the parent" do
expect(subject).to be_success
expect(work_package.reload.parent).to be_nil
@@ -1274,7 +1274,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'updating an invalid work package' do
+ describe "updating an invalid work package" do
# The work package does not have a required custom field set.
let(:custom_field) do
create(:integer_wp_custom_field, is_required: true, is_for_all: true, default_value: nil) do |cf|
@@ -1282,11 +1282,11 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
project.work_package_custom_fields << cf
end
end
- let(:attributes) { { subject: 'A new subject' } }
+ let(:attributes) { { subject: "A new subject" } }
let(:work_package_attributes) do
{
- subject: 'The old subject',
+ subject: "The old subject",
project:,
type: project.types.first
}
@@ -1298,7 +1298,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
custom_field
end
- it 'is a failure and does not save the change' do
+ it "is a failure and does not save the change" do
expect(subject).to be_failure
expect(work_package.reload.subject)
@@ -1306,7 +1306,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
end
end
- describe 'updating the type (custom field resetting)' do
+ describe "updating the type (custom field resetting)" do
let(:project_types) { [type, new_type] }
let(:new_type) { create(:type) }
let!(:custom_field_of_current_type) do
@@ -1333,7 +1333,7 @@ RSpec.describe WorkPackages::UpdateService, 'integration', type: :model do
}
end
- it 'is success, removes the existing custom field value and sets the default for the new one' do
+ it "is success, removes the existing custom field value and sets the default for the new one" do
expect(subject).to be_success
expect(work_package.reload.custom_values.pluck(:custom_field_id, :value))