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

auto correct quotes

Ivan Kuchin6678cab48d44
diff --git a/app/components/mailer/label_component.rb b/app/components/mailer/label_component.rb
index bfe254a3703..ac7f62c3285 100644
--- a/app/components/mailer/label_component.rb
+++ b/app/components/mailer/label_component.rb
@@ -30,16 +30,16 @@
module Mailer
LABEL_SCHEME_COLORS = {
- default: 'rgb(208, 215, 222)',
- primary: 'rgb(110, 119, 129)',
- secondary: 'rgb(208, 215, 222)',
- accent: 'rgb(9, 105, 218)',
- success: 'rgb(31, 136, 61)',
- attention: 'rgb(154, 103, 0)',
- danger: 'rgb(207, 34, 46)',
- severe: 'rgb(188, 76, 0)',
- done: 'rgb(130, 80, 223)',
- sponsor: 'rgb(191, 57, 137)'
+ default: "rgb(208, 215, 222)",
+ primary: "rgb(110, 119, 129)",
+ secondary: "rgb(208, 215, 222)",
+ accent: "rgb(9, 105, 218)",
+ success: "rgb(31, 136, 61)",
+ attention: "rgb(154, 103, 0)",
+ danger: "rgb(207, 34, 46)",
+ severe: "rgb(188, 76, 0)",
+ done: "rgb(130, 80, 223)",
+ sponsor: "rgb(191, 57, 137)"
}.freeze
class LabelComponent < ViewComponent::Base
diff --git a/app/components/projects/settings/project_custom_field_sections/index_component.rb b/app/components/projects/settings/project_custom_field_sections/index_component.rb
index 38f061e9a5f..3ea8e301d04 100644
--- a/app/components/projects/settings/project_custom_field_sections/index_component.rb
+++ b/app/components/projects/settings/project_custom_field_sections/index_component.rb
@@ -45,8 +45,8 @@ module Projects
def wrapper_data_attributes
{
- controller: 'projects--settings--project-custom-fields-mapping-filter',
- 'application-target': 'dynamic'
+ controller: "projects--settings--project-custom-fields-mapping-filter",
+ "application-target": "dynamic"
}
end
end
diff --git a/app/components/settings/project_custom_field_sections/index_component.rb b/app/components/settings/project_custom_field_sections/index_component.rb
index 7f4d7bdff1a..8693b2a586b 100644
--- a/app/components/settings/project_custom_field_sections/index_component.rb
+++ b/app/components/settings/project_custom_field_sections/index_component.rb
@@ -47,23 +47,23 @@ module Settings
def wrapper_data_attributes
{
- controller: 'generic-drag-and-drop',
- 'application-target': 'dynamic'
+ controller: "generic-drag-and-drop",
+ "application-target": "dynamic"
}
end
def drop_target_config
{
- 'is-drag-and-drop-target': true,
- 'target-allowed-drag-type': 'section' # the type of dragged items which are allowed to be dropped in this target
+ "is-drag-and-drop-target": true,
+ "target-allowed-drag-type": "section" # the type of dragged items which are allowed to be dropped in this target
}
end
def draggable_item_config(section)
{
- 'draggable-id': section.id,
- 'draggable-type': 'section',
- 'drop-url': drop_admin_settings_project_custom_field_section_path(section)
+ "draggable-id": section.id,
+ "draggable-type": "section",
+ "drop-url": drop_admin_settings_project_custom_field_section_path(section)
}
end
end
diff --git a/app/contracts/base_contract.rb b/app/contracts/base_contract.rb
index 9402f313181..18838af93b5 100644
--- a/app/contracts/base_contract.rb
+++ b/app/contracts/base_contract.rb
@@ -101,7 +101,7 @@ class BaseContract < Disposable::Twin
private
def add_writable(attribute, writable)
- attribute_name = attribute.to_s.delete_suffix('_id')
+ attribute_name = attribute.to_s.delete_suffix("_id")
unless writable == false
writable_attributes << attribute_name
@@ -260,7 +260,7 @@ class BaseContract < Disposable::Twin
attribute_permissions = collect_ancestor_attributes(:attribute_permissions)
attributes.reject do |attribute|
- canonical_attribute = attribute.delete_suffix('_id')
+ canonical_attribute = attribute.delete_suffix("_id")
permissions = attribute_permissions[canonical_attribute] ||
attribute_permissions["#{canonical_attribute}_id"] ||
diff --git a/app/controllers/admin/settings/projects_settings_controller.rb b/app/controllers/admin/settings/projects_settings_controller.rb
index 11355769a88..69e1cd2e8ac 100644
--- a/app/controllers/admin/settings/projects_settings_controller.rb
+++ b/app/controllers/admin/settings/projects_settings_controller.rb
@@ -48,9 +48,9 @@ module Admin::Settings
.select { |m| m[:dependencies] && enabled_modules.include?(m[:name]) && (m[:dependencies] & enabled_modules) != m[:dependencies] }
.map do |m|
I18n.t(
- 'settings.projects.missing_dependencies',
+ "settings.projects.missing_dependencies",
module: I18n.t("project_module_#{m[:name]}"),
- dependencies: m[:dependencies].map { |dep| I18n.t("project_module_#{dep}") }.join(', ')
+ dependencies: m[:dependencies].map { |dep| I18n.t("project_module_#{dep}") }.join(", ")
)
end
diff --git a/app/controllers/concerns/custom_fields/shared_actions.rb b/app/controllers/concerns/custom_fields/shared_actions.rb
index 1e8265f0e76..a2b54097a7c 100644
--- a/app/controllers/concerns/custom_fields/shared_actions.rb
+++ b/app/controllers/concerns/custom_fields/shared_actions.rb
@@ -32,7 +32,7 @@ module CustomFields
included do
def index_path(custom_field, params = {})
- if custom_field.type == 'ProjectCustomField'
+ if custom_field.type == "ProjectCustomField"
admin_settings_project_custom_fields_path(**params)
else
custom_fields_path(**params)
@@ -40,7 +40,7 @@ module CustomFields
end
def edit_path(custom_field, params = {})
- if custom_field.type == 'ProjectCustomField'
+ if custom_field.type == "ProjectCustomField"
admin_settings_project_custom_field_path(**params)
else
edit_custom_field_path(**params)
@@ -58,7 +58,7 @@ module CustomFields
redirect_to index_path(call.result, tab: call.result.class.name)
else
@custom_field = call.result || new_custom_field
- render action: 'new'
+ render action: "new"
end
end
@@ -76,7 +76,7 @@ module CustomFields
call_hook(:controller_custom_fields_edit_after_save, custom_field: @custom_field)
redirect_back_or_default(edit_path(@custom_field, id: @custom_field.id))
else
- render action: 'edit'
+ render action: "edit"
end
end
diff --git a/app/controllers/custom_fields_controller.rb b/app/controllers/custom_fields_controller.rb
index b35ed052dd1..7b8c5bfa0d4 100644
--- a/app/controllers/custom_fields_controller.rb
+++ b/app/controllers/custom_fields_controller.rb
@@ -28,7 +28,7 @@
class CustomFieldsController < ApplicationController
include CustomFields::SharedActions # share logic with ProjectCustomFieldsControlller
- layout 'admin'
+ layout "admin"
before_action :require_admin
before_action :find_custom_field, only: %i(edit update destroy delete_option reorder_alphabetical)
@@ -38,12 +38,12 @@ class CustomFieldsController < ApplicationController
def index
# loading wp cfs exclicity to allow for eager loading
@custom_fields_by_type = CustomField.all
- .where.not(type: ['WorkPackageCustomField', 'ProjectCustomField'])
+ .where.not(type: ["WorkPackageCustomField", "ProjectCustomField"])
.group_by { |f| f.class.name }
- @custom_fields_by_type['WorkPackageCustomField'] = WorkPackageCustomField.includes(:types).all
+ @custom_fields_by_type["WorkPackageCustomField"] = WorkPackageCustomField.includes(:types).all
- @tab = params[:tab] || 'WorkPackageCustomField'
+ @tab = params[:tab] || "WorkPackageCustomField"
end
def new
@@ -59,10 +59,10 @@ class CustomFieldsController < ApplicationController
protected
def default_breadcrumb
- if action_name == 'index'
- t('label_custom_field_plural')
+ if action_name == "index"
+ t("label_custom_field_plural")
else
- ActionController::Base.helpers.link_to(t('label_custom_field_plural'), custom_fields_path)
+ ActionController::Base.helpers.link_to(t("label_custom_field_plural"), custom_fields_path)
end
end
@@ -78,8 +78,8 @@ class CustomFieldsController < ApplicationController
def check_custom_field
# ProjecCustomFields now managed in a different UI
- if @custom_field.nil? || @custom_field.type == 'ProjectCustomField'
- flash[:error] = 'Invalid CF type'
+ if @custom_field.nil? || @custom_field.type == "ProjectCustomField"
+ flash[:error] = "Invalid CF type"
redirect_to action: :index
end
end
diff --git a/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb b/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
index 76de92b4f45..f8a5f756220 100644
--- a/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
+++ b/app/forms/custom_fields/inputs/base/autocomplete/multi_value_input.rb
@@ -31,7 +31,7 @@ class CustomFields::Inputs::Base::Autocomplete::MultiValueInput < CustomFields::
base_input_attributes.merge(
autocomplete_options:,
wrapper_data_attributes: {
- 'qa-field-name': qa_field_name
+ "qa-field-name": qa_field_name
}
)
end
@@ -57,6 +57,6 @@ class CustomFields::Inputs::Base::Autocomplete::MultiValueInput < CustomFields::
end
def validation_message
- custom_values.map { |custom_value| custom_value.errors.full_messages }.join(', ') if invalid?
+ custom_values.map { |custom_value| custom_value.errors.full_messages }.join(", ") if invalid?
end
end
diff --git a/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb b/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
index ce6c7fcd740..d067a42478a 100644
--- a/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
+++ b/app/forms/custom_fields/inputs/base/autocomplete/single_value_input.rb
@@ -31,7 +31,7 @@ class CustomFields::Inputs::Base::Autocomplete::SingleValueInput < CustomFields:
base_input_attributes.merge(
autocomplete_options:,
wrapper_data_attributes: {
- 'qa-field-name': qa_field_name
+ "qa-field-name": qa_field_name
}
)
end
diff --git a/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb b/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb
index 8aa77123129..ad2460cf8c4 100644
--- a/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb
+++ b/app/forms/custom_fields/inputs/base/autocomplete/user_query_utils.rb
@@ -29,7 +29,7 @@
module CustomFields::Inputs::Base::Autocomplete::UserQueryUtils
def user_autocomplete_options
{
- component: 'opce-user-autocompleter',
+ component: "opce-user-autocompleter",
defaultData: false,
placeholder: I18n.t(:label_user_search),
resource:,
@@ -43,18 +43,18 @@ module CustomFields::Inputs::Base::Autocomplete::UserQueryUtils
end
def resource
- 'principals'
+ "principals"
end
def search_key
- 'any_name_attribute'
+ "any_name_attribute"
end
def filters
[
- { name: 'type', operator: '=', values: ['User', 'Group', 'PlaceholderUser'] },
- { name: 'member', operator: '=', values: [@object.id.to_s] },
- { name: 'status', operator: '!', values: [Principal.statuses["locked"].to_s] }
+ { name: "type", operator: "=", values: ["User", "Group", "PlaceholderUser"] },
+ { name: "member", operator: "=", values: [@object.id.to_s] },
+ { name: "status", operator: "!", values: [Principal.statuses["locked"].to_s] }
]
end
end
diff --git a/app/forms/custom_fields/inputs/base/input.rb b/app/forms/custom_fields/inputs/base/input.rb
index a578a692ef9..5f00afda992 100644
--- a/app/forms/custom_fields/inputs/base/input.rb
+++ b/app/forms/custom_fields/inputs/base/input.rb
@@ -40,7 +40,7 @@ class CustomFields::Inputs::Base::Input < ApplicationForm
def input_attributes
base_input_attributes.merge(
{
- data: { 'qa-field-name': qa_field_name },
+ data: { "qa-field-name": qa_field_name },
value:
}
)
@@ -55,6 +55,6 @@ class CustomFields::Inputs::Base::Input < ApplicationForm
end
def validation_message
- custom_value.errors.full_messages.join(', ') if invalid?
+ custom_value.errors.full_messages.join(", ") if invalid?
end
end
diff --git a/app/forms/custom_fields/inputs/base/utils.rb b/app/forms/custom_fields/inputs/base/utils.rb
index 5d517a04fe0..fe786cc07fd 100644
--- a/app/forms/custom_fields/inputs/base/utils.rb
+++ b/app/forms/custom_fields/inputs/base/utils.rb
@@ -60,6 +60,6 @@ module CustomFields::Inputs::Base::Utils
# used within autocompleter inputs
def append_to
- options.fetch(:wrapper_id, 'body')
+ options.fetch(:wrapper_id, "body")
end
end
diff --git a/app/forms/work_packages/share/invitee.rb b/app/forms/work_packages/share/invitee.rb
index ad08a74c283..de2d34f7369 100644
--- a/app/forms/work_packages/share/invitee.rb
+++ b/app/forms/work_packages/share/invitee.rb
@@ -30,27 +30,27 @@ module WorkPackages::Share
form do |user_invite_form|
user_invite_form.autocompleter(
name: :user_id,
- label: I18n.t('work_package.sharing.label_search'),
+ label: I18n.t("work_package.sharing.label_search"),
visually_hide_label: true,
- data: { 'work-packages--share--user-limit-target': 'autocompleter' },
+ data: { "work-packages--share--user-limit-target": "autocompleter" },
autocomplete_options: {
- component: 'opce-user-autocompleter',
+ component: "opce-user-autocompleter",
defaultData: false,
id: "op-share-wp-invite-autocomplete",
- placeholder: I18n.t('work_package.sharing.label_search_placeholder'),
+ placeholder: I18n.t("work_package.sharing.label_search_placeholder"),
data: {
- 'test-selector': 'op-share-wp-invite-autocomplete'
+ "test-selector": "op-share-wp-invite-autocomplete"
},
url: ::API::V3::Utilities::PathHelper::ApiV3Path.principals,
- filters: [{ name: 'type', operator: '=', values: %w[User Group] },
- { name: 'id', operator: '!', values: [::Queries::Filters::MeValue::KEY] },
- { name: 'status', operator: '=', values: [Principal.statuses[:active], Principal.statuses[:invited]] }],
- searchKey: 'any_name_attribute',
+ filters: [{ name: "type", operator: "=", values: %w[User Group] },
+ { name: "id", operator: "!", values: [::Queries::Filters::MeValue::KEY] },
+ { name: "status", operator: "=", values: [Principal.statuses[:active], Principal.statuses[:invited]] }],
+ searchKey: "any_name_attribute",
addTag: User.current.allowed_globally?(:create_user),
- addTagText: I18n.t('members.send_invite_to'),
+ addTagText: I18n.t("members.send_invite_to"),
multiple: true,
focusDirectly: true,
- appendTo: 'body',
+ appendTo: "body",
disabled: @disabled
}
)
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb
index 4e9434ff4ee..6d93fdb5427 100644
--- a/app/helpers/custom_fields_helper.rb
+++ b/app/helpers/custom_fields_helper.rb
@@ -30,32 +30,32 @@ module CustomFieldsHelper
def custom_fields_tabs
[
{
- name: 'WorkPackageCustomField',
- partial: 'custom_fields/tab',
+ name: "WorkPackageCustomField",
+ partial: "custom_fields/tab",
path: custom_fields_path(tab: :WorkPackageCustomField),
label: :label_work_package_plural
},
{
- name: 'TimeEntryCustomField',
- partial: 'custom_fields/tab',
+ name: "TimeEntryCustomField",
+ partial: "custom_fields/tab",
path: custom_fields_path(tab: :TimeEntryCustomField),
label: :label_spent_time
},
{
- name: 'VersionCustomField',
- partial: 'custom_fields/tab',
+ name: "VersionCustomField",
+ partial: "custom_fields/tab",
path: custom_fields_path(tab: :VersionCustomField),
label: :label_version_plural
},
{
- name: 'UserCustomField',
- partial: 'custom_fields/tab',
+ name: "UserCustomField",
+ partial: "custom_fields/tab",
path: custom_fields_path(tab: :UserCustomField),
label: :label_user_plural
},
{
- name: 'GroupCustomField',
- partial: 'custom_fields/tab',
+ name: "GroupCustomField",
+ partial: "custom_fields/tab",
path: custom_fields_path(tab: :GroupCustomField),
label: :label_group_plural
}
@@ -71,71 +71,71 @@ module CustomFieldsHelper
field_format = OpenProject::CustomFieldFormat.find_by_name(custom_field.field_format)
tag = case field_format.try(:edit_as)
- when 'date'
- angular_component_tag 'op-basic-single-date-picker',
+ when "date"
+ angular_component_tag "op-basic-single-date-picker",
inputs: {
required: custom_field.is_required,
value: custom_value.value,
id: field_id,
name: field_name
}
- when 'text'
- styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3, container_class: '-middle',
+ when "text"
+ styled_text_area_tag(field_name, custom_value.value, id: field_id, rows: 3, container_class: "-middle",
required: custom_field.is_required)
- when 'bool'
- hidden_tag = hidden_field_tag(field_name, '0')
- checkbox_tag = styled_check_box_tag(field_name, '1', custom_value.typed_value, id: field_id,
+ when "bool"
+ hidden_tag = hidden_field_tag(field_name, "0")
+ checkbox_tag = styled_check_box_tag(field_name, "1", custom_value.typed_value, id: field_id,
required: custom_field.is_required)
hidden_tag + checkbox_tag
- when 'list'
+ when "list"
blank_option = if custom_field.is_required? && custom_field.default_value.blank?
"<option value=\"\">--- #{I18n.t(:actionview_instancetag_blank_option)} ---</option>"
elsif custom_field.is_required? && custom_field.default_value.present?
- ''
+ ""
else
- '<option></option>'
+ "<option></option>"
end
options = blank_option.html_safe + options_for_select(custom_field.possible_values_options(custom_value.customized),
custom_value.value)
- styled_select_tag(field_name, options, id: field_id, container_class: '-middle', required: custom_field.is_required)
+ styled_select_tag(field_name, options, id: field_id, container_class: "-middle", required: custom_field.is_required)
else
- styled_text_field_tag(field_name, custom_value.value, id: field_id, container_class: '-middle',
+ styled_text_field_tag(field_name, custom_value.value, id: field_id, container_class: "-middle",
required: custom_field.is_required)
end
- tag = content_tag :span, tag, lang: custom_field.name_locale, class: 'form--field-container'
+ tag = content_tag :span, tag, lang: custom_field.name_locale, class: "form--field-container"
if custom_value.errors.empty?
tag
else
- ActionView::Base.wrap_with_error_span(tag, custom_value, 'value')
+ ActionView::Base.wrap_with_error_span(tag, custom_value, "value")
end
end
# Return custom field label tag
def custom_field_label_tag(name, custom_value)
- content_tag 'label', h(custom_value.custom_field.name) +
- (custom_value.custom_field.is_required? ? content_tag('span', ' *', class: 'required') : ''),
+ content_tag "label", h(custom_value.custom_field.name) +
+ (custom_value.custom_field.is_required? ? content_tag("span", " *", class: "required") : ""),
for: "#{name}_custom_field_values_#{custom_value.custom_field.id}",
class: "form--label #{custom_value.errors.empty? ? nil : 'error'}",
lang: custom_value.custom_field.name_locale
end
def hidden_custom_field_label_tag(name, custom_value)
- content_tag 'label', h(custom_value.custom_field.name) +
- (custom_value.custom_field.is_required? ? content_tag('span', ' *', class: 'required') : ''),
+ content_tag "label", h(custom_value.custom_field.name) +
+ (custom_value.custom_field.is_required? ? content_tag("span", " *", class: "required") : ""),
for: "#{name}_custom_field_values_#{custom_value.custom_field.id}",
class: "hidden-for-sighted",
lang: custom_value.custom_field.name_locale
end
def blank_custom_field_label_tag(name, custom_field)
- content_tag 'label', h(custom_field.name) +
- (custom_field.is_required? ? content_tag('span', ' *', class: 'required') : ''),
+ content_tag "label", h(custom_field.name) +
+ (custom_field.is_required? ? content_tag("span", " *", class: "required") : ""),
for: "#{name}_custom_field_values_#{custom_field.id}",
- class: 'form--label'
+ class: "form--label"
end
# Return custom field tag with its label tag
@@ -149,37 +149,37 @@ module CustomFieldsHelper
field_format = OpenProject::CustomFieldFormat.find_by_name(custom_field.field_format)
case field_format.try(:edit_as)
- when 'date'
- angular_component_tag 'op-modal-single-date-picker',
+ when "date"
+ angular_component_tag "op-modal-single-date-picker",
inputs: {
id: field_id,
name: field_name
}
- when 'text'
- styled_text_area_tag(field_name, '', id: field_id, rows: 3, with_text_formatting: true)
- when 'bool'
- styled_select_tag(field_name, options_for_select([[I18n.t(:label_no_change_option), ''],
- ([I18n.t(:label_none), 'none'] unless custom_field.required?),
- [I18n.t(:general_text_yes), '1'],
- [I18n.t(:general_text_no), '0']].compact), id: field_id)
- when 'list'
- base_options = [[I18n.t(:label_no_change_option), '']]
+ when "text"
+ styled_text_area_tag(field_name, "", id: field_id, rows: 3, with_text_formatting: true)
+ when "bool"
+ styled_select_tag(field_name, options_for_select([[I18n.t(:label_no_change_option), ""],
+ ([I18n.t(:label_none), "none"] unless custom_field.required?),
+ [I18n.t(:general_text_yes), "1"],
+ [I18n.t(:general_text_no), "0"]].compact), id: field_id)
+ when "list"
+ base_options = [[I18n.t(:label_no_change_option), ""]]
unless custom_field.required?
- unset_label = custom_field.field_format == 'user' ? :label_nobody : :label_none
- base_options << [I18n.t(unset_label), 'none']
+ unset_label = custom_field.field_format == "user" ? :label_nobody : :label_none
+ base_options << [I18n.t(unset_label), "none"]
end
styled_select_tag(field_name,
options_for_select(base_options + custom_field.possible_values_options(project)),
id: field_id,
multiple: custom_field.multi_value?)
else
- styled_text_field_tag(field_name, '', id: field_id)
+ styled_text_field_tag(field_name, "", id: field_id)
end
end
# Return a string used to display a custom value
def show_value(custom_value)
- return '' unless custom_value
+ return "" unless custom_value
custom_value.formatted_value
end
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index ef07583c930..7b86c4c97c9 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -38,15 +38,15 @@ class CustomField < ApplicationRecord
has_many :custom_options,
-> { order(position: :asc) },
dependent: :delete_all,
- inverse_of: 'custom_field'
+ inverse_of: "custom_field"
accepts_nested_attributes_for :custom_options
acts_as_list scope: [:type]
validates :field_format, presence: true
validates :custom_options,
- presence: { message: ->(*) { I18n.t(:'activerecord.errors.models.custom_field.at_least_one_custom_option') } },
- if: ->(*) { field_format == 'list' }
+ presence: { message: ->(*) { I18n.t(:"activerecord.errors.models.custom_field.at_least_one_custom_option") } },
+ if: ->(*) { field_format == "list" }
validates :name, presence: true, length: { maximum: 256 }
validate :uniqueness_of_name_with_scope
@@ -127,11 +127,11 @@ class CustomField < ApplicationRecord
def possible_values_options(obj = nil)
case field_format
- when 'user'
+ when "user"
possible_user_values_options(obj)
- when 'version'
+ when "version"
possible_version_values_options(obj)
- when 'list'
+ when "list"
possible_list_values_options
else
possible_values
@@ -153,9 +153,9 @@ class CustomField < ApplicationRecord
# You MUST NOT pass a customizable if this CF has any other format
def possible_values(obj = nil)
case field_format
- when 'user', 'version'
+ when "user", "version"
possible_values_options(obj).map(&:last)
- when 'list'
+ when "list"
custom_options
else
read_attribute(:possible_values)
@@ -184,27 +184,27 @@ class CustomField < ApplicationRecord
return if value.blank?
case field_format
- when 'string', 'text', 'list'
+ when "string", "text", "list"
value
- when 'date'
+ when "date"
begin
value.to_date
rescue StandardError
nil
end
- when 'bool'
+ when "bool"
ActiveRecord::Type::Boolean.new.cast(value)
- when 'int'
+ when "int"
value.to_i
- when 'float'
+ when "float"
value.to_f
- when 'user', 'version'
+ when "user", "version"
field_format.classify.constantize.find_by(id: value.to_i)
end
end
def <=>(other)
- if type == 'WorkPackageCustomField'
+ if type == "WorkPackageCustomField"
name.downcase <=> other.name.downcase
else
position <=> other.position
diff --git a/app/models/custom_value.rb b/app/models/custom_value.rb
index ea8fde49706..0e331d84f54 100644
--- a/app/models/custom_value.rb
+++ b/app/models/custom_value.rb
@@ -58,7 +58,7 @@ class CustomValue < ApplicationRecord
def strategy
@strategy ||= begin
- format = custom_field&.field_format || 'empty'
+ format = custom_field&.field_format || "empty"
OpenProject::CustomFieldFormat.find_by_name(format).formatter.new(self) # rubocop:disable Rails/DynamicFindBy
end
end
diff --git a/app/models/project_custom_field_project_mapping.rb b/app/models/project_custom_field_project_mapping.rb
index 217e06eadd4..f2832d96a6d 100644
--- a/app/models/project_custom_field_project_mapping.rb
+++ b/app/models/project_custom_field_project_mapping.rb
@@ -28,7 +28,7 @@
class ProjectCustomFieldProjectMapping < ApplicationRecord
belongs_to :project
- belongs_to :project_custom_field, class_name: 'ProjectCustomField', foreign_key: 'custom_field_id',
+ belongs_to :project_custom_field, class_name: "ProjectCustomField", foreign_key: "custom_field_id",
inverse_of: :project_custom_field_project_mappings
validates :custom_field_id, uniqueness: { scope: :project_id }
diff --git a/app/models/projects/acts_as_customizable_patches.rb b/app/models/projects/acts_as_customizable_patches.rb
index 41441fe6cc7..9fdd53b0b0c 100644
--- a/app/models/projects/acts_as_customizable_patches.rb
+++ b/app/models/projects/acts_as_customizable_patches.rb
@@ -35,9 +35,9 @@ module Projects::ActsAsCustomizablePatches
# not needed for now, but might be relevant if we want to have edit dialogs just for one custom field
included do
- has_many :project_custom_field_project_mappings, class_name: 'ProjectCustomFieldProjectMapping', foreign_key: :project_id,
+ has_many :project_custom_field_project_mappings, class_name: "ProjectCustomFieldProjectMapping", foreign_key: :project_id,
dependent: :destroy, inverse_of: :project
- has_many :project_custom_fields, through: :project_custom_field_project_mappings, class_name: 'ProjectCustomField'
+ has_many :project_custom_fields, through: :project_custom_field_project_mappings, class_name: "ProjectCustomField"
# we need to reset the query_available_custom_fields_on_global_level already after validation
# as the update service just calls .valid? and returns if invalid
@@ -86,7 +86,7 @@ module Projects::ActsAsCustomizablePatches
def reject_section_scoped_validation_for_creation
if _limit_custom_fields_validation_to_section_id.present?
raise ArgumentError,
- 'Section scoped validation is not supported for project creation, only for project updates'
+ "Section scoped validation is not supported for project creation, only for project updates"
end
end
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 4839e5f294d..a9ab75a41aa 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'active_support/core_ext/integer/time'
+require "active_support/core_ext/integer/time"
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -37,7 +37,7 @@ Rails.application.configure do
config.enable_reloading = true
# Do not eager load code on boot by default.
- config.eager_load = ENV['EAGER_LOAD'].present?
+ config.eager_load = ENV["EAGER_LOAD"].present?
# Asynchronous file watcher
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
@@ -111,12 +111,12 @@ Rails.application.configure do
config.action_mailer.delivery_method = :letter_opener_web
# Set email preview locations to rspec
- config.action_mailer.preview_paths << Rails.root.join('spec/mailers/previews')
+ config.action_mailer.preview_paths << Rails.root.join("spec/mailers/previews")
- config.hosts << 'bs-local.com' if ENV['OPENPROJECT_DISABLE_DEV_ASSET_PROXY'].present?
+ config.hosts << "bs-local.com" if ENV["OPENPROJECT_DISABLE_DEV_ASSET_PROXY"].present?
- if ENV['OPENPROJECT_DEV_EXTRA_HOSTS'].present?
- config.hosts.push(*ENV['OPENPROJECT_DEV_EXTRA_HOSTS'].split(','))
+ if ENV["OPENPROJECT_DEV_EXTRA_HOSTS"].present?
+ config.hosts.push(*ENV["OPENPROJECT_DEV_EXTRA_HOSTS"].split(","))
end
end
diff --git a/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb b/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb
index 42462529531..ff9580a45df 100644
--- a/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb
+++ b/db/migrate/20231031133334_create_project_custom_field_project_mappings.rb
@@ -2,7 +2,7 @@ class CreateProjectCustomFieldProjectMappings < ActiveRecord::Migration[7.0]
def up
create_table :project_custom_field_project_mappings do |t|
t.references :custom_field, foreign_key: true, index: {
- name: 'index_project_cf_project_mappings_on_custom_field_id'
+ name: "index_project_cf_project_mappings_on_custom_field_id"
}
t.references :project, foreign_key: true
diff --git a/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb b/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb
index 9168d770fb8..8ac7940f7b7 100644
--- a/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb
+++ b/db/migrate/20240208100316_enable_required_project_custom_fields_in_all_projects.rb
@@ -8,7 +8,7 @@ class EnableRequiredProjectCustomFieldsInAllProjects < ActiveRecord::Migration[7
missing_custom_field_attributes =
Project
.includes(:project_custom_field_project_mappings)
- .pluck(:id, 'project_custom_field_project_mappings.custom_field_id')
+ .pluck(:id, "project_custom_field_project_mappings.custom_field_id")
.group_by(&:first)
.transform_values { |values| values.map(&:last) }
.reduce([]) do |acc, (project_id, custom_field_ids)|
diff --git a/lib/api/v3/principals/principals_api.rb b/lib/api/v3/principals/principals_api.rb
index 8ddaf82484f..a939525ae7c 100644
--- a/lib/api/v3/principals/principals_api.rb
+++ b/lib/api/v3/principals/principals_api.rb
@@ -37,9 +37,9 @@ module API
.mount
params do
- requires :id, desc: 'Principal ID'
+ requires :id, desc: "Principal ID"
end
- route_param :id, type: Integer, desc: 'Principal ID' do
+ route_param :id, type: Integer, desc: "Principal ID" do
after_validation do
@principal = Principal.visible.find(params[:id])
end
diff --git a/lib/open_project/events.rb b/lib/open_project/events.rb
index edf7d3eefee..47f08cceade 100644
--- a/lib/open_project/events.rb
+++ b/lib/open_project/events.rb
@@ -42,15 +42,15 @@ module OpenProject
AGGREGATED_NEWS_JOURNAL_READY = "aggregated_news_journal_ready".freeze
AGGREGATED_MESSAGE_JOURNAL_READY = "aggregated_message_journal_ready".freeze
- ATTACHMENT_CREATED = 'attachment_created'.freeze
+ ATTACHMENT_CREATED = "attachment_created".freeze
- JOURNAL_CREATED = 'journal_created'.freeze
+ JOURNAL_CREATED = "journal_created".freeze
- MEMBER_CREATED = 'member_created'.freeze
- MEMBER_UPDATED = 'member_updated'.freeze
- MEMBER_DESTROYED = 'member_destroyed'.freeze
+ MEMBER_CREATED = "member_created".freeze
+ MEMBER_UPDATED = "member_updated".freeze
+ MEMBER_DESTROYED = "member_destroyed".freeze
- OAUTH_CLIENT_TOKEN_CREATED = 'oauth_client_token_created'.freeze
+ OAUTH_CLIENT_TOKEN_CREATED = "oauth_client_token_created".freeze
TIME_ENTRY_CREATED = "time_entry_created".freeze
@@ -72,9 +72,9 @@ module OpenProject
ROLE_UPDATED = "role_updated".freeze
ROLE_DESTROYED = "role_destroyed".freeze
- WATCHER_ADDED = 'watcher_added'.freeze
- WATCHER_DESTROYED = 'watcher_destroyed'.freeze
+ WATCHER_ADDED = "watcher_added".freeze
+ WATCHER_DESTROYED = "watcher_destroyed".freeze
- WORK_PACKAGE_SHARED = 'work_package_shared'.freeze
+ WORK_PACKAGE_SHARED = "work_package_shared".freeze
end
end
diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rb
index b488b858a60..3bde27c86b6 100644
--- a/lib/open_project/static/links.rb
+++ b/lib/open_project/static/links.rb
@@ -276,10 +276,10 @@ module OpenProject
href: "https://apps.nextcloud.com/apps/integration_openproject"
},
one_drive_oauth_application: {
- href: 'https://portal.azure.com/'
+ href: "https://portal.azure.com/"
},
troubleshooting: {
- href: 'https://www.openproject.org/docs/user-guide/file-management/nextcloud-integration/#possible-errors-and-troubleshooting'
+ href: "https://www.openproject.org/docs/user-guide/file-management/nextcloud-integration/#possible-errors-and-troubleshooting"
}
},
ical_docs: {
diff --git a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
index a98e168399a..16aaf44125a 100644
--- a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -77,8 +77,8 @@ module Redmine
def custom_fields=(values)
values_to_hash = values.inject({}) do |hash, v|
v = v.stringify_keys
- if v['id'] && v.has_key?('value')
- hash[v['id']] = v['value']
+ if v["id"] && v.has_key?("value")
+ hash[v["id"]] = v["value"]
end
hash
end
diff --git a/modules/overviews/config/routes.rb b/modules/overviews/config/routes.rb
index 755569db7e3..846ce8d17a1 100644
--- a/modules/overviews/config/routes.rb
+++ b/modules/overviews/config/routes.rb
@@ -1,11 +1,11 @@
Rails.application.routes.draw do
constraints(project_id: Regexp.new("(?!(#{Project::RESERVED_IDENTIFIERS.join('|')})$)(\\w|-)+"), format: :html) do
- get 'projects/:project_id',
+ get "projects/:project_id",
to: "overviews/overviews#show",
as: :project_overview
- get 'projects/:project_id/project_custom_fields_sidebar', to: "overviews/overviews#project_custom_fields_sidebar", as: :project_custom_fields_sidebar
- get 'projects/:project_id/project_custom_field_section_dialog/:section_id', to: "overviews/overviews#project_custom_field_section_dialog",
+ get "projects/:project_id/project_custom_fields_sidebar", to: "overviews/overviews#project_custom_fields_sidebar", as: :project_custom_fields_sidebar
+ get "projects/:project_id/project_custom_field_section_dialog/:section_id", to: "overviews/overviews#project_custom_field_section_dialog",
as: :project_custom_field_section_dialog
- put 'projects/:project_id/update_project_custom_values/:section_id', to: "overviews/overviews#update_project_custom_values", as: :update_project_custom_values
+ put "projects/:project_id/update_project_custom_values/:section_id", to: "overviews/overviews#update_project_custom_values", as: :update_project_custom_values
end
end
diff --git a/modules/overviews/lib/overviews/engine.rb b/modules/overviews/lib/overviews/engine.rb
index c738f08b13a..dbc9f9392e4 100644
--- a/modules/overviews/lib/overviews/engine.rb
+++ b/modules/overviews/lib/overviews/engine.rb
@@ -32,42 +32,42 @@ module Overviews
include OpenProject::Plugins::ActsAsOpEngine
- initializer 'overviews.menu' do
+ initializer "overviews.menu" do
::Redmine::MenuManager.map(:project_menu) do |menu|
menu.push(:overview,
- { controller: '/overviews/overviews', action: 'show' },
- caption: :'overviews.label',
+ { controller: "/overviews/overviews", action: "show" },
+ caption: :"overviews.label",
first: true,
- icon: 'info1')
+ icon: "info1")
end
end
- initializer 'overviews.permissions' do
+ initializer "overviews.permissions" do
Rails.application.reloader.to_prepare do
OpenProject::AccessControl.permission(:view_project)
.controller_actions
.push(
- 'overviews/overviews/show',
- 'overviews/overviews/project_custom_fields_sidebar'
+ "overviews/overviews/show",
+ "overviews/overviews/project_custom_fields_sidebar"
)
OpenProject::AccessControl.permission(:edit_project)
.controller_actions
.push(
- 'overviews/overviews/project_custom_field_section_dialog',
- 'overviews/overviews/update_project_custom_values'
+ "overviews/overviews/project_custom_field_section_dialog",
+ "overviews/overviews/update_project_custom_values"
)
OpenProject::AccessControl.permission(:view_work_packages)
.controller_actions
- .push('overviews/overviews/show')
+ .push("overviews/overviews/show")
OpenProject::AccessControl.map do |ac_map|
ac_map.project_module nil do |map|
map.permission :manage_overview,
- { 'overviews/overviews':
+ { "overviews/overviews":
[
- 'show'
+ "show"
] },
permissible_on: :project,
require: :member
@@ -76,10 +76,10 @@ module Overviews
end
end
- initializer 'overviews.conversion' do
- require Rails.root.join('config/constants/ar_to_api_conversions')
+ initializer "overviews.conversion" do
+ require Rails.root.join("config/constants/ar_to_api_conversions")
- Constants::ARToAPIConversions.add('grids/overview': 'grid')
+ Constants::ARToAPIConversions.add("grids/overview": "grid")
end
config.to_prepare do
diff --git a/modules/storages/app/common/storages/peripherals/nextcloud.rb b/modules/storages/app/common/storages/peripherals/nextcloud.rb
index d59f4d003d3..8c8a0c33599 100644
--- a/modules/storages/app/common/storages/peripherals/nextcloud.rb
+++ b/modules/storages/app/common/storages/peripherals/nextcloud.rb
@@ -30,8 +30,8 @@
module Storages
module Peripherals
- Nextcloud = Dry::Container::Namespace.new('nextcloud') do
- namespace('queries') do
+ Nextcloud = Dry::Container::Namespace.new("nextcloud") do
+ namespace("queries") do
register(:auth_check, StorageInteraction::Nextcloud::AuthCheckQuery)
register(:download_link, StorageInteraction::Nextcloud::DownloadLinkQuery)
register(:file_ids, StorageInteraction::Nextcloud::FileIdsQuery)
@@ -46,7 +46,7 @@ module Storages
register(:open_storage, StorageInteraction::Nextcloud::OpenStorageQuery)
end
- namespace('commands') do
+ namespace("commands") do
register(:add_user_to_group, StorageInteraction::Nextcloud::AddUserToGroupCommand)
register(:copy_template_folder, StorageInteraction::Nextcloud::CopyTemplateFolderCommand)
register(:create_folder, StorageInteraction::Nextcloud::CreateFolderCommand)
@@ -57,11 +57,11 @@ module Storages
register(:set_permissions, StorageInteraction::Nextcloud::SetPermissionsCommand)
end
- namespace('contracts') do
+ namespace("contracts") do
register(:storage, ::Storages::Storages::NextcloudContract)
end
- namespace('models') do
+ namespace("models") do
register(:managed_folder_identifier, ManagedFolderIdentifier::Nextcloud)
end
end
diff --git a/modules/storages/app/common/storages/peripherals/one_drive.rb b/modules/storages/app/common/storages/peripherals/one_drive.rb
index 5ec1cc2975a..0d9b6faef0b 100644
--- a/modules/storages/app/common/storages/peripherals/one_drive.rb
+++ b/modules/storages/app/common/storages/peripherals/one_drive.rb
@@ -30,8 +30,8 @@
module Storages
module Peripherals
- OneDrive = Dry::Container::Namespace.new('one_drive') do
- namespace('queries') do
+ OneDrive = Dry::Container::Namespace.new("one_drive") do
+ namespace("queries") do
register(:auth_check, StorageInteraction::OneDrive::AuthCheckQuery)
register(:download_link, StorageInteraction::OneDrive::DownloadLinkQuery)
register(:files, StorageInteraction::OneDrive::FilesQuery)
@@ -43,18 +43,18 @@ module Storages
register(:upload_link, StorageInteraction::OneDrive::UploadLinkQuery)
end
- namespace('commands') do
+ namespace("commands") do
register(:create_folder, StorageInteraction::OneDrive::CreateFolderCommand)
register(:delete_folder, StorageInteraction::OneDrive::DeleteFolderCommand)
register(:rename_file, StorageInteraction::OneDrive::RenameFileCommand)
register(:set_permissions, StorageInteraction::OneDrive::SetPermissionsCommand)
end
- namespace('contracts') do
+ namespace("contracts") do
register(:storage, ::Storages::Storages::OneDriveContract)
end
- namespace('models') do
+ namespace("models") do
register(:managed_folder_identifier, ManagedFolderIdentifier::OneDrive)
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
index 0cf4f57d18a..90a18bf3ca7 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/group_users_query.rb
@@ -47,7 +47,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
response = OpenProject
.httpx
.basic_auth(@username, @password)
- .with(headers: { 'OCS-APIRequest' => 'true' })
+ .with(headers: { "OCS-APIRequest" => "true" })
.get(Util.join_uri_path(@uri, "ocs/v1.php/cloud/groups", CGI.escapeURIComponent(group)))
error_data = Storages::StorageErrorData.new(source: self.class, payload: response)
@@ -55,19 +55,19 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
case response
in { status: 200..299 }
group_users = Nokogiri::XML(response.body.to_s)
- .xpath('/ocs/data/users/element')
+ .xpath("/ocs/data/users/element")
.map(&:text)
ServiceResult.success(result: group_users)
in { status: 405 }
- Util.error(:not_allowed, 'Outbound request method not allowed', error_data)
+ Util.error(:not_allowed, "Outbound request method not allowed", error_data)
in { status: 401 }
- Util.error(:unauthorized, 'Outbound request not authorized', error_data)
+ Util.error(:unauthorized, "Outbound request not authorized", error_data)
in { status: 404 }
- Util.error(:not_found, 'Outbound request destination not found', error_data)
+ Util.error(:not_found, "Outbound request destination not found", error_data)
in { status: 409 }
Util.error(:conflict, error_text_from_response(response), error_data)
else
- Util.error(:error, 'Outbound request failed', error_data)
+ Util.error(:error, "Outbound request failed", error_data)
end
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
index 1bf71362f34..436b40364fa 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/create_folder_command.rb
@@ -66,7 +66,7 @@ module Storages
case response
in { status: 200..299 }
ServiceResult.success(result: file_info_for(MultiJson.load(response.body, symbolize_keys: true)),
- message: 'Folder was successfully created.')
+ message: "Folder was successfully created.")
in { status: 404 }
ServiceResult.failure(result: :not_found,
errors: ::Storages::StorageError.new(code: :not_found, data:))
@@ -101,7 +101,7 @@ module Storages
{
name: folder_path,
folder: {},
- '@microsoft.graph.conflictBehavior' => "fail"
+ "@microsoft.graph.conflictBehavior" => "fail"
}.to_json
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb
index 596d009d78e..8a6f3a091b8 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/download_link_query.rb
@@ -49,7 +49,7 @@ module Storages
@uri,
uri_path_for(file_link.origin_id)
),
- headers: { 'Authorization' => "Bearer #{token.access_token}" }
+ headers: { "Authorization" => "Bearer #{token.access_token}" }
)
handle_errors(response)
@@ -61,7 +61,7 @@ module Storages
def handle_errors(response)
case response
in { status: 300..399 }
- ServiceResult.success(result: response.headers['Location'])
+ ServiceResult.success(result: response.headers["Location"])
in { status: 404 }
ServiceResult.failure(result: :not_found,
errors: ::Storages::StorageError.new(code: :not_found, data: response))
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query.rb
index af82c7c2964..efce5928626 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query.rb
@@ -108,7 +108,7 @@ module Storages::Peripherals::StorageInteraction::OneDrive
response = http.get(Util.join_uri_path(@storage.uri, "#{uri_path}?$select=id,name,parentReference"))
handle_responses(response).map do |json|
if folder.root?
- { '/' => Storages::StorageFileInfo.from_id(json[:id]) }
+ { "/" => Storages::StorageFileInfo.from_id(json[:id]) }
else
parse_drive_item_info(json)[:entry]
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb
index b952e054411..49e4721aac4 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/set_permissions_command.rb
@@ -124,8 +124,8 @@ module Storages
permission[:id]
end.curry
- write_permissions = permission_set.filter_map(&filter.call('write'))
- read_permissions = permission_set.filter_map(&filter.call('read'))
+ write_permissions = permission_set.filter_map(&filter.call("write"))
+ read_permissions = permission_set.filter_map(&filter.call("read"))
{ read: read_permissions, write: write_permissions }
end
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
index 529dd2632b4..fae746357b7 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/upload_link_query.rb
@@ -43,12 +43,12 @@ module Storages
end
def call(user:, data:)
- folder, filename = data.slice('parent', 'file_name').values
+ folder, filename = data.slice("parent", "file_name").values
Util.using_user_token(@storage, user) do |token|
response = OpenProject.httpx
- .with(headers: { 'Authorization' => "Bearer #{token.access_token}",
- 'Content-Type' => 'application/json' })
+ .with(headers: { "Authorization" => "Bearer #{token.access_token}",
+ "Content-Type" => "application/json" })
.post(
Util.join_uri_path(@uri, uri_path_for(folder, filename)),
json: payload(filename)
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
index 159862dd869..93529fcba79 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/one_drive/util.rb
@@ -33,7 +33,7 @@ module Storages::Peripherals::StorageInteraction::OneDrive::Util
class << self
def mime_type(json)
- json.dig(:file, :mimeType) || (json.key?(:folder) ? 'application/x-op-directory' : nil)
+ json.dig(:file, :mimeType) || (json.key?(:folder) ? "application/x-op-directory" : nil)
end
def using_user_token(storage, user, &)
@@ -52,7 +52,7 @@ module Storages::Peripherals::StorageInteraction::OneDrive::Util
errors: ::Storages::StorageError.new(
code: :unauthorized,
data: ::Storages::StorageErrorData.new(source: connection_manager),
- log_message: 'Query could not be created! No access token found!'
+ log_message: "Query could not be created! No access token found!"
)
)
end
@@ -78,7 +78,7 @@ module Storages::Peripherals::StorageInteraction::OneDrive::Util
token_result = begin
Rails.cache.fetch("storage.#{storage.id}.access_token", expires_in: 50.minutes) do
- ServiceResult.success(result: oauth_client.access_token!(scope: 'https://graph.microsoft.com/.default'))
+ ServiceResult.success(result: oauth_client.access_token!(scope: "https://graph.microsoft.com/.default"))
end
rescue Rack::OAuth2::Client::Error => e
ServiceResult.failure(errors: ::Storages::StorageError.new(
@@ -93,16 +93,16 @@ module Storages::Peripherals::StorageInteraction::OneDrive::Util
yield OpenProject.httpx.with(origin: storage.uri,
headers: { authorization: "Bearer #{token.access_token}",
accept: "application/json",
- 'content-type': 'application/json' })
+ "content-type": "application/json" })
end,
on_failure: ->(errors) { ServiceResult.failure(result: :unauthorized, errors:) }
)
end
- def extract_location(parent_reference, file_name = '')
- location = parent_reference[:path].gsub(/.*root:/, '')
+ def extract_location(parent_reference, file_name = "")
+ location = parent_reference[:path].gsub(/.*root:/, "")
- appendix = file_name.blank? ? '' : "/#{file_name}"
+ appendix = file_name.blank? ? "" : "/#{file_name}"
location.empty? ? "/#{file_name}" : "#{location}#{appendix}"
end
end
diff --git a/modules/storages/app/mailers/storages/storages_mailer.rb b/modules/storages/app/mailers/storages/storages_mailer.rb
index 50dbe4fcd1d..42088376911 100644
--- a/modules/storages/app/mailers/storages/storages_mailer.rb
+++ b/modules/storages/app/mailers/storages/storages_mailer.rb
@@ -30,7 +30,7 @@
module Storages
class StoragesMailer < ApplicationMailer
- layout 'mailer'
+ layout "mailer"
include MessagesHelper
include MailNotificationHelper
@@ -43,7 +43,7 @@ module Storages
@storage = storage
@reason = storage.health_reason
@url = edit_admin_settings_storage_url(storage)
- subject = I18n.t('mail.storages.health.unhealthy.subject', name: @storage.name)
+ subject = I18n.t("mail.storages.health.unhealthy.subject", name: @storage.name)
mail(to: admin.mail, subject:)
end
@@ -52,7 +52,7 @@ module Storages
@storage = storage
@reason = reason
@url = edit_admin_settings_storage_url(storage)
- subject = I18n.t('mail.storages.health.healthy.subject', name: @storage.name)
+ subject = I18n.t("mail.storages.health.healthy.subject", name: @storage.name)
mail(to: admin.mail, subject:)
end
end
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 66a57a4e999..fe961c49422 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -139,10 +139,10 @@ module OpenProject::Storages
dependencies: %i[view_file_links],
contract_actions: { file_links: %i[manage] }
permission :manage_storages_in_project,
- { 'storages/admin/project_storages': %i[index members new
+ { "storages/admin/project_storages": %i[index members new
edit update create oauth_access_grant
destroy destroy_info set_permissions],
- 'storages/project_settings/project_storage_members': %i[index] },
+ "storages/project_settings/project_storage_members": %i[index] },
permissible_on: :project,
dependencies: %i[]
@@ -179,14 +179,14 @@ module OpenProject::Storages
(prj_storage.project_folder_automatic? && !u.allowed_in_project?(:read_files, prj))
next if hide_from_menu
- icon = storage.provider_type_nextcloud? ? 'nextcloud-circle' : 'hosting'
+ icon = storage.provider_type_nextcloud? ? "nextcloud-circle" : "hosting"
menu.push(
:"storage_#{storage.id}",
prj_storage.open_with_connection_ensured,
caption: storage.name,
before: :members,
icon:,
- icon_after: 'external-link',
+ icon_after: "external-link",
skip_permissions_check: true
)
end
@@ -302,12 +302,12 @@ module OpenProject::Storages
add_cron_jobs do
{
- 'Storages::CleanupUncontaineredFileLinksJob': {
+ "Storages::CleanupUncontaineredFileLinksJob": {
cron: "06 22 * * *",
class: ::Storages::CleanupUncontaineredFileLinksJob.name
},
- 'Storages::ManageNextcloudIntegrationJob': {
+ "Storages::ManageNextcloudIntegrationJob": {
cron: "1 * * * *",
class: ::Storages::ManageNextcloudIntegrationJob.name
}
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
index b2df40f1df6..53225148061 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/files_query_spec.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery, :webmock do
@@ -36,22 +36,22 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,
let(:user) { create(:user) }
let(:storage) { create(:sharepoint_dev_drive_storage, oauth_client_token_user: user) }
- let(:folder) { Storages::Peripherals::ParentFolder.new('/') }
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/") }
let(:auth_strategy) do
Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken.strategy.with_user(user)
end
- describe '#call' do
- it 'responds with correct parameters' do
+ describe "#call" do
+ it "responds with correct parameters" do
expect(described_class).to respond_to(:call)
method = described_class.method(:call)
expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq auth_strategy], %i[keyreq folder])
end
- context 'with outbound requests successful' do
- context 'with parent folder being root', vcr: 'one_drive/files_query_root' do
- it 'returns a StorageFiles object for root' do
+ context "with outbound requests successful" do
+ context "with parent folder being root", vcr: "one_drive/files_query_root" do
+ it "returns a StorageFiles object for root" do
storage_files = described_class.call(storage:, auth_strategy:, folder:).result
expect(storage_files).to be_a(Storages::StorageFiles)
@@ -59,115 +59,115 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,
expect(storage_files.parent.name).to eq("Root")
expect(storage_files.files.count).to eq(3)
expect(storage_files.files.map(&:to_h).first)
- .to eq({ id: '01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR',
- name: 'Folder',
+ .to eq({ id: "01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR",
+ name: "Folder",
size: 260500,
- created_at: Time.zone.parse('2023-09-26T14:38:50Z'),
- created_by_name: 'Eric Schubert',
- last_modified_at: Time.zone.parse('2023-09-26T14:38:50Z'),
- last_modified_by_name: 'Eric Schubert',
- location: '/Folder',
- mime_type: 'application/x-op-directory',
+ created_at: Time.zone.parse("2023-09-26T14:38:50Z"),
+ created_by_name: "Eric Schubert",
+ last_modified_at: Time.zone.parse("2023-09-26T14:38:50Z"),
+ last_modified_by_name: "Eric Schubert",
+ location: "/Folder",
+ mime_type: "application/x-op-directory",
permissions: %i[readable writeable] })
end
end
- context 'with a given parent folder', vcr: 'one_drive/files_query_parent_folder' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder/Subfolder') }
+ context "with a given parent folder", vcr: "one_drive/files_query_parent_folder" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/Folder/Subfolder") }
subject do
described_class.call(storage:, auth_strategy:, folder:).result
end
# rubocop:disable RSpec/ExampleLength
- it 'returns the files content' do
+ it "returns the files content" do
expect(subject.files.map(&:to_h))
.to eq([
{
- id: '01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA',
- name: 'NextcloudHub.md',
+ id: "01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA",
+ name: "NextcloudHub.md",
size: 1095,
- created_at: '2023-09-26T14:45:25Z',
- created_by_name: 'Eric Schubert',
- last_modified_at: '2023-09-26T14:46:13Z',
- last_modified_by_name: 'Eric Schubert',
- location: '/Folder/Subfolder/NextcloudHub.md',
- mime_type: 'application/octet-stream',
+ created_at: "2023-09-26T14:45:25Z",
+ created_by_name: "Eric Schubert",
+ last_modified_at: "2023-09-26T14:46:13Z",
+ last_modified_by_name: "Eric Schubert",
+ location: "/Folder/Subfolder/NextcloudHub.md",
+ mime_type: "application/octet-stream",
permissions: %i[readable writeable]
}, {
- id: '01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ',
- name: 'test.txt',
+ id: "01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ",
+ name: "test.txt",
size: 28,
- created_at: '2023-09-26T14:45:23Z',
- created_by_name: 'Eric Schubert',
- last_modified_at: '2023-09-26T14:45:45Z',
- last_modified_by_name: 'Eric Schubert',
- location: '/Folder/Subfolder/test.txt',
- mime_type: 'text/plain',
+ created_at: "2023-09-26T14:45:23Z",
+ created_by_name: "Eric Schubert",
+ last_modified_at: "2023-09-26T14:45:45Z",
+ last_modified_by_name: "Eric Schubert",
+ location: "/Folder/Subfolder/test.txt",
+ mime_type: "text/plain",
permissions: %i[readable writeable]
}
])
end
# rubocop:enable RSpec/ExampleLength
- it 'returns ancestors with a forged id' do
+ it "returns ancestors with a forged id" do
expect(subject.ancestors.map { |a| { id: a.id, name: a.name, location: a.location } })
.to eq([
{
- id: 'a1d45ff742d2175c095f0a7173f93fc3fc23664a953ceae6778fe15398818c2d',
- name: 'Root',
- location: '/'
+ id: "a1d45ff742d2175c095f0a7173f93fc3fc23664a953ceae6778fe15398818c2d",
+ name: "Root",
+ location: "/"
}, {
- id: '74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340',
- name: 'Folder',
- location: '/Folder'
+ id: "74ccd43303847f2655300641a934959cdb11689ce171aa0f00faa92917fbd340",
+ name: "Folder",
+ location: "/Folder"
}
])
end
- it 'returns the parent itself' do
- expect(subject.parent.id).to eq('01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG')
- expect(subject.parent.name).to eq('Subfolder')
- expect(subject.parent.location).to eq('/Folder/Subfolder')
+ it "returns the parent itself" do
+ expect(subject.parent.id).to eq("01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG")
+ expect(subject.parent.name).to eq("Subfolder")
+ expect(subject.parent.location).to eq("/Folder/Subfolder")
end
end
- context 'with parent folder being empty', vcr: 'one_drive/files_query_empty_folder' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder with spaces/very empty folder') }
+ context "with parent folder being empty", vcr: "one_drive/files_query_empty_folder" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/Folder with spaces/very empty folder") }
- it 'returns an empty StorageFiles object with parent and ancestors' do
+ it "returns an empty StorageFiles object with parent and ancestors" do
storage_files = described_class.call(storage:, auth_strategy:, folder:).result
expect(storage_files).to be_a(Storages::StorageFiles)
expect(storage_files.files).to be_empty
# in an empty folder the parent id cannot be retrieved, hence the parent id will get forged
- expect(storage_files.parent.id).to eq('01AZJL5PMGEIRPHZPHRRH2NM3D734VIR7H')
+ expect(storage_files.parent.id).to eq("01AZJL5PMGEIRPHZPHRRH2NM3D734VIR7H")
end
end
- context 'with a path full of umlauts', vcr: 'one_drive/files_query_umlauts' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/Folder/Ümlæûts') }
+ context "with a path full of umlauts", vcr: "one_drive/files_query_umlauts" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/Folder/Ümlæûts") }
- it 'returns the correct StorageFiles object' do
+ it "returns the correct StorageFiles object" do
storage_files = described_class.call(storage:, auth_strategy:, folder:).result
expect(storage_files).to be_a(Storages::StorageFiles)
- expect(storage_files.parent.id).to eq('01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB')
- expect(storage_files.parent.name).to eq('Ümlæûts')
- expect(storage_files.parent.location).to eq('/Folder/Ümlæûts')
+ expect(storage_files.parent.id).to eq("01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB")
+ expect(storage_files.parent.name).to eq("Ümlæûts")
+ expect(storage_files.parent.location).to eq("/Folder/Ümlæûts")
expect(storage_files.files.map(&:to_h))
.to eq([
{
- id: '01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE',
- name: 'Anrüchiges deutsches Dokument.docx',
+ id: "01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE",
+ name: "Anrüchiges deutsches Dokument.docx",
size: 18007,
- created_at: '2023-10-09T15:26:45Z',
- created_by_name: 'Eric Schubert',
- last_modified_at: '2023-10-09T15:27:25Z',
- last_modified_by_name: 'Eric Schubert',
- location: '/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx',
- mime_type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ created_at: "2023-10-09T15:26:45Z",
+ created_by_name: "Eric Schubert",
+ last_modified_at: "2023-10-09T15:27:25Z",
+ last_modified_by_name: "Eric Schubert",
+ location: "/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx",
+ mime_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
permissions: %i[readable writeable]
}
])
@@ -175,10 +175,10 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FilesQuery,
end
end
- context 'with not existent parent folder', vcr: 'one_drive/files_query_invalid_parent' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/I/just/made/that/up') }
+ context "with not existent parent folder", vcr: "one_drive/files_query_invalid_parent" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/I/just/made/that/up") }
- it 'must return not found' do
+ it "must return not found" do
result = described_class.call(storage:, auth_strategy:, folder:)
expect(result).to be_failure
expect(result.error_source).to be_a(described_class)
diff --git a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query_spec.rb b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query_spec.rb
index 7a545119bf1..a19b6228469 100644
--- a/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query_spec.rb
+++ b/modules/storages/spec/common/storages/peripherals/storage_interaction/one_drive/folder_files_file_ids_deep_query_spec.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
require_module_spec_helper
RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FolderFilesFileIdsDeepQuery, :webmock do
@@ -36,73 +36,73 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FolderFilesF
let(:user) { create(:user) }
let(:storage) { create(:sharepoint_dev_drive_storage, oauth_client_token_user: user) }
- let(:folder) { Storages::Peripherals::ParentFolder.new('/') }
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/") }
- describe '#call' do
- it 'responds with correct parameters' do
+ describe "#call" do
+ it "responds with correct parameters" do
expect(described_class).to respond_to(:call)
method = described_class.method(:call)
expect(method.parameters).to contain_exactly(%i[keyreq storage], %i[keyreq folder])
end
- context 'with outbound requests successful' do
+ context "with outbound requests successful" do
subject do
described_class.call(storage:, folder:).result
end
- context 'with parent folder being root', vcr: 'one_drive/folder_files_file_ids_deep_query_root' do
- it 'returns the file id dictionary' do
+ context "with parent folder being root", vcr: "one_drive/folder_files_file_ids_deep_query_root" do
+ it "returns the file id dictionary" do
expect(subject.transform_values(&:id))
.to eq({
- '/' => '01AZJL5PN6Y2GOVW7725BZO354PWSELRRZ',
- '/Folder with spaces' => '01AZJL5PKU2WV3U3RKKFF2A7ZCWVBXRTEU',
- '/Folder with spaces/very empty folder' => '01AZJL5PMGEIRPHZPHRRH2NM3D734VIR7H',
- '/Folder with spaces/wordle1.png' => '01AZJL5PPMSBBO3R2BIZHJFCELSW3RP7GN',
- '/Folder with spaces/wordle2.png' => '01AZJL5PIIFUD6A765KBAIAEMYACAFB2WP',
- '/Folder with spaces/wordle3.png' => '01AZJL5PL4AUJEU43CQZFJKN7BQPRP3BLF',
- '/Folder' => '01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR',
- '/Folder/Images' => '01AZJL5PMIF7ND3KH6FVDLZYP3E36ERFGI',
- '/Folder/Subfolder' => '01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG',
- '/Folder/Ümlæûts' => '01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB',
- '/Folder/Document.docx' => '01AZJL5PJTICED3C5YSVAY6NWTBNA2XERU',
- '/Folder/Sheet.xlsx' => '01AZJL5PLB7SH7633RMBHIH6KVMQRU4RJS',
- '/Folder/Images/der_laufende.jpeg' => '01AZJL5PLZFCARRQIDFJF36UL2WTLXTNSY',
- '/Folder/Images/written_in_stone.webp' => '01AZJL5PLNCKWYI752YBHYYJ6RBFZWOZ46',
- '/Folder/Subfolder/NextcloudHub.md' => '01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA',
- '/Folder/Subfolder/test.txt' => '01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ',
- '/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx' => '01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE',
- '/Permissions Folder' => '01AZJL5PN3LVLHH2RSZZDJ6ZFAD3OWSGYB'
+ "/" => "01AZJL5PN6Y2GOVW7725BZO354PWSELRRZ",
+ "/Folder with spaces" => "01AZJL5PKU2WV3U3RKKFF2A7ZCWVBXRTEU",
+ "/Folder with spaces/very empty folder" => "01AZJL5PMGEIRPHZPHRRH2NM3D734VIR7H",
+ "/Folder with spaces/wordle1.png" => "01AZJL5PPMSBBO3R2BIZHJFCELSW3RP7GN",
+ "/Folder with spaces/wordle2.png" => "01AZJL5PIIFUD6A765KBAIAEMYACAFB2WP",
+ "/Folder with spaces/wordle3.png" => "01AZJL5PL4AUJEU43CQZFJKN7BQPRP3BLF",
+ "/Folder" => "01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR",
+ "/Folder/Images" => "01AZJL5PMIF7ND3KH6FVDLZYP3E36ERFGI",
+ "/Folder/Subfolder" => "01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG",
+ "/Folder/Ümlæûts" => "01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB",
+ "/Folder/Document.docx" => "01AZJL5PJTICED3C5YSVAY6NWTBNA2XERU",
+ "/Folder/Sheet.xlsx" => "01AZJL5PLB7SH7633RMBHIH6KVMQRU4RJS",
+ "/Folder/Images/der_laufende.jpeg" => "01AZJL5PLZFCARRQIDFJF36UL2WTLXTNSY",
+ "/Folder/Images/written_in_stone.webp" => "01AZJL5PLNCKWYI752YBHYYJ6RBFZWOZ46",
+ "/Folder/Subfolder/NextcloudHub.md" => "01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA",
+ "/Folder/Subfolder/test.txt" => "01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ",
+ "/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx" => "01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE",
+ "/Permissions Folder" => "01AZJL5PN3LVLHH2RSZZDJ6ZFAD3OWSGYB"
})
end
end
- context 'with a given parent folder', vcr: 'one_drive/folder_files_file_ids_deep_query_parent_folder' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR') }
+ context "with a given parent folder", vcr: "one_drive/folder_files_file_ids_deep_query_parent_folder" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR") }
- it 'returns the file id dictionary' do
+ it "returns the file id dictionary" do
expect(subject.transform_values(&:id))
.to eq({
- '/Folder' => '01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR',
- '/Folder/Images' => '01AZJL5PMIF7ND3KH6FVDLZYP3E36ERFGI',
- '/Folder/Subfolder' => '01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG',
- '/Folder/Ümlæûts' => '01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB',
- '/Folder/Document.docx' => '01AZJL5PJTICED3C5YSVAY6NWTBNA2XERU',
- '/Folder/Sheet.xlsx' => '01AZJL5PLB7SH7633RMBHIH6KVMQRU4RJS',
- '/Folder/Images/der_laufende.jpeg' => '01AZJL5PLZFCARRQIDFJF36UL2WTLXTNSY',
- '/Folder/Images/written_in_stone.webp' => '01AZJL5PLNCKWYI752YBHYYJ6RBFZWOZ46',
- '/Folder/Subfolder/NextcloudHub.md' => '01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA',
- '/Folder/Subfolder/test.txt' => '01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ',
- '/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx' => '01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE'
+ "/Folder" => "01AZJL5PMAXGDWAAKMEBALX4Q6GSN5BSBR",
+ "/Folder/Images" => "01AZJL5PMIF7ND3KH6FVDLZYP3E36ERFGI",
+ "/Folder/Subfolder" => "01AZJL5PPWP5UOATNRJJBYJG5TACDHEUAG",
+ "/Folder/Ümlæûts" => "01AZJL5PNQYF5NM3KWYNA3RJHJIB2XMMMB",
+ "/Folder/Document.docx" => "01AZJL5PJTICED3C5YSVAY6NWTBNA2XERU",
+ "/Folder/Sheet.xlsx" => "01AZJL5PLB7SH7633RMBHIH6KVMQRU4RJS",
+ "/Folder/Images/der_laufende.jpeg" => "01AZJL5PLZFCARRQIDFJF36UL2WTLXTNSY",
+ "/Folder/Images/written_in_stone.webp" => "01AZJL5PLNCKWYI752YBHYYJ6RBFZWOZ46",
+ "/Folder/Subfolder/NextcloudHub.md" => "01AZJL5PNCQCEBFI3N7JGZSX5AOX32Z3LA",
+ "/Folder/Subfolder/test.txt" => "01AZJL5PLOL2KZTJNVFBCJWFXYGYVBQVMZ",
+ "/Folder/Ümlæûts/Anrüchiges deutsches Dokument.docx" => "01AZJL5PNDURPQGKUSGFCJQJMNNWXKTHSE"
})
end
end
end
- context 'with not existent parent folder', vcr: 'one_drive/folder_files_file_ids_deep_query_invalid_parent' do
- let(:folder) { Storages::Peripherals::ParentFolder.new('/I/just/made/that/up') }
+ context "with not existent parent folder", vcr: "one_drive/folder_files_file_ids_deep_query_invalid_parent" do
+ let(:folder) { Storages::Peripherals::ParentFolder.new("/I/just/made/that/up") }
- it 'must return not found' do
+ it "must return not found" do
result = described_class.call(storage:, folder:)
expect(result).to be_failure
expect(result.error_source).to be_a(described_class)
@@ -114,18 +114,18 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FolderFilesF
end
end
- context 'with invalid oauth credentials', vcr: 'one_drive/folder_files_file_ids_deep_query_invalid_credentials' do
+ context "with invalid oauth credentials", vcr: "one_drive/folder_files_file_ids_deep_query_invalid_credentials" do
before do
unauthorized_http = OpenProject.httpx.with(origin: storage.uri,
headers: { authorization: "Bearer YouShallNotPass",
accept: "application/json",
- 'content-type': 'application/json' })
+ "content-type": "application/json" })
allow(Storages::Peripherals::StorageInteraction::OneDrive::Util)
.to receive(:using_admin_token)
.and_yield(unauthorized_http)
end
- it 'must return unauthorized' do
+ it "must return unauthorized" do
result = described_class.call(storage:, folder:)
expect(result).to be_failure
expect(result.error_source).to be_a(described_class)
@@ -137,16 +137,16 @@ RSpec.describe Storages::Peripherals::StorageInteraction::OneDrive::FolderFilesF
end
end
- context 'with network errors' do
+ context "with network errors" do
before do
- request = HTTPX::Request.new(:get, 'https://my.timeout.org/')
- httpx_double = class_double(HTTPX, get: HTTPX::ErrorResponse.new(request, 'Timeout happens', {}))
+ request = HTTPX::Request.new(:get, "https://my.timeout.org/")
+ httpx_double = class_double(HTTPX, get: HTTPX::ErrorResponse.new(request, "Timeout happens", {}))
allow(Storages::Peripherals::StorageInteraction::OneDrive::Util)
.to receive(:using_admin_token)
.and_yield(httpx_double)
end
- it 'must return an error with wrapped network error response' do
+ it "must return an error with wrapped network error response" do
error = described_class.call(storage:, folder:)
expect(error).to be_failure
expect(error.result).to eq(:error)
diff --git a/modules/storages/spec/features/manage_project_storage_spec.rb b/modules/storages/spec/features/manage_project_storage_spec.rb
index 3d4ed0a8eef..5a99a1b35a8 100644
--- a/modules/storages/spec/features/manage_project_storage_spec.rb
+++ b/modules/storages/spec/features/manage_project_storage_spec.rb
@@ -28,7 +28,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
require_module_spec_helper
# Setup storages in Project -> Settings -> File Storages
@@ -37,7 +37,7 @@ require_module_spec_helper
# We decrease the notification polling interval because some portions of the JS code rely on something triggering
# the Angular change detection. This is usually done by the notification polling, but we don't want to wait
-RSpec.describe 'Activation of storages in projects', :js, :webmock, with_settings: { notifications_polling_interval: 1_000 } do
+RSpec.describe "Activation of storages in projects", :js, :webmock, with_settings: { notifications_polling_interval: 1_000 } do
let(:user) { create(:user) }
# The first page is the Project -> Settings -> General page, so we need
# to provide the user with the edit_project permission in the role.
@@ -67,11 +67,11 @@ RSpec.describe 'Activation of storages in projects', :js, :webmock, with_setting
{
ocs: {
data: {
- status: 'OK',
+ status: "OK",
statuscode: 200,
id: 11,
- name: 'Folder1',
- path: 'files/Folder1',
+ name: "Folder1",
+ path: "files/Folder1",
mtime: 1682509719,
ctime: 0
}
@@ -99,146 +99,146 @@ RSpec.describe 'Activation of storages in projects', :js, :webmock, with_setting
login_as user
end
- it 'adds, edits and removes storages to projects' do
+ it "adds, edits and removes storages to projects" do
# Go to Projects -> Settings -> File Storages
visit project_settings_general_path(project)
- page.click_link('File storages')
+ page.click_link("File storages")
# Check for an empty table in Project -> Settings -> File storages
- expect(page).to have_title('File storages')
+ expect(page).to have_title("File storages")
expect(page).to have_current_path project_settings_project_storages_path(project)
- expect(page).to have_text(I18n.t('storages.no_results'))
- page.find('.toolbar .button--icon.icon-add').click
+ expect(page).to have_text(I18n.t("storages.no_results"))
+ page.find(".toolbar .button--icon.icon-add").click
# Can cancel the creation of a new file storage
expect(page).to have_current_path new_project_settings_project_storage_path(project_id: project)
- expect(page).to have_text('Add a file storage')
- page.click_link('Cancel')
+ expect(page).to have_text("Add a file storage")
+ page.click_link("Cancel")
expect(page).to have_current_path project_settings_project_storages_path(project)
# Enable one file storage together with a project folder mode
- page.find('.toolbar .button--icon.icon-add').click
+ page.find(".toolbar .button--icon.icon-add").click
expect(page).to have_current_path new_project_settings_project_storage_path(project_id: project)
- expect(page).to have_text('Add a file storage')
- expect(page).to have_select('storages_project_storage_storage_id',
+ expect(page).to have_text("Add a file storage")
+ expect(page).to have_select("storages_project_storage_storage_id",
options: ["#{storage.name} (#{storage.short_provider_type})"])
- page.click_button('Continue')
+ page.click_button("Continue")
# by default automatic have to be choosen if storage has automatic management enabled
expect(page).to have_checked_field("New folder with automatically managed permissions")
- page.find_by_id('storages_project_storage_project_folder_mode_manual').click
+ page.find_by_id("storages_project_storage_project_folder_mode_manual").click
# Select project folder
- expect(page).to have_text('No selected folder')
- page.click_button('Select folder')
+ expect(page).to have_text("No selected folder")
+ page.click_button("Select folder")
location_picker.expect_open
using_wait_time(20) do
location_picker.wait_for_folder_loaded
- location_picker.enter_folder('Folder1')
+ location_picker.enter_folder("Folder1")
location_picker.wait_for_folder_loaded
end
location_picker.confirm
# Add storage
- expect(page).to have_text('Folder1')
- page.click_button('Add')
+ expect(page).to have_text("Folder1")
+ page.click_button("Add")
# The list of enabled file storages should now contain Storage 1
- expect(page).to have_text('File storages available in this project')
+ expect(page).to have_text("File storages available in this project")
expect(page).to have_text(storage.name)
# Press Edit icon to change the project folder mode to inactive
- page.find('.icon.icon-edit').click
+ page.find(".icon.icon-edit").click
expect(page).to have_current_path edit_project_settings_project_storage_path(project_id: project,
id: Storages::ProjectStorage.last,
- storages_project_storage: {project_folder_mode: 'manual'})
- expect(page).to have_text('Edit the file storage to this project')
- expect(page).to have_no_select('storages_project_storage_storage_id')
+ storages_project_storage: {project_folder_mode: "manual"})
+ expect(page).to have_text("Edit the file storage to this project")
+ expect(page).to have_no_select("storages_project_storage_storage_id")
expect(page).to have_text(storage.name)
- expect(page).to have_checked_field('storages_project_storage_project_folder_mode_manual')
- expect(page).to have_text('Folder1')
+ expect(page).to have_checked_field("storages_project_storage_project_folder_mode_manual")
+ expect(page).to have_text("Folder1")
# Change the project folder mode to inactive, project folder is hidden but retained
- page.find_by_id('storages_project_storage_project_folder_mode_inactive').click
- expect(page).to have_no_text('Folder1')
- page.click_button('Save')
+ page.find_by_id("storages_project_storage_project_folder_mode_inactive").click
+ expect(page).to have_no_text("Folder1")
+ page.click_button("Save")
# The list of enabled file storages should still contain Storage 1
- expect(page).to have_text('File storages available in this project')
+ expect(page).to have_text("File storages available in this project")
expect(page).to have_text(storage.name)
# Click Edit icon again but cancel the edit
- page.find('.icon.icon-edit').click
+ page.find(".icon.icon-edit").click
expect(page).to have_current_path edit_project_settings_project_storage_path(project_id: project,
id: Storages::ProjectStorage.last,
- storages_project_storage: {project_folder_mode: 'inactive'})
- expect(page).to have_text('Edit the file storage to this project')
- page.click_link('Cancel')
+ storages_project_storage: {project_folder_mode: "inactive"})
+ expect(page).to have_text("Edit the file storage to this project")
+ page.click_link("Cancel")
expect(page).to have_current_path project_settings_project_storages_path(project)
# Press Delete icon to remove the storage from the project
- page.find('.icon.icon-delete').click
+ page.find(".icon.icon-delete").click
# Danger zone confirmation flow
- expect(page).to have_css('.form--section-title', text: "DELETE FILE STORAGE")
- expect(page).to have_css('.danger-zone--warning', text: "Deleting a file storage is an irreversible action.")
- expect(page).to have_button('Delete', disabled: true)
+ expect(page).to have_css(".form--section-title", text: "DELETE FILE STORAGE")
+ expect(page).to have_css(".danger-zone--warning", text: "Deleting a file storage is an irreversible action.")
+ expect(page).to have_button("Delete", disabled: true)
# Cancel Confirmation
- page.click_link('Cancel')
+ page.click_link("Cancel")
expect(page).to have_current_path project_settings_project_storages_path(project)
- page.find('.icon.icon-delete').click
+ page.find(".icon.icon-delete").click
# Approve Confirmation
- page.fill_in 'delete_confirmation', with: storage.name
- page.click_button('Delete')
+ page.fill_in "delete_confirmation", with: storage.name
+ page.click_button("Delete")
# List of ProjectStorages empty again
expect(page).to have_current_path project_settings_project_storages_path(project)
- expect(page).to have_text(I18n.t('storages.no_results'))
+ expect(page).to have_text(I18n.t("storages.no_results"))
end
- describe 'automatic project folder mode' do
- context 'when the storage is not automatically managed' do
+ describe "automatic project folder mode" do
+ context "when the storage is not automatically managed" do
let(:oauth_application) { create(:oauth_application) }
let(:storage) { create(:nextcloud_storage, :as_not_automatically_managed, oauth_application:) }
let(:project_storage) { create(:project_storage, storage:, project:) }
- it 'automatic option is not available' do
+ it "automatic option is not available" do
visit edit_project_settings_project_storage_path(project_id: project, id: project_storage)
- expect(page).to have_no_content('New folder with automatically managed permissions')
+ expect(page).to have_no_content("New folder with automatically managed permissions")
end
end
- context 'when the storage is automatically managed' do
+ context "when the storage is automatically managed" do
let(:oauth_application) { create(:oauth_application) }
let(:storage) { create(:nextcloud_storage, :as_automatically_managed, oauth_application:) }
let(:project_storage) { create(:project_storage, storage:, project:) }
- it 'automatic option is available' do
+ it "automatic option is available" do
visit edit_project_settings_project_storage_path(project_id: project, id: project_storage)
- expect(page).to have_content('New folder with automatically managed permissions')
+ expect(page).to have_content("New folder with automatically managed permissions")
end
end
end
- describe 'configuration checks' do
+ describe "configuration checks" do
let(:configured_storage) { storage }
let!(:unconfigured_storage) { create(:nextcloud_storage) }
- it 'excludes storages that are not configured correctly' do
+ it "excludes storages that are not configured correctly" do
visit project_settings_project_storages_path(project)
- page.find('.toolbar .button--icon.icon-add').click
+ page.find(".toolbar .button--icon.icon-add").click
- aggregate_failures 'select field options' do
- expect(page).to have_select('storages_project_storage_storage_id',
+ aggregate_failures "select field options" do
+ expect(page).to have_select("storages_project_storage_storage_id",
options: ["#{configured_storage.name} (#{configured_storage.short_provider_type})"])
- expect(page).to have_no_select('storages_project_storage_storage_id',
+ expect(page).to have_no_select("storages_project_storage_storage_id",
options: ["#{unconfigured_storage.name} (#{unconfigured_storage.short_provider_type})"])
end
end
diff --git a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
index 0a1e11a04b5..681b0ec25e4 100644
--- a/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
+++ b/modules/storages/spec/requests/api/v3/file_links/file_links_api_spec.rb
@@ -28,10 +28,10 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
require_module_spec_helper
-RSpec.describe 'API v3 file links resource' do
+RSpec.describe "API v3 file links resource" do
include API::V3::Utilities::PathHelper
include UserPermissionsHelper
@@ -93,8 +93,8 @@ RSpec.describe 'API v3 file links resource' do
login_as current_user
end
- describe 'POST /api/v3/file_links' do
- let(:path) { '/api/v3/file_links' }
+ describe "POST /api/v3/file_links" do
+ let(:path) { "/api/v3/file_links" }
let(:params) do
{
_type: "Collection",
@@ -121,27 +121,27 @@ RSpec.describe 'API v3 file links resource' do
}
}
},
- build(:file_link_element, storage_url:, origin_id: '200001', origin_name: "file_name_1.txt")
+ build(:file_link_element, storage_url:, origin_id: "200001", origin_name: "file_name_1.txt")
]
end
before do
- header 'Content-Type', 'application/json'
+ header "Content-Type", "application/json"
post path, params.to_json
end
- context 'when storage has been configured' do
+ context "when storage has been configured" do
let(:storage_url) { storage.host }
- context 'when all embedded file link elements are valid' do
- it_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do
+ context "when all embedded file link elements are valid" do
+ it_behaves_like "API V3 collection response", 2, 2, "FileLink" do
let(:elements) { Storages::FileLink.order(id: :asc) }
let(:expected_status_code) { 201 }
end
it(
- 'creates corresponding FileLink records and ' \
- 'does not provide a link to the collection of created file links',
+ "creates corresponding FileLink records and " \
+ "does not provide a link to the collection of created file links",
:aggregate_failures
) do
expect(Storages::FileLink.count).to eq 2
@@ -160,16 +160,16 @@ RSpec.describe 'API v3 file links resource' do
end
expect(response.body).to be_json_eql(
- 'urn:openproject-org:api:v3:file_links:no_link_provided'.to_json
- ).at_path('_links/self/href')
+ "urn:openproject-org:api:v3:file_links:no_link_provided".to_json
+ ).at_path("_links/self/href")
end
end
end
- context 'when storage with such a host does not exist in OpenProject' do
- let(:storage_url) { 'https://qweqwe.qweqwe' }
+ context "when storage with such a host does not exist in OpenProject" do
+ let(:storage_url) { "https://qweqwe.qweqwe" }
- it 'responds with an appropriate error' do
+ it "responds with an appropriate error" do
expect(JSON.parse(response.body)).to eq(
{ "_type" => "Error",
"errorIdentifier" => "urn:openproject-org:api:v3:errors:MultipleErrors",
@@ -189,7 +189,7 @@ RSpec.describe 'API v3 file links resource' do
end
end
- describe 'GET /api/v3/work_packages/:work_package_id/file_links' do
+ describe "GET /api/v3/work_packages/:work_package_id/file_links" do
let(:path) { api_v3_paths.file_links(work_package.id) }
before do
@@ -199,13 +199,13 @@ RSpec.describe 'API v3 file links resource' do
get path
end
- context 'with all preconditions met (happy path)' do
- it_behaves_like 'API V3 collection response', 1, 1, 'FileLink', 'Collection' do
+ context "with all preconditions met (happy path)" do
+ it_behaves_like "API V3 collection response", 1, 1, "FileLink", "Collection" do
let(:elements) { [file_link] }
end
end
- context 'if user has not sufficient permissions' do
+ context "if user has not sufficient permissions" do
before(:all) do
remove_permissions(current_user, :view_file_links)
end
@@ -214,54 +214,54 @@ RSpec.describe 'API v3 file links resource' do
add_permissions(current_user, :view_file_links)
end
- it_behaves_like 'API V3 collection response', 0, 0, 'FileLink', 'Collection' do
+ it_behaves_like "API V3 collection response", 0, 0, "FileLink", "Collection" do
let(:elements) { [] }
end
end
- context 'if storages module is deactivated for the work package\'s project' do
- before(:all) { disable_module(project, 'storages') }
- after(:all) { enable_module(project, 'storages') }
+ context "if storages module is deactivated for the work package's project" do
+ before(:all) { disable_module(project, "storages") }
+ after(:all) { enable_module(project, "storages") }
- it_behaves_like 'API V3 collection response', 0, 0, 'FileLink', 'Collection' do
+ it_behaves_like "API V3 collection response", 0, 0, "FileLink", "Collection" do
let(:elements) { [] }
end
end
- describe 'with filter by storage' do
+ describe "with filter by storage" do
let!(:another_project_storage) { create(:project_storage, project:, storage: another_storage) }
let(:path) { "#{api_v3_paths.file_links(work_package.id)}?filters=#{CGI.escape(filters.to_json)}" }
- let(:filters) { [{ storage: { operator: '=', values: [storage_id] } }] }
+ let(:filters) { [{ storage: { operator: "=", values: [storage_id] } }] }
- context 'if filtered by one storage' do
+ context "if filtered by one storage" do
let(:storage_id) { storage.id }
- it_behaves_like 'API V3 collection response', 1, 1, 'FileLink', 'Collection' do
+ it_behaves_like "API V3 collection response", 1, 1, "FileLink", "Collection" do
let(:elements) { [file_link] }
end
end
- context 'if filtered by another storage' do
+ context "if filtered by another storage" do
let(:storage_id) { another_storage.id }
- it_behaves_like 'API V3 collection response', 1, 1, 'FileLink', 'Collection' do
+ it_behaves_like "API V3 collection response", 1, 1, "FileLink", "Collection" do
# has the now linked storage's file links
let(:elements) { [file_link_of_another_storage] }
end
end
end
- context 'with bad query due to syntax error' do
- let(:filters) { [{ storage: { operator: '#=', values: [storage.id] } }] }
+ context "with bad query due to syntax error" do
+ let(:filters) { [{ storage: { operator: "#=", values: [storage.id] } }] }
let(:path) { "#{api_v3_paths.file_links(work_package.id)}?filters=#{CGI.escape(filters.to_json)}" }
- it 'return a 400 HTTP error' do
+ it "return a 400 HTTP error" do
expect(last_response.status).to be 400
end
end
end
- describe 'POST /api/v3/work_packages/:work_package_id/file_links' do
+ describe "POST /api/v3/work_packages/:work_package_id/file_links" do
let(:path) { api_v3_paths.file_links(work_package.id) }
let(:storage_url) { storage.host }
let(:params) do
@@ -305,19 +305,19 @@ RSpec.describe 'API v3 file links resource' do
end
before do
- header 'Content-Type', 'application/json'
+ header "Content-Type", "application/json"
post path, params.to_json
end
- context 'when all embedded file link elements are valid' do
- it_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do
+ context "when all embedded file link elements are valid" do
+ it_behaves_like "API V3 collection response", 2, 2, "FileLink" do
let(:elements) { Storages::FileLink.order(id: :asc) }
let(:expected_status_code) { 201 }
end
it(
- 'creates corresponding FileLink records and ' \
- 'provides a link to the collection of created file links',
+ "creates corresponding FileLink records and " \
+ "provides a link to the collection of created file links",
:aggregate_failures
) do
expect(Storages::FileLink.count).to eq 2
@@ -329,11 +329,11 @@ RSpec.describe 'API v3 file links resource' do
end
end
- expect(response.body).to be_json_eql(path.to_json).at_path('_links/self/href')
+ expect(response.body).to be_json_eql(path.to_json).at_path("_links/self/href")
end
end
- context 'when some embedded file link elements are NOT valid' do
+ context "when some embedded file link elements are NOT valid" do
let(:embedded_elements) do
[
build(:file_link_element, :invalid, storage_url:),
@@ -341,27 +341,27 @@ RSpec.describe 'API v3 file links resource' do
]
end
- it_behaves_like 'constraint violation' do
- let(:message) { 'Error attempting to create dependent object: File link ' }
+ it_behaves_like "constraint violation" do
+ let(:message) { "Error attempting to create dependent object: File link " }
end
- it 'does not create any FileLink records' do
+ it "does not create any FileLink records" do
expect(Storages::FileLink.find_by(origin_name: "the valid one")).to be_nil
expect(Storages::FileLink.count).to eq 0
end
end
- context 'when some file link elements with matching origin_id, container, and storage already exist in database' do
+ context "when some file link elements with matching origin_id, container, and storage already exist in database" do
let(:existing_file_link) do
create(:file_link,
- origin_name: 'original name',
+ origin_name: "original name",
creator: current_user,
container: work_package,
storage:)
end
let(:already_existing_file_link_payload) do
build(:file_link_element,
- origin_name: 'new name',
+ origin_name: "new name",
origin_id: existing_file_link.origin_id,
storage_url: existing_file_link.storage.host)
end
@@ -375,107 +375,107 @@ RSpec.describe 'API v3 file links resource' do
]
end
- it_behaves_like 'API V3 collection response', 2, 2, 'FileLink' do
+ it_behaves_like "API V3 collection response", 2, 2, "FileLink" do
let(:elements) { Storages::FileLink.order(id: :asc) }
let(:expected_status_code) { 201 }
end
it(
- 'does not create any new FileLink records for the already existing one and' \
- 'does not update the existing FileLink metadata from the POSTed one'
+ "does not create any new FileLink records for the already existing one and" \
+ "does not update the existing FileLink metadata from the POSTed one"
) do
expect(Storages::FileLink.count).to eq 2
- expect(existing_file_link.reload.origin_name).to eq 'original name'
+ expect(existing_file_link.reload.origin_name).to eq "original name"
end
end
- context 'when multiple file links elements are submitted with same origin_id, container, and storage' do
+ context "when multiple file links elements are submitted with same origin_id, container, and storage" do
let(:some_file_link_payload) { build(:file_link_element, storage_url: storage.host) }
let(:embedded_elements) do
[
- some_file_link_payload.deep_merge(originData: { name: 'first name' }),
- some_file_link_payload.deep_merge(originData: { name: 'second name' }),
- some_file_link_payload.deep_merge(originData: { name: 'third name' })
+ some_file_link_payload.deep_merge(originData: { name: "first name" }),
+ some_file_link_payload.deep_merge(originData: { name: "second name" }),
+ some_file_link_payload.deep_merge(originData: { name: "third name" })
]
end
- it_behaves_like 'API V3 collection response', 3, 3, 'FileLink' do
+ it_behaves_like "API V3 collection response", 3, 3, "FileLink" do
let(:elements) { Storages::FileLink.order(id: :asc) }
let(:expected_status_code) { 201 }
end
it(
- 'creates only one FileLink for all duplicates and ' \
- 'uses metadata from the first item and ' \
- 'replies with as many embedded elements as in the request, all identical'
+ "creates only one FileLink for all duplicates and " \
+ "uses metadata from the first item and " \
+ "replies with as many embedded elements as in the request, all identical"
) do
expect(Storages::FileLink.count).to eq 1
- expect(Storages::FileLink.first.origin_name).to eq 'first name'
+ expect(Storages::FileLink.first.origin_name).to eq "first name"
- replied_elements = JSON.parse(last_response.body).dig('_embedded', 'elements')
+ replied_elements = JSON.parse(last_response.body).dig("_embedded", "elements")
expect(replied_elements.count).to eq(embedded_elements.count)
expect(replied_elements[1..]).to all(eq(replied_elements.first))
end
end
- context 'when storage host is invalid' do
- context 'when unknown host' do
- let(:storage_url) { 'https://invalid.host.org/' }
+ context "when storage host is invalid" do
+ context "when unknown host" do
+ let(:storage_url) { "https://invalid.host.org/" }
- it_behaves_like 'constraint violation' do
- let(:message) { 'Storage does not exist' }
+ it_behaves_like "constraint violation" do
+ let(:message) { "Storage does not exist" }
end
end
- context 'when nil' do
+ context "when nil" do
let(:storage_url) { nil }
- it_behaves_like 'constraint violation' do
+ it_behaves_like "constraint violation" do
let(:message) { "Storage can't be blank." }
end
end
- context 'when empty' do
+ context "when empty" do
let(:storage_url) { "" }
- it_behaves_like 'constraint violation' do
+ it_behaves_like "constraint violation" do
let(:message) { "Storage can't be blank." }
end
end
- context 'when not linked to the project of the work package' do
+ context "when not linked to the project of the work package" do
let(:storage_url) { another_storage.host }
- it_behaves_like 'constraint violation' do
- let(:message) { 'Storage is not linked to project' }
+ it_behaves_like "constraint violation" do
+ let(:message) { "Storage is not linked to project" }
end
end
end
- context 'when no _embedded/elements in given json' do
+ context "when no _embedded/elements in given json" do
let(:params) do
{}
end
- it_behaves_like 'missing property', I18n.t('api_v3.errors.missing_property', property: '_embedded/elements')
+ it_behaves_like "missing property", I18n.t("api_v3.errors.missing_property", property: "_embedded/elements")
end
- context 'when _embedded/elements is empty' do
+ context "when _embedded/elements is empty" do
let(:embedded_elements) { [] }
- it_behaves_like 'missing property', I18n.t('api_v3.errors.missing_property', property: '_embedded/elements')
+ it_behaves_like "missing property", I18n.t("api_v3.errors.missing_property", property: "_embedded/elements")
end
- context 'when _embedded/elements is not an array' do
+ context "when _embedded/elements is not an array" do
let(:embedded_elements) { 42 }
- it_behaves_like 'format error',
- I18n.t('api_v3.errors.invalid_format',
- property: '_embedded/elements',
- expected_format: 'Array',
- actual: 'Integer')
+ it_behaves_like "format error",
+ I18n.t("api_v3.errors.invalid_format",
+ property: "_embedded/elements",
+ expected_format: "Array",
+ actual: "Integer")
end
context "when more than #{Storages::Peripherals::ParseCreateParamsService::MAX_ELEMENTS} embedded elements" do
@@ -483,135 +483,135 @@ RSpec.describe 'API v3 file links resource' do
let(:too_many) { max + 1 }
let(:embedded_elements) { build_list(:file_link_element, too_many, storage_url:) }
- it_behaves_like 'constraint violation' do
+ it_behaves_like "constraint violation" do
let(:message) { "Too many elements created at once. Expected #{max} at most, got #{too_many}." }
end
end
end
- describe 'GET /api/v3/file_links/:file_link_id' do
+ describe "GET /api/v3/file_links/:file_link_id" do
let(:path) { api_v3_paths.file_link(file_link.id) }
before { get path }
- it 'is successful' do
+ it "is successful" do
expect(subject.status).to be 200
end
- context 'if user has not sufficient permissions' do
+ context "if user has not sufficient permissions" do
before(:all) { remove_permissions(current_user, :view_file_links) }
after(:all) { add_permissions(current_user, :view_file_links) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if no file link with that id exists' do
+ context "if no file link with that id exists" do
let(:path) { api_v3_paths.file_link(1337) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if file link is in a work package, while its project is not mapped to the file link\'s storage.' do
+ context "if file link is in a work package, while its project is not mapped to the file link's storage." do
let(:path) { api_v3_paths.file_link(file_link_of_another_storage.id) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if file link is in a work package, while the storages module is deactivated in its project.' do
- before(:all) { disable_module(project, 'storages') }
- after(:all) { enable_module(project, 'storages') }
+ context "if file link is in a work package, while the storages module is deactivated in its project." do
+ before(:all) { disable_module(project, "storages") }
+ after(:all) { enable_module(project, "storages") }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if file link does not have a container.' do
+ context "if file link does not have a container." do
let(:file_link) { create(:file_link) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
- describe 'DELETE /api/v3/file_links/:file_link_id' do
+ describe "DELETE /api/v3/file_links/:file_link_id" do
let(:path) { api_v3_paths.file_link(file_link.id) }
before(:all) { add_permissions(current_user, :manage_file_links) }
after(:all) { remove_permissions(current_user, :manage_file_links) }
before do
- header 'Content-Type', 'application/json'
+ header "Content-Type", "application/json"
delete path
end
- it 'is successful' do
+ it "is successful" do
expect(subject.status).to be 204
expect(Storages::FileLink.exists?(id: file_link.id)).to be false
end
- context 'if user has no view permissions' do
+ context "if user has no view permissions" do
before(:all) { remove_permissions(current_user, :view_file_links) }
after(:all) { add_permissions(current_user, :view_file_links) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if user has no manage permissions' do
+ context "if user has no manage permissions" do
before(:all) { remove_permissions(current_user, :manage_file_links) }
after(:all) { add_permissions(current_user, :manage_file_links) }
- it_behaves_like 'unauthorized access'
+ it_behaves_like "unauthorized access"
end
- context 'if no file link with that id exists' do
+ context "if no file link with that id exists" do
let(:path) { api_v3_paths.file_link(1337) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
- describe 'GET /api/v3/file_links/:file_link_id/open' do
+ describe "GET /api/v3/file_links/:file_link_id/open" do
let(:path) { api_v3_paths.file_link_open(file_link.id) }
before { get path }
- it 'is successful' do
+ it "is successful" do
expect(subject.status).to be 303
end
- context 'with location flag' do
+ context "with location flag" do
let(:path) { api_v3_paths.file_link_open(file_link.id, true) }
- it 'is successful' do
+ it "is successful" do
expect(subject.status).to be 303
end
end
- context 'if user has no view permissions' do
+ context "if user has no view permissions" do
before(:all) { remove_permissions(current_user, :view_file_links) }
after(:all) { add_permissions(current_user, :view_file_links) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'if no storage with that id exists' do
+ context "if no storage with that id exists" do
let(:path) { api_v3_paths.file_link(1337) }
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
- describe 'GET /api/v3/file_links/:file_link_id/download' do
+ describe "GET /api/v3/file_links/:file_link_id/download" do
let(:path) { api_v3_paths.file_link_download(file_link.id) }
- let(:url) { 'https://starkiller.nextcloud.com/direct/xyz' }
+ let(:url) { "https://starkiller.nextcloud.com/direct/xyz" }
- describe 'with successful response' do
+ describe "with successful response" do
before do
Storages::Peripherals::Registry.stub(
- 'nextcloud.queries.download_link',
+ "nextcloud.queries.download_link",
->(_) { ServiceResult.success(result: url) }
)
end
- it 'responds successfully' do
+ it "responds successfully" do
get path
expect(subject.status).to be(303)
@@ -619,37 +619,37 @@ RSpec.describe 'API v3 file links resource' do
end
end
- describe 'with query failed' do
+ describe "with query failed" do
before do
Storages::Peripherals::Registry.stub(
- 'nextcloud.queries.download_link',
+ "nextcloud.queries.download_link",
->(_) { ServiceResult.failure(result: error, errors: Storages::StorageError.new(code: error)) }
)
get path
end
- describe 'due to authorization failure' do
+ describe "due to authorization failure" do
let(:error) { :unauthorized }
it { expect(subject.status).to be(500) }
end
- describe 'due to internal error' do
+ describe "due to internal error" do
let(:error) { :error }
it { expect(subject.status).to be(500) }
end
- describe 'due to not found' do
+ describe "due to not found" do
let(:error) { :not_found }
- it 'fails with outbound request failure' do
+ it "fails with outbound request failure" do
expect(last_response.status).to be(500)
body = JSON.parse(last_response.body)
- expect(body['message']).to eq(I18n.t('api_v3.errors.code_500_outbound_request_failure', status_code: 404))
- expect(body['errorIdentifier']).to eq('urn:openproject-org:api:v3:errors:OutboundRequest:NotFound')
+ expect(body["message"]).to eq(I18n.t("api_v3.errors.code_500_outbound_request_failure", status_code: 404))
+ expect(body["errorIdentifier"]).to eq("urn:openproject-org:api:v3:errors:OutboundRequest:NotFound")
end
end
end
diff --git a/spec/factories/custom_field_section.rb b/spec/factories/custom_field_section.rb
index 861b2f049d1..e5a622739a3 100644
--- a/spec/factories/custom_field_section.rb
+++ b/spec/factories/custom_field_section.rb
@@ -32,6 +32,6 @@ FactoryBot.define do
created_at { Time.zone.now }
updated_at { Time.zone.now }
- factory :project_custom_field_section, class: 'ProjectCustomFieldSection'
+ factory :project_custom_field_section, class: "ProjectCustomFieldSection"
end
end
diff --git a/spec/features/admin/project_custom_fields/shared_context.rb b/spec/features/admin/project_custom_fields/shared_context.rb
index ee6b3faf084..a8e407c53e1 100644
--- a/spec/features/admin/project_custom_fields/shared_context.rb
+++ b/spec/features/admin/project_custom_fields/shared_context.rb
@@ -26,75 +26,75 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-RSpec.shared_context 'with seeded project custom fields' do
+RSpec.shared_context "with seeded project custom fields" do
shared_let(:admin) { create(:admin) }
shared_let(:non_admin) { create(:user) }
- shared_let(:section_for_input_fields) { create(:project_custom_field_section, name: 'Input fields') }
- shared_let(:section_for_select_fields) { create(:project_custom_field_section, name: 'Select fields') }
- shared_let(:section_for_multi_select_fields) { create(:project_custom_field_section, name: 'Multi select fields') }
+ shared_let(:section_for_input_fields) { create(:project_custom_field_section, name: "Input fields") }
+ shared_let(:section_for_select_fields) { create(:project_custom_field_section, name: "Select fields") }
+ shared_let(:section_for_multi_select_fields) { create(:project_custom_field_section, name: "Multi select fields") }
let!(:boolean_project_custom_field) do
- create(:boolean_project_custom_field, name: 'Boolean field',
+ create(:boolean_project_custom_field, name: "Boolean field",
project_custom_field_section: section_for_input_fields)
end
let!(:string_project_custom_field) do
- create(:string_project_custom_field, name: 'String field',
+ create(:string_project_custom_field, name: "String field",
project_custom_field_section: section_for_input_fields)
end
let!(:integer_project_custom_field) do
- create(:integer_project_custom_field, name: 'Integer field',
+ create(:integer_project_custom_field, name: "Integer field",
project_custom_field_section: section_for_input_fields)
end
let!(:float_project_custom_field) do
- create(:float_project_custom_field, name: 'Float field',
+ create(:float_project_custom_field, name: "Float field",
project_custom_field_section: section_for_input_fields)
end
let!(:date_project_custom_field) do
- create(:date_project_custom_field, name: 'Date field',
+ create(:date_project_custom_field, name: "Date field",
project_custom_field_section: section_for_input_fields)
end
let!(:text_project_custom_field) do
- create(:text_project_custom_field, name: 'Text field',
+ create(:text_project_custom_field, name: "Text field",
project_custom_field_section: section_for_input_fields)
end
let!(:list_project_custom_field) do
- create(:list_project_custom_field, name: 'List field',
+ create(:list_project_custom_field, name: "List field",
project_custom_field_section: section_for_select_fields,
- possible_values: ['Option 1', 'Option 2', 'Option 3'])
+ possible_values: ["Option 1", "Option 2", "Option 3"])
end
let!(:version_project_custom_field) do
- create(:version_project_custom_field, name: 'Version field',
+ create(:version_project_custom_field, name: "Version field",
project_custom_field_section: section_for_select_fields)
end
let!(:user_project_custom_field) do
- create(:user_project_custom_field, name: 'User field',
+ create(:user_project_custom_field, name: "User field",
project_custom_field_section: section_for_select_fields)
end
let!(:multi_list_project_custom_field) do
- create(:list_project_custom_field, name: 'Multi list field',
+ create(:list_project_custom_field, name: "Multi list field",
project_custom_field_section: section_for_multi_select_fields,
- possible_values: ['Option 1', 'Option 2', 'Option 3'],
+ possible_values: ["Option 1", "Option 2", "Option 3"],
multi_value: true)
end
let!(:multi_version_project_custom_field) do
- create(:version_project_custom_field, name: 'Multi version field',
+ create(:version_project_custom_field, name: "Multi version field",
project_custom_field_section: section_for_multi_select_fields,
multi_value: true)
end
let!(:multi_user_project_custom_field) do
- create(:user_project_custom_field, name: 'Multi user field',
+ create(:user_project_custom_field, name: "Multi user field",
project_custom_field_section: section_for_multi_select_fields,
multi_value: true)
end
diff --git a/spec/features/custom_fields/custom_fields_spec.rb b/spec/features/custom_fields/custom_fields_spec.rb
index ee07c28bde2..d661cbce936 100644
--- a/spec/features/custom_fields/custom_fields_spec.rb
+++ b/spec/features/custom_fields/custom_fields_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
-require 'support/pages/custom_fields'
+require "spec_helper"
+require "support/pages/custom_fields"
-RSpec.describe 'custom fields', :js, :with_cuprite do
+RSpec.describe "custom fields", :js, :with_cuprite do
let(:user) { create(:admin) }
let(:cf_page) { Pages::CustomFields.new }
@@ -21,22 +21,22 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
expect(page).to have_text("Allow multi-select")
check("custom_field_multi_value")
- expect(page).to have_css('.custom-option-row', count: 1)
+ expect(page).to have_css(".custom-option-row", count: 1)
within all(".custom-option-row").last do
find(".custom-option-value input").set "Windows"
find(".custom-option-default-value input").set true
end
- page.find_test_selector('add-custom-option').click
+ page.find_test_selector("add-custom-option").click
- expect(page).to have_css('.custom-option-row', count: 2)
+ expect(page).to have_css(".custom-option-row", count: 2)
within all(".custom-option-row").last do
find(".custom-option-value input").set "Linux"
end
- page.find_test_selector('add-custom-option').click
+ page.find_test_selector("add-custom-option").click
- expect(page).to have_css('.custom-option-row', count: 3)
+ expect(page).to have_css(".custom-option-row", count: 3)
within all(".custom-option-row").last do
find(".custom-option-value input").set "Solaris"
@@ -52,7 +52,7 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
expect(page).to have_field("custom_field_multi_value", checked: true)
- expect(page).to have_css('.custom-option-row', count: 3)
+ expect(page).to have_css(".custom-option-row", count: 3)
expect(page).to have_field("custom_field_custom_options_attributes_0_value", with: "Solaris")
expect(page).to have_field("custom_field_custom_options_attributes_1_value", with: "Windows")
expect(page).to have_field("custom_field_custom_options_attributes_2_value", with: "Linux")
@@ -70,14 +70,14 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
cf_page.set_name "Ignored"
# Form element labels, default English translation in the trailing comment:
- label_min_length = I18n.t('activerecord.attributes.custom_field.min_length') # Minimum length
- label_max_length = I18n.t('activerecord.attributes.custom_field.max_length') # Maximum length
- label_regexp = I18n.t('activerecord.attributes.custom_field.regexp') # Regular expression
- label_multi_value = I18n.t('activerecord.attributes.custom_field.multi_value') # Allow multi-select
- label_allow_non_open_versions = I18n.t('activerecord.attributes.custom_field.allow_non_open_versions') # Allow non-open versions
- label_possible_values = I18n.t('activerecord.attributes.custom_field.possible_values').upcase # Possible values, capitalized on UI
- label_default_value = I18n.t('activerecord.attributes.custom_field.default_value') # Default value
- label_is_required = I18n.t('activerecord.attributes.custom_field.is_required') # Required
+ label_min_length = I18n.t("activerecord.attributes.custom_field.min_length") # Minimum length
+ label_max_length = I18n.t("activerecord.attributes.custom_field.max_length") # Maximum length
+ label_regexp = I18n.t("activerecord.attributes.custom_field.regexp") # Regular expression
+ label_multi_value = I18n.t("activerecord.attributes.custom_field.multi_value") # Allow multi-select
+ label_allow_non_open_versions = I18n.t("activerecord.attributes.custom_field.allow_non_open_versions") # Allow non-open versions
+ label_possible_values = I18n.t("activerecord.attributes.custom_field.possible_values").upcase # Possible values, capitalized on UI
+ label_default_value = I18n.t("activerecord.attributes.custom_field.default_value") # Default value
+ label_is_required = I18n.t("activerecord.attributes.custom_field.is_required") # Required
# Spent time SFs don't show "Searchable". Not tested here.
# Project CFs don't show "For all projects" and "Used as a filter". Not tested here.
# Content right to left is not shown for Project CFs Long text. Strange. Not tested.
@@ -176,23 +176,23 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
click_on "Create a new custom field"
wait_for_reload
- page.within_test_selector('op-breadcrumb') do
- expect(page).to have_css('.breadcrumb-item', text: type)
- expect(page).to have_css('.breadcrumb-item.breadcrumb-item-selected', text: "New custom field")
+ page.within_test_selector("op-breadcrumb") do
+ expect(page).to have_css(".breadcrumb-item", text: type)
+ expect(page).to have_css(".breadcrumb-item.breadcrumb-item-selected", text: "New custom field")
end
end
end
- describe 'work packages' do
- it_behaves_like "creating a new custom field", 'Work packages'
+ describe "work packages" do
+ it_behaves_like "creating a new custom field", "Work packages"
end
- describe 'time entries' do
- it_behaves_like "creating a new custom field", 'Spent time'
+ describe "time entries" do
+ it_behaves_like "creating a new custom field", "Spent time"
end
- describe 'versions' do
- it_behaves_like "creating a new custom field", 'Versions'
+ describe "versions" do
+ it_behaves_like "creating a new custom field", "Versions"
end
context "with an existing list custom field" do
@@ -213,18 +213,18 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
end
it "adds new options" do
- page.find_test_selector('add-custom-option').click
+ page.find_test_selector("add-custom-option").click
wait_for_reload
- expect(page).to have_css('.custom-option-row', count: 5)
+ expect(page).to have_css(".custom-option-row", count: 5)
within all(".custom-option-row").last do
find(".custom-option-value input").set "Sega"
end
- page.find_test_selector('add-custom-option').click
+ page.find_test_selector("add-custom-option").click
wait_for_reload
- expect(page).to have_css('.custom-option-row', count: 6)
+ expect(page).to have_css(".custom-option-row", count: 6)
within all(".custom-option-row").last do
find(".custom-option-value input").set "Atari"
end
@@ -233,7 +233,7 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
expect(page).to have_text("Successful update")
expect(page).to have_text("Platform")
- expect(page).to have_css('.custom-option-row', count: 6)
+ expect(page).to have_css(".custom-option-row", count: 6)
%w[Playstation Xbox Nintendo PC Sega Atari].each_with_index do |value, i|
expect(page).to have_field("custom_field_custom_options_attributes_#{i}_value", with: value)
@@ -243,7 +243,7 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
it "updates the values and orders of the custom options" do
expect(page).to have_text("Platform")
- expect(page).to have_css('.custom-option-row', count: 4)
+ expect(page).to have_css(".custom-option-row", count: 4)
%w[Playstation Xbox Nintendo PC].each_with_index do |value, i|
expect(page).to have_field("custom_field_custom_options_attributes_#{i}_value", with: value)
end
@@ -273,9 +273,9 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
end
it "shows the correct breadcrumbs" do
- page.within_test_selector('op-breadcrumb') do
- expect(page).to have_css('.breadcrumb-item', text: "Work packages")
- expect(page).to have_css('.breadcrumb-item.breadcrumb-item-selected', text: "Platform")
+ page.within_test_selector("op-breadcrumb") do
+ expect(page).to have_css(".breadcrumb-item", text: "Work packages")
+ expect(page).to have_css(".breadcrumb-item.breadcrumb-item-selected", text: "Platform")
end
end
@@ -292,7 +292,7 @@ RSpec.describe 'custom fields', :js, :with_cuprite do
it "deletes a custom option and all values using it" do
within all(".custom-option-row")[1] do
accept_alert do
- find('.icon-delete').click
+ find(".icon-delete").click
end
end
diff --git a/spec/features/menu_items/admin_menu_item_spec.rb b/spec/features/menu_items/admin_menu_item_spec.rb
index d3e62459356..df949576328 100644
--- a/spec/features/menu_items/admin_menu_item_spec.rb
+++ b/spec/features/menu_items/admin_menu_item_spec.rb
@@ -26,9 +26,9 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Admin menu items',
+RSpec.describe "Admin menu items",
:js,
:with_cuprite do
shared_let(:user) { create(:admin) }
@@ -39,39 +39,39 @@ RSpec.describe 'Admin menu items',
end
after do
- OpenProject::Configuration['hidden_menu_items'] = []
+ OpenProject::Configuration["hidden_menu_items"] = []
end
- context 'without having any menu items hidden in configuration' do
- it 'must display all menu items' do
- expect(page).to have_test_selector('menu-blocks--container')
- expect(page).to have_test_selector('menu-block', count: 22)
- expect(page).to have_test_selector('op-menu--item-action', count: 23) # All plus 'overview'
+ context "without having any menu items hidden in configuration" do
+ it "must display all menu items" do
+ expect(page).to have_test_selector("menu-blocks--container")
+ expect(page).to have_test_selector("menu-block", count: 22)
+ expect(page).to have_test_selector("op-menu--item-action", count: 23) # All plus 'overview'
end
end
- context 'having custom hidden menu items',
+ context "having custom hidden menu items",
with_config: {
- 'hidden_menu_items' => { 'admin_menu' => ['colors'] }
+ "hidden_menu_items" => { "admin_menu" => ["colors"] }
} do
- it 'must not display the hidden menu items and blocks' do
- expect(page).to have_test_selector('menu-blocks--container')
- expect(page).to have_test_selector('menu-block', count: 21)
- expect(page).not_to have_test_selector('menu-block', text: I18n.t(:label_color_plural))
+ it "must not display the hidden menu items and blocks" do
+ expect(page).to have_test_selector("menu-blocks--container")
+ expect(page).to have_test_selector("menu-block", count: 21)
+ expect(page).not_to have_test_selector("menu-block", text: I18n.t(:label_color_plural))
- expect(page).to have_test_selector('op-menu--item-action', count: 22) # All plus 'overview'
- expect(page).not_to have_test_selector('op-menu--item-action', text: I18n.t(:label_color_plural))
+ expect(page).to have_test_selector("op-menu--item-action", count: 22) # All plus 'overview'
+ expect(page).not_to have_test_selector("op-menu--item-action", text: I18n.t(:label_color_plural))
end
end
- context 'when logged in with a non-admin user with specific admin permissions' do
+ context "when logged in with a non-admin user with specific admin permissions" do
shared_let(:user) { create(:user, global_permissions: %i[manage_user create_backup]) }
- it 'must display only the actions allowed by global permissions' do
- expect(page).to have_test_selector('menu-block', text: I18n.t('label_user_plural'))
- expect(page).to have_test_selector('menu-block', text: I18n.t('label_backup'))
- expect(page).to have_test_selector('op-menu--item-action', text: I18n.t('label_user_plural'))
- expect(page).to have_test_selector('op-menu--item-action', text: I18n.t('label_backup'))
+ it "must display only the actions allowed by global permissions" do
+ expect(page).to have_test_selector("menu-block", text: I18n.t("label_user_plural"))
+ expect(page).to have_test_selector("menu-block", text: I18n.t("label_backup"))
+ expect(page).to have_test_selector("op-menu--item-action", text: I18n.t("label_user_plural"))
+ expect(page).to have_test_selector("op-menu--item-action", text: I18n.t("label_backup"))
end
end
end
diff --git a/spec/features/projects/create_spec.rb b/spec/features/projects/create_spec.rb
index 286077a6c56..df43430e245 100644
--- a/spec/features/projects/create_spec.rb
+++ b/spec/features/projects/create_spec.rb
@@ -26,17 +26,17 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Projects', 'creation',
+RSpec.describe "Projects", "creation",
:js,
:with_cuprite do
shared_let(:name_field) { FormFields::InputFormField.new :name }
- shared_let(:project_custom_field_section) { create(:project_custom_field_section, name: 'Section A') }
+ shared_let(:project_custom_field_section) { create(:project_custom_field_section, name: "Section A") }
current_user { create(:admin) }
- shared_let(:project) { create(:project, name: 'Foo project', identifier: 'foo-project') }
+ shared_let(:project) { create(:project, name: "Foo project", identifier: "foo-project") }
let(:projects_page) { Pages::Projects::Index.new }
@@ -44,134 +44,134 @@ RSpec.describe 'Projects', 'creation',
projects_page.visit!
end
- context 'with the button on the toolbar items' do
- it 'can navigate to the create project page' do
+ context "with the button on the toolbar items" do
+ it "can navigate to the create project page" do
projects_page.navigate_to_new_project_page_from_toolbar_items
expect(page).to have_current_path(new_project_path)
end
end
- it 'can create a project' do
+ it "can create a project" do
projects_page.navigate_to_new_project_page_from_toolbar_items
- name_field.set_value 'Foo bar'
- click_button 'Save'
+ name_field.set_value "Foo bar"
+ click_button "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
- expect(page).to have_content 'Foo bar'
+ expect(page).to have_content "Foo bar"
end
- it 'does not create a project with an already existing identifier' do
+ it "does not create a project with an already existing identifier" do
projects_page.navigate_to_new_project_page_from_toolbar_items
- name_field.set_value 'Foo project'
- click_on 'Save'
+ name_field.set_value "Foo project"
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-project-1\/?/
project = Project.last
- expect(project.identifier).to eq 'foo-project-1'
+ expect(project.identifier).to eq "foo-project-1"
end
- context 'with a multi-select custom field' do
+ context "with a multi-select custom field" do
let!(:list_custom_field) do
- create(:list_project_custom_field, name: 'List CF', multi_value: true, project_custom_field_section:)
+ create(:list_project_custom_field, name: "List CF", multi_value: true, project_custom_field_section:)
end
let(:list_field) { FormFields::SelectFormField.new list_custom_field }
- it 'can create a project' do
+ it "can create a project" do
projects_page.navigate_to_new_project_page_from_toolbar_items
- name_field.set_value 'Foo bar'
+ name_field.set_value "Foo bar"
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
- list_field.select_option 'A', 'B'
+ list_field.select_option "A", "B"
- click_button 'Save'
+ click_button "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
- expect(page).to have_content 'Foo bar'
+ expect(page).to have_content "Foo bar"
project = Project.last
- expect(project.name).to eq 'Foo bar'
+ expect(project.name).to eq "Foo bar"
cvs = project.custom_value_for(list_custom_field)
expect(cvs.count).to eq 2
- expect(cvs.map(&:typed_value)).to contain_exactly 'A', 'B'
+ expect(cvs.map(&:typed_value)).to contain_exactly "A", "B"
end
end
- it 'hides the active field and the identifier' do
+ it "hides the active field and the identifier" do
visit new_project_path
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
- expect(page).to have_no_content 'Active'
- expect(page).to have_no_content 'Identifier'
+ expect(page).to have_no_content "Active"
+ expect(page).to have_no_content "Identifier"
end
- context 'with optional and required custom fields' do
+ context "with optional and required custom fields" do
let!(:optional_custom_field) do
- create(:project_custom_field, name: 'Optional Foo',
- field_format: 'string',
+ create(:project_custom_field, name: "Optional Foo",
+ field_format: "string",
is_for_all: true,
project_custom_field_section:)
end
let!(:required_custom_field) do
- create(:project_custom_field, name: 'Required Foo',
- field_format: 'string',
+ create(:project_custom_field, name: "Required Foo",
+ field_format: "string",
is_for_all: true,
is_required: true,
project_custom_field_section:)
end
- it 'separates optional and required custom fields for new' do
+ it "separates optional and required custom fields for new" do
visit new_project_path
- expect(page).to have_content 'Required Foo'
+ expect(page).to have_content "Required Foo"
- click_on 'Advanced settings'
+ click_on "Advanced settings"
- within('.op-fieldset') do
- expect(page).to have_text 'Optional Foo'
- expect(page).to have_no_text 'Required Foo'
+ within(".op-fieldset") do
+ expect(page).to have_text "Optional Foo"
+ expect(page).to have_no_text "Required Foo"
end
end
- context 'with correct validations' do
+ context "with correct validations" do
before do
visit new_project_path
end
- it 'requires the required custom field' do
- click_on 'Save'
+ it "requires the required custom field" do
+ click_on "Save"
expect(page).to have_content "Required Foo can't be blank"
expect(page).to have_no_content "Optional Foo can't be blank"
end
end
- context 'with correct custom field activation' do
+ context "with correct custom field activation" do
let!(:unused_custom_field) do
- create(:project_custom_field, name: 'Unused Foo',
- field_format: 'string',
+ create(:project_custom_field, name: "Unused Foo",
+ field_format: "string",
project_custom_field_section:)
end
before do
visit new_project_path
- fill_in 'Name', with: 'Foo bar'
- fill_in 'Required Foo', with: 'Required value'
+ fill_in "Name", with: "Foo bar"
+ fill_in "Required Foo", with: "Required value"
- click_on 'Advanced settings'
+ click_on "Advanced settings"
end
- it 'enables custom fields with provided values for this project' do
- fill_in 'Optional Foo', with: 'Optional value'
- fill_in 'Unused Foo', with: ''
+ it "enables custom fields with provided values for this project" do
+ fill_in "Optional Foo", with: "Optional value"
+ fill_in "Unused Foo", with: ""
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -183,25 +183,25 @@ RSpec.describe 'Projects', 'creation',
)
end
- context 'with correct handling of default values' do
+ context "with correct handling of default values" do
let!(:custom_field_with_default_value) do
- create(:project_custom_field, name: 'Foo with default value',
- field_format: 'string',
- default_value: 'Default value',
+ create(:project_custom_field, name: "Foo with default value",
+ field_format: "string",
+ default_value: "Default value",
project_custom_field_section:)
end
before do
visit new_project_path
- fill_in 'Name', with: 'Foo bar'
- fill_in 'Required Foo', with: 'Required value'
+ fill_in "Name", with: "Foo bar"
+ fill_in "Required Foo", with: "Required value"
- click_on 'Advanced settings'
+ click_on "Advanced settings"
end
- it 'enables custom fields with default values if not set to blank explicitly' do
+ it "enables custom fields with default values if not set to blank explicitly" do
# don't touch the default value
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -212,15 +212,15 @@ RSpec.describe 'Projects', 'creation',
custom_field_with_default_value.id, required_custom_field.id
)
- expect(project.custom_value_for(custom_field_with_default_value).value).to eq('Default value')
+ expect(project.custom_value_for(custom_field_with_default_value).value).to eq("Default value")
end
- it 'does not enable custom fields with default values if set to blank explicitly' do
+ it "does not enable custom fields with default values if set to blank explicitly" do
# native blank input does not work with this input, using support class here
field = FormFields::InputFormField.new(custom_field_with_default_value)
field.set_value("")
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -232,10 +232,10 @@ RSpec.describe 'Projects', 'creation',
)
end
- it 'does enable custom fields with default values if overwritten with a new value' do
- fill_in 'Foo with default value', with: 'foo'
+ it "does enable custom fields with default values if overwritten with a new value" do
+ fill_in "Foo with default value", with: "foo"
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -246,42 +246,42 @@ RSpec.describe 'Projects', 'creation',
custom_field_with_default_value.id, required_custom_field.id
)
- expect(project.custom_value_for(custom_field_with_default_value).value).to eq('foo')
+ expect(project.custom_value_for(custom_field_with_default_value).value).to eq("foo")
end
end
- context 'with correct handling of optional boolean values' do
+ context "with correct handling of optional boolean values" do
let!(:custom_boolean_field_default_true) do
- create(:project_custom_field, name: 'Boolean with default true',
- field_format: 'bool',
+ create(:project_custom_field, name: "Boolean with default true",
+ field_format: "bool",
default_value: true,
project_custom_field_section:)
end
let!(:custom_boolean_field_default_false) do
- create(:project_custom_field, name: 'Boolean with default false',
- field_format: 'bool',
+ create(:project_custom_field, name: "Boolean with default false",
+ field_format: "bool",
default_value: false,
project_custom_field_section:)
end
let!(:custom_boolean_field_with_no_default) do
- create(:project_custom_field, name: 'Boolean with no default',
- field_format: 'bool',
+ create(:project_custom_field, name: "Boolean with no default",
+ field_format: "bool",
project_custom_field_section:)
end
before do
visit new_project_path
- fill_in 'Name', with: 'Foo bar'
- fill_in 'Required Foo', with: 'Required value'
+ fill_in "Name", with: "Foo bar"
+ fill_in "Required Foo", with: "Required value"
- click_on 'Advanced settings'
+ click_on "Advanced settings"
end
- it 'only enables boolean custom fields with default values if untouched' do
+ it "only enables boolean custom fields with default values if untouched" do
# do not touch any of the boolean fields
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -297,10 +297,10 @@ RSpec.describe 'Projects', 'creation',
expect(project.custom_value_for(custom_boolean_field_default_false).typed_value).to be_falsy
end
- it 'enables boolean custom fields without default values if set to true explicitly' do
- check 'Boolean with no default'
+ it "enables boolean custom fields without default values if set to true explicitly" do
+ check "Boolean with no default"
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -316,10 +316,10 @@ RSpec.describe 'Projects', 'creation',
expect(project.custom_value_for(custom_boolean_field_with_no_default).typed_value).to be_truthy
end
- it 'enables boolean custom fields with default values if set to false explicitly' do
- uncheck 'Boolean with default true'
+ it "enables boolean custom fields with default values if set to false explicitly" do
+ uncheck "Boolean with default true"
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -336,28 +336,28 @@ RSpec.describe 'Projects', 'creation',
end
end
- context 'with correct handling of invisible values' do
+ context "with correct handling of invisible values" do
let!(:invisible_field) do
- create(:string_project_custom_field, name: 'Text for Admins only',
+ create(:string_project_custom_field, name: "Text for Admins only",
visible: false,
project_custom_field_section:)
end
before do
visit new_project_path
- fill_in 'Name', with: 'Foo bar'
- fill_in 'Required Foo', with: 'Required value'
+ fill_in "Name", with: "Foo bar"
+ fill_in "Required Foo", with: "Required value"
- click_on 'Advanced settings'
+ click_on "Advanced settings"
end
- context 'with an admin user' do
- it 'shows invisible fields in the form and allows their activation' do
- expect(page).to have_content 'Text for Admins only'
+ context "with an admin user" do
+ it "shows invisible fields in the form and allows their activation" do
+ expect(page).to have_content "Text for Admins only"
- fill_in 'Text for Admins only', with: 'foo'
+ fill_in "Text for Admins only", with: "foo"
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
@@ -367,17 +367,17 @@ RSpec.describe 'Projects', 'creation',
required_custom_field.id, invisible_field.id
)
- expect(project.custom_value_for(invisible_field).typed_value).to eq('foo')
+ expect(project.custom_value_for(invisible_field).typed_value).to eq("foo")
end
end
- context 'with a non-admin user' do
+ context "with a non-admin user" do
current_user { create(:user, global_permissions: %i[add_project]) }
- it 'does not show invisible fields in the form and thus not activates the invisible field' do
- expect(page).to have_no_content 'Text for Admins only'
+ it "does not show invisible fields in the form and thus not activates the invisible field" do
+ expect(page).to have_no_content "Text for Admins only"
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/foo-bar\/?/
diff --git a/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb b/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
index 8bf00e23429..80523365044 100644
--- a/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/dialog/render_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require_relative '../shared_context'
+require "spec_helper"
+require_relative "../shared_context"
-RSpec.describe 'Edit project custom fields on project overview page', :js do
- include_context 'with seeded projects, members and project custom fields'
+RSpec.describe "Edit project custom fields on project overview page", :js do
+ include_context "with seeded projects, members and project custom fields"
let(:overview_page) { Pages::Projects::Show.new(project) }
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section_for_input_fields) }
@@ -40,13 +40,13 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
overview_page.visit_page
end
- it 'opens a dialog showing inputs for project custom fields of a specific section' do
+ it "opens a dialog showing inputs for project custom fields of a specific section" do
overview_page.open_edit_dialog_for_section(section_for_input_fields)
dialog.expect_open
end
- it 'renders the dialog body asynchronically' do
+ it "renders the dialog body asynchronically" do
expect(page).to have_no_css(dialog.async_content_container_css_selector, visible: :all)
overview_page.open_edit_dialog_for_section(section_for_input_fields)
@@ -54,7 +54,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
expect(page).to have_css(dialog.async_content_container_css_selector, visible: :visible)
end
- it 'can be closed via close icon or cancel button' do
+ it "can be closed via close icon or cancel button" do
overview_page.open_edit_dialog_for_section(section_for_input_fields)
dialog.close_via_icon
@@ -68,7 +68,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.expect_closed
end
- it 'shows only the project custom fields of the specific section within the dialog' do
+ it "shows only the project custom fields of the specific section within the dialog" do
overview_page.open_edit_dialog_for_section(section_for_input_fields)
dialog.within_async_content(close_after_yield: true) do
@@ -110,18 +110,18 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
end
end
- it 'shows the inputs in the correct order defined by the position of project custom field in a section' do
+ it "shows the inputs in the correct order defined by the position of project custom field in a section" do
overview_page.open_edit_dialog_for_section(section_for_input_fields)
dialog.within_async_content(close_after_yield: true) do
containers = dialog.input_containers
- expect(containers[0].text).to include('Boolean field')
- expect(containers[1].text).to include('String field')
- expect(containers[2].text).to include('Integer field')
- expect(containers[3].text).to include('Float field')
- expect(containers[4].text).to include('Date field')
- expect(containers[5].text).to include('Text field')
+ expect(containers[0].text).to include("Boolean field")
+ expect(containers[1].text).to include("String field")
+ expect(containers[2].text).to include("Integer field")
+ expect(containers[3].text).to include("Float field")
+ expect(containers[4].text).to include("Date field")
+ expect(containers[5].text).to include("Text field")
end
boolean_project_custom_field.move_to_bottom
@@ -131,21 +131,21 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
dialog.within_async_content(close_after_yield: true) do
containers = dialog.input_containers
- expect(containers[0].text).to include('String field')
- expect(containers[1].text).to include('Integer field')
- expect(containers[2].text).to include('Float field')
- expect(containers[3].text).to include('Date field')
- expect(containers[4].text).to include('Text field')
- expect(containers[5].text).to include('Boolean field')
+ expect(containers[0].text).to include("String field")
+ expect(containers[1].text).to include("Integer field")
+ expect(containers[2].text).to include("Float field")
+ expect(containers[3].text).to include("Date field")
+ expect(containers[4].text).to include("Text field")
+ expect(containers[5].text).to include("Boolean field")
end
end
- context 'with visibility of project custom fields' do
- let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: 'Section with invisible fields') }
+ context "with visibility of project custom fields" do
+ let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: "Section with invisible fields") }
let!(:visible_project_custom_field) do
create(:project_custom_field,
- name: 'Normal field',
+ name: "Normal field",
visible: true,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
@@ -153,7 +153,7 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
- name: 'Admin only field',
+ name: "Admin only field",
visible: false,
projects: [project],
project_custom_field_section: section_with_invisible_fields)
@@ -161,34 +161,34 @@ RSpec.describe 'Edit project custom fields on project overview page', :js do
let(:dialog) { Components::Projects::ProjectCustomFields::EditDialog.new(project, section_with_invisible_fields) }
- context 'with admin permissions' do
+ context "with admin permissions" do
before do
login_as admin
overview_page.visit_page
end
- it 'shows all project custom fields' do
+ it "shows all project custom fields" do
overview_page.open_edit_dialog_for_section(section_with_invisible_fields)
dialog.within_async_content(close_after_yield: true) do
- expect(page).to have_content('Normal field')
- expect(page).to have_content('Admin only field')
+ expect(page).to have_content("Normal field")
+ expect(page).to have_content("Admin only field")
end
end
end
- context 'with non-admin permissions' do
+ context "with non-admin permissions" do
before do
login_as member_with_project_edit_permissions
overview_page.visit_page
end
- it 'shows only visible project custom fields' do
+ it "shows only visible project custom fields" do
overview_page.open_edit_dialog_for_section(section_with_invisible_fields)
dialog.within_async_content(close_after_yield: true) do
- expect(page).to have_content('Normal field')
- expect(page).to have_no_content('Admin only field')
+ expect(page).to have_content("Normal field")
+ expect(page).to have_no_content("Admin only field")
end
end
end
diff --git a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
index 5cfb258b243..8379cab6607 100644
--- a/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
+++ b/spec/features/projects/project_custom_fields/overview_page/shared_context.rb
@@ -26,13 +26,13 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-RSpec.shared_context 'with seeded projects, members and project custom fields' do
- let(:project) { create(:project, name: 'Foo project', identifier: 'foo-project') }
- let(:other_project) { create(:project, name: 'Bar project', identifier: 'bar-project') }
+RSpec.shared_context "with seeded projects, members and project custom fields" do
+ let(:project) { create(:project, name: "Foo project", identifier: "foo-project") }
+ let(:other_project) { create(:project, name: "Bar project", identifier: "bar-project") }
- let!(:first_version) { create(:version, name: 'Version 1', project:) }
- let!(:second_version) { create(:version, name: 'Version 2', project:) }
- let!(:third_version) { create(:version, name: 'Version 3', project:) }
+ let!(:first_version) { create(:version, name: "Version 1", project:) }
+ let!(:second_version) { create(:version, name: "Version 2", project:) }
+ let!(:third_version) { create(:version, name: "Version 3", project:) }
shared_let(:reader_role) do
create(:project_role, permissions: %i[view_work_packages])
@@ -48,29 +48,29 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
let!(:member_in_project) do
create(:user,
- firstname: 'Member 1',
- lastname: 'In Project',
+ firstname: "Member 1",
+ lastname: "In Project",
member_with_roles: { project => reader_role })
end
let!(:another_member_in_project) do
create(:user,
- firstname: 'Member 2',
- lastname: 'In Project',
+ firstname: "Member 2",
+ lastname: "In Project",
member_with_roles: { project => reader_role })
end
let!(:one_more_member_in_project) do
create(:user,
- firstname: 'Member 3',
- lastname: 'In Project',
+ firstname: "Member 3",
+ lastname: "In Project",
member_with_roles: { project => reader_role })
end
let!(:member_with_project_edit_permissions) do
create(:user,
- firstname: 'Member',
- lastname: 'With Project Edit Permissions',
+ firstname: "Member",
+ lastname: "With Project Edit Permissions",
member_with_roles: { project => edit_role })
end
@@ -78,12 +78,12 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
member_in_project
end
- let!(:section_for_input_fields) { create(:project_custom_field_section, name: 'Input fields') }
- let!(:section_for_select_fields) { create(:project_custom_field_section, name: 'Select fields') }
- let!(:section_for_multi_select_fields) { create(:project_custom_field_section, name: 'Multi select fields') }
+ let!(:section_for_input_fields) { create(:project_custom_field_section, name: "Input fields") }
+ let!(:section_for_select_fields) { create(:project_custom_field_section, name: "Select fields") }
+ let!(:section_for_multi_select_fields) { create(:project_custom_field_section, name: "Multi select fields") }
let!(:boolean_project_custom_field) do
- field = create(:boolean_project_custom_field, projects: [project], name: 'Boolean field',
+ field = create(:boolean_project_custom_field, projects: [project], name: "Boolean field",
project_custom_field_section: section_for_input_fields)
create(:custom_value, customized: project, custom_field: field, value: true)
@@ -92,16 +92,16 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:string_project_custom_field) do
- field = create(:string_project_custom_field, projects: [project], name: 'String field',
+ field = create(:string_project_custom_field, projects: [project], name: "String field",
project_custom_field_section: section_for_input_fields)
- create(:custom_value, customized: project, custom_field: field, value: 'Foo')
+ create(:custom_value, customized: project, custom_field: field, value: "Foo")
field
end
let!(:integer_project_custom_field) do
- field = create(:integer_project_custom_field, projects: [project], name: 'Integer field',
+ field = create(:integer_project_custom_field, projects: [project], name: "Integer field",
project_custom_field_section: section_for_input_fields)
create(:custom_value, customized: project, custom_field: field, value: 123)
@@ -110,7 +110,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:float_project_custom_field) do
- field = create(:float_project_custom_field, projects: [project], name: 'Float field',
+ field = create(:float_project_custom_field, projects: [project], name: "Float field",
project_custom_field_section: section_for_input_fields)
create(:custom_value, customized: project, custom_field: field, value: 123.456)
@@ -119,7 +119,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:date_project_custom_field) do
- field = create(:date_project_custom_field, projects: [project], name: 'Date field',
+ field = create(:date_project_custom_field, projects: [project], name: "Date field",
project_custom_field_section: section_for_input_fields)
create(:custom_value, customized: project, custom_field: field, value: Date.new(2024, 1, 1))
@@ -128,7 +128,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:text_project_custom_field) do
- field = create(:text_project_custom_field, projects: [project], name: 'Text field',
+ field = create(:text_project_custom_field, projects: [project], name: "Text field",
project_custom_field_section: section_for_input_fields)
create(:custom_value, customized: project, custom_field: field, value: "Lorem\n\nipsum")
@@ -137,9 +137,9 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:list_project_custom_field) do
- field = create(:list_project_custom_field, projects: [project], name: 'List field',
+ field = create(:list_project_custom_field, projects: [project], name: "List field",
project_custom_field_section: section_for_select_fields,
- possible_values: ['Option 1', 'Option 2', 'Option 3'])
+ possible_values: ["Option 1", "Option 2", "Option 3"])
create(:custom_value, customized: project, custom_field: field, value: field.custom_options.first)
@@ -147,7 +147,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:version_project_custom_field) do
- field = create(:version_project_custom_field, projects: [project], name: 'Version field',
+ field = create(:version_project_custom_field, projects: [project], name: "Version field",
project_custom_field_section: section_for_select_fields)
create(:custom_value, customized: project, custom_field: field, value: first_version.id)
@@ -156,7 +156,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:user_project_custom_field) do
- field = create(:user_project_custom_field, projects: [project], name: 'User field',
+ field = create(:user_project_custom_field, projects: [project], name: "User field",
project_custom_field_section: section_for_select_fields)
create(:custom_value, customized: project, custom_field: field, value: member_in_project.id)
@@ -165,9 +165,9 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:multi_list_project_custom_field) do
- field = create(:list_project_custom_field, projects: [project], name: 'Multi list field',
+ field = create(:list_project_custom_field, projects: [project], name: "Multi list field",
project_custom_field_section: section_for_multi_select_fields,
- possible_values: ['Option 1', 'Option 2', 'Option 3'],
+ possible_values: ["Option 1", "Option 2", "Option 3"],
multi_value: true)
create(:custom_value, customized: project, custom_field: field, value: field.custom_options.first.id)
@@ -177,7 +177,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:multi_version_project_custom_field) do
- field = create(:version_project_custom_field, projects: [project], name: 'Multi version field',
+ field = create(:version_project_custom_field, projects: [project], name: "Multi version field",
project_custom_field_section: section_for_multi_select_fields,
multi_value: true)
@@ -188,7 +188,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:multi_user_project_custom_field) do
- field = create(:user_project_custom_field, projects: [project], name: 'Multi user field',
+ field = create(:user_project_custom_field, projects: [project], name: "Multi user field",
project_custom_field_section: section_for_multi_select_fields,
multi_value: true)
@@ -226,7 +226,7 @@ RSpec.shared_context 'with seeded projects, members and project custom fields' d
end
let!(:boolean_project_custom_field_activated_in_other_project) do
- create(:boolean_project_custom_field, projects: [other_project], name: 'Other Boolean field',
+ create(:boolean_project_custom_field, projects: [other_project], name: "Other Boolean field",
project_custom_field_section: section_for_input_fields)
end
end
diff --git a/spec/features/projects/projects_custom_fields_spec.rb b/spec/features/projects/projects_custom_fields_spec.rb
index 60aba1edbcd..0685b6a0d29 100644
--- a/spec/features/projects/projects_custom_fields_spec.rb
+++ b/spec/features/projects/projects_custom_fields_spec.rb
@@ -26,11 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Projects custom fields', :js, :with_cuprite do
+RSpec.describe "Projects custom fields", :js, :with_cuprite do
shared_let(:current_user) { create(:admin) }
- shared_let(:project) { create(:project, name: 'Foo project', identifier: 'foo-project') }
+ shared_let(:project) { create(:project, name: "Foo project", identifier: "foo-project") }
let(:name_field) { FormFields::InputFormField.new :name }
let(:identifier) { "[data-qa-field-name='customField#{custom_field.id}'] input[type=checkbox]" }
@@ -38,33 +38,33 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
login_as current_user
end
- describe 'with version CF' do
+ describe "with version CF" do
let!(:custom_field) do
create(:version_project_custom_field)
end
let(:cf_field) { FormFields::SelectFormField.new custom_field }
- it 'allows creating a new project (regression #29099)' do
+ it "allows creating a new project (regression #29099)" do
visit new_project_path
- name_field.set_value 'My project name'
+ name_field.set_value "My project name"
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
cf_field.expect_visible
- click_button 'Save'
+ click_button "Save"
expect(page).to have_current_path /\/projects\/my-project-name\/?/
end
end
- describe 'with default values' do
+ describe "with default values" do
let!(:default_int_custom_field) do
create(:integer_project_custom_field, default_value: 123)
end
let!(:default_string_custom_field) do
- create(:string_project_custom_field, default_value: 'lorem')
+ create(:string_project_custom_field, default_value: "lorem")
end
let!(:no_default_string_custom_field) do
create(:string_project_custom_field)
@@ -75,19 +75,19 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
let(:default_string_field) { FormFields::InputFormField.new default_string_custom_field }
let(:no_default_string_field) { FormFields::InputFormField.new no_default_string_custom_field }
- it 'sets the default values on custom fields and allows overwriting them' do
+ it "sets the default values on custom fields and allows overwriting them" do
visit new_project_path
- name_field.set_value 'My project name'
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ name_field.set_value "My project name"
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
default_int_field.expect_value default_int_custom_field.default_value.to_s
default_string_field.expect_value default_string_custom_field.default_value.to_s
- no_default_string_field.expect_value ''
+ no_default_string_field.expect_value ""
- default_string_field.set_value 'Overwritten'
+ default_string_field.set_value "Overwritten"
- click_button 'Save'
+ click_button "Save"
expect(page).to have_current_path /\/projects\/my-project-name\/?/
created_project = Project.last
@@ -95,7 +95,7 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
visit project_settings_general_path(created_project)
default_int_field.expect_value default_int_custom_field.default_value.to_s
- default_string_field.expect_value 'Overwritten'
+ default_string_field.expect_value "Overwritten"
# The custom field without default value should not be shown
# as it didn't got activated with a value during project creation
@@ -103,7 +103,7 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
end
end
- describe 'with long text CF' do
+ describe "with long text CF" do
let!(:custom_field) do
create(:text_project_custom_field)
end
@@ -114,92 +114,92 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
project.project_custom_fields << custom_field
end
- it 'allows settings the project boolean CF (regression #26313)' do
+ it "allows settings the project boolean CF (regression #26313)" do
visit project_settings_general_path(project.id)
# expect CF, description and status description ckeditor-augmented-textarea
- expect(page).to have_css('.op-ckeditor--wrapper', count: 3)
+ expect(page).to have_css(".op-ckeditor--wrapper", count: 3)
# single hash autocomplete
- editor.insert_link 'http://example.org/link with spaces'
+ editor.insert_link "http://example.org/link with spaces"
sleep 2
# Save project settings
- click_on 'Save'
+ click_on "Save"
- expect(page).to have_text I18n.t('js.notice_successful_update')
+ expect(page).to have_text I18n.t("js.notice_successful_update")
project.reload
cv = project.custom_values.find_by(custom_field_id: custom_field.id).value
- expect(cv).to include '[http://example.org/link with spaces](http://example.org/link%20with%20spaces)'
+ expect(cv).to include "[http://example.org/link with spaces](http://example.org/link%20with%20spaces)"
expect(page).to have_css('a[href="http://example.org/link with spaces"]')
end
end
- describe 'with float CF' do
+ describe "with float CF" do
let!(:float_cf) do
- create(:float_project_custom_field, name: 'MyFloat')
+ create(:float_project_custom_field, name: "MyFloat")
end
let(:float_field) { FormFields::InputFormField.new float_cf }
- context 'with english locale' do
- let(:current_user) { create(:admin, language: 'en') }
+ context "with english locale" do
+ let(:current_user) { create(:admin, language: "en") }
- it 'displays the float with english locale' do
+ it "displays the float with english locale" do
visit new_project_path
- name_field.set_value 'My project name'
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ name_field.set_value "My project name"
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
- float_field.set_value '10000.55'
+ float_field.set_value "10000.55"
# Save project settings
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/my-project-name\/?/
- project = Project.find_by(name: 'My project name')
+ project = Project.find_by(name: "My project name")
cv = project.custom_values.find_by(custom_field_id: float_cf.id).typed_value
expect(cv).to eq 10000.55
visit project_settings_general_path(project)
- float_field.expect_value '10000.55'
+ float_field.expect_value "10000.55"
end
end
- context 'with german locale',
+ context "with german locale",
driver: :firefox_de,
with_cuprite: false do
- let(:current_user) { create(:admin, language: 'de') }
+ let(:current_user) { create(:admin, language: "de") }
- it 'displays the float with german locale' do
+ it "displays the float with german locale" do
I18n.locale = :de
visit new_project_path
- name_field.set_value 'My project name'
- find('.op-fieldset--toggle', text: I18n.t('js.forms.advanced_settings').upcase).click
+ name_field.set_value "My project name"
+ find(".op-fieldset--toggle", text: I18n.t("js.forms.advanced_settings").upcase).click
- float_field.set_value '10000,55'
+ float_field.set_value "10000,55"
# Save project settings
- click_on I18n.t('js.button_save')
+ click_on I18n.t("js.button_save")
expect(page).to have_current_path /\/projects\/my-project-name\/?/
- project = Project.find_by(name: 'My project name')
+ project = Project.find_by(name: "My project name")
cv = project.custom_values.find_by(custom_field_id: float_cf.id).typed_value
expect(cv).to eq 10000.55
visit project_settings_general_path(project)
# The field renders in german locale, but there's no way to test that
# as the internal value is always english locale
- float_field.expect_value '10000.55'
+ float_field.expect_value "10000.55"
end
end
end
- describe 'with boolean CF' do
+ describe "with boolean CF" do
let!(:custom_field) do
create(:boolean_project_custom_field)
end
@@ -209,14 +209,14 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
project.project_custom_fields << custom_field
end
- it 'allows settings the project boolean CF (regression #26313)' do
+ it "allows settings the project boolean CF (regression #26313)" do
visit project_settings_general_path(project.id)
field = page.find(identifier)
expect(field).not_to be_checked
field.check
- click_on 'Save'
+ click_on "Save"
expect(page).to have_text I18n.t(:notice_successful_update)
field = page.find(identifier)
@@ -224,7 +224,7 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
end
end
- describe 'with user CF' do
+ describe "with user CF" do
let!(:custom_field) do
create(:user_project_custom_field)
end
@@ -234,9 +234,9 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
let!(:existing_project) { create(:project) }
# Assume one user is visible
- let!(:invisible_user) { create(:user, firstname: 'Invisible', lastname: 'User') }
+ let!(:invisible_user) { create(:user, firstname: "Invisible", lastname: "User") }
let!(:visible_user) do
- create(:user, firstname: 'Visible', lastname: 'User',
+ create(:user, firstname: "Visible", lastname: "User",
member_with_permissions: { existing_project => %i[view_work_packages edit_work_packages] })
end
@@ -246,29 +246,29 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
Components::Users::InviteUserModal.new project:,
principal: invisible_user,
role:,
- invite_message: 'you are invited'
+ invite_message: "you are invited"
end
- it 'allows setting a visible user CF (regression #26313)' do
+ it "allows setting a visible user CF (regression #26313)" do
visit new_project_path
- name_field.set_value 'My project name'
+ name_field.set_value "My project name"
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
cf_field.expect_visible
cf_field.expect_no_option invisible_user
cf_field.select_option visible_user
- click_on 'Save'
+ click_on "Save"
expect(page).to have_current_path /\/projects\/my-project-name\/?/
- project = Project.find_by(name: 'My project name')
+ project = Project.find_by(name: "My project name")
cv = project.custom_values.find_by(custom_field_id: custom_field.id).typed_value
expect(cv).to eq visible_user
end
- it 'allows inviting a new user immediately (regression #39166)' do
+ it "allows inviting a new user immediately (regression #39166)" do
project.project_custom_fields << custom_field # enable the custom field for the project
visit project_settings_general_path(project.id)
@@ -277,17 +277,17 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
cf_field.expect_no_option invisible_user
# Invite the other user to the project
- find('.ng-dropdown-footer button', text: 'Invite', wait: 5).click
+ find(".ng-dropdown-footer button", text: "Invite", wait: 5).click
modal.run_all_steps
sleep 2
# The newly invited user can be directly selected
cf_field.expect_visible
- cf_field.search('invis')
+ cf_field.search("invis")
cf_field.select_option invisible_user
- click_on 'Save'
+ click_on "Save"
expect(page).to have_text I18n.t(:notice_successful_update)
project.reload
@@ -295,16 +295,16 @@ RSpec.describe 'Projects custom fields', :js, :with_cuprite do
expect(cv).to eq invisible_user
end
- it 'does not show invite user button when there is no project selected' do
+ it "does not show invite user button when there is no project selected" do
visit new_project_path
- name_field.set_value 'My project name'
+ name_field.set_value "My project name"
- find('.op-fieldset--toggle', text: 'ADVANCED SETTINGS').click
+ find(".op-fieldset--toggle", text: "ADVANCED SETTINGS").click
cf_field.expect_visible
cf_field.expect_no_option invisible_user
- expect(page).to have_no_css('.ng-dropdown-footer button', text: 'Invite')
+ expect(page).to have_no_css(".ng-dropdown-footer button", text: "Invite")
end
end
end
diff --git a/spec/features/users/my_spec.rb b/spec/features/users/my_spec.rb
index 500d91cd84c..53ff55f7994 100644
--- a/spec/features/users/my_spec.rb
+++ b/spec/features/users/my_spec.rb
@@ -26,15 +26,15 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'my', :js, :with_cuprite do
- let(:user_password) { 'bob' * 4 }
- let!(:string_cf) { create(:user_custom_field, :string, name: 'Hobbies', is_required: false) }
+RSpec.describe "my", :js, :with_cuprite do
+ let(:user_password) { "bob" * 4 }
+ let!(:string_cf) { create(:user_custom_field, :string, name: "Hobbies", is_required: false) }
let(:user) do
create(:user,
- login: 'bob',
+ login: "bob",
password: user_password,
password_confirmation: user_password)
end
@@ -46,218 +46,218 @@ RSpec.describe 'my', :js, :with_cuprite do
expect(page).to have_content I18n.t(:notice_account_other_session_expired)
# expect session to be removed
- expect(Sessions::UserSession.for_user(user).where(session_id: 'other').count).to eq 0
+ expect(Sessions::UserSession.for_user(user).where(session_id: "other").count).to eq 0
user.reload
- expect(user.mail).to eq '[email protected]'
- expect(user.name).to eq 'Foo Bar'
+ expect(user.mail).to eq "[email protected]"
+ expect(user.name).to eq "Foo Bar"
end
before do
login_as user
# Create dangling session
- session = Sessions::SqlBypass.new data: { user_id: user.id }, session_id: 'other'
+ session = Sessions::SqlBypass.new data: { user_id: user.id }, session_id: "other"
session.save
- expect(Sessions::UserSession.for_user(user).where(session_id: 'other').count).to eq 1
+ expect(Sessions::UserSession.for_user(user).where(session_id: "other").count).to eq 1
end
- shared_examples 'common tests for normal and LDAP user' do
- describe 'settings' do
- context 'with a default time zone', with_settings: { user_default_timezone: 'Asia/Tokyo' } do
- it 'can override a time zone' do
- expect(user.pref.time_zone).to eq 'Asia/Tokyo'
+ shared_examples "common tests for normal and LDAP user" do
+ describe "settings" do
+ context "with a default time zone", with_settings: { user_default_timezone: "Asia/Tokyo" } do
+ it "can override a time zone" do
+ expect(user.pref.time_zone).to eq "Asia/Tokyo"
visit my_settings_path
- expect(page).to have_select 'pref_time_zone', selected: '(UTC+09:00) Tokyo'
- select '(UTC+01:00) Paris', from: 'pref_time_zone'
- click_on 'Save'
+ expect(page).to have_select "pref_time_zone", selected: "(UTC+09:00) Tokyo"
+ select "(UTC+01:00) Paris", from: "pref_time_zone"
+ click_on "Save"
- expect(page).to have_select 'pref_time_zone', selected: '(UTC+01:00) Paris'
- expect(user.pref.time_zone).to eq 'Europe/Paris'
+ expect(page).to have_select "pref_time_zone", selected: "(UTC+01:00) Paris"
+ expect(user.pref.time_zone).to eq "Europe/Paris"
end
end
end
end
- context 'user' do
- describe '#account' do
+ context "user" do
+ describe "#account" do
let(:dialog) { Components::PasswordConfirmationDialog.new }
before do
visit my_account_path
- fill_in 'user[mail]', with: '[email protected]'
- fill_in 'user[firstname]', with: 'Foo'
- fill_in 'user[lastname]', with: 'Bar'
- click_on 'Save'
+ fill_in "user[mail]", with: "[email protected]"
+ fill_in "user[firstname]", with: "Foo"
+ fill_in "user[lastname]", with: "Bar"
+ click_on "Save"
end
- context 'when confirmation disabled',
+ context "when confirmation disabled",
with_config: { internal_password_confirmation: false } do
- it 'does not request confirmation' do
+ it "does not request confirmation" do
expect_changed!
end
end
- context 'when confirmation required',
+ context "when confirmation required",
with_config: { internal_password_confirmation: true } do
- it 'requires the password for a regular user' do
+ it "requires the password for a regular user" do
dialog.confirm_flow_with(user_password)
expect_changed!
end
- it 'declines the change when invalid password is given' do
- dialog.confirm_flow_with(user_password + 'INVALID', should_fail: true)
+ it "declines the change when invalid password is given" do
+ dialog.confirm_flow_with(user_password + "INVALID", should_fail: true)
user.reload
- expect(user.mail).to eq('[email protected]')
+ expect(user.mail).to eq("[email protected]")
end
- context 'as admin' do
+ context "as admin" do
shared_let(:admin) { create(:admin) }
let(:user) { admin }
- it 'requires the password' do
- dialog.confirm_flow_with('adminADMIN!')
+ it "requires the password" do
+ dialog.confirm_flow_with("adminADMIN!")
expect_changed!
end
end
end
end
- include_examples 'common tests for normal and LDAP user'
+ include_examples "common tests for normal and LDAP user"
describe "API tokens" do
- context 'when API access is disabled via global settings', with_settings: { rest_api_enabled: false } do
- it 'shows notice about disabled token' do
+ context "when API access is disabled via global settings", with_settings: { rest_api_enabled: false } do
+ it "shows notice about disabled token" do
visit my_access_token_path
- within '#api-token-section' do
- expect(page).to have_content('API tokens are not enabled by the administrator.')
- expect(page).not_to have_test_selector('api-token-add', text: 'API token')
+ within "#api-token-section" do
+ expect(page).to have_content("API tokens are not enabled by the administrator.")
+ expect(page).not_to have_test_selector("api-token-add", text: "API token")
end
end
end
- context 'when API access is enabled via global settings', with_settings: { rest_api_enabled: true } do
- it 'API tokens can generated and revoked' do
+ context "when API access is enabled via global settings", with_settings: { rest_api_enabled: true } do
+ it "API tokens can generated and revoked" do
visit my_access_token_path
- expect(page).to have_no_content('API tokens are not enabled by the administrator.')
+ expect(page).to have_no_content("API tokens are not enabled by the administrator.")
- within '#api-token-section' do
- expect(page).to have_test_selector('api-token-add', text: 'API token')
+ within "#api-token-section" do
+ expect(page).to have_test_selector("api-token-add", text: "API token")
find_test_selector("api-token-add").click
end
- expect(page).to have_content 'A new API token has been generated. Your access token is'
+ expect(page).to have_content "A new API token has been generated. Your access token is"
User.current.reload
visit my_access_token_path
# only one API token can be created
- within '#api-token-section' do
- expect(page).not_to have_test_selector('api-token-add', text: 'API token')
+ within "#api-token-section" do
+ expect(page).not_to have_test_selector("api-token-add", text: "API token")
end
# revoke API token
- within '#api-token-section' do
+ within "#api-token-section" do
accept_confirm do
find_test_selector("api-token-revoke").click
end
end
- expect(page).to have_content 'The API token has been deleted.'
+ expect(page).to have_content "The API token has been deleted."
User.current.reload
visit my_access_token_path
# API token can be created again
- within '#api-token-section' do
- expect(page).to have_test_selector('api-token-add', text: 'API token')
+ within "#api-token-section" do
+ expect(page).to have_test_selector("api-token-add", text: "API token")
end
end
end
end
describe "RSS tokens" do
- context 'when RSS access is disabled via global settings', with_settings: { feeds_enabled: false } do
- it 'shows notice about disabled token' do
+ context "when RSS access is disabled via global settings", with_settings: { feeds_enabled: false } do
+ it "shows notice about disabled token" do
visit my_access_token_path
- within '#rss-token-section' do
- expect(page).to have_content('RSS tokens are not enabled by the administrator.')
- expect(page).not_to have_test_selector('rss-token-add', text: 'RSS token')
+ within "#rss-token-section" do
+ expect(page).to have_content("RSS tokens are not enabled by the administrator.")
+ expect(page).not_to have_test_selector("rss-token-add", text: "RSS token")
end
end
end
- context 'when RSS access is enabled via global settings', with_settings: { feeds_enabled: true } do
- it 'in Access Tokens they can generate and revoke their RSS key' do
+ context "when RSS access is enabled via global settings", with_settings: { feeds_enabled: true } do
+ it "in Access Tokens they can generate and revoke their RSS key" do
visit my_access_token_path
- expect(page).to have_no_content('RSS tokens are not enabled by the administrator.')
+ expect(page).to have_no_content("RSS tokens are not enabled by the administrator.")
- within '#rss-token-section' do
- expect(page).to have_test_selector('rss-token-add', text: 'RSS token')
+ within "#rss-token-section" do
+ expect(page).to have_test_selector("rss-token-add", text: "RSS token")
find_test_selector("rss-token-add").click
end
- expect(page).to have_content 'A new RSS token has been generated. Your access token is'
+ expect(page).to have_content "A new RSS token has been generated. Your access token is"
User.current.reload
visit my_access_token_path
# only one RSS token can be created
- within '#rss-token-section' do
- expect(page).not_to have_test_selector('rss-token-add', text: 'RSS token')
+ within "#rss-token-section" do
+ expect(page).not_to have_test_selector("rss-token-add", text: "RSS token")
end
# revoke RSS token
- within '#rss-token-section' do
+ within "#rss-token-section" do
accept_confirm do
find_test_selector("rss-token-revoke").click
end
end
- expect(page).to have_content 'The RSS token has been deleted.'
+ expect(page).to have_content "The RSS token has been deleted."
User.current.reload
visit my_access_token_path
# RSS token can be created again
- within '#rss-token-section' do
- expect(page).to have_test_selector('rss-token-add', text: 'RSS token')
+ within "#rss-token-section" do
+ expect(page).to have_test_selector("rss-token-add", text: "RSS token")
end
end
end
end
describe "iCalendar tokens" do
- context 'when iCalendar access is disabled via global settings', with_settings: { ical_enabled: false } do
- it 'shows notice about disabled token' do
+ context "when iCalendar access is disabled via global settings", with_settings: { ical_enabled: false } do
+ it "shows notice about disabled token" do
visit my_access_token_path
- within '#icalendar-token-section' do
- expect(page).to have_content('iCalendar subscriptions are not enabled by the administrator.')
+ within "#icalendar-token-section" do
+ expect(page).to have_content("iCalendar subscriptions are not enabled by the administrator.")
end
end
end
- context 'when iCalendar access is enable via global settings', with_settings: { ical_enabled: true } do
- context 'when no iCalendar token exists' do
- it 'shows notice about how to use iCalendar tokens' do
+ context "when iCalendar access is enable via global settings", with_settings: { ical_enabled: true } do
+ context "when no iCalendar token exists" do
+ it "shows notice about how to use iCalendar tokens" do
visit my_access_token_path
- within '#icalendar-token-section' do
- expect(page).to have_content('To add an iCalendar token') # ...
+ within "#icalendar-token-section" do
+ expect(page).to have_content("To add an iCalendar token") # ...
end
end
end
- context 'when multiple iCalendar tokens exist' do
+ context "when multiple iCalendar tokens exist" do
let!(:project) { create(:project) }
let!(:query) { create(:query, project:) }
let!(:another_query) { create(:query, project:) }
@@ -265,12 +265,12 @@ RSpec.describe 'my', :js, :with_cuprite do
let!(:ical_token_for_another_query) { create(:ical_token, user:, query: another_query, name: "Second Token Name") }
let!(:second_ical_token_for_query) { create(:ical_token, user:, query:, name: "Third Token Name") }
- it 'shows iCalendar tokens with their calender and project info' do
+ it "shows iCalendar tokens with their calender and project info" do
visit my_access_token_path
- expect(page).to have_no_content('To add an iCalendar token') # ...
+ expect(page).to have_no_content("To add an iCalendar token") # ...
- within '#icalendar-token-section' do
+ within "#icalendar-token-section" do
[
ical_token_for_query,
ical_token_for_another_query,
@@ -287,21 +287,21 @@ RSpec.describe 'my', :js, :with_cuprite do
end
end
- it 'single iCalendar tokens can be deleted' do
+ it "single iCalendar tokens can be deleted" do
visit my_access_token_path
- within '#icalendar-token-section' do
+ within "#icalendar-token-section" do
accept_confirm do
find_test_selector("ical-token-row-#{ical_token_for_query.id}-revoke").click
end
end
- expect(page).to have_content 'The iCalendar URL with this token is now invalid.'
+ expect(page).to have_content "The iCalendar URL with this token is now invalid."
User.current.reload
visit my_access_token_path
- within '#icalendar-token-section' do
+ within "#icalendar-token-section" do
expect(page).not_to have_test_selector('ical-token-row-#{ical_token_for_query.id}-revoke')
end
end
@@ -310,20 +310,20 @@ RSpec.describe 'my', :js, :with_cuprite do
end
describe "OAuth tokens" do
- context 'when no OAuth access is configured' do
- it 'shows notice about no existing tokens' do
+ context "when no OAuth access is configured" do
+ it "shows notice about no existing tokens" do
visit my_access_token_path
- within '#oauth-token-section' do
- expect(page).to have_content('There is no third-party application access configured and active for you')
+ within "#oauth-token-section" do
+ expect(page).to have_content("There is no third-party application access configured and active for you")
end
end
end
- context 'when OAuth access is configured' do
+ context "when OAuth access is configured" do
let!(:app) do
create(:oauth_application,
- name: 'Some App',
+ name: "Some App",
confidential: false)
end
let!(:token_for_app) do
@@ -333,8 +333,8 @@ RSpec.describe 'my', :js, :with_cuprite do
end
let!(:second_app) do
create(:oauth_application,
- name: 'Some Second App',
- uid: '56789',
+ name: "Some Second App",
+ uid: "56789",
confidential: false)
end
let!(:token_for_second_app) do
@@ -343,23 +343,23 @@ RSpec.describe 'my', :js, :with_cuprite do
resource_owner: user)
end
- context 'when single OAuth token per app is configured' do
- it 'shows token for granted applications' do
+ context "when single OAuth token per app is configured" do
+ it "shows token for granted applications" do
visit my_access_token_path
[app, second_app].each do |app|
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: app.name)
- expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: '(one active token)')
+ expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: "(one active token)")
end
end
end
- it 'can revoke tokens' do
+ it "can revoke tokens" do
visit my_access_token_path
[app, second_app].each do |app|
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
accept_confirm do
find_test_selector("oauth-token-row-#{app.id}-revoke").click
end
@@ -370,14 +370,14 @@ RSpec.describe 'my', :js, :with_cuprite do
visit my_access_token_path
[app, second_app].each do |app|
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
expect(page).not_to have_test_selector("oauth-token-row-#{app.id}-revoke")
end
end
end
end
- context 'when multiple OAuth tokens per app are configured' do
+ context "when multiple OAuth tokens per app are configured" do
let!(:second_token_for_app) do
create(:oauth_access_token,
application: app,
@@ -389,21 +389,21 @@ RSpec.describe 'my', :js, :with_cuprite do
resource_owner: user)
end
- it 'shows token for granted applications' do
+ it "shows token for granted applications" do
visit my_access_token_path
[app, second_app].each do |app|
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: app.name)
- expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: '(2 active token)')
+ expect(page).to have_test_selector("oauth-token-row-#{app.id}-name", text: "(2 active token)")
end
end
end
- it 'can revoke mutliple tokens per app' do
+ it "can revoke mutliple tokens per app" do
visit my_access_token_path
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
accept_confirm do
find_test_selector("oauth-token-row-#{app.id}-revoke").click
end
@@ -412,7 +412,7 @@ RSpec.describe 'my', :js, :with_cuprite do
User.current.reload
visit my_access_token_path
- within '#oauth-token-section' do
+ within "#oauth-token-section" do
expect(page).not_to have_test_selector("oauth-token-row-#{app.id}-revoke")
end
end
@@ -422,43 +422,43 @@ RSpec.describe 'my', :js, :with_cuprite do
end
# Without password confirmation the test doesn't try to connect to the LDAP:
- context 'LDAP user', with_config: { internal_password_confirmation: false } do
+ context "LDAP user", with_config: { internal_password_confirmation: false } do
let(:ldap_auth_source) { create(:ldap_auth_source) }
let(:user) do
create(:user,
- login: 'bob',
+ login: "bob",
ldap_auth_source:)
end
- describe '#account' do
+ describe "#account" do
before do
visit my_account_path
end
- it 'does not allow change of name and email but other fields can be changed' do
- email_field = find_field('user[mail]', disabled: true)
- firstname_field = find_field('user[firstname]', disabled: true)
- lastname_field = find_field('user[lastname]', disabled: true)
+ it "does not allow change of name and email but other fields can be changed" do
+ email_field = find_field("user[mail]", disabled: true)
+ firstname_field = find_field("user[firstname]", disabled: true)
+ lastname_field = find_field("user[lastname]", disabled: true)
expect(email_field).to be_disabled
expect(firstname_field).to be_disabled
expect(lastname_field).to be_disabled
- expect(page).to have_text(I18n.t('user.text_change_disabled_for_ldap_login'), count: 3)
+ expect(page).to have_text(I18n.t("user.text_change_disabled_for_ldap_login"), count: 3)
- fill_in 'Hobbies', with: 'Ruby, DCS'
- uncheck 'pref[hide_mail]'
- click_on 'Save'
+ fill_in "Hobbies", with: "Ruby, DCS"
+ uncheck "pref[hide_mail]"
+ click_on "Save"
expect(page).to have_content I18n.t(:notice_account_updated)
user.reload
- expect(user.custom_values.find_by(custom_field_id: string_cf).value).to eql 'Ruby, DCS'
+ expect(user.custom_values.find_by(custom_field_id: string_cf).value).to eql "Ruby, DCS"
expect(user.pref.hide_mail).to be false
end
end
- include_examples 'common tests for normal and LDAP user'
+ include_examples "common tests for normal and LDAP user"
end
end
diff --git a/spec/models/custom_value_spec.rb b/spec/models/custom_value_spec.rb
index 47966bc810f..47f735b1bfb 100644
--- a/spec/models/custom_value_spec.rb
+++ b/spec/models/custom_value_spec.rb
@@ -26,16 +26,16 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe CustomValue do
shared_let(:version) { create(:version) }
- let(:format) { 'bool' }
+ let(:format) { "bool" }
let(:custom_field) { create(:version_custom_field, field_format: format) }
let(:custom_value) { create(:custom_value, custom_field:, value:, customized: version) }
- describe '#typed_value' do
+ describe "#typed_value" do
subject { custom_value }
before do
@@ -44,68 +44,68 @@ RSpec.describe CustomValue do
subject.reload
end
- describe 'boolean custom value' do
- let(:format) { 'bool' }
+ describe "boolean custom value" do
+ let(:format) { "bool" }
let(:value) { true }
- context 'when it is true' do
+ context "when it is true" do
it { expect(subject.typed_value).to eql(value) }
end
- context 'when it is false' do
+ context "when it is false" do
let(:value) { false }
it { expect(subject.typed_value).to eql(value) }
end
- context 'when it is nil' do
+ context "when it is nil" do
let(:value) { nil }
it { expect(subject.typed_value).to eql(value) }
end
end
- describe 'string custom value' do
- let(:format) { 'string' }
- let(:value) { 'This is a string!' }
+ describe "string custom value" do
+ let(:format) { "string" }
+ let(:value) { "This is a string!" }
it { expect(subject.typed_value).to eql(value) }
end
- describe 'integer custom value' do
- let(:format) { 'int' }
+ describe "integer custom value" do
+ let(:format) { "int" }
let(:value) { 123 }
it { expect(subject.typed_value).to eql(value) }
end
- describe 'float custom value' do
- let(:format) { 'float' }
+ describe "float custom value" do
+ let(:format) { "float" }
let(:value) { 3.147 }
it { expect(subject.typed_value).to eql(value) }
end
- describe 'date custom value' do
- let(:format) { 'date' }
+ describe "date custom value" do
+ let(:format) { "date" }
let(:value) { Date.new(2016, 12, 1) }
it { expect(subject.typed_value).to eql(value) }
- context 'for a date format', with_settings: { date_format: '%Y/%m/%d' } do
- it { expect(subject.formatted_value).to eq('2016/12/01') }
+ context "for a date format", with_settings: { date_format: "%Y/%m/%d" } do
+ it { expect(subject.formatted_value).to eq("2016/12/01") }
end
end
end
- describe '#default?' do
+ describe "#default?" do
shared_let(:project) { create(:project) }
RSpec::Matchers.define_negated_matcher :not_be_default, :be_default
- shared_examples 'returns true for generated custom value' do
+ shared_examples "returns true for generated custom value" do
describe "for a generated custom value" do
- it 'returns true' do
+ it "returns true" do
custom_values = project.custom_field_values
expect(custom_values.count).to eq(1)
@@ -114,9 +114,9 @@ RSpec.describe CustomValue do
end
end
- shared_examples 'returns false for custom value with value' do |value:|
+ shared_examples "returns false for custom value with value" do |value:|
describe "for a custom value with #{value.inspect} value" do
- it 'returns false' do
+ it "returns false" do
project.send(custom_field.attribute_setter, value)
custom_value = project.custom_values.last
@@ -125,22 +125,22 @@ RSpec.describe CustomValue do
end
end
- context 'for a boolean custom field without default value' do
+ context "for a boolean custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :boolean, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: false
- include_examples 'returns false for custom value with value', value: true
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: false
+ include_examples "returns false for custom value with value", value: true
end
- context 'for a boolean custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
+ context "for a boolean custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
create(:project_custom_field, :boolean, default_value: true)
create(:project_custom_field, :boolean, default_value: false)
# the admin interface saves default value as "1" (checked) or "0" (unchecked)
- create(:project_custom_field, :boolean, default_value: '1')
- create(:project_custom_field, :boolean, default_value: '0')
+ create(:project_custom_field, :boolean, default_value: "1")
+ create(:project_custom_field, :boolean, default_value: "0")
custom_values = project.custom_field_values
@@ -152,15 +152,15 @@ RSpec.describe CustomValue do
context "for a string custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :string, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: 'Hello world!'
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: "Hello world!"
end
- context 'for a string custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
- create(:project_custom_field, :string, default_value: 'Hello world!', projects: [project])
- create(:project_custom_field, :string, default_value: '', projects: [project])
+ context "for a string custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
+ create(:project_custom_field, :string, default_value: "Hello world!", projects: [project])
+ create(:project_custom_field, :string, default_value: "", projects: [project])
custom_values = project.custom_field_values
@@ -169,19 +169,19 @@ RSpec.describe CustomValue do
end
end
- context 'for a text custom field without default value' do
+ context "for a text custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :text, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: "Hello world!"
- include_examples 'returns false for custom value with value', value: "Hello world!\nHello world!\nHello world!"
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: "Hello world!"
+ include_examples "returns false for custom value with value", value: "Hello world!\nHello world!\nHello world!"
end
- context 'for a text custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
- create(:project_custom_field, :text, default_value: 'Hello world!', projects: [project])
- create(:project_custom_field, :text, default_value: '', projects: [project])
+ context "for a text custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
+ create(:project_custom_field, :text, default_value: "Hello world!", projects: [project])
+ create(:project_custom_field, :text, default_value: "", projects: [project])
custom_values = project.custom_field_values
@@ -190,23 +190,23 @@ RSpec.describe CustomValue do
end
end
- context 'for an integer custom field without default value' do
+ context "for an integer custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :integer, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: 123
- include_examples 'returns false for custom value with value', value: 0
- include_examples 'returns false for custom value with value', value: -12
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: 123
+ include_examples "returns false for custom value with value", value: 0
+ include_examples "returns false for custom value with value", value: -12
end
- context 'for an integer custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
+ context "for an integer custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
create(:project_custom_field, :integer, default_value: 0, projects: [project])
create(:project_custom_field, :integer, default_value: 123, projects: [project])
- create(:project_custom_field, :integer, default_value: '456', projects: [project])
+ create(:project_custom_field, :integer, default_value: "456", projects: [project])
create(:project_custom_field, :integer, default_value: -987, projects: [project])
- create(:project_custom_field, :integer, default_value: '-678', projects: [project])
+ create(:project_custom_field, :integer, default_value: "-678", projects: [project])
custom_values = project.custom_field_values
@@ -215,23 +215,23 @@ RSpec.describe CustomValue do
end
end
- context 'for a float custom field without default value' do
+ context "for a float custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :float, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: 3.14
- include_examples 'returns false for custom value with value', value: 0
- include_examples 'returns false for custom value with value', value: -12
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: 3.14
+ include_examples "returns false for custom value with value", value: 0
+ include_examples "returns false for custom value with value", value: -12
end
- context 'for a float custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
+ context "for a float custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
create(:project_custom_field, :float, default_value: 0.0, projects: [project])
create(:project_custom_field, :float, default_value: 12.3, projects: [project])
- create(:project_custom_field, :float, default_value: '45.6', projects: [project])
+ create(:project_custom_field, :float, default_value: "45.6", projects: [project])
create(:project_custom_field, :float, default_value: -98.7, projects: [project])
- create(:project_custom_field, :float, default_value: '-67', projects: [project])
+ create(:project_custom_field, :float, default_value: "-67", projects: [project])
custom_values = project.custom_field_values
@@ -240,22 +240,22 @@ RSpec.describe CustomValue do
end
end
- context 'for a date custom field' do
+ context "for a date custom field" do
shared_let(:custom_field) { create(:project_custom_field, :date, projects: [project]) }
- include_examples 'returns true for generated custom value'
- include_examples 'returns false for custom value with value', value: "2023-08-08"
- include_examples 'returns false for custom value with value', value: Date.current
+ include_examples "returns true for generated custom value"
+ include_examples "returns false for custom value with value", value: "2023-08-08"
+ include_examples "returns false for custom value with value", value: Date.current
end
- context 'for a list custom field without default value' do
+ context "for a list custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :list, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
describe "for a custom value with option 'B' selected" do
- it 'returns false' do
- project.send(custom_field.attribute_setter, custom_field.value_of('B'))
+ it "returns false" do
+ project.send(custom_field.attribute_setter, custom_field.value_of("B"))
custom_value = project.custom_values.last
expect(custom_value).to not_be_default
@@ -263,10 +263,10 @@ RSpec.describe CustomValue do
end
end
- context 'for a list custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
- create(:project_custom_field, :list, default_option: 'B', projects: [project])
+ context "for a list custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
+ create(:project_custom_field, :list, default_option: "B", projects: [project])
custom_values = project.custom_field_values
@@ -276,14 +276,14 @@ RSpec.describe CustomValue do
end
end
- context 'for a multi-value list custom field without default value' do
+ context "for a multi-value list custom field without default value" do
shared_let(:custom_field) { create(:project_custom_field, :multi_list, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
describe "for a custom value with option 'B' and 'D' selected" do
- it 'returns false' do
- project.send(custom_field.attribute_setter, [custom_field.value_of('B'), custom_field.value_of('D')])
+ it "returns false" do
+ project.send(custom_field.attribute_setter, [custom_field.value_of("B"), custom_field.value_of("D")])
project.save!
expect(project.custom_values).to all(not_be_default)
@@ -291,11 +291,11 @@ RSpec.describe CustomValue do
end
end
- context 'for a multi-value list custom field with default value' do
- describe 'for a generated custom value' do
- it 'returns true' do
- create(:project_custom_field, :multi_list, default_options: ['B'], projects: [project])
- create(:project_custom_field, :multi_list, default_options: ['G', 'B', 'C'], projects: [project])
+ context "for a multi-value list custom field with default value" do
+ describe "for a generated custom value" do
+ it "returns true" do
+ create(:project_custom_field, :multi_list, default_options: ["B"], projects: [project])
+ create(:project_custom_field, :multi_list, default_options: ["G", "B", "C"], projects: [project])
custom_values = project.custom_field_values
@@ -306,15 +306,15 @@ RSpec.describe CustomValue do
end
end
- context 'for a version custom field' do
+ context "for a version custom field" do
shared_let(:custom_field) { create(:project_custom_field, :version, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
- describe 'for a custom value with a version selected' do
- let!(:version_turfu) { create(:version, name: 'turfu', project:) }
+ describe "for a custom value with a version selected" do
+ let!(:version_turfu) { create(:version, name: "turfu", project:) }
- it 'returns false' do
+ it "returns false" do
project.send(custom_field.attribute_setter, version_turfu.id)
project.save!
custom_value = project.custom_values.last
@@ -324,16 +324,16 @@ RSpec.describe CustomValue do
end
end
- context 'for a multi version custom field' do
+ context "for a multi version custom field" do
shared_let(:custom_field) { create(:project_custom_field, :multi_version, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
- describe 'for a custom value with multiple versions selected' do
- let!(:version_ringbo) { create(:version, name: 'ringbo', project:) }
- let!(:version_turfu) { create(:version, name: 'turfu', project:) }
+ describe "for a custom value with multiple versions selected" do
+ let!(:version_ringbo) { create(:version, name: "ringbo", project:) }
+ let!(:version_turfu) { create(:version, name: "turfu", project:) }
- it 'returns false' do
+ it "returns false" do
project.send(custom_field.attribute_setter, [version_ringbo.id, version_turfu.id])
project.save!
@@ -342,17 +342,17 @@ RSpec.describe CustomValue do
end
end
- context 'for a user custom field' do
+ context "for a user custom field" do
shared_let(:custom_field) { create(:project_custom_field, :user, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
- describe 'for a custom value with a user selected' do
+ describe "for a custom value with a user selected" do
let!(:alice) do
- create(:user, firstname: 'Alice', member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
+ create(:user, firstname: "Alice", member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
end
- it 'returns false' do
+ it "returns false" do
project.send(custom_field.attribute_setter, alice.id)
project.save!
custom_value = project.custom_values.last
@@ -362,20 +362,20 @@ RSpec.describe CustomValue do
end
end
- context 'for a multi user custom field' do
+ context "for a multi user custom field" do
shared_let(:custom_field) { create(:project_custom_field, :multi_user, projects: [project]) }
- include_examples 'returns true for generated custom value'
+ include_examples "returns true for generated custom value"
- describe 'for a custom value with multiple users selected' do
+ describe "for a custom value with multiple users selected" do
let!(:alice) do
- create(:user, firstname: 'Alice', member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
+ create(:user, firstname: "Alice", member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
end
let!(:bob) do
- create(:user, firstname: 'Bob', member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
+ create(:user, firstname: "Bob", member_with_permissions: { project => %i[view_work_packages edit_work_packages] })
end
- it 'returns false' do
+ it "returns false" do
project.send(custom_field.attribute_setter, [alice.id, bob.id])
project.save!
@@ -385,18 +385,18 @@ RSpec.describe CustomValue do
end
end
- describe 'trying to use a custom field that does not exist' do
- subject { build(:custom_value, custom_field_id: 123412341, value: 'my value') }
+ describe "trying to use a custom field that does not exist" do
+ subject { build(:custom_value, custom_field_id: 123412341, value: "my value") }
- it 'returns an empty placeholder' do
+ it "returns an empty placeholder" do
expect(subject.custom_field).to be_nil
expect(subject.send(:strategy)).to be_a CustomValue::EmptyStrategy
- expect(subject.typed_value).to eq 'my value not found'
- expect(subject.formatted_value).to eq 'my value not found'
+ expect(subject.typed_value).to eq "my value not found"
+ expect(subject.formatted_value).to eq "my value not found"
end
end
- describe '#valid?' do
+ describe "#valid?" do
let(:custom_field) do
build_stubbed(:custom_field, field_format:, is_required:, min_length:, max_length:, regexp:)
end
@@ -406,304 +406,304 @@ RSpec.describe CustomValue do
let(:max_length) { 0 }
let(:regexp) { nil }
- context 'for a data custom field' do
- let(:field_format) { 'date' }
+ context "for a data custom field" do
+ let(:field_format) { "date" }
- context 'with a valid date' do
- let(:value) { '1975-07-14' }
+ context "with a valid date" do
+ let(:value) { "1975-07-14" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with some non date string' do
- let(:value) { 'abc' }
+ context "with some non date string" do
+ let(:value) { "abc" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
end
- context 'for a string custom field' do
- let(:field_format) { 'string' }
+ context "for a string custom field" do
+ let(:field_format) { "string" }
- context 'with some string' do
- let(:value) { 'abc' }
+ context "with some string" do
+ let(:value) { "abc" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a nil value' do
+ context "with a nil value" do
let(:value) { nil }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with an empty value' do
- let(:value) { '' }
+ context "with an empty value" do
+ let(:value) { "" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a nil value when required' do
+ context "with a nil value when required" do
let(:value) { nil }
let(:is_required) { true }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with an empty value when required' do
- let(:value) { '' }
+ context "with an empty value when required" do
+ let(:value) { "" }
let(:is_required) { true }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with an empty value when having a min_length' do
- let(:value) { '' }
+ context "with an empty value when having a min_length" do
+ let(:value) { "" }
let(:min_length) { 1 }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with too short a value when having a min_length' do
- let(:value) { 'a' }
+ context "with too short a value when having a min_length" do
+ let(:value) { "a" }
let(:min_length) { 2 }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with too long a value when having a max_length' do
- let(:value) { 'a' * 6 }
+ context "with too long a value when having a max_length" do
+ let(:value) { "a" * 6 }
let(:max_length) { 5 }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with a value of the correct length when having a max_length and a min_value' do
- let(:value) { 'a' * 4 }
+ context "with a value of the correct length when having a max_length and a min_value" do
+ let(:value) { "a" * 4 }
let(:min_length) { 4 }
let(:max_length) { 4 }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.to be_valid
end
end
- context 'with an empty value when having a regexp' do
- let(:value) { '' }
- let(:regexp) { '^[A-Z0-9]*$' }
+ context "with an empty value when having a regexp" do
+ let(:value) { "" }
+ let(:regexp) { "^[A-Z0-9]*$" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a not matching value when having a regexp' do
- let(:value) { 'a' }
- let(:regexp) { '^[A-Z0-9]*$' }
+ context "with a not matching value when having a regexp" do
+ let(:value) { "a" }
+ let(:regexp) { "^[A-Z0-9]*$" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with a matching value when having a regexp' do
- let(:value) { 'A' }
- let(:regexp) { '^[A-Z0-9]*$' }
+ context "with a matching value when having a regexp" do
+ let(:value) { "A" }
+ let(:regexp) { "^[A-Z0-9]*$" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
end
- context 'for a list custom field' do
- let(:custom_option1) { build_stubbed(:custom_option, value: 'value1') }
- let(:custom_option2) { build_stubbed(:custom_option, value: 'value1') }
+ context "for a list custom field" do
+ let(:custom_option1) { build_stubbed(:custom_option, value: "value1") }
+ let(:custom_option2) { build_stubbed(:custom_option, value: "value1") }
let(:custom_field) do
- build_stubbed(:custom_field, field_format: 'list', custom_options: [custom_option1, custom_option2])
+ build_stubbed(:custom_field, field_format: "list", custom_options: [custom_option1, custom_option2])
end
- context 'with a value from the list' do
+ context "with a value from the list" do
let(:value) { custom_option1.id }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with some string' do
- let(:value) { 'abc' }
+ context "with some string" do
+ let(:value) { "abc" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with nil string' do
+ context "with nil string" do
let(:value) { nil }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.to be_valid
end
end
end
- context 'for an int custom field' do
- let(:field_format) { 'int' }
+ context "for an int custom field" do
+ let(:field_format) { "int" }
- context 'with a valid int string' do
- let(:value) { '123' }
+ context "with a valid int string" do
+ let(:value) { "123" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a valid negative int string' do
- let(:value) { '-123' }
+ context "with a valid negative int string" do
+ let(:value) { "-123" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a valid positive int string' do
- let(:value) { '+123' }
+ context "with a valid positive int string" do
+ let(:value) { "+123" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with some non int string' do
- let(:value) { 'abc' }
+ context "with some non int string" do
+ let(:value) { "abc" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with a float string' do
- let(:value) { '5.5' }
+ context "with a float string" do
+ let(:value) { "5.5" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with an empty string' do
- let(:value) { '' }
+ context "with an empty string" do
+ let(:value) { "" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
end
- context 'for a float custom field' do
- let(:field_format) { 'float' }
+ context "for a float custom field" do
+ let(:field_format) { "float" }
- context 'with a valid float string' do
- let(:value) { '123.5' }
+ context "with a valid float string" do
+ let(:value) { "123.5" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a valid negative float string' do
- let(:value) { '-123.5' }
+ context "with a valid negative float string" do
+ let(:value) { "-123.5" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a valid positive float string' do
- let(:value) { '+123.5' }
+ context "with a valid positive float string" do
+ let(:value) { "+123.5" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with some non float string' do
- let(:value) { 'abc' }
+ context "with some non float string" do
+ let(:value) { "abc" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
end
- context 'with an int string' do
- let(:value) { '5' }
+ context "with an int string" do
+ let(:value) { "5" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with an empty string' do
- let(:value) { '' }
+ context "with an empty string" do
+ let(:value) { "" }
- it 'is valid' do
+ it "is valid" do
expect(custom_value)
.to be_valid
end
end
- context 'with a mixed string' do
- let(:value) { '6.5a' }
+ context "with a mixed string" do
+ let(:value) { "6.5a" }
- it 'is invalid' do
+ it "is invalid" do
expect(custom_value)
.not_to be_valid
end
@@ -711,13 +711,13 @@ RSpec.describe CustomValue do
end
end
- describe 'value/value=' do
+ describe "value/value=" do
let(:custom_value) { build_stubbed(:custom_value) }
let(:strategy_double) { instance_double(CustomValue::FormatStrategy) }
- it 'calls the strategy for parsing and uses that value' do
- original_value = 'original value'
- parsed_value = 'parsed value'
+ it "calls the strategy for parsing and uses that value" do
+ original_value = "original value"
+ parsed_value = "parsed value"
allow(custom_value)
.to receive(:strategy)
@@ -734,36 +734,36 @@ RSpec.describe CustomValue do
end
end
- describe '#activate_custom_field_in_customized_project' do
+ describe "#activate_custom_field_in_customized_project" do
let(:project) { create(:project) }
- context 'with a given default value' do
+ context "with a given default value" do
let(:custom_field) { create(:string_project_custom_field, default_value: "foo") }
- context 'when a value other than the default value is set' do
+ context "when a value other than the default value is set" do
let(:custom_value) { build(:custom_value, custom_field:, customized: project, value: "bar") }
- it 'activates the custom field in the project after create if missing' do
+ it "activates the custom field in the project after create if missing" do
expect(project.project_custom_fields).not_to include(custom_field)
custom_value.save!
expect(project.reload.project_custom_fields).to include(custom_field)
end
end
- context 'when a value equal to the default value is set' do
+ context "when a value equal to the default value is set" do
let(:custom_value) { build(:custom_value, custom_field:, customized: project, value: "foo") }
- it 'activates the custom field in the project after create if missing' do
+ it "activates the custom field in the project after create if missing" do
expect(project.project_custom_fields).not_to include(custom_field)
custom_value.save!
expect(project.reload.project_custom_fields).not_to include(custom_field)
end
end
- context 'when a value is not set' do
+ context "when a value is not set" do
let(:custom_value) { build(:custom_value, custom_field:, customized: project) }
- it 'does not activate the custom field in the project after create if missing' do
+ it "does not activate the custom field in the project after create if missing" do
expect(project.project_custom_fields).not_to include(custom_field)
custom_value.save!
expect(project.reload.project_custom_fields).not_to include(custom_field)
@@ -771,23 +771,23 @@ RSpec.describe CustomValue do
end
end
- context 'with no default value given' do
+ context "with no default value given" do
let(:custom_field) { create(:string_project_custom_field) }
- context 'when a value is set' do
+ context "when a value is set" do
let(:custom_value) { build(:custom_value, custom_field:, customized: project, value: "bar") }
- it 'activates the custom field in the project after create if missing' do
+ it "activates the custom field in the project after create if missing" do
expect(project.project_custom_fields).not_to include(custom_field)
custom_value.save!
expect(project.reload.project_custom_fields).to include(custom_field)
end
end
- context 'when a value is not set' do
+ context "when a value is not set" do
let(:custom_value) { build(:custom_value, custom_field:, customized: project) }
- it 'does not activate the custom field in the project after create if missing' do
+ it "does not activate the custom field in the project after create if missing" do
expect(project.project_custom_fields).not_to include(custom_field)
custom_value.save!
expect(project.reload.project_custom_fields).not_to include(custom_field)
diff --git a/spec/models/project_custom_field_project_mapping_spec.rb b/spec/models/project_custom_field_project_mapping_spec.rb
index f7baa6fc572..a404c842693 100644
--- a/spec/models/project_custom_field_project_mapping_spec.rb
+++ b/spec/models/project_custom_field_project_mapping_spec.rb
@@ -26,14 +26,14 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe ProjectCustomFieldProjectMapping do
- describe 'uniqueness by project' do
+ describe "uniqueness by project" do
let!(:project) { create(:project) }
let!(:project_custom_field) { create(:project_custom_field) }
- it 'a project custom field can only be mapped to a project once' do
+ it "a project custom field can only be mapped to a project once" do
project.project_custom_fields << project_custom_field
expect(described_class).to exist(custom_field_id: project_custom_field.id,
diff --git a/spec/models/project_custom_field_spec.rb b/spec/models/project_custom_field_spec.rb
index 376bfd811ba..787f0238227 100644
--- a/spec/models/project_custom_field_spec.rb
+++ b/spec/models/project_custom_field_spec.rb
@@ -26,15 +26,15 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe ProjectCustomField do
- describe 'activation in projects' do
- context 'when creating a new required project custom field' do
+ describe "activation in projects" do
+ context "when creating a new required project custom field" do
let!(:project) { create(:project) }
let!(:another_project) { create(:project) }
- it 'activates the required project custom fields in all projects' do
+ it "activates the required project custom fields in all projects" do
project_custom_field = create(:project_custom_field, is_required: true)
expect(ProjectCustomFieldProjectMapping).to exist(custom_field_id: project_custom_field.id,
@@ -44,14 +44,14 @@ RSpec.describe ProjectCustomField do
end
end
- context 'when setting an existing project custom field to required' do
+ context "when setting an existing project custom field to required" do
let!(:project_custom_field) { create(:string_project_custom_field) } # optional now
let!(:project) do
create(:project, custom_field_values: { "#{project_custom_field.id}": "foo" })
end
let!(:another_project) { create(:project) } # not using the custom field
- it 'activates the required project custom fields in all projects where it is not already activated' do
+ it "activates the required project custom fields in all projects where it is not already activated" do
expect(ProjectCustomFieldProjectMapping).to exist(custom_field_id: project_custom_field.id,
project_id: project.id)
expect(ProjectCustomFieldProjectMapping).not_to exist(custom_field_id: project_custom_field.id,
@@ -65,7 +65,7 @@ RSpec.describe ProjectCustomField do
project_id: another_project.id)
end
- it 'does not disabled project custom fields when set to optional' do
+ it "does not disabled project custom fields when set to optional" do
project_custom_field.update!(is_required: true) # required now
project_custom_field.update!(is_required: false) # optional again
@@ -75,7 +75,7 @@ RSpec.describe ProjectCustomField do
project_id: another_project.id)
end
- it 'does not create duplicate mappings' do
+ it "does not create duplicate mappings" do
project_custom_field.update!(is_required: true) # required now
# mapping existed before, should not be duplicated
@@ -84,13 +84,13 @@ RSpec.describe ProjectCustomField do
end
end
- context 'when deleting a project custom field' do
+ context "when deleting a project custom field" do
let!(:project_custom_field) { create(:string_project_custom_field) }
let!(:project) do
create(:project, custom_field_values: { "#{project_custom_field.id}": "foo" })
end
- it 'deletes the project custom field mappings' do
+ it "deletes the project custom field mappings" do
expect(ProjectCustomFieldProjectMapping).to exist(custom_field_id: project_custom_field.id,
project_id: project.id)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 121b8bdce4f..ab9055a9595 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -143,14 +143,14 @@ RSpec.describe User do
end
end
- context 'with other letter char classes' do
+ context "with other letter char classes" do
let(:login) { "célîneüberölig" }
- it 'is valid' do
+ it "is valid" do
expect(user).to be_valid
end
- it 'may be stored in the database' do
+ it "may be stored in the database" do
expect(user.save).to be_truthy
end
end
diff --git a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb
index c6314920eeb..cfff744ab78 100644
--- a/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb
+++ b/spec/models/work_packages/pdf_export/work_package_list_to_pdf_spec.rb
@@ -148,7 +148,7 @@ RSpec.describe WorkPackage::PDFExport::WorkPackageListToPdf do
end
def pdf_eq_ignore_spacing(strings)
- expect(pdf.strings.join(' ')).to eq(strings.join(' '))
+ expect(pdf.strings.join(" ")).to eq(strings.join(" "))
end
describe "with a request for a PDF table" do
diff --git a/spec/permissions/manage_project_custom_field_mappings_spec.rb b/spec/permissions/manage_project_custom_field_mappings_spec.rb
index 5920cf56291..04f5b4ecf73 100644
--- a/spec/permissions/manage_project_custom_field_mappings_spec.rb
+++ b/spec/permissions/manage_project_custom_field_mappings_spec.rb
@@ -26,15 +26,15 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require File.expand_path('../support/permission_specs', __dir__)
+require "spec_helper"
+require File.expand_path("../support/permission_specs", __dir__)
-RSpec.describe Projects::Settings::ProjectCustomFieldsController, 'manage_project_custom_field mappings permission',
+RSpec.describe Projects::Settings::ProjectCustomFieldsController, "manage_project_custom_field mappings permission",
type: :controller do
include PermissionSpecs
- check_permission_required_for('projects/settings/project_custom_fields#show', :select_project_custom_fields)
- check_permission_required_for('projects/settings/project_custom_fields#toggle', :select_project_custom_fields)
- check_permission_required_for('projects/settings/project_custom_fields#enable_all_of_section', :select_project_custom_fields)
- check_permission_required_for('projects/settings/project_custom_fields#disable_all_of_section', :select_project_custom_fields)
+ check_permission_required_for("projects/settings/project_custom_fields#show", :select_project_custom_fields)
+ check_permission_required_for("projects/settings/project_custom_fields#toggle", :select_project_custom_fields)
+ check_permission_required_for("projects/settings/project_custom_fields#enable_all_of_section", :select_project_custom_fields)
+ check_permission_required_for("projects/settings/project_custom_fields#disable_all_of_section", :select_project_custom_fields)
end
diff --git a/spec/permissions/manage_project_custom_values_spec.rb b/spec/permissions/manage_project_custom_values_spec.rb
index 4aa31a852cf..13d4c532e93 100644
--- a/spec/permissions/manage_project_custom_values_spec.rb
+++ b/spec/permissions/manage_project_custom_values_spec.rb
@@ -26,25 +26,25 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require File.expand_path('../support/permission_specs', __dir__)
+require "spec_helper"
+require File.expand_path("../support/permission_specs", __dir__)
-RSpec.describe Overviews::OverviewsController, 'manage_project_custom_values permission',
+RSpec.describe Overviews::OverviewsController, "manage_project_custom_values permission",
type: :controller do
include PermissionSpecs
# render sidebar on project overview page with view_project permission
# TODO: prevents calling overviews/overviews#project_custom_fields_sidebar when not having the permission view_project (FAILED - 1)
- it 'prevents calling overviews/overviews#project_custom_fields_sidebar when not having the permission view_project' do
- pending 'spec failing, reason unknown'
+ it "prevents calling overviews/overviews#project_custom_fields_sidebar when not having the permission view_project" do
+ pending "spec failing, reason unknown"
# wrapping the check_permission_required_for in a block to mark it as pending
# spec should not be executed in this block, but standalone, will fail then with real error
- check_permission_required_for('overviews/overviews#project_custom_fields_sidebar', :view_project)
+ check_permission_required_for("overviews/overviews#project_custom_fields_sidebar", :view_project)
end
# render dialog with inputs for editing project attributes with edit_project permission
- check_permission_required_for('overviews/overviews#project_custom_field_section_dialog', :edit_project)
+ check_permission_required_for("overviews/overviews#project_custom_field_section_dialog", :edit_project)
# update project attributes with edit_project permission, deeper permission check via contract in place
- check_permission_required_for('overviews/overviews#update_project_custom_values', :edit_project)
+ check_permission_required_for("overviews/overviews#update_project_custom_values", :edit_project)
end
diff --git a/spec/requests/api/v3/projects/create_resource_spec.rb b/spec/requests/api/v3/projects/create_resource_spec.rb
index 0ff82ecfcbd..02106e9baa6 100644
--- a/spec/requests/api/v3/projects/create_resource_spec.rb
+++ b/spec/requests/api/v3/projects/create_resource_spec.rb
@@ -26,10 +26,10 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require 'rack/test'
+require "spec_helper"
+require "rack/test"
-RSpec.describe 'API v3 Project resource create', content_type: :json do
+RSpec.describe "API v3 Project resource create", content_type: :json do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -41,7 +41,7 @@ RSpec.describe 'API v3 Project resource create', content_type: :json do
end
let(:custom_value) do
CustomValue.create(custom_field:,
- value: '1234',
+ value: "1234",
customized: project)
end
let(:global_role) do
@@ -51,8 +51,8 @@ RSpec.describe 'API v3 Project resource create', content_type: :json do
let(:path) { api_v3_paths.projects }
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name'
+ identifier: "new_project_identifier",
+ name: "Project name"
}.to_json
end
@@ -62,42 +62,42 @@ RSpec.describe 'API v3 Project resource create', content_type: :json do
post path, body
end
- it 'responds with 201 CREATED' do
+ it "responds with 201 CREATED" do
expect(last_response.status).to eq(201)
end
- it 'creates a project' do
+ it "creates a project" do
expect(Project.count)
.to be(1)
end
- it 'returns the created project' do
+ it "returns the created project" do
expect(last_response.body)
- .to be_json_eql('Project'.to_json)
- .at_path('_type')
+ .to be_json_eql("Project".to_json)
+ .at_path("_type")
expect(last_response.body)
- .to be_json_eql('Project name'.to_json)
- .at_path('name')
+ .to be_json_eql("Project name".to_json)
+ .at_path("name")
end
- context 'with a status' do
+ context "with a status" do
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name',
+ identifier: "new_project_identifier",
+ name: "Project name",
statusExplanation: { raw: "Some explanation." },
_links: {
status: {
- href: api_v3_paths.project_status('off_track')
+ href: api_v3_paths.project_status("off_track")
}
}
}.to_json
end
- it 'sets the status' do
+ it "sets the status" do
expect(last_response.body)
- .to be_json_eql(api_v3_paths.project_status('off_track').to_json)
- .at_path('_links/status/href')
+ .to be_json_eql(api_v3_paths.project_status("off_track").to_json)
+ .at_path("_links/status/href")
expect(last_response.body)
.to be_json_eql(
@@ -110,145 +110,145 @@ RSpec.describe 'API v3 Project resource create', content_type: :json do
.at_path("statusExplanation")
end
- it 'creates a project' do
+ it "creates a project" do
expect(Project.count)
.to be(1)
end
end
- context 'with a visible custom field' do
+ context "with a visible custom field" do
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name',
+ identifier: "new_project_identifier",
+ name: "Project name",
custom_field.attribute_name(:camel_case) => {
raw: "CF text"
}
}.to_json
end
- it 'sets the cf value' do
+ it "sets the cf value" do
expect(last_response.body)
.to be_json_eql("CF text".to_json)
.at_path("customField#{custom_field.id}/raw")
end
- it 'automatically activates the cf for project if the value was provided' do
+ it "automatically activates the cf for project if the value was provided" do
expect(Project.last.project_custom_fields)
.to contain_exactly(custom_field)
end
end
- context 'with an invisible custom field' do
+ context "with an invisible custom field" do
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name',
+ identifier: "new_project_identifier",
+ name: "Project name",
invisible_custom_field.attribute_name(:camel_case) => {
raw: "CF text"
}
}.to_json
end
- context 'with admin permissions' do
+ context "with admin permissions" do
current_user { create(:admin) }
- it 'sets the cf value' do
+ it "sets the cf value" do
expect(last_response.body)
.to be_json_eql("CF text".to_json)
.at_path("customField#{invisible_custom_field.id}/raw")
end
- it 'automatically activates the cf for project if the value was provided' do
+ it "automatically activates the cf for project if the value was provided" do
expect(Project.last.project_custom_fields)
.to contain_exactly(invisible_custom_field)
end
end
- context 'with non-admin permissions' do
- it 'does not set the cf value' do
+ context "with non-admin permissions" do
+ it "does not set the cf value" do
expect(last_response.body)
.not_to have_json_path("customField#{invisible_custom_field.id}/raw")
end
- it 'does not activate the cf for project' do
+ it "does not activate the cf for project" do
expect(Project.last.project_custom_fields)
.to be_empty
end
end
end
- context 'without permission to create projects' do
+ context "without permission to create projects" do
let(:permissions) { [] }
- it 'responds with 403' do
+ it "responds with 403" do
expect(last_response.status).to eq(403)
end
- it 'creates no project' do
+ it "creates no project" do
expect(Project.count)
.to be(0)
end
end
- context 'with missing name' do
+ context "with missing name" do
let(:body) do
{
- identifier: 'some_identifier'
+ identifier: "some_identifier"
}.to_json
end
- it 'responds with 422' do
+ it "responds with 422" do
expect(last_response.status).to eq(422)
end
- it 'creates no project' do
+ it "creates no project" do
expect(Project.count)
.to be(0)
end
- it 'denotes the error' do
+ it "denotes the error" do
expect(last_response.body)
- .to be_json_eql('Error'.to_json)
- .at_path('_type')
+ .to be_json_eql("Error".to_json)
+ .at_path("_type")
expect(last_response.body)
.to be_json_eql("Name can't be blank.".to_json)
- .at_path('message')
+ .at_path("message")
end
end
- context 'with a faulty status' do
+ context "with a faulty status" do
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name',
+ identifier: "new_project_identifier",
+ name: "Project name",
statusExplanation: "Some explanation.",
_links: {
status: {
- href: api_v3_paths.project_status('faulty')
+ href: api_v3_paths.project_status("faulty")
}
}
}.to_json
end
- it 'responds with 422' do
+ it "responds with 422" do
expect(last_response.status).to eq(422)
end
- it 'creates no project' do
+ it "creates no project" do
expect(Project.count)
.to be(0)
end
- it 'denotes the error' do
+ it "denotes the error" do
expect(last_response.body)
- .to be_json_eql('Error'.to_json)
- .at_path('_type')
+ .to be_json_eql("Error".to_json)
+ .at_path("_type")
expect(last_response.body)
.to be_json_eql("Status is not set to one of the allowed values.".to_json)
- .at_path('message')
+ .at_path("message")
end
end
end
diff --git a/spec/requests/api/v3/projects/show_resource_spec.rb b/spec/requests/api/v3/projects/show_resource_spec.rb
index 7fe2ac10cab..5c20d8f1984 100644
--- a/spec/requests/api/v3/projects/show_resource_spec.rb
+++ b/spec/requests/api/v3/projects/show_resource_spec.rb
@@ -26,10 +26,10 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require 'rack/test'
+require "spec_helper"
+require "rack/test"
-RSpec.describe 'API v3 Project resource show', content_type: :json do
+RSpec.describe "API v3 Project resource show", content_type: :json do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -50,7 +50,7 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
end
let(:custom_value) do
CustomValue.create(custom_field:,
- value: '1234',
+ value: "1234",
customized: project)
end
let(:invisible_custom_field) do
@@ -58,7 +58,7 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
end
let(:invisible_custom_value) do
CustomValue.create(custom_field: invisible_custom_field,
- value: '1234',
+ value: "1234",
customized: project)
end
@@ -84,27 +84,27 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
last_response
end
- context 'for a logged in user' do
- it 'responds with 200 OK' do
+ context "for a logged in user" do
+ it "responds with 200 OK" do
expect(subject.status).to eq(200)
end
- it 'responds with the correct project' do
- expect(subject.body).to include_json('Project'.to_json).at_path('_type')
- expect(subject.body).to be_json_eql(project.identifier.to_json).at_path('identifier')
+ it "responds with the correct project" do
+ expect(subject.body).to include_json("Project".to_json).at_path("_type")
+ expect(subject.body).to be_json_eql(project.identifier.to_json).at_path("identifier")
end
- it 'links to the parent/ancestor project' do
+ it "links to the parent/ancestor project" do
expect(subject.body)
.to be_json_eql(api_v3_paths.project(parent_project.id).to_json)
- .at_path('_links/parent/href')
+ .at_path("_links/parent/href")
expect(subject.body)
.to be_json_eql(api_v3_paths.project(parent_project.id).to_json)
- .at_path('_links/ancestors/0/href')
+ .at_path("_links/ancestors/0/href")
end
- it 'includes only visible custom fields' do
+ it "includes only visible custom fields" do
custom_value
invisible_custom_value
@@ -116,10 +116,10 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
.not_to have_json_path("customField#{invisible_custom_field.id}/raw")
end
- context 'with admin permissions' do
+ context "with admin permissions" do
current_user { admin }
- it 'includes invisible custom fields' do
+ it "includes invisible custom fields" do
custom_value
invisible_custom_value
@@ -133,7 +133,7 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
end
end
- it 'includes the project status' do
+ it "includes the project status" do
expect(subject.body)
.to be_json_eql(project.status_explanation.to_json)
.at_path("statusExplanation/raw")
@@ -143,69 +143,69 @@ RSpec.describe 'API v3 Project resource show', content_type: :json do
.at_path("_links/status/href")
end
- context 'when requesting nonexistent project' do
+ context "when requesting nonexistent project" do
let(:get_path) { api_v3_paths.project 9999 }
before do
response
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'when requesting project without sufficient permissions' do
+ context "when requesting project without sufficient permissions" do
let(:get_path) { api_v3_paths.project other_project.id }
before do
response
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'when not being allowed to see the parent project' do
+ context "when not being allowed to see the parent project" do
let!(:parent_memberships) do
# no parent memberships
end
- it 'shows the `undisclosed` uri' do
+ it "shows the `undisclosed` uri" do
expect(subject.body)
.to be_json_eql(API::V3::URN_UNDISCLOSED.to_json)
- .at_path('_links/parent/href')
+ .at_path("_links/parent/href")
end
end
- context 'with the project being archived/inactive' do
+ context "with the project being archived/inactive" do
let(:project_active) { false }
- context 'with the user being admin' do
+ context "with the user being admin" do
current_user { admin }
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(subject.status).to eq(200)
end
- it 'responds with the correct project' do
- expect(subject.body).to include_json('Project'.to_json).at_path('_type')
- expect(subject.body).to be_json_eql(project.identifier.to_json).at_path('identifier')
+ it "responds with the correct project" do
+ expect(subject.body).to include_json("Project".to_json).at_path("_type")
+ expect(subject.body).to be_json_eql(project.identifier.to_json).at_path("identifier")
end
end
- context 'with the user being no admin' do
- it 'responds with 404' do
+ context "with the user being no admin" do
+ it "responds with 404" do
expect(subject.status).to eq(404)
end
end
end
end
- context 'for a not logged in user' do
+ context "for a not logged in user" do
current_user { create(:anonymous) }
before do
get get_path
end
- it_behaves_like 'not found response based on login_required'
+ it_behaves_like "not found response based on login_required"
end
end
diff --git a/spec/requests/api/v3/projects/update_resource_spec.rb b/spec/requests/api/v3/projects/update_resource_spec.rb
index fe1a05c6b21..9a34d40a0cc 100644
--- a/spec/requests/api/v3/projects/update_resource_spec.rb
+++ b/spec/requests/api/v3/projects/update_resource_spec.rb
@@ -26,10 +26,10 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
-require 'rack/test'
+require "spec_helper"
+require "rack/test"
-RSpec.describe 'API v3 Project resource update', content_type: :json do
+RSpec.describe "API v3 Project resource update", content_type: :json do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
@@ -49,15 +49,15 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
end
let(:custom_value) do
CustomValue.create(custom_field:,
- value: '1234',
+ value: "1234",
customized: project)
end
let(:permissions) { [:edit_project] }
let(:path) { api_v3_paths.project(project.id) }
let(:body) do
{
- identifier: 'new_project_identifier',
- name: 'Project name'
+ identifier: "new_project_identifier",
+ name: "Project name"
}
end
@@ -69,11 +69,11 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
patch path, body.to_json
end
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status).to eq(200)
end
- it 'alters the project' do
+ it "alters the project" do
project.reload
expect(project.name)
@@ -83,16 +83,16 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
.to eql(body[:identifier])
end
- it 'returns the updated project' do
+ it "returns the updated project" do
expect(last_response.body)
- .to be_json_eql('Project'.to_json)
- .at_path('_type')
+ .to be_json_eql("Project".to_json)
+ .at_path("_type")
expect(last_response.body)
.to be_json_eql(body[:name].to_json)
- .at_path('name')
+ .at_path("name")
end
- context 'with a visible custom field' do
+ context "with a visible custom field" do
let(:body) do
{
custom_field.attribute_name(:camel_case) => {
@@ -101,22 +101,22 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status).to eq(200)
end
- it 'sets the cf value' do
+ it "sets the cf value" do
expect(project.reload.send(custom_field.attribute_getter))
.to eql("CF text")
end
- it 'automatically activates the cf for project if the value was provided' do
+ it "automatically activates the cf for project if the value was provided" do
expect(project.project_custom_fields)
.to contain_exactly(custom_field)
end
end
- context 'with an invisible custom field' do
+ context "with an invisible custom field" do
let(:body) do
{
invisible_custom_field.attribute_name(:camel_case) => {
@@ -125,58 +125,58 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- context 'with admin permissions' do
+ context "with admin permissions" do
let(:current_user) { create(:admin) }
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status).to eq(200)
end
- it 'sets the cf value' do
+ it "sets the cf value" do
expect(project.reload.send(invisible_custom_field.attribute_getter))
.to eql("CF text")
end
- it 'automatically activates the cf for project if the value was provided' do
+ it "automatically activates the cf for project if the value was provided" do
expect(project.reload.project_custom_fields)
.to contain_exactly(invisible_custom_field)
end
end
- context 'with non-admin permissions' do
- it 'responds with 200 OK' do
+ context "with non-admin permissions" do
+ it "responds with 200 OK" do
# TBD: trying to set a not accessible custom field is silently ignored
expect(last_response.status).to eq(200)
end
- it 'does not set the cf value' do
+ it "does not set the cf value" do
expect(project.reload.custom_values)
.to be_empty
end
- it 'does not activate the cf for project' do
+ it "does not activate the cf for project" do
expect(project.reload.project_custom_fields)
.to be_empty
end
end
end
- context 'without permission to patch projects' do
+ context "without permission to patch projects" do
let(:permissions) { [] }
- it 'responds with 403' do
+ it "responds with 403" do
expect(last_response.status).to eq(403)
end
- it 'does not change the project' do
+ it "does not change the project" do
attributes_before = project.attributes
expect(project.reload.name)
- .to eql(attributes_before['name'])
+ .to eql(attributes_before["name"])
end
end
- context 'with a nil status' do
+ context "with a nil status" do
let(:body) do
{
statusExplanation: {
@@ -190,14 +190,14 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- it 'alters the status' do
+ it "alters the status" do
expect(last_response.body)
.to be_json_eql(nil.to_json)
- .at_path('_links/status/href')
+ .at_path("_links/status/href")
project.reload
expect(project.status_code).to be_nil
- expect(project.status_explanation).to eq 'Some explanation.'
+ expect(project.status_explanation).to eq "Some explanation."
expect(last_response.body)
.to be_json_eql(
@@ -211,7 +211,7 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
end
end
- context 'with a status' do
+ context "with a status" do
let(:body) do
{
statusExplanation: {
@@ -219,16 +219,16 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
},
_links: {
status: {
- href: api_v3_paths.project_status('off_track')
+ href: api_v3_paths.project_status("off_track")
}
}
}
end
- it 'alters the status' do
+ it "alters the status" do
expect(last_response.body)
- .to be_json_eql(api_v3_paths.project_status('off_track').to_json)
- .at_path('_links/status/href')
+ .to be_json_eql(api_v3_paths.project_status("off_track").to_json)
+ .at_path("_links/status/href")
expect(last_response.body)
.to be_json_eql(
@@ -241,47 +241,47 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
.at_path("statusExplanation")
end
- it 'persists the altered status' do
+ it "persists the altered status" do
project.reload
expect(project.status_code)
- .to eql('off_track')
+ .to eql("off_track")
expect(project.status_explanation)
- .to eql('Some explanation.')
+ .to eql("Some explanation.")
end
end
- context 'with faulty name' do
+ context "with faulty name" do
let(:body) do
{
name: nil
}
end
- it 'responds with 422' do
+ it "responds with 422" do
expect(last_response.status).to eq(422)
end
- it 'does not change the project' do
+ it "does not change the project" do
attributes_before = project.attributes
expect(project.reload.name)
- .to eql(attributes_before['name'])
+ .to eql(attributes_before["name"])
end
- it 'denotes the error' do
+ it "denotes the error" do
expect(last_response.body)
- .to be_json_eql('Error'.to_json)
- .at_path('_type')
+ .to be_json_eql("Error".to_json)
+ .at_path("_type")
expect(last_response.body)
.to be_json_eql("Name can't be blank.".to_json)
- .at_path('message')
+ .at_path("message")
end
end
- context 'with a faulty status' do
+ context "with a faulty status" do
let(:body) do
{
_links: {
@@ -292,36 +292,36 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- it 'responds with 422' do
+ it "responds with 422" do
expect(last_response.status).to eq(422)
end
- it 'does not change the project status' do
+ it "does not change the project status" do
code_before = project.status_code
expect(project.reload.status_code)
.to eql(code_before)
end
- it 'denotes the error' do
+ it "denotes the error" do
expect(last_response.body)
- .to be_json_eql('Error'.to_json)
- .at_path('_type')
+ .to be_json_eql("Error".to_json)
+ .at_path("_type")
expect(last_response.body)
.to be_json_eql("Status is not set to one of the allowed values.".to_json)
- .at_path('message')
+ .at_path("message")
end
end
- context 'when archiving the project (change active from true to false)' do
+ context "when archiving the project (change active from true to false)" do
let(:body) do
{
active: false
}
end
- context 'for an admin' do
+ context "for an admin" do
let(:current_user) do
create(:admin)
end
@@ -334,51 +334,51 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
create(:project)
end
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status)
.to eq(200)
end
- it 'archives the project' do
+ it "archives the project" do
expect(project.reload.active)
.to be_falsey
end
- it 'archives the child project' do
+ it "archives the child project" do
expect(child_project.reload.active)
.to be_falsey
end
end
- context 'for a user with only edit_project permission' do
+ context "for a user with only edit_project permission" do
let(:permissions) { [:edit_project] }
- it 'responds with 403' do
+ it "responds with 403" do
expect(last_response.status)
.to eq(403)
end
- it 'does not alter the project' do
+ it "does not alter the project" do
expect(project.reload.active)
.to be_truthy
end
end
- context 'for a user with only archive_project permission' do
+ context "for a user with only archive_project permission" do
let(:permissions) { [:archive_project] }
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status)
.to eq(200)
end
- it 'archives the project' do
+ it "archives the project" do
expect(project.reload.active)
.to be_falsey
end
end
- context 'for a user missing archive_project permission on child project' do
+ context "for a user missing archive_project permission on child project" do
let(:permissions) { [:archive_project] }
let(:project) do
create(:project).tap do |p|
@@ -387,19 +387,19 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
end
let(:child_project) { create(:project) }
- it 'responds with 422 (and not 403?)' do
+ it "responds with 422 (and not 403?)" do
expect(last_response.status)
.to eq(422)
end
- it 'does not alter the project' do
+ it "does not alter the project" do
expect(project.reload.active)
.to be_truthy
end
end
end
- context 'when setting a custom field and archiving the project' do
+ context "when setting a custom field and archiving the project" do
let(:body) do
{
active: false,
@@ -409,7 +409,7 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- context 'for an admin' do
+ context "for an admin" do
let(:current_user) do
create(:admin)
end
@@ -422,56 +422,56 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
create(:project)
end
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status)
.to eq(200)
end
- it 'sets the cf value' do
+ it "sets the cf value" do
expect(project.reload.send(custom_field.attribute_getter))
.to eql("CF text")
end
- it 'archives the project' do
+ it "archives the project" do
expect(project.reload.active)
.to be_falsey
end
- it 'archives the child project' do
+ it "archives the child project" do
expect(child_project.reload.active)
.to be_falsey
end
end
- context 'for a user with only edit_project permission' do
+ context "for a user with only edit_project permission" do
let(:permissions) { [:edit_project] }
- it 'responds with 403' do
+ it "responds with 403" do
expect(last_response.status)
.to eq(403)
end
end
- context 'for a user with only archive_project permission' do
+ context "for a user with only archive_project permission" do
let(:permissions) { [:archive_project] }
- it 'responds with 403' do
+ it "responds with 403" do
expect(last_response.status)
.to eq(403)
end
end
- context 'for a user with both archive_project and edit_project permissions' do
+ context "for a user with both archive_project and edit_project permissions" do
let(:permissions) { %i[archive_project edit_project] }
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status)
.to eq(200)
end
end
end
- context 'when unarchiving the project (change active from false to true)' do
+ context "when unarchiving the project (change active from false to true)" do
let(:project_active) { false }
let(:body) do
{
@@ -479,7 +479,7 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
}
end
- context 'for an admin' do
+ context "for an admin" do
let(:current_user) do
create(:admin)
end
@@ -492,31 +492,31 @@ RSpec.describe 'API v3 Project resource update', content_type: :json do
create(:project)
end
- it 'responds with 200 OK' do
+ it "responds with 200 OK" do
expect(last_response.status)
.to eq(200)
end
- it 'unarchives the project' do
+ it "unarchives the project" do
expect(project.reload)
.to be_active
end
- it 'unarchives the child project' do
+ it "unarchives the child project" do
expect(child_project.reload)
.to be_active
end
end
- context 'for a non-admin user, even with both archive_project and edit_project permissions' do
+ context "for a non-admin user, even with both archive_project and edit_project permissions" do
let(:permissions) { %i[archive_project edit_project] }
- it 'responds with 404' do
+ it "responds with 404" do
expect(last_response.status)
.to eq(404)
end
- it 'does not alter the project' do
+ it "does not alter the project" do
expect(project.reload)
.not_to be_active
end
diff --git a/spec/requests/auth/ldap_sso_spec.rb b/spec/requests/auth/ldap_sso_spec.rb
index d1367a9fc0c..ce3cc736283 100644
--- a/spec/requests/auth/ldap_sso_spec.rb
+++ b/spec/requests/auth/ldap_sso_spec.rb
@@ -58,20 +58,20 @@ RSpec.describe "LDAP authentication",
expect(subject).to redirect_to "/?first_time_user=true"
end
- context 'with a user that has umlauts in their name' do
- let(:username) { 'bölle' }
- let(:password) { 'bólle' }
+ context "with a user that has umlauts in their name" do
+ let(:username) { "bölle" }
+ let(:password) { "bólle" }
- it 'creates a user with umlauts on the fly' do
- expect(User.find_by(login: 'bölle')).to be_nil
+ it "creates a user with umlauts on the fly" do
+ expect(User.find_by(login: "bölle")).to be_nil
expect { subject }.to change(User.not_builtin.active, :count).by(1)
- user = User.find_by(login: 'bölle')
+ user = User.find_by(login: "bölle")
expect(user).to be_present
expect(user).to be_active
expect(session[:user_id]).to eq user.id
- expect(subject).to redirect_to '/?first_time_user=true'
+ expect(subject).to redirect_to "/?first_time_user=true"
end
end
diff --git a/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb b/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
index 799403ac449..9c7d6f934f3 100644
--- a/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
+++ b/spec/services/project_custom_field_project_mappings/bulk_update_service_spec.rb
@@ -26,22 +26,22 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
let!(:project) { create(:project) }
- let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: 'Section with invisible fields') }
+ let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: "Section with invisible fields") }
let!(:visible_project_custom_field) do
create(:project_custom_field,
- name: 'Visible field',
+ name: "Visible field",
visible: true,
project_custom_field_section: section_with_invisible_fields)
end
let!(:visible_required_project_custom_field) do
create(:project_custom_field,
- name: 'Visible required field',
+ name: "Visible required field",
visible: true,
is_required: true,
project_custom_field_section: section_with_invisible_fields)
@@ -49,17 +49,17 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
- name: 'Admin only field',
+ name: "Admin only field",
visible: false,
project_custom_field_section: section_with_invisible_fields)
end
let(:instance) { described_class.new(user:, project:, project_custom_field_section: section_with_invisible_fields) }
- context 'with admin permissions' do
+ context "with admin permissions" do
let(:user) { create(:admin) }
- it 'bulk enables/disables all (non-required) fields of the section, including invisible ones' do
+ it "bulk enables/disables all (non-required) fields of the section, including invisible ones" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -79,11 +79,11 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
end
end
- context 'with non-admin but sufficient permissions' do
+ context "with non-admin but sufficient permissions" do
let(:user) do
create(:user,
- firstname: 'Project',
- lastname: 'Admin',
+ firstname: "Project",
+ lastname: "Admin",
member_with_permissions: {
project => %w[
view_work_packages
@@ -93,7 +93,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
})
end
- it 'bulk enables/disables all fields of the section, excluding invisible ones' do
+ it "bulk enables/disables all fields of the section, excluding invisible ones" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -115,11 +115,11 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
end
end
- context 'with insufficient permissions' do
+ context "with insufficient permissions" do
let(:user) do
create(:user,
- firstname: 'Project',
- lastname: 'Editor',
+ firstname: "Project",
+ lastname: "Editor",
member_with_permissions: {
project => %w[
view_work_packages
@@ -128,7 +128,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::BulkUpdateService do
})
end
- it 'cannot bulk enable/disable project custom fields' do
+ it "cannot bulk enable/disable project custom fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
diff --git a/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb b/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
index 929514c7003..b480dcb7db5 100644
--- a/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
+++ b/spec/services/project_custom_field_project_mappings/toggle_service_spec.rb
@@ -26,22 +26,22 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-require 'spec_helper'
+require "spec_helper"
RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
let!(:project) { create(:project) }
- let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: 'Section with invisible fields') }
+ let!(:section_with_invisible_fields) { create(:project_custom_field_section, name: "Section with invisible fields") }
let!(:visible_project_custom_field) do
create(:project_custom_field,
- name: 'Visible field',
+ name: "Visible field",
visible: true,
project_custom_field_section: section_with_invisible_fields)
end
let!(:visible_required_project_custom_field) do
create(:project_custom_field,
- name: 'Visible required field',
+ name: "Visible required field",
visible: true,
is_required: true,
project_custom_field_section: section_with_invisible_fields)
@@ -49,17 +49,17 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
let!(:invisible_project_custom_field) do
create(:project_custom_field,
- name: 'Admin only field',
+ name: "Admin only field",
visible: false,
project_custom_field_section: section_with_invisible_fields)
end
let(:instance) { described_class.new(user:) }
- context 'with admin permissions' do
+ context "with admin permissions" do
let(:user) { create(:admin) }
- it 'toggles visible, non-required fields' do
+ it "toggles visible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -77,7 +77,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'toggles invisible, non-required fields' do
+ it "toggles invisible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -95,7 +95,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'does not toggle required fields' do
+ it "does not toggle required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -108,11 +108,11 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
end
end
- context 'with non-admin but sufficient permissions' do
+ context "with non-admin but sufficient permissions" do
let(:user) do
create(:user,
- firstname: 'Project',
- lastname: 'Admin',
+ firstname: "Project",
+ lastname: "Admin",
member_with_permissions: {
project => %w[
view_work_packages
@@ -122,7 +122,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
})
end
- it 'toggles visible, non-required fields' do
+ it "toggles visible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -140,7 +140,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'does not toggle invisible, non-required fields' do
+ it "does not toggle invisible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -152,7 +152,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'does not toggle required fields' do
+ it "does not toggle required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -165,11 +165,11 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
end
end
- context 'with insufficient permissions' do
+ context "with insufficient permissions" do
let(:user) do
create(:user,
- firstname: 'Project',
- lastname: 'Editor',
+ firstname: "Project",
+ lastname: "Editor",
member_with_permissions: {
project => %w[
view_work_packages
@@ -178,7 +178,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
})
end
- it 'does not toggle visible, non-required fields' do
+ it "does not toggle visible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -190,7 +190,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'does not toggle invisible, non-required fields' do
+ it "does not toggle invisible, non-required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
@@ -202,7 +202,7 @@ RSpec.describe ProjectCustomFieldProjectMappings::ToggleService do
)
end
- it 'does not toggle required fields' do
+ it "does not toggle required fields" do
expect(project.project_custom_fields).to contain_exactly(
visible_required_project_custom_field
)
diff --git a/spec/support/form_fields/primerized/autocomplete_field.rb b/spec/support/form_fields/primerized/autocomplete_field.rb
index 8e4b0bf37e0..536a3a24dc3 100644
--- a/spec/support/form_fields/primerized/autocomplete_field.rb
+++ b/spec/support/form_fields/primerized/autocomplete_field.rb
@@ -1,4 +1,4 @@
-require_relative 'form_field'
+require_relative "form_field"
module FormFields
module Primerized
@@ -7,69 +7,69 @@ module FormFields
def select_option(*values)
values.each do |val|
- field_container.find('.ng-select-container').click
- expect(page).to have_css('.ng-option', text: val, visible: :all)
- page.find('.ng-option', text: val, visible: :all).click
+ field_container.find(".ng-select-container").click
+ expect(page).to have_css(".ng-option", text: val, visible: :all)
+ page.find(".ng-option", text: val, visible: :all).click
sleep 0.25 # still required?
end
end
def deselect_option(*values)
values.each do |val|
- field_container.find('.ng-select-container').click
- page.find('.ng-value', text: val, visible: :all).find('.ng-value-icon').click
+ field_container.find(".ng-select-container").click
+ page.find(".ng-value", text: val, visible: :all).find(".ng-value-icon").click
sleep 0.25 # still required?
end
- field_container.find('.ng-arrow-wrapper').click # close dropdown
+ field_container.find(".ng-arrow-wrapper").click # close dropdown
sleep 0.25
end
def search(text)
- field_container.find('.ng-select-container input').set text
+ field_container.find(".ng-select-container input").set text
end
def open_options
- field_container.find('.ng-select-container').click
+ field_container.find(".ng-select-container").click
end
def clear
- field_container.find('.ng-clear-wrapper', visible: :all).click
+ field_container.find(".ng-clear-wrapper", visible: :all).click
end
### expectations
def expect_selected(*values)
values.each do |val|
- expect(field_container).to have_css('.ng-value', text: val)
+ expect(field_container).to have_css(".ng-value", text: val)
end
end
def expect_not_selected(*values)
values.each do |val|
- expect(field_container).to have_no_css('.ng-value', text: val, wait: 1)
+ expect(field_container).to have_no_css(".ng-value", text: val, wait: 1)
end
end
def expect_blank
- expect(field_container).to have_css('.ng-value', count: 0)
+ expect(field_container).to have_css(".ng-value", count: 0)
end
def expect_no_option(option)
expect(page)
- .to have_no_css('.ng-option', text: option, visible: :all, wait: 1)
+ .to have_no_css(".ng-option", text: option, visible: :all, wait: 1)
end
def expect_option(option)
expect(page)
- .to have_css('.ng-option', text: option, visible: :visible)
+ .to have_css(".ng-option", text: option, visible: :visible)
end
def expect_visible
- expect(field_container).to have_css('ng-select')
+ expect(field_container).to have_css("ng-select")
end
def expect_error(string = nil)
- expect(field_container).to have_css('.FormControl-inlineValidation')
+ expect(field_container).to have_css(".FormControl-inlineValidation")
expect(field_container).to have_content(string) if string
end
end
diff --git a/spec/support/form_fields/primerized/editor_form_field.rb b/spec/support/form_fields/primerized/editor_form_field.rb
index 6f6b5970564..b8e6c8b362e 100644
--- a/spec/support/form_fields/primerized/editor_form_field.rb
+++ b/spec/support/form_fields/primerized/editor_form_field.rb
@@ -1,4 +1,4 @@
-require_relative 'form_field'
+require_relative "form_field"
module FormFields
module Primerized
@@ -37,7 +37,7 @@ module FormFields
def expect_error(string = nil)
sleep 2 # quick fix for stale element error
- expect(field_container).to have_css('.FormControl-inlineValidation')
+ expect(field_container).to have_css(".FormControl-inlineValidation")
expect(field_container).to have_content(string) if string
end
end
diff --git a/spec/support/form_fields/primerized/input_field.rb b/spec/support/form_fields/primerized/input_field.rb
index 6b7d87db7da..5917f9684f1 100644
--- a/spec/support/form_fields/primerized/input_field.rb
+++ b/spec/support/form_fields/primerized/input_field.rb
@@ -1,4 +1,4 @@
-require_relative 'form_field'
+require_relative "form_field"
module FormFields
module Primerized
@@ -26,7 +26,7 @@ module FormFields
def expect_value(value)
scroll_to_element(field_container)
- expect(field_container).to have_css('input') { |el| el.value == value }
+ expect(field_container).to have_css("input") { |el| el.value == value }
end
end
end