#{avatar(journal.user)}
@@ -57,11 +57,11 @@ module MeetingsHelper
if journal.details.any?
details = content_tag 'ul', class: 'details journal-attributes' do
- journal.details.map { |detail|
+ journal.details.map do |detail|
if d = journal.render_detail(detail, cache: options[:cache])
content_tag('li', d.html_safe)
end
- }.compact.join(' ').html_safe
+ end.compact.join(' ').html_safe
end
end
diff --git a/modules/meeting/app/models/activities/meeting_activity_provider.rb b/modules/meeting/app/models/activities/meeting_activity_provider.rb
index 55b1584e2b..bf1b03238a 100644
--- a/modules/meeting/app/models/activities/meeting_activity_provider.rb
+++ b/modules/meeting/app/models/activities/meeting_activity_provider.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -109,7 +110,11 @@ class Activities::MeetingActivityProvider < Activities::BaseActivityProvider
end
end_time = start_time + event['meeting_duration'].to_f.hours
- "#{I18n.t(:label_meeting)}: #{event['meeting_title']} (#{format_date start_time} #{format_time start_time, false}-#{format_time end_time, false})"
+ fstart_with = format_date start_time
+ fstart_without = format_time start_time, false
+ fend_without = format_time end_time, false
+
+ "#{I18n.t(:label_meeting)}: #{event['meeting_title']} (#{fstart_with} #{fstart_without}-#{fend_without})"
else
"#{event['meeting_content_type'].constantize.model_name.human}: #{event['meeting_title']}"
end
diff --git a/modules/meeting/app/models/journal/meeting_content_journal.rb b/modules/meeting/app/models/journal/meeting_content_journal.rb
index 54953c294e..f6a1ed00bc 100644
--- a/modules/meeting/app/models/journal/meeting_content_journal.rb
+++ b/modules/meeting/app/models/journal/meeting_content_journal.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/modules/meeting/app/models/journal/meeting_journal.rb b/modules/meeting/app/models/journal/meeting_journal.rb
index 002da7f9e7..49c3b4a89a 100644
--- a/modules/meeting/app/models/journal/meeting_journal.rb
+++ b/modules/meeting/app/models/journal/meeting_journal.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rb
index 15c19a4139..ad5f2c868e 100644
--- a/modules/meeting/app/models/meeting.rb
+++ b/modules/meeting/app/models/meeting.rb
@@ -38,9 +38,9 @@ class Meeting < ApplicationRecord
has_many :contents, -> { readonly }, class_name: 'MeetingContent'
has_many :participants, dependent: :destroy, class_name: 'MeetingParticipant'
- default_scope {
+ default_scope do
order("#{Meeting.table_name}.start_time DESC")
- }
+ end
scope :from_tomorrow, -> { where(['start_time >= ?', Date.tomorrow.beginning_of_day]) }
scope :with_users_by_date, -> {
order("#{Meeting.table_name}.title ASC")
@@ -50,19 +50,19 @@ class Meeting < ApplicationRecord
acts_as_watchable
acts_as_searchable columns: ["#{table_name}.title", "#{MeetingContent.table_name}.text"],
- include: [:contents, :project],
+ include: %i[contents project],
references: :meeting_contents,
date_column: "#{table_name}.created_at"
acts_as_journalized
acts_as_event title: Proc.new { |o|
- "#{I18n.t(:label_meeting)}: #{o.title} \
+ "#{I18n.t(:label_meeting)}: #{o.title} \
#{format_date o.start_time} \
#{format_time o.start_time, false}-#{format_time o.end_time, false})"
- },
- url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o } },
- author: Proc.new(&:user),
- description: ''
+ },
+ url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o } },
+ author: Proc.new(&:user),
+ description: ''
register_on_journal_formatter(:plaintext, 'title')
register_on_journal_formatter(:fraction, 'duration')
@@ -126,7 +126,7 @@ class Meeting < ApplicationRecord
def author=(user)
super
# Don't add the author as participant if we already have some through nested attributes
- participants.build(user: user, invited: true) if self.new_record? && participants.empty? && user
+ participants.build(user: user, invited: true) if new_record? && participants.empty? && user
end
# Returns true if usr or current user is allowed to view the meeting
@@ -227,8 +227,8 @@ class Meeting < ApplicationRecord
if parse_start_time?
errors.add :start_date, :not_an_iso_date if parsed_start_date.nil?
errors.add :start_time_hour, :invalid_time_format if parsed_start_time_hour.nil?
- else
- errors.add :start_time, :invalid if start_time.nil?
+ elsif start_time.nil?
+ errors.add :start_time, :invalid
end
end
diff --git a/modules/meeting/app/models/meeting_content.rb b/modules/meeting/app/models/meeting_content.rb
index 804a77896f..03f48a054d 100644
--- a/modules/meeting/app/models/meeting_content.rb
+++ b/modules/meeting/app/models/meeting_content.rb
@@ -50,7 +50,7 @@ class MeetingContent < ApplicationRecord
)
acts_as_journalized
- acts_as_event type: Proc.new { |o| "#{o.class.to_s.underscore.dasherize}" },
+ acts_as_event type: Proc.new { |o| o.class.to_s.underscore.dasherize.to_s },
title: Proc.new { |o| "#{o.class.model_name.human}: #{o.meeting.title}" },
url: Proc.new { |o| { controller: '/meetings', action: 'show', id: o.meeting } }
diff --git a/modules/meeting/app/models/meeting_participant.rb b/modules/meeting/app/models/meeting_participant.rb
index 57cc29b1d1..798866540d 100644
--- a/modules/meeting/app/models/meeting_participant.rb
+++ b/modules/meeting/app/models/meeting_participant.rb
@@ -45,8 +45,8 @@ class MeetingParticipant < ApplicationRecord
user.present? ? user.mail : mail
end
- def <=>(participant)
- to_s.downcase <=> participant.to_s.downcase
+ def <=>(other)
+ to_s.downcase <=> other.to_s.downcase
end
alias :to_s :name
diff --git a/modules/meeting/app/services/meeting_notification_service.rb b/modules/meeting/app/services/meeting_notification_service.rb
index 059a71cae7..9673bb806d 100644
--- a/modules/meeting/app/services/meeting_notification_service.rb
+++ b/modules/meeting/app/services/meeting_notification_service.rb
@@ -1,5 +1,4 @@
class MeetingNotificationService
-
attr_reader :meeting, :content_type
def initialize(meeting, content_type)
@@ -20,16 +19,14 @@ class MeetingNotificationService
recipients_with_errors = []
meeting.participants.includes(:user).each do |recipient|
- begin
- next if recipient.mail == author_mail && do_not_notify_author
+ next if recipient.mail == author_mail && do_not_notify_author
- MeetingMailer.send(action, content, content_type, recipient.user).deliver_now
- rescue => e
- Rails.logger.error {
- "Failed to deliver #{action} notification to #{recipient.mail}: #{e.message}"
- }
- recipients_with_errors << recipient
+ MeetingMailer.send(action, content, content_type, recipient.user).deliver_now
+ rescue StandardError => e
+ Rails.logger.error do
+ "Failed to deliver #{action} notification to #{recipient.mail}: #{e.message}"
end
+ recipients_with_errors << recipient
end
recipients_with_errors
diff --git a/modules/meeting/config/routes.rb b/modules/meeting/config/routes.rb
index 0eadbb6e10..93636c38d1 100644
--- a/modules/meeting/config/routes.rb
+++ b/modules/meeting/config/routes.rb
@@ -27,13 +27,11 @@
#++
OpenProject::Application.routes.draw do
-
scope 'projects/:project_id' do
- resources :meetings, only: [:new, :create, :index]
+ resources :meetings, only: %i[new create index]
end
- resources :meetings, except: [:new, :create, :index] do
-
+ resources :meetings, except: %i[new create index] do
resource :agenda, controller: 'meeting_agendas', only: [:update] do
member do
get :history
@@ -49,7 +47,7 @@ OpenProject::Application.routes.draw do
controller: 'meeting_agendas'
end
- resource :contents, controller: 'meeting_contents', only: [:show, :update] do
+ resource :contents, controller: 'meeting_contents', only: %i[show update] do
member do
get :history
get :diff
diff --git a/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb b/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb
index 077b9cff6c..157161dcb4 100644
--- a/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb
+++ b/modules/meeting/db/migrate/20180323135408_to_v710_aggregated_meeting_migrations.rb
@@ -26,10 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require Rails.root.join("db","migrate","migration_utils","migration_squasher").to_s
+require Rails.root.join("db", "migrate", "migration_utils", "migration_squasher").to_s
# This migration aggregates the migrations detailed in MIGRATION_FILES
class ToV710AggregatedMeetingMigrations < ActiveRecord::Migration[5.1]
-
MIGRATION_FILES = <<-MIGRATIONS
20111605171865_aggregated_meeting_migrations.rb
20130924114042_legacy_meeting_minutes_journal_data.rb
@@ -51,7 +50,7 @@ class ToV710AggregatedMeetingMigrations < ActiveRecord::Migration[5.1]
t.integer 'lock_version'
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
- t.boolean 'locked', default: false
+ t.boolean 'locked', default: false
end
create_table 'meeting_participants', id: :integer do |t|
@@ -75,10 +74,9 @@ class ToV710AggregatedMeetingMigrations < ActiveRecord::Migration[5.1]
t.datetime 'created_at', null: false
t.datetime 'updated_at', null: false
- t.index [:project_id, :updated_at]
+ t.index %i[project_id updated_at]
end
-
create_table :meeting_journals, id: :integer do |t|
t.integer :journal_id, null: false
t.string :title
diff --git a/modules/meeting/lib/api/v3/meeting_contents/meeting_content_representer.rb b/modules/meeting/lib/api/v3/meeting_contents/meeting_content_representer.rb
index 4d6f164075..d6841657bd 100644
--- a/modules/meeting/lib/api/v3/meeting_contents/meeting_content_representer.rb
+++ b/modules/meeting/lib/api/v3/meeting_contents/meeting_content_representer.rb
@@ -43,6 +43,7 @@ module API
associated_resource :project,
link: ->(*) do
next unless represented.project.present?
+
{
href: api_v3_paths.project(represented.project.id),
title: represented.project.name
diff --git a/modules/meeting/lib/open_project/meeting/default_data.rb b/modules/meeting/lib/open_project/meeting/default_data.rb
index cba1fa0862..66aacf3285 100644
--- a/modules/meeting/lib/open_project/meeting/default_data.rb
+++ b/modules/meeting/lib/open_project/meeting/default_data.rb
@@ -17,17 +17,17 @@ module OpenProject
end
def member_permissions
- [
- :create_meetings,
- :edit_meetings,
- :delete_meetings,
- :view_meetings,
- :create_meeting_agendas,
- :close_meeting_agendas,
- :send_meeting_agendas_notification,
- :send_meeting_agendas_icalendar,
- :create_meeting_minutes,
- :send_meeting_minutes_notification
+ %i[
+ create_meetings
+ edit_meetings
+ delete_meetings
+ view_meetings
+ create_meeting_agendas
+ close_meeting_agendas
+ send_meeting_agendas_notification
+ send_meeting_agendas_icalendar
+ create_meeting_minutes
+ send_meeting_minutes_notification
]
end
diff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rb
index 87a41a9748..d130f8dd7e 100644
--- a/modules/meeting/lib/open_project/meeting/engine.rb
+++ b/modules/meeting/lib/open_project/meeting/engine.rb
@@ -38,16 +38,17 @@ module OpenProject::Meeting
author_url: 'https://www.openproject.com',
bundled: true do
project_module :meetings do
- permission :view_meetings, meetings: [:index, :show], meeting_agendas: [:history, :show, :diff], meeting_minutes: [:history, :show, :diff]
- permission :create_meetings, { meetings: [:new, :create, :copy] }, require: :member
- permission :edit_meetings, { meetings: [:edit, :update] }, require: :member
+ permission :view_meetings, meetings: %i[index show], meeting_agendas: %i[history show diff],
+ meeting_minutes: %i[history show diff]
+ permission :create_meetings, { meetings: %i[new create copy] }, require: :member
+ permission :edit_meetings, { meetings: %i[edit update] }, require: :member
permission :delete_meetings, { meetings: [:destroy] }, require: :member
permission :meetings_send_invite, { meetings: [:icalendar] }, require: :member
- permission :create_meeting_agendas, { meeting_agendas: [:update, :preview] }, require: :member
- permission :close_meeting_agendas, { meeting_agendas: [:close, :open] }, require: :member
+ permission :create_meeting_agendas, { meeting_agendas: %i[update preview] }, require: :member
+ permission :close_meeting_agendas, { meeting_agendas: %i[close open] }, require: :member
permission :send_meeting_agendas_notification, { meeting_agendas: [:notify] }, require: :member
permission :send_meeting_agendas_icalendar, { meeting_agendas: [:icalendar] }, require: :member
- permission :create_meeting_minutes, { meeting_minutes: [:update, :preview] }, require: :member
+ permission :create_meeting_minutes, { meeting_minutes: %i[update preview] }, require: :member
permission :send_meeting_minutes_notification, { meeting_minutes: [:notify] }, require: :member
end
diff --git a/modules/meeting/lib/open_project/meeting/patches/project_patch.rb b/modules/meeting/lib/open_project/meeting/patches/project_patch.rb
index a9e3decb00..ae6211a751 100644
--- a/modules/meeting/lib/open_project/meeting/patches/project_patch.rb
+++ b/modules/meeting/lib/open_project/meeting/patches/project_patch.rb
@@ -38,4 +38,4 @@ module OpenProject::Meeting
end
end
-Project.send(:include, OpenProject::Meeting::Patches::ProjectPatch)
+Project.include OpenProject::Meeting::Patches::ProjectPatch
diff --git a/modules/meeting/lib/open_project/meeting/patches/setting_seeder_patch.rb b/modules/meeting/lib/open_project/meeting/patches/setting_seeder_patch.rb
index 33c4e338db..5bcb63c152 100644
--- a/modules/meeting/lib/open_project/meeting/patches/setting_seeder_patch.rb
+++ b/modules/meeting/lib/open_project/meeting/patches/setting_seeder_patch.rb
@@ -43,4 +43,3 @@ module OpenProject::Meeting::Patches::SettingSeederPatch
end
end
end
-
diff --git a/modules/meeting/openproject-meeting.gemspec b/modules/meeting/openproject-meeting.gemspec
index a1cfd12525..9ff5b8d09a 100644
--- a/modules/meeting/openproject-meeting.gemspec
+++ b/modules/meeting/openproject-meeting.gemspec
@@ -1,4 +1,5 @@
# encoding: UTF-8
+
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = 'openproject-meeting'
diff --git a/modules/meeting/spec/controllers/meetings_controller_spec.rb b/modules/meeting/spec/controllers/meetings_controller_spec.rb
index 7a20c7f6ad..0d922234d7 100644
--- a/modules/meeting/spec/controllers/meetings_controller_spec.rb
+++ b/modules/meeting/spec/controllers/meetings_controller_spec.rb
@@ -47,7 +47,7 @@ describe MeetingsController, type: :controller do
allow(@ms).to receive(:from_tomorrow).and_return(@ms)
allow(project).to receive(:meetings).and_return(@ms)
- [:with_users_by_date, :page, :per_page].each do |meth|
+ %i[with_users_by_date page per_page].each do |meth|
expect(@ms).to receive(meth).and_return(@ms)
end
@grouped = double('grouped')
@@ -55,7 +55,7 @@ describe MeetingsController, type: :controller do
end
describe 'html' do
before(:each) do
- get 'index', params: { project_id: project.id }
+ get 'index', params: { project_id: project.id }
end
it { expect(response).to be_successful }
it { expect(assigns(:meetings_by_start_year_month_date)).to eql @grouped }
@@ -97,7 +97,7 @@ describe MeetingsController, type: :controller do
end
describe 'html' do
before(:each) do
- get 'edit', params: { id: @m.id }
+ get 'edit', params: { id: @m.id }
end
it { expect(response).to be_successful }
it { expect(assigns(:meeting)).to eql @m }
diff --git a/modules/meeting/spec/features/meetings_locking_spec.rb b/modules/meeting/spec/features/meetings_locking_spec.rb
index c2db89ddb2..97a96c6223 100644
--- a/modules/meeting/spec/features/meetings_locking_spec.rb
+++ b/modules/meeting/spec/features/meetings_locking_spec.rb
@@ -41,7 +41,6 @@ describe 'Meetings locking', type: :feature, js: true do
end
it 'shows an error when trying to update a meeting update while editing' do
-
# Edit agenda
within '#tab-content-agenda' do
find('.button--edit-agenda').click
diff --git a/modules/meeting/spec/lib/open_project/markdown_formatting_spec.rb b/modules/meeting/spec/lib/open_project/markdown_formatting_spec.rb
index b055a44aa5..72d3272feb 100644
--- a/modules/meeting/spec/lib/open_project/markdown_formatting_spec.rb
+++ b/modules/meeting/spec/lib/open_project/markdown_formatting_spec.rb
@@ -32,7 +32,6 @@ describe OpenProject::TextFormatting,
'Meeting links',
# Speeds up the spec by avoiding event mailers to be procssed
with_settings: { notified_events: [] } do
-
include ActionView::Helpers::UrlHelper # soft-dependency
include ActionView::Context
include OpenProject::StaticRouting::UrlHelpers
diff --git a/modules/meeting/spec/mailers/meeting_mailer_spec.rb b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
index aa39b74022..006d1af438 100644
--- a/modules/meeting/spec/mailers/meeting_mailer_spec.rb
+++ b/modules/meeting/spec/mailers/meeting_mailer_spec.rb
@@ -82,7 +82,7 @@ describe MeetingMailer, type: :mailer do
expect(mail.text_part.body).to include('GMT+09:00')
expect(mail.html_part.body).to include('Tokyo')
expect(mail.html_part.body).to include('GMT+09:00')
-
+
expect(mail.to).to match_array([watcher1.mail])
end
end
@@ -91,9 +91,9 @@ describe MeetingMailer, type: :mailer do
def check_meeting_mail_content(body)
expect(body).to include(meeting.project.name)
expect(body).to include(meeting.title)
- expect(body).to include(i18n.format_date meeting.start_date)
- expect(body).to include(i18n.format_time meeting.start_time, false)
- expect(body).to include(i18n.format_time meeting.end_time, false)
+ expect(body).to include(i18n.format_date(meeting.start_date))
+ expect(body).to include(i18n.format_time(meeting.start_time, false))
+ expect(body).to include(i18n.format_time(meeting.end_time, false))
expect(body).to include(meeting.participants[0].name)
expect(body).to include(meeting.participants[1].name)
end
diff --git a/modules/meeting/spec/models/project/activity_spec.rb b/modules/meeting/spec/models/project/activity_spec.rb
index 4c515fe5f3..2304a52723 100644
--- a/modules/meeting/spec/models/project/activity_spec.rb
+++ b/modules/meeting/spec/models/project/activity_spec.rb
@@ -37,17 +37,17 @@ describe Projects::Activity, type: :model do
let(:meeting) do
FactoryBot.create(:meeting,
- project: project)
+ project: project)
end
let(:meeting2) do
FactoryBot.create(:meeting,
- project: project)
+ project: project)
end
let(:work_package) do
FactoryBot.create(:work_package,
- project: project)
+ project: project)
end
def latest_activity
diff --git a/modules/meeting/spec/models/user_deletion_spec.rb b/modules/meeting/spec/models/user_deletion_spec.rb
index 16a55c8784..9cd260d496 100644
--- a/modules/meeting/spec/models/user_deletion_spec.rb
+++ b/modules/meeting/spec/models/user_deletion_spec.rb
@@ -148,7 +148,7 @@ describe User, '#destroy', type: :model do
let(:associations) { [:author] }
let(:associated_instance) do
FactoryBot.build(:meeting_agenda, meeting: meeting,
- text: 'lorem')
+ text: 'lorem')
end
let(:associated_class) { MeetingAgenda }
@@ -159,7 +159,7 @@ describe User, '#destroy', type: :model do
let(:associations) { [:author] }
let(:associated_instance) do
FactoryBot.build(:meeting_agenda, meeting: meeting,
- text: 'lorem')
+ text: 'lorem')
end
let(:associated_class) { MeetingAgenda }
diff --git a/modules/my_page/spec/features/my/my_page_spec.rb b/modules/my_page/spec/features/my/my_page_spec.rb
index 817d1104cc..d7af475f3a 100644
--- a/modules/my_page/spec/features/my/my_page_spec.rb
+++ b/modules/my_page/spec/features/my/my_page_spec.rb
@@ -91,7 +91,7 @@ describe 'My page', type: :feature, js: true do
end
def find_area(name)
- index = grid.widgets.sort_by(&:id).each_with_index.detect { |w, index| w.options["name"] == name }.last
+ index = grid.widgets.sort_by(&:id).each_with_index.detect { |w, _index| w.options["name"] == name }.last
Components::Grids::GridArea.new(".grid--area.-widgeted:nth-of-type(#{index + 1})")
end
diff --git a/modules/openid_connect/app/cells/openid_connect/providers/table_cell.rb b/modules/openid_connect/app/cells/openid_connect/providers/table_cell.rb
index aa8bc4f600..d26f8b9968 100644
--- a/modules/openid_connect/app/cells/openid_connect/providers/table_cell.rb
+++ b/modules/openid_connect/app/cells/openid_connect/providers/table_cell.rb
@@ -4,7 +4,7 @@ module OpenIDConnect
columns :name
def initial_sort
- [:id, :asc]
+ %i[id asc]
end
def sortable?
@@ -17,7 +17,7 @@ module OpenIDConnect
def headers
[
- ['name', caption: I18n.t('attributes.name')]
+ ['name', { caption: I18n.t('attributes.name') }]
]
end
end
diff --git a/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb b/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
index 9fadc28776..b0cecf0186 100644
--- a/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
+++ b/modules/openid_connect/app/controllers/openid_connect/providers_controller.rb
@@ -5,7 +5,7 @@ module OpenIDConnect
before_action :require_admin
before_action :check_ee
- before_action :find_provider, only: [:edit, :update, :destroy]
+ before_action :find_provider, only: %i[edit update destroy]
def index; end
@@ -57,7 +57,7 @@ module OpenIDConnect
def check_ee
if EnterpriseToken.show_banners?
render template: '/openid_connect/providers/upsale'
- return false
+ false
end
end
diff --git a/modules/openid_connect/app/models/openid_connect/provider.rb b/modules/openid_connect/app/models/openid_connect/provider.rb
index cd133292dd..56ae712dce 100644
--- a/modules/openid_connect/app/models/openid_connect/provider.rb
+++ b/modules/openid_connect/app/models/openid_connect/provider.rb
@@ -14,6 +14,7 @@ module OpenIDConnect
attr_reader :errors, :omniauth_provider
attr_accessor :display_name
+
delegate :name, to: :omniauth_provider, allow_nil: true
delegate :identifier, to: :omniauth_provider, allow_nil: true
delegate :secret, to: :omniauth_provider, allow_nil: true
@@ -40,6 +41,7 @@ module OpenIDConnect
def id
return nil unless persisted?
+
name
end
@@ -52,6 +54,7 @@ module OpenIDConnect
def save
return false unless valid?
+
config = Setting.plugin_openproject_openid_connect || Hash.new
config["providers"] ||= Hash.new
config["providers"][name] = omniauth_provider.to_h.stringify_keys
diff --git a/modules/openid_connect/config/routes.rb b/modules/openid_connect/config/routes.rb
index aba9d6fd24..f27795fcca 100644
--- a/modules/openid_connect/config/routes.rb
+++ b/modules/openid_connect/config/routes.rb
@@ -3,7 +3,7 @@ Rails.application.routes.draw do
scope :admin do
namespace :openid_connect do
- resources :providers, only: [:index, :new, :create, :edit, :update, :destroy]
+ resources :providers, only: %i[index new create edit update destroy]
end
end
end
diff --git a/modules/openid_connect/openproject-openid_connect.gemspec b/modules/openid_connect/openproject-openid_connect.gemspec
index ff00db3e35..3619e8b253 100644
--- a/modules/openid_connect/openproject-openid_connect.gemspec
+++ b/modules/openid_connect/openproject-openid_connect.gemspec
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.files = Dir['{app,config,db,lib}/**/*'] + %w(CHANGELOG.md README.md)
- s.add_dependency 'openproject-auth_plugins'
- s.add_dependency 'omniauth-openid_connect-providers', '~> 0.1'
s.add_dependency 'lobby_boy', '~> 0.1.3'
+ s.add_dependency 'omniauth-openid_connect-providers', '~> 0.1'
+ s.add_dependency 'openproject-auth_plugins'
end
diff --git a/modules/openid_connect/spec/controllers/providers_controller_spec.rb b/modules/openid_connect/spec/controllers/providers_controller_spec.rb
index 719c38c996..aa6ddcdd45 100644
--- a/modules/openid_connect/spec/controllers/providers_controller_spec.rb
+++ b/modules/openid_connect/spec/controllers/providers_controller_spec.rb
@@ -160,7 +160,6 @@ describe ::OpenIDConnect::ProvidersController, type: :controller do
"providers" => { "azure" => { "identifier" => "IDENTIFIER", "secret" => "SECRET" } }
}
} do
-
it 'removes the provider' do
delete :destroy, params: { id: "azure" }
expect(response).to be_redirect
diff --git a/modules/overviews/spec/controllers/overviews/overviews_controller_spec.rb b/modules/overviews/spec/controllers/overviews/overviews_controller_spec.rb
index ca00beddf3..9a042760b2 100644
--- a/modules/overviews/spec/controllers/overviews/overviews_controller_spec.rb
+++ b/modules/overviews/spec/controllers/overviews/overviews_controller_spec.rb
@@ -29,7 +29,6 @@
require 'spec_helper'
describe Overviews::OverviewsController, type: :controller do
-
let(:permissions) do
%i(view_project)
end
diff --git a/modules/pdf_export/app/controllers/export_card_configurations_controller.rb b/modules/pdf_export/app/controllers/export_card_configurations_controller.rb
index 5b1724c3bb..8791520b72 100644
--- a/modules/pdf_export/app/controllers/export_card_configurations_controller.rb
+++ b/modules/pdf_export/app/controllers/export_card_configurations_controller.rb
@@ -26,22 +26,18 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
class ExportCardConfigurationsController < ApplicationController
layout 'admin'
before_action :require_admin
- before_action :load_config, only: [:show, :update, :edit, :destroy, :activate, :deactivate]
+ before_action :load_config, only: %i[show update edit destroy activate deactivate]
before_action :load_configs, only: [:index]
- def index
- end
+ def index; end
- def show
- end
+ def show; end
- def edit
- end
+ def edit; end
def new
@config = ExportCardConfiguration.new
diff --git a/modules/pdf_export/app/models/export_card_configuration.rb b/modules/pdf_export/app/models/export_card_configuration.rb
index e1be84704a..009e9f7476 100644
--- a/modules/pdf_export/app/models/export_card_configuration.rb
+++ b/modules/pdf_export/app/models/export_card_configuration.rb
@@ -26,9 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
class ExportCardConfiguration < ApplicationRecord
-
class RowsYamlValidator < ActiveModel::Validator
REQUIRED_GROUP_KEYS = ["rows"]
VALID_GROUP_KEYS = ["rows", "has_border", "height"]
@@ -39,8 +37,8 @@ class ExportCardConfiguration < ApplicationRecord
# VALID_MODEL_PROPERTIES = [""]
REQUIRED_COLUMN_KEYS = []
VALID_COLUMN_KEYS = ["has_label", "min_font_size", "max_font_size",
- "font_size", "font_style", "text_align", "minimum_lines", "render_if_empty",
- "width", "indented", "custom_label", "has_count"]
+ "font_size", "font_style", "text_align", "minimum_lines", "render_if_empty",
+ "width", "indented", "custom_label", "has_count"]
NUMERIC_COLUMN_VALUE = ["min_font_size", "max_font_size", "font_size", "minimum_lines"]
def raise_yaml_error
@@ -54,15 +52,18 @@ class ExportCardConfiguration < ApplicationRecord
hash.assert_valid_keys valid_keys
rescue ArgumentError => e
# Small hack alert: Catch a raise error again but with localised text
- raise ArgumentError, "#{I18n.t('validation_error_uknown_key')} '#{e.message.split(": ")[1]}'"
+ raise ArgumentError, "#{I18n.t('validation_error_uknown_key')} '#{e.message.split(': ')[1]}'"
end
pending_keys = required_keys - hash.keys
- raise(ArgumentError, "#{I18n.t('validation_error_required_keys_not_present')} #{pending_keys.join(", ")}") unless pending_keys.empty?
+ unless pending_keys.empty?
+ raise(ArgumentError,
+ "#{I18n.t('validation_error_required_keys_not_present')} #{pending_keys.join(', ')}")
+ end
end
def check_valid_value_type(value, type)
- raise(ArgumentError, "#{I18n.t('validation_error_yaml_is_badly_formed')}") unless value.is_a?type
+ raise(ArgumentError, I18n.t('validation_error_yaml_is_badly_formed').to_s) unless value.is_a? type
end
def validate(record)
@@ -73,20 +74,20 @@ class ExportCardConfiguration < ApplicationRecord
end
rescue Psych::SyntaxError => e
record.errors[:rows] << I18n.t('validation_error_yaml_is_badly_formed')
- return false
+ return false
end
begin
groups = YAML::load(record.rows)
- groups.each do |gk, gv|
+ groups.each do |_gk, gv|
assert_required_keys(gv, VALID_GROUP_KEYS, REQUIRED_GROUP_KEYS)
raise_yaml_error if !gv["rows"].is_a?(Hash)
- gv["rows"].each do |rk, rv|
+ gv["rows"].each do |_rk, rv|
assert_required_keys(rv, VALID_ROW_KEYS, REQUIRED_ROW_KEYS)
raise_yaml_error if !rv["columns"].is_a?(Hash)
- rv["columns"].each do |ck, cv|
+ rv["columns"].each do |_ck, cv|
assert_required_keys(cv, VALID_COLUMN_KEYS, REQUIRED_COLUMN_KEYS)
- cv.map{|cname, cvalue | check_valid_value_type(cvalue, Numeric) if NUMERIC_COLUMN_VALUE.include?(cname)}
+ cv.map { |cname, cvalue| check_valid_value_type(cvalue, Numeric) if NUMERIC_COLUMN_VALUE.include?(cname) }
end
end
end
@@ -111,12 +112,12 @@ class ExportCardConfiguration < ApplicationRecord
end
def activate
- self.update!({active: true})
+ update!({ active: true })
end
def deactivate
- if !self.is_default?
- self.update!({active: false})
+ if !is_default?
+ update!({ active: false })
else
false
end
@@ -133,22 +134,23 @@ class ExportCardConfiguration < ApplicationRecord
def rows_hash
config = YAML::load(rows)
raise BadlyFormedExportCardConfigurationError.new(I18n.t('validation_error_yaml_is_badly_formed')) if !config.is_a?(Hash)
+
config
end
def is_default?
- self.name.downcase == "default"
+ name.downcase == "default"
end
def can_delete?
- !self.is_default?
+ !is_default?
end
def can_activate?
- !self.active
+ !active
end
def can_deactivate?
- self.active && !is_default?
+ active && !is_default?
end
end
diff --git a/modules/pdf_export/config/routes.rb b/modules/pdf_export/config/routes.rb
index a7e0052428..1749b0d6b8 100644
--- a/modules/pdf_export/config/routes.rb
+++ b/modules/pdf_export/config/routes.rb
@@ -26,14 +26,11 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
OpenProject::Application.routes.draw do
-
scope "", as: "pdf_export" do
- resources :export_card_configurations, :controller => :export_card_configurations do
+ resources :export_card_configurations, controller: :export_card_configurations do
post 'activate', on: :member
post 'deactivate', on: :member
end
end
-
end
diff --git a/modules/pdf_export/db/seeds/export_card_configurations.rb b/modules/pdf_export/db/seeds/export_card_configurations.rb
index d95eb47ea4..400e7f4a75 100644
--- a/modules/pdf_export/db/seeds/export_card_configurations.rb
+++ b/modules/pdf_export/db/seeds/export_card_configurations.rb
@@ -26,11 +26,10 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
if ExportCardConfiguration.find_by_identifier("default").nil?
- ExportCardConfiguration.create({name: "Default",
- per_page: 2,
- page_size: "A4",
- orientation: "landscape",
- rows: "rows:\n row1:\n has_border: false\n columns:\n id:\n has_label: false\n font_size: 20\n font_style: bold\n priority: 1\n minimum_lines: 2\n render_if_empty: false\n width: 30%\n due_date:\n has_label: false\n font_size: 15\n font_style: italic\n priority: 1\n minimum_lines: 2\n render_if_empty: false\n width: 70%\n row2:\n has_border: false\n columns:\n description:\n has_label: false\n font_size: 15\n font_style: normal\n priority: 4\n minimum_lines: 5\n render_if_empty: false\n width: 100%\n"})
+ ExportCardConfiguration.create({ name: "Default",
+ per_page: 2,
+ page_size: "A4",
+ orientation: "landscape",
+ rows: "rows:\n row1:\n has_border: false\n columns:\n id:\n has_label: false\n font_size: 20\n font_style: bold\n priority: 1\n minimum_lines: 2\n render_if_empty: false\n width: 30%\n due_date:\n has_label: false\n font_size: 15\n font_style: italic\n priority: 1\n minimum_lines: 2\n render_if_empty: false\n width: 70%\n row2:\n has_border: false\n columns:\n description:\n has_label: false\n font_size: 15\n font_style: normal\n priority: 4\n minimum_lines: 5\n render_if_empty: false\n width: 100%\n" })
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/engine.rb b/modules/pdf_export/lib/open_project/pdf_export/engine.rb
index ad6033ef96..55ee9061f2 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/engine.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/engine.rb
@@ -37,7 +37,6 @@ module OpenProject::PDFExport
register 'openproject-pdf_export',
author_url: 'https://www.openproject.com',
bundled: true do
-
menu :admin_menu,
:export_card_configurations,
{ controller: '/export_card_configurations', action: 'index' },
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb
index 8dca689bc2..e829276f2b 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/card_element.rb
@@ -50,9 +50,9 @@ module OpenProject::PDFExport::ExportCard
current_y_offset = text_padding
# Initialize groups
- @groups_config.each_with_index do |(g_key, g_value), i|
+ @groups_config.each_with_index do |(_g_key, g_value), i|
row_count = g_value["rows"].count
- row_heights = all_heights[:row_heights].reject {|row| row[:group] != i}.map{|row| row[:height]}
+ row_heights = all_heights[:row_heights].reject { |row| row[:group] != i }.map { |row| row[:height] }
group_height = all_heights[:group_heights][i]
group_orientation = {
y_offset: @orientation[:height] - current_y_offset,
@@ -75,11 +75,11 @@ module OpenProject::PDFExport::ExportCard
group_heights = Array.new
row_heights = Array.new
- groups.each_with_index do |(gk, gv), i|
+ groups.each_with_index do |(_gk, gv), i|
enforced_group_height = gv["height"] || -1
used_group_height = 0
- gv["rows"].each do |rk, rv|
+ gv["rows"].each do |_rk, rv|
# The + 1 on the height is needed as prawn does not seem to render
# when the string to render has the same size as the row height.
if rv["height"]
@@ -101,6 +101,7 @@ module OpenProject::PDFExport::ExportCard
available = @orientation[:height] - (@orientation[:group_padding] * 2)
diff = available - heights[:group_heights].sum
return false if diff >= 0
+
diff *= -1
rows = heights[:row_heights]
@@ -108,8 +109,8 @@ module OpenProject::PDFExport::ExportCard
priorities = *(0..rows.count - 1)
.zip(rows.map { |row| row[:priority] or 10 })
- .sort {|x,y| y[1] <=> x[1]}
- .map {|x| x[0]}
+ .sort { |x, y| y[1] <=> x[1] }
+ .map { |x| x[0] }
priorities.each do |p|
to_reduce = rows[p]
@@ -132,7 +133,7 @@ module OpenProject::PDFExport::ExportCard
# Look through each of the row's columns for the column with the largest minimum height
largest = 0
- row["columns"].each do |rk, rv|
+ row["columns"].each do |_rk, rv|
min_lines = rv["minimum_lines"] || 1
font_size = rv["min_font_size"] || rv["font_size"] || 10
min_col_height = (@pdf.font.height_at(font_size) * min_lines).floor
@@ -155,7 +156,6 @@ module OpenProject::PDFExport::ExportCard
@pdf.stroke_bounds
end
-
end
end
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb
index 4cc9bc2ca5..17e9e0b670 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/column_element.rb
@@ -38,11 +38,11 @@ module OpenProject::PDFExport::ExportCard
def draw
# Get value from model
- if @work_package.respond_to?(@property_name)
- value = extract_property
- else
- value = extract_custom_field
- end
+ value = if @work_package.respond_to?(@property_name)
+ extract_property
+ else
+ extract_custom_field
+ end
draw_value(value)
end
@@ -65,7 +65,9 @@ module OpenProject::PDFExport::ExportCard
value = ""
available_languages.each do |locale|
I18n.with_locale(locale) do
- if (customs = @work_package.custom_field_values.select {|cf| cf.custom_field.name == @property_name} and customs.count > 0)
+ if customs = @work_package.custom_field_values.select do |cf|
+ cf.custom_field.name == @property_name
+ end and customs.count > 0
value = customs.first.value
@custom_field = customs.first.custom_field
end
@@ -84,10 +86,10 @@ module OpenProject::PDFExport::ExportCard
if @has_label
custom_label = @config['custom_label']
label_text = if custom_label
- "#{custom_label}"
- else
- localised_property_name
- end
+ custom_label.to_s
+ else
+ localised_property_name
+ end
if @config['has_count'] && value.is_a?(Array)
label_text = "#{label_text} (#{value.count})"
end
@@ -102,13 +104,13 @@ module OpenProject::PDFExport::ExportCard
def abbreviated_text(text, options)
options = options.merge!({ document: @pdf })
text_box = Prawn::Text::Box.new(text, options)
- left_over = text_box.render(:dry_run => true)
+ left_over = text_box.render(dry_run: true)
# Be sure to do length arithmetics on chars, not bytes!
left_over = left_over.mb_chars
text = text.to_s.mb_chars
- text = left_over.size > 0 ? text[0 ... -(left_over.size + 5)] + "[...]" : text
+ text = left_over.size > 0 ? text[0...-(left_over.size + 5)] + "[...]" : text
text.to_s
rescue Prawn::Errors::CannotFit
''
@@ -147,10 +149,9 @@ module OpenProject::PDFExport::ExportCard
@has_label = @config['has_label']
indented = @config['indented']
-
# Flatten value to a display string
display_value = value
- display_value = display_value.map{|c| c.to_s }.join("\n") if display_value.is_a?(Array)
+ display_value = display_value.map { |c| c.to_s }.join("\n") if display_value.is_a?(Array)
display_value = display_value.to_s if !display_value.is_a?(String)
if @has_label && indented
@@ -159,57 +160,58 @@ module OpenProject::PDFExport::ExportCard
# Label Textbox
offset = [@orientation[:x_offset], @orientation[:height] - (@orientation[:text_padding] / 2)]
box = @pdf.text_box(label_text(value),
- {:height => @orientation[:height],
- :width => @orientation[:width] * width_ratio,
- :at => offset,
- :style => :bold,
- :overflow => overflow,
- :size => font_size,
- :min_font_size => min_font_size,
- :align => :left})
+ { height: @orientation[:height],
+ width: @orientation[:width] * width_ratio,
+ at: offset,
+ style: :bold,
+ overflow: overflow,
+ size: font_size,
+ min_font_size: min_font_size,
+ align: :left })
# Get abbraviated text
- options = {:height => @orientation[:height],
- :width => @orientation[:width] * (1 - width_ratio),
- :at => offset,
- :style => font_style,
- :overflow => overflow,
- :size => font_size,
- :min_font_size => min_font_size,
- :align => text_align}
+ options = { height: @orientation[:height],
+ width: @orientation[:width] * (1 - width_ratio),
+ at: offset,
+ style: font_style,
+ overflow: overflow,
+ size: font_size,
+ min_font_size: min_font_size,
+ align: text_align }
text = abbreviated_text(display_value, options)
- offset = [@orientation[:x_offset] + (@orientation[:width] * width_ratio), @orientation[:height] - (@orientation[:text_padding] / 2)]
+ offset = [@orientation[:x_offset] + (@orientation[:width] * width_ratio),
+ @orientation[:height] - (@orientation[:text_padding] / 2)]
# Content Textbox
- box = @pdf.text_box(text, {:height => @orientation[:height],
- :width => @orientation[:width] * (1 - width_ratio),
- :at => offset,
- :style => font_style,
- :overflow => overflow,
- :size => font_size,
- :min_font_size => min_font_size,
- :align => text_align})
+ box = @pdf.text_box(text, { height: @orientation[:height],
+ width: @orientation[:width] * (1 - width_ratio),
+ at: offset,
+ style: font_style,
+ overflow: overflow,
+ size: font_size,
+ min_font_size: min_font_size,
+ align: text_align })
else
- options = {:height => @orientation[:height],
- :width => @orientation[:width],
- :at => offset,
- :style => font_style,
- :overflow => overflow,
- :min_font_size => min_font_size,
- :align => text_align}
+ options = { height: @orientation[:height],
+ width: @orientation[:width],
+ at: offset,
+ style: font_style,
+ overflow: overflow,
+ min_font_size: min_font_size,
+ align: text_align }
text = abbreviated_text(display_value, options)
- texts = [{ text: label_text(value), styles: [:bold], :size => font_size }, { text: text, :size => font_size }]
+ texts = [{ text: label_text(value), styles: [:bold], size: font_size }, { text: text, size: font_size }]
# Label and Content Textbox
offset = [@orientation[:x_offset], @orientation[:height] - (@orientation[:text_padding] / 2)]
- box = @pdf.formatted_text_box(texts, {:height => @orientation[:height],
- :width => @orientation[:width],
- :at => offset,
- :style => font_style,
- :overflow => overflow,
- :min_font_size => min_font_size,
- :align => text_align})
+ box = @pdf.formatted_text_box(texts, { height: @orientation[:height],
+ width: @orientation[:width],
+ at: offset,
+ style: font_style,
+ overflow: overflow,
+ min_font_size: min_font_size,
+ align: text_align })
end
end
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb
index 26a2f4a6bb..187074b281 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/document_generator.rb
@@ -31,13 +31,7 @@ require 'prawn'
module OpenProject::PDFExport::ExportCard
require "open_project/pdf_export/export_card/model_display/work_package_display"
class DocumentGenerator
-
- attr_reader :config
- attr_reader :work_packages
- attr_reader :pdf
- attr_reader :current_position
- attr_reader :paper_width
- attr_reader :paper_height
+ attr_reader :config, :work_packages, :pdf, :current_position, :paper_width, :paper_height
def initialize(config, work_packages)
patch_models
@@ -51,12 +45,13 @@ module OpenProject::PDFExport::ExportCard
page_size = config.page_size or defaults[:page_size]
@pdf = Prawn::Document.new(
- :page_layout => page_layout,
- :left_margin => 0,
- :right_margin => 0,
- :top_margin => 0,
- :bottom_margin => 0,
- :page_size => page_size)
+ page_layout: page_layout,
+ left_margin: 0,
+ right_margin: 0,
+ top_margin: 0,
+ bottom_margin: 0,
+ page_size: page_size
+ )
view = ::WorkPackage::PDFExport::View.new(I18n.locale)
view.register_fonts! @pdf
@@ -76,7 +71,7 @@ module OpenProject::PDFExport::ExportCard
group_padding = 5
text_padding = 5
card_width = pdf.bounds.width - (card_padding * 2)
- card_height = ((pdf.bounds.height - (card_padding * config.per_page )) / config.per_page) - (card_padding / config.per_page)
+ card_height = ((pdf.bounds.height - (card_padding * config.per_page)) / config.per_page) - (card_padding / config.per_page)
card_y_offset = pdf.bounds.height - card_padding
@work_packages.each_with_index do |wp, i|
@@ -106,7 +101,7 @@ module OpenProject::PDFExport::ExportCard
def patch_models
# Note: Can't seem to patch the models when initializing for reasons which I don't understand
- WorkPackage.send(:include, OpenProject::PDFExport::ExportCard::ModelDisplay::WorkPackageDisplay)
+ WorkPackage.include OpenProject::PDFExport::ExportCard::ModelDisplay::WorkPackageDisplay
end
end
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb
index 281084647b..cbb3126e1a 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/group_element.rb
@@ -26,7 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
module OpenProject::PDFExport::ExportCard
class GroupElement
include OpenProject::PDFExport::Exceptions
@@ -42,7 +41,7 @@ module OpenProject::PDFExport::ExportCard
current_y_offset = 0
row_heights = @orientation[:row_heights]
- @rows_config.each_with_index do |(r_key, r_value), i|
+ @rows_config.each_with_index do |(_r_key, r_value), i|
current_y_offset += (row_heights[i - 1]) if i > 0
row_orientation = {
y_offset: @orientation[:height] - current_y_offset,
@@ -70,11 +69,10 @@ module OpenProject::PDFExport::ExportCard
row.draw
end
- if (@config["has_border"] or false)
+ if @config["has_border"] or false
@pdf.stroke_bounds
end
end
-
end
end
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb
index c5a6298bb6..35803ee238 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/model_display/work_package_display.rb
@@ -1,7 +1,7 @@
module OpenProject::PDFExport::ExportCard::ModelDisplay
module WorkPackageDisplay
def display_id
- "#{kind.is_standard ? "" : "#{kind.name}"} ##{id}"
+ "#{kind.is_standard ? '' : kind.name.to_s} ##{id}"
end
end
end
diff --git a/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb b/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb
index cd2f7279c5..528169f7a3 100644
--- a/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb
+++ b/modules/pdf_export/lib/open_project/pdf_export/export_card/row_element.rb
@@ -77,13 +77,12 @@ module OpenProject::PDFExport::ExportCard
c.draw
end
end
-
end
def self.prune_empty_groups(groups, wp)
# Prune rows in groups
- groups.each do |gk, gv|
- self.prune_empty_rows(gv["rows"], wp)
+ groups.each do |_gk, gv|
+ prune_empty_rows(gv["rows"], wp)
end
# Prune empty groups
@@ -105,13 +104,13 @@ module OpenProject::PDFExport::ExportCard
end
def self.is_empty_column(property_name, column, wp)
- if wp.respond_to?(property_name)
- value = wp.send(property_name)
- elsif (field = locale_independent_custom_field(property_name, wp)) && !!field
- value = field.value
- else
- value = ""
- end
+ value = if wp.respond_to?(property_name)
+ wp.send(property_name)
+ elsif (field = locale_independent_custom_field(property_name, wp)) && !!field
+ field.value
+ else
+ ""
+ end
value = "" if value.is_a?(Array) && value.empty?
value = value.to_s if !value.is_a?(String)
@@ -120,7 +119,7 @@ module OpenProject::PDFExport::ExportCard
end
def self.is_existing_column?(property_name, wp)
- wp.respond_to?(property_name) || is_existing_custom_field?(property_name, wp)
+ wp.respond_to?(property_name) || is_existing_custom_field?(property_name, wp)
end
def self.is_existing_custom_field?(property_name, wp)
@@ -130,7 +129,7 @@ module OpenProject::PDFExport::ExportCard
def self.locale_independent_custom_field(property_name, wp)
Setting.available_languages.each do |locale|
I18n.with_locale(locale) do
- if (fields = wp.custom_field_values.select {|cf| cf.custom_field.name == property_name} and fields.count > 0)
+ if fields = wp.custom_field_values.select { |cf| cf.custom_field.name == property_name } and fields.count > 0
return fields.first
end
end
diff --git a/modules/pdf_export/openproject-pdf_export.gemspec b/modules/pdf_export/openproject-pdf_export.gemspec
index 4b1a380fe8..c8d00fd364 100644
--- a/modules/pdf_export/openproject-pdf_export.gemspec
+++ b/modules/pdf_export/openproject-pdf_export.gemspec
@@ -12,6 +12,6 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib,doc}/**/*", "README.md"]
- s.add_dependency "prawn", "~> 2.2"
s.add_dependency "pdf-inspector", "~> 1.3.0"
+ s.add_dependency "prawn", "~> 2.2"
end
diff --git a/modules/pdf_export/spec/controllers/export_card_configurations_controller_spec.rb b/modules/pdf_export/spec/controllers/export_card_configurations_controller_spec.rb
index 40f197d730..cbaa7f492a 100644
--- a/modules/pdf_export/spec/controllers/export_card_configurations_controller_spec.rb
+++ b/modules/pdf_export/spec/controllers/export_card_configurations_controller_spec.rb
@@ -26,11 +26,10 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
require 'spec_helper'
require File.dirname(__FILE__) + '/../shared_examples'
-describe ExportCardConfigurationsController, :type => :controller do
+describe ExportCardConfigurationsController, type: :controller do
before do
allow(@controller).to receive(:require_admin) { true }
@@ -47,38 +46,44 @@ describe ExportCardConfigurationsController, :type => :controller do
describe 'Create' do
context 'with all the values set' do
it_behaves_like "should let you create a configuration" do
- let(:params) { { :export_card_configuration => { name: "Config 1",
- description: "This is a description",
- rows: @valid_rows_yaml,
- per_page: 5,
- page_size: "A4",
- orientation: "landscape" } } }
+ let(:params) do
+ { export_card_configuration: { name: "Config 1",
+ description: "This is a description",
+ rows: @valid_rows_yaml,
+ per_page: 5,
+ page_size: "A4",
+ orientation: "landscape" } }
+ end
end
end
context 'with missing data' do
it_behaves_like "should not let you create a configuration" do
- let(:params) { { :export_card_configuration => { name: "Config 1" } } }
+ let(:params) { { export_card_configuration: { name: "Config 1" } } }
end
end
context 'with invalid data' do
it_behaves_like "should not let you create a configuration" do
- let(:params) { { :export_card_configuration => { name: "Config 1",
- rows: @invalid_rows_yaml,
- per_page: 0,
- page_size: "invalid",
- orientation: "invalid" } } }
+ let(:params) do
+ { export_card_configuration: { name: "Config 1",
+ rows: @invalid_rows_yaml,
+ per_page: 0,
+ page_size: "invalid",
+ orientation: "invalid" } }
+ end
end
end
context 'with invalid data format' do
it_behaves_like "should not let you create a configuration" do
- let(:params) { { :export_card_configuration => { name: "Config 1",
- rows: @invalid_property_value_format,
- per_page: 1,
- page_size: "A4",
- orientation: "landscape" } } }
+ let(:params) do
+ { export_card_configuration: { name: "Config 1",
+ rows: @invalid_property_value_format,
+ per_page: 1,
+ page_size: "A4",
+ orientation: "landscape" } }
+ end
end
end
end
@@ -89,7 +94,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:export_card_configuration] = { per_page: 4 }
put 'update', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_successful_update))
end
@@ -103,7 +108,7 @@ describe ExportCardConfigurationsController, :type => :controller do
it 'should not let you update a configuration with invalid page_size' do
@params[:id] = @custom_config.id
- @params[:export_card_configuration] = { page_size: "invalid"}
+ @params[:export_card_configuration] = { page_size: "invalid" }
put 'update', params: @params
expect(response).to render_template('edit')
@@ -119,7 +124,7 @@ describe ExportCardConfigurationsController, :type => :controller do
it 'should not let you update a configuration with invalid rows yaml' do
@params[:id] = @custom_config.id
- @params[:export_card_configuration] = { rows: "asdf ',#\""}
+ @params[:export_card_configuration] = { rows: "asdf ',#\"" }
put 'update', params: @params
expect(response).to render_template('edit')
@@ -131,7 +136,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:id] = @custom_config.id
delete 'destroy', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_successful_delete))
end
@@ -139,7 +144,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:id] = @default_config.id
delete 'destroy', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:error_can_not_delete_export_card_configuration))
end
end
@@ -149,7 +154,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:id] = @inactive_config.id
post 'activate', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_export_card_configuration_activated))
end
end
@@ -159,7 +164,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:id] = @active_config.id
post 'deactivate', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:notice_export_card_configuration_deactivated))
end
@@ -167,7 +172,7 @@ describe ExportCardConfigurationsController, :type => :controller do
@params[:id] = @default_config.id
post 'deactivate', params: @params
- expect(response).to redirect_to :action => 'index'
+ expect(response).to redirect_to action: 'index'
expect(flash[:notice]).to eql(I18n.t(:error_can_not_deactivate_export_card_configuration))
end
end
diff --git a/modules/pdf_export/spec/export_card/document_generator_spec.rb b/modules/pdf_export/spec/export_card/document_generator_spec.rb
index 3dec2e98eb..e2da46deae 100644
--- a/modules/pdf_export/spec/export_card/document_generator_spec.rb
+++ b/modules/pdf_export/spec/export_card/document_generator_spec.rb
@@ -29,24 +29,30 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe OpenProject::PDFExport::ExportCard::DocumentGenerator do
- let(:config) { ExportCardConfiguration.new({
- name: "Default",
- description: "This is a description",
- per_page: 1,
- page_size: "A4",
- orientation: "landscape",
- rows: "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n subject:\n has_label: false\n font_size: 15\n row2:\n height: 50\n priority: 1\n columns:\n non_existent:\n has_label: true\n font_size: 15\n render_if_empty: true"
- })}
+ let(:config) do
+ ExportCardConfiguration.new({
+ name: "Default",
+ description: "This is a description",
+ per_page: 1,
+ page_size: "A4",
+ orientation: "landscape",
+ rows: "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n subject:\n has_label: false\n font_size: 15\n row2:\n height: 50\n priority: 1\n columns:\n non_existent:\n has_label: true\n font_size: 15\n render_if_empty: true"
+ })
+ end
- let(:work_package1) { WorkPackage.new({
- subject: "Work package 1",
- description: "This is a description"
- })}
+ let(:work_package1) do
+ WorkPackage.new({
+ subject: "Work package 1",
+ description: "This is a description"
+ })
+ end
- let(:work_package2) { WorkPackage.new({
- subject: "Work package 2",
- description: "This is work package 2"
- })}
+ let(:work_package2) do
+ WorkPackage.new({
+ subject: "Work package 2",
+ description: "This is work package 2"
+ })
+ end
describe "Single work package rendering" do
before(:each) do
@@ -87,5 +93,4 @@ describe OpenProject::PDFExport::ExportCard::DocumentGenerator do
expect(page_analysis.pages.size).to eq(2)
end
end
-
end
diff --git a/modules/pdf_export/spec/factories/export_card_configuration_factory.rb b/modules/pdf_export/spec/factories/export_card_configuration_factory.rb
index 905e8784dd..1e3776451c 100644
--- a/modules/pdf_export/spec/factories/export_card_configuration_factory.rb
+++ b/modules/pdf_export/spec/factories/export_card_configuration_factory.rb
@@ -26,28 +26,31 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
FactoryBot.define do
factory :export_card_configuration do
name { "Config 1" }
description { "This is a description" }
- rows { "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false" }
+ rows do
+ "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false"
+ end
per_page { 5 }
page_size { "A4" }
orientation { "landscape" }
end
- factory :default_export_card_configuration, :class => ExportCardConfiguration do
+ factory :default_export_card_configuration, class: ExportCardConfiguration do
name { "Default" }
description { "This is a description" }
active { true }
- rows { "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false" }
+ rows do
+ "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false"
+ end
per_page { 5 }
page_size { "A4" }
orientation { "landscape" }
end
- factory :invalid_export_card_configuration, :class => ExportCardConfiguration do
+ factory :invalid_export_card_configuration, class: ExportCardConfiguration do
name { "Invalid" }
description { "This is a description" }
rows { "row1" }
@@ -56,21 +59,25 @@ FactoryBot.define do
orientation { "qwer" }
end
- factory :active_export_card_configuration, :class => ExportCardConfiguration do
+ factory :active_export_card_configuration, class: ExportCardConfiguration do
name { "Config active" }
description { "This is a description" }
active { true }
- rows { "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false" }
+ rows do
+ "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false"
+ end
per_page { 5 }
page_size { "A4" }
orientation { "landscape" }
end
- factory :inactive_export_card_configuration, :class => ExportCardConfiguration do
+ factory :inactive_export_card_configuration, class: ExportCardConfiguration do
name { "Config inactive" }
description { "This is a description" }
active { false }
- rows { "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false" }
+ rows do
+ "group1:\n has_border: false\n rows:\n row1:\n height: 50\n priority: 1\n columns:\n id:\n has_label: false"
+ end
per_page { 5 }
page_size { "A4" }
orientation { "landscape" }
diff --git a/modules/pdf_export/spec/shared_examples.rb b/modules/pdf_export/spec/shared_examples.rb
index dee9d211c6..0816a44489 100644
--- a/modules/pdf_export/spec/shared_examples.rb
+++ b/modules/pdf_export/spec/shared_examples.rb
@@ -1,19 +1,17 @@
shared_examples_for "should let you create a configuration" do
-
before do
post 'create', params: params
end
- it { expect(response).to redirect_to :action => 'index' }
+ it { expect(response).to redirect_to action: 'index' }
it { expect(flash[:notice]).to eq(I18n.t(:notice_successful_create)) }
end
shared_examples_for "should not let you create a configuration" do
-
before do
post 'create', params: params
end
it { expect(response).to render_template('new') }
- it {expect(assigns(:config).errors.messages).to_not be_empty}
+ it { expect(assigns(:config).errors.messages).to_not be_empty }
end
diff --git a/modules/pdf_export/spec/views/edit.html.erb_spec.rb b/modules/pdf_export/spec/views/edit.html.erb_spec.rb
index 314a2bfabd..86a7439574 100644
--- a/modules/pdf_export/spec/views/edit.html.erb_spec.rb
+++ b/modules/pdf_export/spec/views/edit.html.erb_spec.rb
@@ -26,10 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
require 'spec_helper'
-describe 'export_card_configurations/edit', :type => :view do
+describe 'export_card_configurations/edit', type: :view do
let(:config) { FactoryBot.build(:export_card_configuration) }
before do
diff --git a/modules/pdf_export/spec/views/index.html.erb_spec.rb b/modules/pdf_export/spec/views/index.html.erb_spec.rb
index 2a698fc084..4eabf78aab 100644
--- a/modules/pdf_export/spec/views/index.html.erb_spec.rb
+++ b/modules/pdf_export/spec/views/index.html.erb_spec.rb
@@ -26,10 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
require 'spec_helper'
-describe 'export_card_configurations/index', :type => :view do
+describe 'export_card_configurations/index', type: :view do
let(:config1) { FactoryBot.build(:export_card_configuration, name: "Config 1") }
let(:config2) { FactoryBot.build(:export_card_configuration, name: "Config 2") }
@@ -45,5 +44,4 @@ describe 'export_card_configurations/index', :type => :view do
expect(rendered).to have_selector("a", text: config1.name)
expect(rendered).to have_selector("a", text: config2.name)
end
-
end
diff --git a/modules/pdf_export/spec/views/new.html.erb_spec.rb b/modules/pdf_export/spec/views/new.html.erb_spec.rb
index 78c02cdcb3..1c0ce72296 100644
--- a/modules/pdf_export/spec/views/new.html.erb_spec.rb
+++ b/modules/pdf_export/spec/views/new.html.erb_spec.rb
@@ -26,10 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
require 'spec_helper'
-describe 'export_card_configurations/new', :type => :view do
+describe 'export_card_configurations/new', type: :view do
let(:config) { FactoryBot.build(:export_card_configuration) }
before do
@@ -45,5 +44,4 @@ describe 'export_card_configurations/new', :type => :view do
expect(rendered).to have_css("select#export_card_configuration_orientation")
expect(rendered).to have_css("textarea#export_card_configuration_rows")
end
-
end
diff --git a/modules/recaptcha/config/routes.rb b/modules/recaptcha/config/routes.rb
index eb86a6435f..d4f7ddeb07 100644
--- a/modules/recaptcha/config/routes.rb
+++ b/modules/recaptcha/config/routes.rb
@@ -1,5 +1,4 @@
OpenProject::Application::routes.draw do
-
namespace 'recaptcha' do
get :settings, to: 'admin#show'
post :settings, to: 'admin#update'
diff --git a/modules/recaptcha/lib/open_project/recaptcha/engine.rb b/modules/recaptcha/lib/open_project/recaptcha/engine.rb
index 72d5b134c0..639c10caf2 100644
--- a/modules/recaptcha/lib/open_project/recaptcha/engine.rb
+++ b/modules/recaptcha/lib/open_project/recaptcha/engine.rb
@@ -23,7 +23,7 @@ module OpenProject::Recaptcha
end
config.after_initialize do
- SecureHeaders::Configuration.named_append(:recaptcha) do |request|
+ SecureHeaders::Configuration.named_append(:recaptcha) do |_request|
{ frame_src: %w(https://www.google.com/recaptcha/) }
end
diff --git a/modules/reporting/app/controllers/cost_reports_controller.rb b/modules/reporting/app/controllers/cost_reports_controller.rb
index 539b601dc8..2884f4d0ea 100644
--- a/modules/reporting/app/controllers/cost_reports_controller.rb
+++ b/modules/reporting/app/controllers/cost_reports_controller.rb
@@ -49,7 +49,8 @@ class CostReportsController < ApplicationController
helper_method :cost_type
helper_method :unit_id
- attr_accessor :report_engine
+ attr_accessor :report_engine, :cost_types, :unit_id, :cost_type
+
helper_method :current_user
helper_method :allowed_to?
@@ -58,12 +59,10 @@ class CostReportsController < ApplicationController
helper { def engine; @report_engine; end }
before_action :determine_engine
- before_action :prepare_query, only: [:index, :create]
- before_action :find_optional_report, only: [:index, :show, :update, :destroy, :rename]
+ before_action :prepare_query, only: %i[index create]
+ before_action :find_optional_report, only: %i[index show update destroy rename]
before_action :possibly_only_narrow_values
- attr_accessor :cost_types, :unit_id, :cost_type
-
before_action :set_cost_types # has to be set AFTER the Report::Controller filters run
layout 'angular'
@@ -78,11 +77,13 @@ class CostReportsController < ApplicationController
def index
table
- respond_to do |format|
- format.html {
- session[report_engine.name.underscore.to_sym].try(:delete, :name)
- }
- end unless performed?
+ unless performed?
+ respond_to do |format|
+ format.html do
+ session[report_engine.name.underscore.to_sym].try(:delete, :name)
+ end
+ end
+ end
end
##
@@ -170,10 +171,10 @@ class CostReportsController < ApplicationController
@query.public! if make_query_public?
@query.save!
store_query(@query)
- unless request.xhr?
- redirect_to action: 'show', id: @query.id
- else
+ if request.xhr?
render plain: @query.name
+ else
+ redirect_to action: 'show', id: @query.id
end
end
@@ -249,7 +250,6 @@ class CostReportsController < ApplicationController
##
# Clear the query if the project context changed
def update_project_context!(filters)
-
# Only in project context
return unless @project
@@ -284,11 +284,11 @@ class CostReportsController < ApplicationController
# Set a default query to cut down initial load time
def default_group_parameters
{ columns: [:week], rows: [] }.tap do |h|
- if @project
- h[:rows] << :work_package_id
- else
- h[:rows] << :project_id
- end
+ h[:rows] << if @project
+ :work_package_id
+ else
+ :project_id
+ end
end
end
@@ -309,7 +309,7 @@ class CostReportsController < ApplicationController
cost_type_filter = @query.filters.detect { |f| f.is_a?(CostQuery::Filter::CostTypeId) }
cost_type_filter.values.first.to_i if cost_type_filter
- end
+ end
@unit_id = -1 unless @cost_types.include? @unit_id
end
@@ -359,11 +359,11 @@ class CostReportsController < ApplicationController
# If report does not belong to a project, it is ok to look for the
# permission in any project. Otherwise, the user should have the permission
# in this project.
- if report.project.present?
- options = {}
- else
- options = { global: true }
- end
+ options = if report.project.present?
+ {}
+ else
+ { global: true }
+ end
case action
when :create
@@ -433,7 +433,8 @@ class CostReportsController < ApplicationController
##
# Determines if the request contains filters to set
- def set_filter? # FIXME: rename to set_query?
+ # FIXME: rename to set_query?
+ def set_filter?
params[:set_filter].to_i == 1
end
diff --git a/modules/reporting/app/controllers/work_package_costlog_controller.rb b/modules/reporting/app/controllers/work_package_costlog_controller.rb
index 3edbd2ed35..27eabce58b 100644
--- a/modules/reporting/app/controllers/work_package_costlog_controller.rb
+++ b/modules/reporting/app/controllers/work_package_costlog_controller.rb
@@ -48,13 +48,13 @@ class WorkPackageCostlogController < ApplicationController
filters[:values][:project_id] = [@project.id.to_s]
respond_to do |format|
- format.html {
+ format.html do
session[CostQuery.name.underscore.to_sym] = { filters: filters, groups: { rows: [], columns: [] } }
redirect_to_cost_reports
- }
- format.all {
+ end
+ format.all do
redirect_to_cost_reports
- }
+ end
end
end
diff --git a/modules/reporting/app/helpers/reporting_helper.rb b/modules/reporting/app/helpers/reporting_helper.rb
index 6c13139757..7544d68149 100644
--- a/modules/reporting/app/helpers/reporting_helper.rb
+++ b/modules/reporting/app/helpers/reporting_helper.rb
@@ -35,7 +35,8 @@ module ReportingHelper
def with_project(project)
project = Project.find(project) unless project.is_a? Project
- project_was, @project = @project, project
+ project_was = @project
+ @project = project
yield
@project = project_was
end
@@ -52,6 +53,7 @@ module ReportingHelper
if name.starts_with?('label')
return I18n.t(field)
end
+
name = name.camelcase
if CostQuery::Filter.const_defined? name
CostQuery::Filter.const_get(name).label
@@ -239,6 +241,7 @@ module ReportingHelper
def filter_class(filter_name)
klass = CostQuery::Filter.const_get(filter_name.to_s.camelize)
return klass if klass.is_a? Class
+
nil
rescue NameError
nil
diff --git a/modules/reporting/app/models/cost_query.rb b/modules/reporting/app/models/cost_query.rb
index 85a02154e5..4c4d8ace0d 100644
--- a/modules/reporting/app/models/cost_query.rb
+++ b/modules/reporting/app/models/cost_query.rb
@@ -92,11 +92,11 @@ class CostQuery < ApplicationRecord
end
def deserialize
- unless @chain
+ if @chain
+ raise ArgumentError, 'Cannot deserialize a report which already has a chain'
+ else
hash = serialized || serialize
self.class.deserialize(hash, self)
- else
- raise ArgumentError, 'Cannot deserialize a report which already has a chain'
end
end
@@ -121,7 +121,7 @@ class CostQuery < ApplicationRecord
# This may be used to alter report properties without
# creating a new report in a database.
def migrate(report)
- [:@chain, :@query, :@transformer, :@walker, :@table, :@depths, :@chain_initializer].each do |inst_var|
+ %i[@chain @query @transformer @walker @table @depths @chain_initializer].each do |inst_var|
instance_variable_set inst_var, (report.instance_variable_get inst_var)
end
end
@@ -140,7 +140,10 @@ class CostQuery < ApplicationRecord
def add_chain(type, name, options)
chain type.const_get(name.to_s.camelcase), options
- @transformer, @table, @depths, @walker = nil, nil, nil, nil
+ @transformer = nil
+ @table = nil
+ @depths = nil
+ @walker = nil
self
end
@@ -252,9 +255,9 @@ class CostQuery < ApplicationRecord
CostQuery.where(['user_id = ?', user.id]).update_all ['user_id = ?', DeletedUser.first.id]
max_query_id = 0
- while((current_queries = CostQuery.limit(1000)
+ while (current_queries = CostQuery.limit(1000)
.where(["id > ?", max_query_id])
- .order("id ASC")).size > 0) do
+ .order("id ASC")).size > 0
current_queries.each do |query|
serialized = query.serialized
@@ -262,9 +265,9 @@ class CostQuery < ApplicationRecord
serialized[:filters] = serialized[:filters].map do |name, options|
options[:values].delete(user.id.to_s) if ["UserId", "AuthorId", "AssignedToId"].include?(name)
- options[:values].nil? || options[:values].size > 0 ?
- [name, options] :
- nil
+ if options[:values].nil? || options[:values].size > 0
+ [name, options]
+ end
end.compact
CostQuery.where(["id = ?", query.id]).update_all ["serialized = ?", YAML::dump(serialized)]
diff --git a/modules/reporting/app/models/cost_query/cache.rb b/modules/reporting/app/models/cost_query/cache.rb
index 4fdbe28b80..16ff9e4146 100644
--- a/modules/reporting/app/models/cost_query/cache.rb
+++ b/modules/reporting/app/models/cost_query/cache.rb
@@ -28,7 +28,6 @@
module CostQuery::Cache
class << self
-
def check
reset! if reset_required?
end
diff --git a/modules/reporting/app/models/cost_query/custom_field_mixin.rb b/modules/reporting/app/models/cost_query/custom_field_mixin.rb
index 8dad0ae5f7..05df3de0bb 100644
--- a/modules/reporting/app/models/cost_query/custom_field_mixin.rb
+++ b/modules/reporting/app/models/cost_query/custom_field_mixin.rb
@@ -30,6 +30,7 @@ module CostQuery::CustomFieldMixin
include Report::QueryUtils
attr_reader :custom_field
+
SQL_TYPES = {
'string' => 'varchar',
'list' => 'varchar',
diff --git a/modules/reporting/app/models/cost_query/filter/cost_type_id.rb b/modules/reporting/app/models/cost_query/filter/cost_type_id.rb
index 345784ff69..218bd653bc 100644
--- a/modules/reporting/app/models/cost_query/filter/cost_type_id.rb
+++ b/modules/reporting/app/models/cost_query/filter/cost_type_id.rb
@@ -44,6 +44,7 @@ class CostQuery::Filter::CostTypeId < Report::Filter::Base
# Displayability is decided on the instance
def display?
return super if @display.nil?
+
@display
end
diff --git a/modules/reporting/app/models/cost_query/filter/user_id.rb b/modules/reporting/app/models/cost_query/filter/user_id.rb
index 2049e1529b..ddf70512a0 100644
--- a/modules/reporting/app/models/cost_query/filter/user_id.rb
+++ b/modules/reporting/app/models/cost_query/filter/user_id.rb
@@ -47,8 +47,6 @@ class CostQuery::Filter::UserId < Report::Filter::Base
if User.current.logged?
User.current.id
- else
- nil
end
end
diff --git a/modules/reporting/app/models/cost_query/group_by/cost_type_id.rb b/modules/reporting/app/models/cost_query/group_by/cost_type_id.rb
index 86da607521..48cad33e03 100644
--- a/modules/reporting/app/models/cost_query/group_by/cost_type_id.rb
+++ b/modules/reporting/app/models/cost_query/group_by/cost_type_id.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::CostTypeId < Report::GroupBy::Base
-
def self.label
CostType.model_name.human
end
diff --git a/modules/reporting/app/models/cost_query/group_by/project_id.rb b/modules/reporting/app/models/cost_query/group_by/project_id.rb
index 2f0d278e44..70750bd6f9 100644
--- a/modules/reporting/app/models/cost_query/group_by/project_id.rb
+++ b/modules/reporting/app/models/cost_query/group_by/project_id.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::ProjectId < Report::GroupBy::Base
-
def self.label
Project.model_name.human
end
diff --git a/modules/reporting/app/models/cost_query/group_by/tmonth.rb b/modules/reporting/app/models/cost_query/group_by/tmonth.rb
index 41fc1c823a..ac2fbf9fc4 100644
--- a/modules/reporting/app/models/cost_query/group_by/tmonth.rb
+++ b/modules/reporting/app/models/cost_query/group_by/tmonth.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::Tmonth < Report::GroupBy::Base
-
def self.label
I18n.t(:label_month_reporting)
end
diff --git a/modules/reporting/app/models/cost_query/group_by/tweek.rb b/modules/reporting/app/models/cost_query/group_by/tweek.rb
index dd9fbf21eb..a8c436915b 100644
--- a/modules/reporting/app/models/cost_query/group_by/tweek.rb
+++ b/modules/reporting/app/models/cost_query/group_by/tweek.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::Tweek < Report::GroupBy::Base
-
def self.label
I18n.t(:label_week_reporting)
end
diff --git a/modules/reporting/app/models/cost_query/group_by/tyear.rb b/modules/reporting/app/models/cost_query/group_by/tyear.rb
index 2310e927b0..b7c373790d 100644
--- a/modules/reporting/app/models/cost_query/group_by/tyear.rb
+++ b/modules/reporting/app/models/cost_query/group_by/tyear.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::Tyear < Report::GroupBy::Base
-
def self.label
I18n.t(:label_year_reporting)
end
diff --git a/modules/reporting/app/models/cost_query/group_by/user_id.rb b/modules/reporting/app/models/cost_query/group_by/user_id.rb
index 9605473c3f..19dc2f6a6a 100644
--- a/modules/reporting/app/models/cost_query/group_by/user_id.rb
+++ b/modules/reporting/app/models/cost_query/group_by/user_id.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::UserId < Report::GroupBy::Base
-
def self.label
WorkPackage.human_attribute_name(:user)
end
diff --git a/modules/reporting/app/models/cost_query/group_by/work_package_id.rb b/modules/reporting/app/models/cost_query/group_by/work_package_id.rb
index c4519cdd1c..7638c7b591 100644
--- a/modules/reporting/app/models/cost_query/group_by/work_package_id.rb
+++ b/modules/reporting/app/models/cost_query/group_by/work_package_id.rb
@@ -27,7 +27,6 @@
#++
class CostQuery::GroupBy::WorkPackageId < Report::GroupBy::Base
-
def self.label
WorkPackage.model_name.human
end
diff --git a/modules/reporting/app/models/cost_query/operator.rb b/modules/reporting/app/models/cost_query/operator.rb
index b9af049877..afca19f7ad 100644
--- a/modules/reporting/app/models/cost_query/operator.rb
+++ b/modules/reporting/app/models/cost_query/operator.rb
@@ -29,26 +29,28 @@
class CostQuery::Operator < Report::Operator
# Operators from Redmine
new "c", arity: 0, label: :label_closed do
- def modify(query, field, *values)
+ def modify(query, field, *_values)
raise "wrong field" if field.to_s.split('.').last != "status_id"
+
query.where "(#{Status.table_name}.is_closed = #{quoted_true})"
query
end
end
new "o", arity: 0, label: :label_open do
- def modify(query, field, *values)
+ def modify(query, field, *_values)
raise "wrong field" if field.to_s.split('.').last != "status_id"
+
query.where "(#{Status.table_name}.is_closed = #{quoted_false})"
query
end
end
- new "=_child_projects", validate: :integers, label: :label_is_project_with_subprojects do
+ new "=_child_projects", validate: :integers, label: :label_is_project_with_subprojects do
def modify(query, field, *values)
p_ids = []
values.each do |value|
- p_ids += ([value] << Project.find(value).descendants.map{ |p| p.id })
+ p_ids += ([value] << Project.find(value).descendants.map { |p| p.id })
end
"=".to_operator.modify query, field, p_ids
rescue ActiveRecord::RecordNotFound
@@ -56,11 +58,11 @@ class CostQuery::Operator < Report::Operator
end
end
- new "!_child_projects", validate: :integers, label: :label_is_not_project_with_subprojects do
+ new "!_child_projects", validate: :integers, label: :label_is_not_project_with_subprojects do
def modify(query, field, *values)
p_ids = []
values.each do |value|
- p_ids += ([value] << Project.find(value).descendants.map{ |p| p.id })
+ p_ids += ([value] << Project.find(value).descendants.map { |p| p.id })
end
"!".to_operator.modify query, field, p_ids
rescue ActiveRecord::RecordNotFound
diff --git a/modules/reporting/app/models/cost_query/sql_statement.rb b/modules/reporting/app/models/cost_query/sql_statement.rb
index 7c5f6084f9..1a33a2e82c 100644
--- a/modules/reporting/app/models/cost_query/sql_statement.rb
+++ b/modules/reporting/app/models/cost_query/sql_statement.rb
@@ -44,7 +44,7 @@ class CostQuery::SqlStatement < Report::SqlStatement
# this is a hack to ensure that additional joins added by filters do not result
# in additional columns being selected.
def to_s
- select(['entries.*']) if select == ['*'] && group_by.empty? && self.entry_union
+ select(['entries.*']) if select == ['*'] && group_by.empty? && entry_union
super
end
@@ -86,11 +86,12 @@ class CostQuery::SqlStatement < Report::SqlStatement
query.select COMMON_FIELDS
query.desc = "Subquery for #{table}"
query.select({
- count: 1, id: [model, :id], display_costs: 1,
- real_costs: switch("#{table}.overridden_costs IS NULL" => [model, :costs], else: [model, :overridden_costs]),
- week: iso_year_week(:spent_on, model),
- singleton_value: 1 })
- #FIXME: build this subquery from a sql_statement
+ count: 1, id: [model, :id], display_costs: 1,
+ real_costs: switch("#{table}.overridden_costs IS NULL" => [model, :costs], else: [model, :overridden_costs]),
+ week: iso_year_week(:spent_on, model),
+ singleton_value: 1
+ })
+ # FIXME: build this subquery from a sql_statement
query.from "(SELECT *, #{typed :text, model.model_name.to_s} AS type FROM #{table}) AS #{table}"
send("unify_#{table}", query)
end
diff --git a/modules/reporting/app/models/entry.rb b/modules/reporting/app/models/entry.rb
index 66fd5e8bae..816b9199c2 100644
--- a/modules/reporting/app/models/entry.rb
+++ b/modules/reporting/app/models/entry.rb
@@ -43,7 +43,8 @@ module Entry
end
def calculate(type, *args)
- a, b = TimeEntry.calculate(type, *args), CostEntry.calculate(type, *args)
+ a = TimeEntry.calculate(type, *args)
+ b = CostEntry.calculate(type, *args)
case type
when :sum, :count then a + b
when :avg then (a + b) / 2
@@ -54,13 +55,14 @@ module Entry
end
undef_method :create, :update, :delete, :destroy, :new, :update_counters,
- :increment_counter, :decrement_counter
+ :increment_counter, :decrement_counter
%w[update_all destroy_all delete_all].each do |meth|
define_method(meth) { |*args| send_all(meth, *args) }
end
private
+
def all(*args)
ActiveSupport::Deprecation.warn('Passing arguments is deprecated') if args.any?
find_many :all # *args
@@ -72,9 +74,12 @@ module Entry
end
def find_initial(options) find_one :find_initial, options end
+
def find_last(options) find_one :find_last, options end
+
def find_every(options) find_many :find_every, options end
- def find_from_ids(args, options) find_many :find_from_ids, options end
+
+ def find_from_ids(_args, options) find_many :find_from_ids, options end
def find_one(*args)
TimeEntry.send(*args) || CostEntry.send(*args)
diff --git a/modules/reporting/config/routes.rb b/modules/reporting/config/routes.rb
index e1437093cd..a7752ebdb9 100644
--- a/modules/reporting/config/routes.rb
+++ b/modules/reporting/config/routes.rb
@@ -30,7 +30,7 @@ OpenProject::Application.routes.draw do
scope 'projects/:project_id' do
resources :cost_reports, except: :create do
collection do
- match :index, via: [:get, :post]
+ match :index, via: %i[get post]
end
member do
@@ -42,10 +42,10 @@ OpenProject::Application.routes.draw do
resources :cost_reports, except: :create do
collection do
- match :index, via: [:get, :post]
+ match :index, via: %i[get post]
post :save_as, action: :create
get :drill_down
- match :available_values, via: [:get, :post]
+ match :available_values, via: %i[get post]
get :display_report_list
end
diff --git a/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb b/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb
index f97e3a8433..fe692f756b 100644
--- a/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb
+++ b/modules/reporting/db/migrate/20180323130704_to_v710_aggregated_reporting_migrations.rb
@@ -38,13 +38,13 @@ class ToV710AggregatedReportingMigrations < ActiveRecord::Migration[5.1]
def up
Migration::MigrationSquasher.squash(migrations) do
create_table "cost_queries", id: :integer do |t|
- t.integer "user_id", :null => false
+ t.integer "user_id", null: false
t.integer "project_id"
- t.string "name", :null => false
- t.boolean "is_public", :default => false, :null => false
- t.datetime "created_on", :null => false
- t.datetime "updated_on", :null => false
- t.string "serialized", :limit => 2000, :null => false
+ t.string "name", null: false
+ t.boolean "is_public", default: false, null: false
+ t.datetime "created_on", null: false
+ t.datetime "updated_on", null: false
+ t.string "serialized", limit: 2000, null: false
end
end
end
diff --git a/modules/reporting/lib/open_project/reporting/default_data.rb b/modules/reporting/lib/open_project/reporting/default_data.rb
index be7cbe4f6f..eb88df8dfa 100644
--- a/modules/reporting/lib/open_project/reporting/default_data.rb
+++ b/modules/reporting/lib/open_project/reporting/default_data.rb
@@ -22,9 +22,9 @@ module OpenProject
end
def restricted_project_admin_permissions
- [
- :save_cost_reports,
- :save_private_cost_reports
+ %i[
+ save_cost_reports
+ save_private_cost_reports
]
end
end
diff --git a/modules/reporting/lib/open_project/reporting/engine.rb b/modules/reporting/lib/open_project/reporting/engine.rb
index 82144b5a9f..df13df24d4 100644
--- a/modules/reporting/lib/open_project/reporting/engine.rb
+++ b/modules/reporting/lib/open_project/reporting/engine.rb
@@ -37,17 +37,16 @@ module OpenProject::Reporting
register 'openproject-reporting',
author_url: 'https://www.openproject.com',
bundled: true do
+ view_actions = %i[index show drill_down available_values display_report_list]
+ edit_actions = %i[create update rename destroy]
- view_actions = [:index, :show, :drill_down, :available_values, :display_report_list]
- edit_actions = [:create, :update, :rename, :destroy]
-
- #register reporting_module including permissions
+ # register reporting_module including permissions
project_module :costs do
permission :save_cost_reports, { cost_reports: edit_actions }
permission :save_private_cost_reports, { cost_reports: edit_actions }
end
- #register additional permissions for viewing time and cost entries through the CostReportsController
+ # register additional permissions for viewing time and cost entries through the CostReportsController
view_actions.each do |action|
OpenProject::AccessControl.permission(:view_time_entries).actions << "cost_reports/#{action}"
OpenProject::AccessControl.permission(:view_own_time_entries).actions << "cost_reports/#{action}"
@@ -55,7 +54,7 @@ module OpenProject::Reporting
OpenProject::AccessControl.permission(:view_own_cost_entries).actions << "cost_reports/#{action}"
end
- #menu extensions
+ # menu extensions
menu :top_menu,
:cost_reports_global,
{ controller: '/cost_reports', action: 'index', project_id: nil },
@@ -67,7 +66,7 @@ module OpenProject::Reporting
User.current.allowed_to?(:view_own_time_entries, nil, global: true) ||
User.current.allowed_to?(:view_cost_entries, nil, global: true) ||
User.current.allowed_to?(:view_own_cost_entries, nil, global: true)
- )
+ )
}
menu :project_menu,
diff --git a/modules/reporting/lib/open_project/reporting/patches/custom_fields_controller_patch.rb b/modules/reporting/lib/open_project/reporting/patches/custom_fields_controller_patch.rb
index 616e704d6f..4b9319d4ca 100644
--- a/modules/reporting/lib/open_project/reporting/patches/custom_fields_controller_patch.rb
+++ b/modules/reporting/lib/open_project/reporting/patches/custom_fields_controller_patch.rb
@@ -42,7 +42,7 @@ module OpenProject::Reporting::Patches
remove_custom_field_from_cost_report(reports, id)
remove_custom_field_from_session(id)
- rescue => e
+ rescue StandardError => e
Rails.logger.error "Failed to remove custom_field #{id} from custom queries. " \
"#{e.class}: #{e.message}"
ensure
diff --git a/modules/reporting/lib/open_project/reporting/patches/open_project/configuration_patch.rb b/modules/reporting/lib/open_project/reporting/patches/open_project/configuration_patch.rb
index 4e7d91a1d0..9a73f14097 100644
--- a/modules/reporting/lib/open_project/reporting/patches/open_project/configuration_patch.rb
+++ b/modules/reporting/lib/open_project/reporting/patches/open_project/configuration_patch.rb
@@ -26,7 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
require_dependency 'open_project/configuration'
module OpenProject::Reporting::Patches
diff --git a/modules/reporting/lib/open_project/reporting/patches/to_date_patch.rb b/modules/reporting/lib/open_project/reporting/patches/to_date_patch.rb
index 2d29662d73..3cd8ec0efe 100644
--- a/modules/reporting/lib/open_project/reporting/patches/to_date_patch.rb
+++ b/modules/reporting/lib/open_project/reporting/patches/to_date_patch.rb
@@ -35,6 +35,7 @@ module OpenProject::Reporting::Patches::ToDatePatch
def to_dateish
return Date.today if blank?
+
Date.parse self
end
end
@@ -50,6 +51,7 @@ module OpenProject::Reporting::Patches::ToDatePatch
def force_utc
return to_time.force_utc unless respond_to? :utc_offset
return self if utc?
+
utc - utc_offset
end
end
diff --git a/modules/reporting/lib/report/chainable.rb b/modules/reporting/lib/report/chainable.rb
index 6518919d88..ebb628584f 100644
--- a/modules/reporting/lib/report/chainable.rb
+++ b/modules/reporting/lib/report/chainable.rb
@@ -58,6 +58,7 @@ module Report
def self.base
return self if base?
+
superclass.base
end
@@ -81,6 +82,7 @@ module Report
def self.table_from(value)
return value.table_name if value.respond_to? :table_name
return value unless value.respond_to? :to_ary or value.respond_to? :to_hash
+
table_from value.to_a.first
end
@@ -124,6 +126,7 @@ module Report
end
attr_accessor :parent, :child, :type
+
accepts_property :type
def each(&block)
@@ -149,6 +152,7 @@ module Report
def top
return self if top?
+
parent.top
end
@@ -162,6 +166,7 @@ module Report
def bottom
return self if bottom?
+
child.bottom
end
@@ -170,10 +175,14 @@ module Report
options.each do |key, value|
unless self.class.extra_options.include? key
raise ArgumentError, "may not set #{key}" unless engine.accepted_properties.include? key.to_s
+
send "#{key}=", value
end
end
- self.child, child.parent = child, self if child
+ if child
+ self.child = child
+ child.parent = self
+ end
move_down until correct_position?
clear
end
@@ -249,6 +258,7 @@ module Report
def sql_statement
raise "should not get here (#{inspect})" if bottom?
+
child.cached(:sql_statement).tap do |q|
chain_collect(:table_joins).each { |args| q.join(*args) } if responsible_for_sql?
end
@@ -301,6 +311,7 @@ module Report
class << self
def new(chain = nil, options = {})
return chain if chain and chain.map(&:class).include? self
+
super
end
end
diff --git a/modules/reporting/lib/report/filter/base.rb b/modules/reporting/lib/report/filter/base.rb
index c40cddc263..61cdeef4c2 100644
--- a/modules/reporting/lib/report/filter/base.rb
+++ b/modules/reporting/lib/report/filter/base.rb
@@ -105,7 +105,7 @@ class Report::Filter
def self.inherited(klass)
if base?
- self.dont_display!
+ dont_display!
klass.display!
end
super
@@ -187,7 +187,7 @@ class Report::Filter
arity = operator.arity
query_values = [*transformed_values].compact
# if there is just the nil it might be actually intendet to be there
- query_values.unshift nil if Array(self.values).size == 1 && Array(self.values).first.nil?
+ query_values.unshift nil if Array(values).size == 1 && Array(values).first.nil?
query_values = query_values[0, arity] if query_values and arity >= 0 and arity != query_values.size
operator.modify(query, field, *query_values) unless field.empty?
end
diff --git a/modules/reporting/lib/report/group_by/base.rb b/modules/reporting/lib/report/group_by/base.rb
index 821089c806..2f07b76d63 100644
--- a/modules/reporting/lib/report/group_by/base.rb
+++ b/modules/reporting/lib/report/group_by/base.rb
@@ -69,7 +69,7 @@ class Report::GroupBy
def select_fields
# + (parent ? parent.select_fields : [])
- self.class.select_fields ? self.class.select_fields : group_fields
+ self.class.select_fields || group_fields
end
##
diff --git a/modules/reporting/lib/report/inherited_attribute.rb b/modules/reporting/lib/report/inherited_attribute.rb
index 7d4da310a2..dc0d765ff7 100644
--- a/modules/reporting/lib/report/inherited_attribute.rb
+++ b/modules/reporting/lib/report/inherited_attribute.rb
@@ -43,17 +43,19 @@ module Report::InheritedAttribute
define_singleton_method(name) do |*values|
# FIXME: I'm ugly
return get_inherited_attribute(name, default, list, uniq) if values.empty?
+
if list
old = instance_variable_get("@#{name}") if merge
old ||= []
return set_inherited_attribute(name, values.map(&map) + old)
end
raise ArgumentError, "wrong number of arguments (#{values.size} for 1)" if values.size > 1
+
set_inherited_attribute name, map.call(values.first)
end
define_method(name) { |*values| self.class.send(name, *values) }
end
- end
+ end
def define_singleton_method(name, &block)
singleton_class.send :attr_writer, name
@@ -63,6 +65,7 @@ module Report::InheritedAttribute
def get_inherited_attribute(name, default = nil, list = false, uniq = false)
return get_inherited_attribute(name, default, list, false).uniq if list and uniq
+
result = instance_variable_get("@#{name}")
super_result = superclass.get_inherited_attribute(name, default, list) if inherit? name
if result.nil?
diff --git a/modules/reporting/lib/report/operator.rb b/modules/reporting/lib/report/operator.rb
index cdffa955ec..c09fda8144 100644
--- a/modules/reporting/lib/report/operator.rb
+++ b/modules/reporting/lib/report/operator.rb
@@ -36,7 +36,7 @@ class Report::Operator
def self.define_operators # :nodoc:
# Defaults
defaults do
- def_delegators :'singleton_class', :forced?, :force!, :forced
+ def_delegators :singleton_class, :forced?, :force!, :forced
def sql_operator
name
@@ -115,10 +115,9 @@ class Report::Operator
new '=', label: :label_equals do
def modify(query, field, *values)
- case
- when values.size == 1 && values.first.nil?
+ if values.size == 1 && values.first.nil?
query.where "#{field} IS NULL"
- when values.compact.empty?
+ elsif values.compact.empty?
query.where '1=0'
else
query.where "#{field} IN #{collection(*values)}"
@@ -187,6 +186,7 @@ class Report::Operator
new '
d', label: :label_greater_or_equal, validate: :dates do
def modify(query, field, value)
return query if value.to_s.empty?
+
'>='.to_operator.modify query, field, quoted_date(value)
end
end
@@ -201,6 +202,7 @@ class Report::Operator
new '<>d', label: :label_between, validate: :dates do
def modify(query, field, from, to)
return query if from.to_s.empty? || to.to_s.empty?
+
query.where "#{field} BETWEEN '#{quoted_date from}' AND '#{quoted_date to}'"
query
end
@@ -209,6 +211,7 @@ class Report::Operator
new '=d', label: :label_date_on, validate: :dates do
def modify(query, field, value)
return query if value.to_s.empty?
+
'='.to_operator.modify query, field, quoted_date(value)
end
end
@@ -276,6 +279,7 @@ class Report::Operator
def self.load
return if @done
+
@done = true
define_operators
end
@@ -358,6 +362,7 @@ class Report::Operator
all = self.class.all
alt = alt_name.to_s
raise ArgumentError, "Can't alias operator with an existing one's name ( #{alt} )." if all.has_key?(alt)
+
op = all[name].clone
op.send(:rename_to, alt_name)
op.singleton_class.send(:define_method, 'label') { alt_label }
diff --git a/modules/reporting/lib/report/query_utils.rb b/modules/reporting/lib/report/query_utils.rb
index 0d91f6588d..db5ee78da0 100644
--- a/modules/reporting/lib/report/query_utils.rb
+++ b/modules/reporting/lib/report/query_utils.rb
@@ -42,6 +42,7 @@ module Report::QueryUtils
# @return [Object] Quoted version
def quote_string(str)
return str unless str.respond_to? :to_str
+
engine.reporting_connection.quote_string(str)
end
@@ -111,6 +112,7 @@ module Report::QueryUtils
# @return [String] The table name.
def table_name_for(object)
return object.table_name if object.respond_to? :table_name
+
object.to_s.tableize
end
@@ -133,6 +135,7 @@ module Report::QueryUtils
return arg if arg.is_a? String and arg =~ /\.| |\(.*\)/
return table_name_for(arg.first || default_table) + '.' << arg.last.to_s if arg.is_a? Array and arg.size == 2
return arg.to_s unless default_table
+
field_name_for [default_table, arg]
end
@@ -155,14 +158,14 @@ module Report::QueryUtils
# @param [Hash] options Condition => Result.
# @return [String] Case statement.
def switch(options)
- desc = "#{__method__} #{options.inspect[1..-2]}".gsub(/(Cost|Time)Entry\([^\)]*\)/, '\1Entry')
+ desc = "#{__method__} #{options.inspect[1..-2]}".gsub(/(Cost|Time)Entry\([^)]*\)/, '\1Entry')
options = options.with_indifferent_access
else_part = options.delete :else
"-- #{desc}\n\t" \
- "CASE #{options.map { |k, v|
+ "CASE #{options.map do |k, v|
"\n\t\tWHEN #{field_name_for k}\n\t\t" \
"THEN #{field_name_for v}"
- }.join(', ')}\n\t\tELSE #{field_name_for else_part}\n\tEND"
+ end.join(', ')}\n\t\tELSE #{field_name_for else_part}\n\tEND"
end
##
diff --git a/modules/reporting/lib/report/result.rb b/modules/reporting/lib/report/result.rb
index 4eb8104cfa..3c1efc755a 100644
--- a/modules/reporting/lib/report/result.rb
+++ b/modules/reporting/lib/report/result.rb
@@ -30,8 +30,7 @@ class Report::Result
include Report::QueryUtils
class Base
- attr_accessor :parent, :type, :important_fields
- attr_accessor :key
+ attr_accessor :parent, :type, :important_fields, :key
attr_reader :value
alias values value
include Enumerable
@@ -117,8 +116,7 @@ class Report::Result
type == :direct
end
- def each_row
- end
+ def each_row; end
def final?(type)
type? type and (direct? or size == 0 or first.type != type)
@@ -137,6 +135,7 @@ class Report::Result
def final_number(type)
return 1 if final? type
return 0 if direct?
+
@final_number ||= {}
@final_number[type] ||= sum { |v| v.final_number type }
end
@@ -181,11 +180,13 @@ class Report::Result
def each
return enum_for(__method__) unless block_given?
+
yield self
end
def each_direct_result(_cached = false)
return enum_for(__method__) unless block_given?
+
yield self
end
@@ -204,6 +205,7 @@ class Report::Result
def sort!(force = false)
return false if @sorted and not force
+
values.sort! { |a, b| compare a.key, b.key }
values.each { |e| e.sort! force }
@sorted = true
@@ -252,6 +254,7 @@ class Report::Result
def each_row
return enum_for(:each_row) unless block_given?
+
if final_row? then yield self
else each { |c| c.each_row(&Proc.new) }
end
@@ -266,10 +269,11 @@ class Report::Result
values.each(&block)
end
- def each_direct_result(cached = true)
+ def each_direct_result(cached = true, &block)
return enum_for(__method__) unless block_given?
+
if @direct_results
- @direct_results.each { |r| yield(r) }
+ @direct_results.each(&block)
else
values.each do |value|
value.each_direct_result(false) do |result|
diff --git a/modules/reporting/lib/report/sql_statement.rb b/modules/reporting/lib/report/sql_statement.rb
index eadb0a84e3..2b7732b6d8 100644
--- a/modules/reporting/lib/report/sql_statement.rb
+++ b/modules/reporting/lib/report/sql_statement.rb
@@ -29,8 +29,11 @@
class Report::SqlStatement
class Union
attr_accessor :first, :second, :as
+
def initialize(first, second, as = nil)
- @first, @second, @as = first, second, as
+ @first = first
+ @second = second
+ @as = as
end
def to_s
@@ -80,6 +83,7 @@ class Report::SqlStatement
def sum(field, name = :sum, type = :sum)
@sql = nil
return sum({ name => field }, nil, type) unless field.respond_to? :to_hash
+
field.each { |k, v| field[k] = "#{type}(#{v})" }
select field
end
@@ -201,6 +205,7 @@ class Report::SqlStatement
# @return [Array] All fields/statements for select part
def select(*fields)
return(@select || default_select) if fields.empty?
+
(@select ||= []).tap do
@sql = nil
fields.reject { |f| never_select.include? f }.each do |f|
diff --git a/modules/reporting/lib/report/table.rb b/modules/reporting/lib/report/table.rb
index 0f09d36c3b..8bef5a85dd 100644
--- a/modules/reporting/lib/report/table.rb
+++ b/modules/reporting/lib/report/table.rb
@@ -30,6 +30,7 @@
class Report::Table
attr_accessor :query
+
include Report::QueryUtils
def initialize(query)
@@ -76,15 +77,15 @@ class Report::Table
def fields_for(type)
@fields_for ||= begin
- child = query.chain
- fields = Hash.new { |h, k| h[k] = [] }
-
- until child.filter?
- fields[child.type].push(*child.group_fields)
- child = child.child
- end
- fields
- end
+ child = query.chain
+ fields = Hash.new { |h, k| h[k] = [] }
+
+ until child.filter?
+ fields[child.type].push(*child.group_fields)
+ child = child.child
+ end
+ fields
+ end
@fields_for[type]
end
@@ -112,7 +113,7 @@ class Report::Table
def get_index(type)
@indexes ||= begin
indexes = Hash.new { |h, k| h[k] = Set.new }
- query.each_direct_result { |result| [:row, :column].each { |t| indexes[t] << fields_from(result, t) } }
+ query.each_direct_result { |result| %i[row column].each { |t| indexes[t] << fields_from(result, t) } }
indexes.keys.each { |k| indexes[k] = indexes[k].sort { |x, y| compare x, y } }
indexes
end
diff --git a/modules/reporting/lib/report/transformer.rb b/modules/reporting/lib/report/transformer.rb
index 45b673b684..76b8689e75 100644
--- a/modules/reporting/lib/report/transformer.rb
+++ b/modules/reporting/lib/report/transformer.rb
@@ -27,6 +27,7 @@
#++
# encoding: UTF-8
+
class Report::Transformer
attr_reader :query
@@ -47,9 +48,11 @@ class Report::Transformer
def column_first
@column_first ||= begin
# reverse since we fake recursion ↓↓↓
- list, all_fields = restructured.reverse, @all_fields.dup
+ list = restructured.reverse
+ all_fields = @all_fields.dup
result = list.inject(@ungrouped) do |aggregate, (current_fields, type)|
- fields, all_fields = all_fields, all_fields - current_fields
+ fields = all_fields
+ all_fields = all_fields - current_fields
aggregate.grouped_by fields, type, current_fields
end
result or query.result
@@ -60,7 +63,9 @@ class Report::Transformer
# Important side effect: it sets @ungrouped, @all_fields.
# @return [Array, Symbol>>] Group by fields + types (:row or :column)
def restructured
- rows, columns, current = [], [], query.chain
+ rows = []
+ columns = []
+ current = query.chain
@all_fields = []
until current.filter?
@ungrouped = current.result if current.responsible_for_sql?
diff --git a/modules/reporting/lib/report/validation.rb b/modules/reporting/lib/report/validation.rb
index 2a9def7396..9f4b25764b 100644
--- a/modules/reporting/lib/report/validation.rb
+++ b/modules/reporting/lib/report/validation.rb
@@ -63,6 +63,7 @@ module Report::Validation
def validate(*values)
errors.clear
return true if validations.empty?
+
validations.all? do |validation|
values.empty? ? true : send(validation, *values)
end
diff --git a/modules/reporting/lib/report/validation/dates.rb b/modules/reporting/lib/report/validation/dates.rb
index 8009528ae8..579818f547 100644
--- a/modules/reporting/lib/report/validation/dates.rb
+++ b/modules/reporting/lib/report/validation/dates.rb
@@ -31,14 +31,13 @@ module Report::Validation
def validate_dates(*values)
values = values.flatten
return true if values.empty?
+
values.flatten.all? do |val|
- begin
- !!val.to_dateish
- rescue ArgumentError
- errors[:date] << val
- validate_dates(values - [val])
- false
- end
+ !!val.to_dateish
+ rescue ArgumentError
+ errors[:date] << val
+ validate_dates(values - [val])
+ false
end
end
end
diff --git a/modules/reporting/lib/report/validation/integers.rb b/modules/reporting/lib/report/validation/integers.rb
index 9d7dc927e7..35579fa268 100644
--- a/modules/reporting/lib/report/validation/integers.rb
+++ b/modules/reporting/lib/report/validation/integers.rb
@@ -31,6 +31,7 @@ module Report::Validation
def validate_integers(*values)
values = values.flatten
return true if values.empty?
+
values.flatten.all? do |val|
if val.to_i.to_s != val.to_s
errors[:int] << val
diff --git a/modules/reporting/lib/report/walker.rb b/modules/reporting/lib/report/walker.rb
index 6d6e9adb7c..0616a6a995 100644
--- a/modules/reporting/lib/report/walker.rb
+++ b/modules/reporting/lib/report/walker.rb
@@ -28,6 +28,7 @@
class Report::Walker
attr_accessor :query, :header_stack
+
def initialize(query)
@query = query
end
@@ -68,6 +69,7 @@ class Report::Walker
sublevel = 0
result.recursive_each_with_level(0, false) do |level, result|
break if result.final_column?
+
if first_in_col = (last_level < level)
list = []
last_level = level
@@ -86,6 +88,7 @@ class Report::Walker
def reverse_headers
fail 'call header first' unless @header_stack
+
first = true
@header_stack.reverse_each do |list|
list.each do |result, first_in_col, last_in_col|
@@ -97,6 +100,7 @@ class Report::Walker
def headers_empty?
fail 'call header first' unless @header_stack
+
@header_stack.empty?
end
@@ -109,8 +113,9 @@ class Report::Walker
result.sort!
end
- def body(result = nil)
- return [*body(result)].each { |a| yield a } if block_given?
+ def body(result = nil, &block)
+ return [*body(result)].each(&block) if block_given?
+
result ||= query.result.tap { |r| sort(r) }
if result.row?
if result.final_row?
diff --git a/modules/reporting/lib/widget/controls/apply.rb b/modules/reporting/lib/widget/controls/apply.rb
index d7e2233033..3f4dbbb8b8 100644
--- a/modules/reporting/lib/widget/controls/apply.rb
+++ b/modules/reporting/lib/widget/controls/apply.rb
@@ -32,6 +32,6 @@ class Widget::Controls::Apply < Widget::Controls
'#',
id: 'query-icon-apply-button',
class: 'button -highlight',
- :'data-target' => url_for(action: 'index', set_filter: '1'))
+ 'data-target': url_for(action: 'index', set_filter: '1'))
end
end
diff --git a/modules/reporting/lib/widget/controls/delete.rb b/modules/reporting/lib/widget/controls/delete.rb
index d7b776be91..1858a99f08 100644
--- a/modules/reporting/lib/widget/controls/delete.rb
+++ b/modules/reporting/lib/widget/controls/delete.rb
@@ -29,6 +29,7 @@
class Widget::Controls::Delete < Widget::Controls
def render
return '' if @subject.new_record? or !@options[:can_delete]
+
button = link_to(I18n.t(:button_delete),
'#',
id: 'query-icon-delete',
diff --git a/modules/reporting/lib/widget/controls/save.rb b/modules/reporting/lib/widget/controls/save.rb
index ade8a301ec..1174391da4 100644
--- a/modules/reporting/lib/widget/controls/save.rb
+++ b/modules/reporting/lib/widget/controls/save.rb
@@ -29,10 +29,11 @@
class Widget::Controls::Save < Widget::Controls
def render
return '' if @subject.new_record? or !@options[:can_save]
+
write link_to(I18n.t(:button_save),
'#',
id: 'query-breadcrumb-save',
class: 'button icon-context icon-save',
- :"data-target" => url_for(action: 'update', id: @subject.id, set_filter: '1'))
+ "data-target": url_for(action: 'update', id: @subject.id, set_filter: '1'))
end
end
diff --git a/modules/reporting/lib/widget/controls/save_as.rb b/modules/reporting/lib/widget/controls/save_as.rb
index 4bb2bfc8f1..8a63b025d7 100644
--- a/modules/reporting/lib/widget/controls/save_as.rb
+++ b/modules/reporting/lib/widget/controls/save_as.rb
@@ -50,31 +50,31 @@ class Widget::Controls::SaveAs < Widget::Controls
class: 'form--label -transparent') do
Query.human_attribute_name(:name).html_safe
end +
- content_tag(:span,
- class: 'form--field-container') do
content_tag(:span,
- class: 'form--text-field-container') do
- text_field_tag(:query_name,
- @subject.name,
- required: true)
+ class: 'form--field-container') do
+ content_tag(:span,
+ class: 'form--text-field-container') do
+ text_field_tag(:query_name,
+ @subject.name,
+ required: true)
+ end
end
- end
end
if @options[:can_save_as_public]
box = content_tag :p, class: 'form--field -wide-label' do
label_tag(:query_is_public,
Query.human_attribute_name(:is_public),
class: 'form--label -transparent') +
- content_tag(:span,
- class: 'form--field-container') do
content_tag(:span,
- class: 'form--check-box-container') do
- check_box_tag(:query_is_public,
- 1,
- false,
- class: 'form--check-box')
+ class: 'form--field-container') do
+ content_tag(:span,
+ class: 'form--check-box-container') do
+ check_box_tag(:query_is_public,
+ 1,
+ false,
+ class: 'form--check-box')
+ end
end
- end
end
name + box
else
@@ -90,7 +90,7 @@ class Widget::Controls::SaveAs < Widget::Controls
'#',
id: 'query-icon-save-button',
class: 'button -highlight icon-context icon-save',
- :"data-target" => url_for(**save_url_params))
+ "data-target": url_for(**save_url_params))
cancel = link_to(I18n.t(:button_cancel),
'#',
diff --git a/modules/reporting/lib/widget/filters.rb b/modules/reporting/lib/widget/filters.rb
index a506aa188c..55894bc726 100644
--- a/modules/reporting/lib/widget/filters.rb
+++ b/modules/reporting/lib/widget/filters.rb
@@ -35,8 +35,8 @@ class Widget::Filters < ::Widget::Base
add_filter_label = label_tag 'add_filter_select', I18n.t(:label_filter_add),
class: 'advanced-filters--add-filter-label'
add_filter_label += label_tag 'add_filter_select', I18n.t('js.filter.description.text_open_filter') + ' ' +
- I18n.t('js.filter.description.text_close_filter'),
- class: 'hidden-for-sighted'
+ I18n.t('js.filter.description.text_close_filter'),
+ class: 'hidden-for-sighted'
add_filter_value = content_tag :div, class: 'advanced-filters--add-filter-value' do
select_tag 'add_filter_select',
@@ -67,8 +67,8 @@ class Widget::Filters < ::Widget::Base
engine::Filter.all.select(&:selectable?).map do |filter|
opts = { id: "filter_#{filter.underscore_name}",
class: "#{filter.underscore_name} advanced-filters--filter",
- :"data-filter-name" => filter.underscore_name }
- active_instance = active_filters.detect { |f| f.class == filter }
+ "data-filter-name": filter.underscore_name }
+ active_instance = active_filters.detect { |f| f.instance_of?(filter) }
if active_instance
opts[:"data-selected"] = true
else
@@ -97,12 +97,10 @@ class Widget::Filters < ::Widget::Base
else
render_widget MultiValues, f, to: html, lazy: true
end
+ elsif f_cls.is_multiple_choice?
+ render_widget MultiChoice, f, to: html
else
- if f_cls.is_multiple_choice?
- render_widget MultiChoice, f, to: html
- else
- render_widget MultiValues, f, to: html, lazy: true
- end
+ render_widget MultiValues, f, to: html, lazy: true
end
render_widget RemoveButton, f, to: html
end
diff --git a/modules/reporting/lib/widget/filters/base.rb b/modules/reporting/lib/widget/filters/base.rb
index d68ded18aa..2b36280ea0 100644
--- a/modules/reporting/lib/widget/filters/base.rb
+++ b/modules/reporting/lib/widget/filters/base.rb
@@ -30,7 +30,7 @@ class Widget::Filters::Base < Widget::Base
attr_reader :filter, :filter_class
def initialize(filter)
- if filter.class == Class
+ if filter.instance_of?(Class)
@filter_class = filter
@filter = filter.new
else
diff --git a/modules/reporting/lib/widget/filters/date.rb b/modules/reporting/lib/widget/filters/date.rb
index b38ca935d2..1eebc90ab9 100644
--- a/modules/reporting/lib/widget/filters/date.rb
+++ b/modules/reporting/lib/widget/filters/date.rb
@@ -46,7 +46,7 @@ class Widget::Filters::Date < Widget::Filters::Base
size: 10,
class: 'advanced-filters--text-field -augmented-datepicker',
id: "#{id_prefix}arg_1_val",
- :'data-type' => 'date'
+ 'data-type': 'date'
label1 + text1
end
@@ -55,11 +55,11 @@ class Widget::Filters::Date < Widget::Filters::Base
class: 'hidden-for-sighted'
arg2 = content_tag :span, id: "#{id_prefix}arg_2", class: 'advanced-filters--filter-value2' do
- text2 = text_field_tag "#{name}", @filter.values.second.to_s,
+ text2 = text_field_tag name.to_s, @filter.values.second.to_s,
size: 10,
class: 'advanced-filters--text-field -augmented-datepicker',
id: "#{id_prefix}arg_2_val",
- :'data-type' => 'date'
+ 'data-type': 'date'
label2 + text2
end
diff --git a/modules/reporting/lib/widget/filters/heavy.rb b/modules/reporting/lib/widget/filters/heavy.rb
index 049949ca06..b217de8b78 100644
--- a/modules/reporting/lib/widget/filters/heavy.rb
+++ b/modules/reporting/lib/widget/filters/heavy.rb
@@ -41,13 +41,13 @@ class Widget::Filters::Heavy < Widget::Filters::Base
values = filter.values.first.is_a?(Array) ? filter.values.first : filter.values
opts = Array(values).empty? ? [] : values.map { |i| filter_class.label_for_value(i.to_i) }
div = content_tag :div, id: "#{filter_class.underscore_name}_arg_1", class: 'advanced-filters--filter-value hidden' do
- select_options = { :"data-remote-url" => url_for(action: 'available_values'),
- :"data-initially-selected" => JSON::dump(Array(filter.values).flatten),
+ select_options = { "data-remote-url": url_for(action: 'available_values'),
+ "data-initially-selected": JSON::dump(Array(filter.values).flatten),
name: "values[#{filter_class.underscore_name}][]",
- :"data-loading" => '',
+ "data-loading": '',
id: "#{filter_class.underscore_name}_arg_1_val",
class: 'advanced-filters--select filter-value',
- :"data-filter-name" => filter_class.underscore_name }
+ "data-filter-name": filter_class.underscore_name }
box = content_tag :select, select_options do
render_widget Widget::Filters::Option, filter, to: '', content: opts
end
diff --git a/modules/reporting/lib/widget/filters/label.rb b/modules/reporting/lib/widget/filters/label.rb
index 633b64c5f9..7f755105c9 100644
--- a/modules/reporting/lib/widget/filters/label.rb
+++ b/modules/reporting/lib/widget/filters/label.rb
@@ -32,7 +32,7 @@ require_dependency 'widget/filters/base'
class Widget::Filters::Label < Widget::Filters::Base
def render
options = {
- id: filter_class.underscore_name,
+ id: filter_class.underscore_name,
class: 'advanced-filters--filter-name',
title: h(filter_class.label)
}
diff --git a/modules/reporting/lib/widget/filters/multi_choice.rb b/modules/reporting/lib/widget/filters/multi_choice.rb
index bb013fb64d..6e569620a5 100644
--- a/modules/reporting/lib/widget/filters/multi_choice.rb
+++ b/modules/reporting/lib/widget/filters/multi_choice.rb
@@ -44,7 +44,7 @@ class Widget::Filters::MultiChoice < Widget::Filters::Base
radio_button = tag :input, opts
content_tag :label, radio_button + translate(label),
for: "#{filterName}_radio_option_#{i}",
- :'data-filter-name' => filter_class.underscore_name,
+ 'data-filter-name': filter_class.underscore_name,
class: "#{filterName}_radio_option filter_radio_option"
end
content_tag :div, choices.join.html_safe,
diff --git a/modules/reporting/lib/widget/filters/multi_values.rb b/modules/reporting/lib/widget/filters/multi_values.rb
index 56d04a34c1..6eee034131 100644
--- a/modules/reporting/lib/widget/filters/multi_values.rb
+++ b/modules/reporting/lib/widget/filters/multi_values.rb
@@ -32,14 +32,14 @@ require_dependency 'widget/filters/base'
class Widget::Filters::MultiValues < Widget::Filters::Base
def render
write(content_tag(:div, id: "#{filter_class.underscore_name}_arg_1", class: 'advanced-filters--filter-value') do
- select_options = { :"data-remote-url" => url_for(action: 'available_values'),
- :"data-initially-selected" => JSON::dump(Array(filter.values).flatten),
+ select_options = { "data-remote-url": url_for(action: 'available_values'),
+ "data-initially-selected": JSON::dump(Array(filter.values).flatten),
style: 'vertical-align: top;', # FIXME: Do CSS
name: "values[#{filter_class.underscore_name}][]",
- :"data-loading" => @options[:lazy] ? 'ajax' : '',
+ "data-loading": @options[:lazy] ? 'ajax' : '',
id: "#{filter_class.underscore_name}_arg_1_val",
class: 'form--select filter-value',
- :"data-filter-name" => filter_class.underscore_name }
+ "data-filter-name": filter_class.underscore_name }
box_content = ''.html_safe
label = label_tag "#{filter_class.underscore_name}_arg_1_val",
h(filter_class.label) + ' ' + I18n.t(:label_filter_value),
@@ -51,14 +51,14 @@ class Widget::Filters::MultiValues < Widget::Filters::Base
plus = content_tag :a,
href: '#',
class: 'form-label filter_multi-select -transparent',
- :"data-filter-name" => filter_class.underscore_name,
+ "data-filter-name": filter_class.underscore_name,
title: I18n.t(:description_multi_select) do
- content_tag :span,
- '',
- class: 'icon-context icon-button icon-add icon4',
- title: I18n.t(:label_enable_multi_select) do
- content_tag :span, I18n.t(:label_enable_multi_select), class: 'hidden-for-sighted'
- end
+ content_tag :span,
+ '',
+ class: 'icon-context icon-button icon-add icon4',
+ title: I18n.t(:label_enable_multi_select) do
+ content_tag :span, I18n.t(:label_enable_multi_select), class: 'hidden-for-sighted'
+ end
end
content_tag(:span, class: 'inline-label') do
diff --git a/modules/reporting/lib/widget/filters/operators.rb b/modules/reporting/lib/widget/filters/operators.rb
index 3805f89efd..ee491c5e27 100644
--- a/modules/reporting/lib/widget/filters/operators.rb
+++ b/modules/reporting/lib/widget/filters/operators.rb
@@ -36,13 +36,13 @@ class Widget::Filters::Operators < Widget::Filters::Base
options = { class: 'advanced-filters--select filters-select filter_operator',
id: "operators[#{filter_class.underscore_name}]",
name: "operators[#{filter_class.underscore_name}]",
- :"data-filter-name" => filter_class.underscore_name }
+ "data-filter-name": filter_class.underscore_name }
options.merge! style: 'display: none' if hide_select_box
select_box = content_tag :select, options do
filter_class.available_operators.map do |o|
- opts = { value: h(o.to_s), :"data-arity" => o.arity }
- opts.reverse_merge! :"data-forced" => o.forced if o.forced?
+ opts = { value: h(o.to_s), "data-arity": o.arity }
+ opts.reverse_merge! "data-forced": o.forced if o.forced?
opts[:selected] = 'selected' if filter.operator.to_s == o.to_s
content_tag(:option, opts) { h(I18n.t(o.label)) }
end.join.html_safe
diff --git a/modules/reporting/lib/widget/filters/option.rb b/modules/reporting/lib/widget/filters/option.rb
index f461c4c26b..338b284763 100644
--- a/modules/reporting/lib/widget/filters/option.rb
+++ b/modules/reporting/lib/widget/filters/option.rb
@@ -41,7 +41,7 @@ class Widget::Filters::Option < Widget::Filters::Base
level = options[:level] # nesting_level is optional for values
name = I18n.t(name) if name.is_a? Symbol
name = name.empty? ? I18n.t(:label_none) : name
- name_prefix = ((level && level > 0) ? (' ' * 2 * level + '> ') : '')
+ name_prefix = (level && level > 0 ? (' ' * 2 * level + '> ') : '')
if options[:optgroup]
tag :optgroup, label: I18n.t(:label_sector)
else
diff --git a/modules/reporting/lib/widget/filters/text_box.rb b/modules/reporting/lib/widget/filters/text_box.rb
index c965a1f40f..45c4c1af93 100644
--- a/modules/reporting/lib/widget/filters/text_box.rb
+++ b/modules/reporting/lib/widget/filters/text_box.rb
@@ -41,7 +41,7 @@ class Widget::Filters::TextBox < Widget::Filters::Base
size: '6',
class: 'advanced-filters--text-field',
id: "#{filter_class.underscore_name}_arg_1_val",
- :'data-filter-name' => filter_class.underscore_name)
+ 'data-filter-name': filter_class.underscore_name)
end)
end
end
diff --git a/modules/reporting/lib/widget/group_bys.rb b/modules/reporting/lib/widget/group_bys.rb
index 743ea5fac5..bf3299516b 100644
--- a/modules/reporting/lib/widget/group_bys.rb
+++ b/modules/reporting/lib/widget/group_bys.rb
@@ -30,7 +30,8 @@ class Widget::GroupBys < Widget::Base
def render_options(group_by_ary)
group_by_ary.sort_by(&:label).map do |group_by|
next unless group_by.selectable?
- content_tag :option, value: group_by.underscore_name, :'data-label' => "#{CGI::escapeHTML(h(group_by.label))}" do
+
+ content_tag :option, value: group_by.underscore_name, 'data-label': CGI::escapeHTML(h(group_by.label)).to_s do
h(group_by.label)
end
end.join.html_safe
@@ -47,7 +48,7 @@ class Widget::GroupBys < Widget::Base
container = content_tag :div,
id: "group-by--#{type}",
class: 'group-by--container grid-block',
- :'data-initially-selected' => initially_selected.to_json.gsub('"', "'") do
+ 'data-initially-selected': initially_selected.to_json.gsub('"', "'") do
out = content_tag :span, class: 'group-by--caption grid-content shrink' do
content_tag :span do
I18n.t(:"label_#{type}")
@@ -59,7 +60,7 @@ class Widget::GroupBys < Widget::Base
out += content_tag :span,
class: 'group-by--control grid-content shrink' do
label = label_tag "group-by--add-#{type}",
- I18n.t(:"label_group_by_add") + ' ' +
+ I18n.t(:label_group_by_add) + ' ' +
I18n.t('js.filter.description.text_open_filter'),
class: 'hidden-for-sighted'
diff --git a/modules/reporting/lib/widget/reporting_widget.rb b/modules/reporting/lib/widget/reporting_widget.rb
index ed01dd2b55..ec6ad7b601 100644
--- a/modules/reporting/lib/widget/reporting_widget.rb
+++ b/modules/reporting/lib/widget/reporting_widget.rb
@@ -73,5 +73,5 @@ class Widget::ReportingWidget < ActionView::Base
end
end
-ActionView::Base.send(:include, Widget::ReportingWidget::RenderWidgetInstanceMethods)
-ActionController::Base.send(:include, Widget::ReportingWidget::RenderWidgetInstanceMethods)
+ActionView::Base.include Widget::ReportingWidget::RenderWidgetInstanceMethods
+ActionController::Base.include Widget::ReportingWidget::RenderWidgetInstanceMethods
diff --git a/modules/reporting/lib/widget/settings/fieldset.rb b/modules/reporting/lib/widget/settings/fieldset.rb
index fadb5b7adb..6f045f6e69 100644
--- a/modules/reporting/lib/widget/settings/fieldset.rb
+++ b/modules/reporting/lib/widget/settings/fieldset.rb
@@ -31,7 +31,7 @@ class Widget::Settings::Fieldset < Widget::Base
def render_with_options(options, &block)
@type = options.delete(:type) || 'filter'
- @id = "#{@type}"
+ @id = @type.to_s
@label = :"label_#{@type}"
super(options, &block)
end
diff --git a/modules/reporting/lib/widget/settings_patch.rb b/modules/reporting/lib/widget/settings_patch.rb
index 287d3d7b26..23609faa16 100644
--- a/modules/reporting/lib/widget/settings_patch.rb
+++ b/modules/reporting/lib/widget/settings_patch.rb
@@ -58,4 +58,4 @@ module Widget::SettingsPatch
end
end
-Widget::Settings.send(:include, Widget::SettingsPatch)
+Widget::Settings.include Widget::SettingsPatch
diff --git a/modules/reporting/lib/widget/table.rb b/modules/reporting/lib/widget/table.rb
index ef7ebe0f0f..6750235fbf 100644
--- a/modules/reporting/lib/widget/table.rb
+++ b/modules/reporting/lib/widget/table.rb
@@ -30,12 +30,11 @@ class Widget::Table < Widget::Base
extend Report::InheritedAttribute
include ReportingHelper
- attr_accessor :debug
- attr_accessor :fields
- attr_accessor :mapping
+ attr_accessor :debug, :fields, :mapping
def initialize(query)
raise ArgumentError, 'Tables only work on CostQuery!' unless query.is_a? CostQuery
+
super
end
diff --git a/modules/reporting/lib/widget/table/entry_table.rb b/modules/reporting/lib/widget/table/entry_table.rb
index 41a21c8aad..e1b6f1b837 100644
--- a/modules/reporting/lib/widget/table/entry_table.rb
+++ b/modules/reporting/lib/widget/table/entry_table.rb
@@ -27,7 +27,7 @@
#++
class ::Widget::Table::EntryTable < ::Widget::Table
- FIELDS = [:spent_on, :user_id, :activity_id, :work_package_id, :comments, :project_id]
+ FIELDS = %i[spent_on user_id activity_id work_package_id comments project_id]
detailed_table self
@@ -87,6 +87,7 @@ class ::Widget::Table::EntryTable < ::Widget::Table
hit = false
@subject.each_direct_result do |result|
next if hit
+
if entry_for(result).editable_by? User.current
concat content_tag(:th, class: 'unsortable') {
content_tag(:div, '', class: 'generic-table--empty-header')
@@ -134,16 +135,16 @@ class ::Widget::Table::EntryTable < ::Widget::Table
''.html_safe
FIELDS.each do |field|
concat content_tag(:td, show_field(field, result.fields[field.to_s]).html_safe,
- :'raw-data' => raw_field(field, result.fields[field.to_s]),
+ 'raw-data': raw_field(field, result.fields[field.to_s]),
class: 'left')
end
concat content_tag :td, show_result(result, result.fields['cost_type_id'].to_i).html_safe,
class: 'units right',
- :'raw-data' => result.units
+ 'raw-data': result.units
concat content_tag :td,
- (show_result(result, 0)).html_safe,
+ show_result(result, 0).html_safe,
class: 'currency right',
- :'raw-data' => result.real_costs
+ 'raw-data': result.real_costs
concat content_tag :td, icons(result)
end)
end
@@ -162,8 +163,8 @@ class ::Widget::Table::EntryTable < ::Widget::Table
title: I18n.t(:button_edit))
icons << link_to(icon_wrapper('icon-context icon-delete', I18n.t(:button_delete)),
- (action_for(result, action: 'destroy')
- .reverse_merge(authenticity_token: form_authenticity_token)),
+ action_for(result, action: 'destroy')
+ .reverse_merge(authenticity_token: form_authenticity_token),
data: { confirm: I18n.t(:text_are_you_sure) },
method: :delete,
class: 'no-decoration-on-hover',
diff --git a/modules/reporting/lib/widget/table/report_table.rb b/modules/reporting/lib/widget/table/report_table.rb
index 4f3c4226e7..6b695d167c 100644
--- a/modules/reporting/lib/widget/table/report_table.rb
+++ b/modules/reporting/lib/widget/table/report_table.rb
@@ -130,6 +130,7 @@ class Widget::Table::ReportTable < Widget::Table
def render_tfoot
return if walker.headers_empty?
+
write ''
walker.reverse_headers do |list, first, first_in_col, last_in_col|
if first_in_col
diff --git a/modules/reporting/spec/controllers/custom_fields_controller_spec.rb b/modules/reporting/spec/controllers/custom_fields_controller_spec.rb
index db504a3446..e37404fc29 100644
--- a/modules/reporting/spec/controllers/custom_fields_controller_spec.rb
+++ b/modules/reporting/spec/controllers/custom_fields_controller_spec.rb
@@ -121,14 +121,14 @@ describe CustomFieldsController do
context 'session' do
let(:engine_name) { CostQuery.name.underscore.to_sym }
let(:key) { :"custom_field#{custom_field.id}" }
- let(:query) { { filters:
+ let(:query) do
+ { filters:
{
operators: { user_id: "=", key => "=" },
values: { user_id: ["96"], key => "" }
},
- groups: { rows: [key.to_s], columns: [key.to_s] }
- }
- }
+ groups: { rows: [key.to_s], columns: [key.to_s] } }
+ end
before { session[engine_name] = query }
describe 'does not contain custom field reference' do
diff --git a/modules/reporting/spec/features/calculations_spec.rb b/modules/reporting/spec/features/calculations_spec.rb
index dfe7b5e19a..06abba7640 100644
--- a/modules/reporting/spec/features/calculations_spec.rb
+++ b/modules/reporting/spec/features/calculations_spec.rb
@@ -9,41 +9,40 @@ describe 'Cost report calculations', type: :feature, js: true do
let!(:hourly_rate2) { FactoryBot.create :default_hourly_rate, user: user, rate: 5.00, valid_from: 2.years.ago }
let!(:hourly_rate3) { FactoryBot.create :default_hourly_rate, user: user, rate: 10.00, valid_from: 3.years.ago }
- let!(:time_entry1) {
+ let!(:time_entry1) do
FactoryBot.create :time_entry,
- spent_on: 6.months.ago,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
- let!(:time_entry2) {
+ spent_on: 6.months.ago,
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
+ let!(:time_entry2) do
FactoryBot.create :time_entry,
- spent_on: 18.months.ago,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
- let!(:time_entry3) {
+ spent_on: 18.months.ago,
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
+ let!(:time_entry3) do
FactoryBot.create :time_entry,
- spent_on: 30.months.ago,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
+ spent_on: 30.months.ago,
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
before do
login_as(user)
visit '/cost_reports?set_filter=1'
end
-
it 'shows the correct calculations' do
expect(page).to have_text '10.00' # 1 EUR x 10
expect(page).to have_text '50.00' # 5 EUR x 10
expect(page).to have_text '100.00' # 10 EUR x 10
expect(page).to have_text '160.00'
end
-end
\ No newline at end of file
+end
diff --git a/modules/reporting/spec/features/custom_fields_spec.rb b/modules/reporting/spec/features/custom_fields_spec.rb
index d378a36e8f..1f1ceed431 100644
--- a/modules/reporting/spec/features/custom_fields_spec.rb
+++ b/modules/reporting/spec/features/custom_fields_spec.rb
@@ -57,7 +57,6 @@ describe 'Custom fields reporting', type: :feature, js: true do
hours: 2.50
end
-
def custom_value_for(cf, str)
cf.custom_options.find { |co| co.value == str }.try(:id)
end
@@ -130,7 +129,7 @@ describe 'Custom fields reporting', type: :feature, js: true do
# Expect row of work package
within('#result-table') do
- expect(page).to have_selector('a.issue', text: "#{work_package.type.to_s} ##{work_package.id}")
+ expect(page).to have_selector('a.issue', text: "#{work_package.type} ##{work_package.id}")
expect(page).to have_selector('th.inner', text: 'First option')
expect(page).to have_no_selector('th.inner', text: 'Second option')
@@ -159,7 +158,7 @@ describe 'Custom fields reporting', type: :feature, js: true do
let!(:work_package2) do
FactoryBot.create :work_package,
project: project,
- custom_values: { custom_field_2.id => custom_value_for(custom_field_2, 'A')}
+ custom_values: { custom_field_2.id => custom_value_for(custom_field_2, 'A') }
end
let!(:time_entry1) do
@@ -191,7 +190,7 @@ describe 'Custom fields reporting', type: :feature, js: true do
# Expect row of work package
within('#result-table') do
- expect(page).to have_selector('a.issue', text: "#{work_package.type.to_s} ##{work_package.id}")
+ expect(page).to have_selector('a.issue', text: "#{work_package.type} ##{work_package.id}")
expect(page).to have_selector('th.inner', text: '1')
expect(page).to have_no_selector('th.inner', text: 'invalid!')
end
@@ -224,7 +223,7 @@ describe 'Custom fields reporting', type: :feature, js: true do
# Expect row of work package
within('#result-table') do
- expect(page).to have_selector('a.issue', text: "#{work_package.type.to_s} ##{work_package.id}")
+ expect(page).to have_selector('a.issue', text: "#{work_package.type} ##{work_package.id}")
expect(page).to have_selector('th.inner', text: 'foo')
expect(page).to have_no_selector('th.inner', text: 'None')
diff --git a/modules/reporting/spec/features/filter_spec.rb b/modules/reporting/spec/features/filter_spec.rb
index 045fdacc53..b17d510f4d 100644
--- a/modules/reporting/spec/features/filter_spec.rb
+++ b/modules/reporting/spec/features/filter_spec.rb
@@ -32,4 +32,4 @@ describe 'Cost report calculations', type: :feature, js: true do
expect(page).to have_selector("#user_id_arg_1_val", text: 'me')
end
-end
\ No newline at end of file
+end
diff --git a/modules/reporting/spec/features/group_by_spec.rb b/modules/reporting/spec/features/group_by_spec.rb
index daf6733dd8..eaf7cb8b99 100644
--- a/modules/reporting/spec/features/group_by_spec.rb
+++ b/modules/reporting/spec/features/group_by_spec.rb
@@ -8,109 +8,108 @@ describe 'Cost report calculations', type: :feature, js: true do
let(:work_package) { FactoryBot.create :work_package, project: project }
let!(:hourly_rate1) { FactoryBot.create :default_hourly_rate, user: user, rate: 1.00, valid_from: 1.year.ago }
- let(:report_page) { ::Pages::CostReportPage.new project}
+ let(:report_page) { ::Pages::CostReportPage.new project }
- let!(:time_entry1) {
+ let!(:time_entry1) do
FactoryBot.create :time_entry,
- spent_on: 6.months.ago,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
+ spent_on: 6.months.ago,
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
before do
login_as(user)
visit cost_reports_path(project)
end
-
it 'provides grouping' do
- # Then I should see "Week (Spent)" in columns
- # And I should see "Work package" in rows
- report_page.expect_column_element('Week (Spent)')
- report_page.expect_row_element('Work package')
-
- # When I click on "Clear"
- report_page.clear
- # Then I should not see "Week (Spent)" in columns
- # And I should not see "Work package" in rows
- report_page.expect_column_element('Week (Spent)', present: false)
- report_page.expect_row_element('Work package', present: false)
-
- # And I group rows by "User"
- report_page.add_to_rows 'User'
- # And I group rows by "Cost type"
- report_page.add_to_rows 'Cost type'
-
- # When I click on "Clear"
- report_page.clear
-
- # Then I should not see "Week (Spent)" in columns
- # And I should not see "Work package" in rows
- report_page.expect_column_element('Week (Spent)', present: false)
- report_page.expect_row_element('Work package', present: false)
- # And I should not see "User" in rows
- # And I should not see "Cost type" in rows
- report_page.expect_row_element('User', present: false)
- report_page.expect_row_element('Cost type', present: false)
-
- # When I click on "Clear"
- report_page.clear
- # And I group columns by "Work package"
- report_page.add_to_columns 'Work package'
-
- # Then I should see "Work package" in columns
- report_page.expect_column_element('Work package')
- # When I group rows by "Project"
- report_page.add_to_columns 'Project'
- # Then I should see "Project" in rows
- report_page.expect_column_element('Project')
-
- # When I click on "Clear"
- report_page.clear
- # And I group columns by "Work package"
- report_page.add_to_columns 'Work package'
- # And I group rows by "Project"
- report_page.add_to_rows 'Project'
-
- # Then I should see "Work package" in columns
- report_page.expect_column_element('Work package')
- # And I should see "Project" in rows
- report_page.expect_row_element('Project')
-
- # When I remove "Project" from rows
- report_page.remove_row_element('Project')
-
- # And I remove "Work package" from columns
- report_page.remove_column_element('Work package')
-
- # Then I should not see "Work package" in columns
- report_page.expect_column_element('Work package', present: false)
- # And I should not see "Project" in rows
- report_page.expect_row_element('Project', present: false)
-
- # When I click on "Clear"
- report_page.clear
-
- # And I group columns by "Project"
- report_page.add_to_columns 'Project'
- # And I group columns by "Work package"
- report_page.add_to_columns 'Work package'
- # And I group rows by "User"
- report_page.add_to_rows 'User'
- # And I group rows by "Cost type"
- report_page.add_to_rows 'Cost type'
-
- # And I send the query
- report_page.apply
-
- # Then I should see "Project" in columns
- report_page.expect_column_element('Work package')
- # And I should see "Work package" in columns
- report_page.expect_column_element('Project')
- # And I should see "User" in rows
- report_page.expect_row_element('User')
- # And I should see "Cost type" in rows
- report_page.expect_row_element('Cost type')
+ # Then I should see "Week (Spent)" in columns
+ # And I should see "Work package" in rows
+ report_page.expect_column_element('Week (Spent)')
+ report_page.expect_row_element('Work package')
+
+ # When I click on "Clear"
+ report_page.clear
+ # Then I should not see "Week (Spent)" in columns
+ # And I should not see "Work package" in rows
+ report_page.expect_column_element('Week (Spent)', present: false)
+ report_page.expect_row_element('Work package', present: false)
+
+ # And I group rows by "User"
+ report_page.add_to_rows 'User'
+ # And I group rows by "Cost type"
+ report_page.add_to_rows 'Cost type'
+
+ # When I click on "Clear"
+ report_page.clear
+
+ # Then I should not see "Week (Spent)" in columns
+ # And I should not see "Work package" in rows
+ report_page.expect_column_element('Week (Spent)', present: false)
+ report_page.expect_row_element('Work package', present: false)
+ # And I should not see "User" in rows
+ # And I should not see "Cost type" in rows
+ report_page.expect_row_element('User', present: false)
+ report_page.expect_row_element('Cost type', present: false)
+
+ # When I click on "Clear"
+ report_page.clear
+ # And I group columns by "Work package"
+ report_page.add_to_columns 'Work package'
+
+ # Then I should see "Work package" in columns
+ report_page.expect_column_element('Work package')
+ # When I group rows by "Project"
+ report_page.add_to_columns 'Project'
+ # Then I should see "Project" in rows
+ report_page.expect_column_element('Project')
+
+ # When I click on "Clear"
+ report_page.clear
+ # And I group columns by "Work package"
+ report_page.add_to_columns 'Work package'
+ # And I group rows by "Project"
+ report_page.add_to_rows 'Project'
+
+ # Then I should see "Work package" in columns
+ report_page.expect_column_element('Work package')
+ # And I should see "Project" in rows
+ report_page.expect_row_element('Project')
+
+ # When I remove "Project" from rows
+ report_page.remove_row_element('Project')
+
+ # And I remove "Work package" from columns
+ report_page.remove_column_element('Work package')
+
+ # Then I should not see "Work package" in columns
+ report_page.expect_column_element('Work package', present: false)
+ # And I should not see "Project" in rows
+ report_page.expect_row_element('Project', present: false)
+
+ # When I click on "Clear"
+ report_page.clear
+
+ # And I group columns by "Project"
+ report_page.add_to_columns 'Project'
+ # And I group columns by "Work package"
+ report_page.add_to_columns 'Work package'
+ # And I group rows by "User"
+ report_page.add_to_rows 'User'
+ # And I group rows by "Cost type"
+ report_page.add_to_rows 'Cost type'
+
+ # And I send the query
+ report_page.apply
+
+ # Then I should see "Project" in columns
+ report_page.expect_column_element('Work package')
+ # And I should see "Work package" in columns
+ report_page.expect_column_element('Project')
+ # And I should see "User" in rows
+ report_page.expect_row_element('User')
+ # And I should see "Cost type" in rows
+ report_page.expect_row_element('Cost type')
end
-end
\ No newline at end of file
+end
diff --git a/modules/reporting/spec/features/me_value_spec.rb b/modules/reporting/spec/features/me_value_spec.rb
index 77dfd973cb..29e4c89bcf 100644
--- a/modules/reporting/spec/features/me_value_spec.rb
+++ b/modules/reporting/spec/features/me_value_spec.rb
@@ -8,20 +8,20 @@ describe 'Cost report showing my own times', type: :feature, js: true do
let(:work_package) { FactoryBot.create :work_package, project: project }
let!(:hourly_rate1) { FactoryBot.create :default_hourly_rate, user: user, rate: 1.00, valid_from: 1.year.ago }
- let!(:time_entry1) {
+ let!(:time_entry1) do
FactoryBot.create :time_entry,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
- let!(:time_entry2) {
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
+ let!(:time_entry2) do
FactoryBot.create :time_entry,
user: user2,
work_package: work_package,
project: project,
hours: 15
- }
+ end
before do
# Login as first user
@@ -29,7 +29,6 @@ describe 'Cost report showing my own times', type: :feature, js: true do
# Create and save cost report
visit cost_reports_path(project)
-
end
shared_examples 'me filter value' do |filter_name, filter_selector|
@@ -43,7 +42,7 @@ describe 'Cost report showing my own times', type: :feature, js: true do
expect(page).to have_selector('.report', text: '10.00')
report = CostQuery.last
- user_filter = report.serialized[:filters].detect { |name,_| name == filter_name }
+ user_filter = report.serialized[:filters].detect { |name, _| name == filter_name }
expect(user_filter[1][:values]).to eq %w(me)
# Login as the next user
@@ -62,21 +61,20 @@ describe 'Cost report showing my own times', type: :feature, js: true do
let(:work_package) { FactoryBot.create :work_package, project: project, assigned_to: user }
let(:work_package2) { FactoryBot.create :work_package, project: project, assigned_to: user2 }
- let!(:time_entry1) {
+ let!(:time_entry1) do
FactoryBot.create :time_entry,
user: user,
work_package: work_package,
project: project,
hours: 10
- }
- let!(:time_entry2) {
+ end
+ let!(:time_entry2) do
FactoryBot.create :time_entry,
user: user2,
work_package: work_package2,
project: project,
hours: 15
- }
-
+ end
before do
# Remove default user filter, add assignee filter
diff --git a/modules/reporting/spec/features/my_time_spec.rb b/modules/reporting/spec/features/my_time_spec.rb
index 9ca9f3baec..0c0bf414e9 100644
--- a/modules/reporting/spec/features/my_time_spec.rb
+++ b/modules/reporting/spec/features/my_time_spec.rb
@@ -8,20 +8,19 @@ describe 'Cost report showing my own times', type: :feature, js: true do
let(:work_package) { FactoryBot.create :work_package, project: project }
let!(:hourly_rate1) { FactoryBot.create :default_hourly_rate, user: user, rate: 1.00, valid_from: 1.year.ago }
- let!(:time_entry1) {
+ let!(:time_entry1) do
FactoryBot.create :time_entry,
- user: user,
- work_package: work_package,
- project: project,
- hours: 10
- }
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
before do
login_as(current_user)
visit cost_reports_path(project)
end
-
context 'as user with logged time' do
let(:current_user) { user }
it 'shows my time' do
diff --git a/modules/reporting/spec/features/permissions_spec.rb b/modules/reporting/spec/features/permissions_spec.rb
index 043c15c693..0d04e539b1 100644
--- a/modules/reporting/spec/features/permissions_spec.rb
+++ b/modules/reporting/spec/features/permissions_spec.rb
@@ -9,8 +9,8 @@ describe 'Cost report calculations', type: :feature, js: true do
let!(:role) { FactoryBot.create :role, permissions: permissions }
let!(:user) do
FactoryBot.create :user,
- member_in_project: project,
- member_through_role: role
+ member_in_project: project,
+ member_through_role: role
end
let(:work_package) { FactoryBot.create :work_package, project: project }
@@ -19,33 +19,33 @@ describe 'Cost report calculations', type: :feature, js: true do
let(:report_page) { ::Pages::CostReportPage.new project }
- let!(:time_entry_user) {
+ let!(:time_entry_user) do
FactoryBot.create :time_entry,
- user: admin,
- work_package: work_package,
- project: project,
- hours: 10
- }
- let!(:time_entry_admin) {
+ user: admin,
+ work_package: work_package,
+ project: project,
+ hours: 10
+ end
+ let!(:time_entry_admin) do
FactoryBot.create :time_entry,
- user: user,
- work_package: work_package,
- project: project,
- hours: 5
- }
- let!(:cost_type) {
+ user: user,
+ work_package: work_package,
+ project: project,
+ hours: 5
+ end
+ let!(:cost_type) do
type = FactoryBot.create :cost_type, name: 'Translations'
FactoryBot.create :cost_rate, cost_type: type, rate: 7.00
type
- }
- let!(:cost_entry_user) {
+ end
+ let!(:cost_entry_user) do
FactoryBot.create :cost_entry,
- work_package: work_package,
- project: project,
- units: 3.00,
- cost_type: cost_type,
- user: user
- }
+ work_package: work_package,
+ project: project,
+ units: 3.00,
+ cost_type: cost_type,
+ user: user
+ end
before do
login_as current_user
@@ -77,7 +77,7 @@ describe 'Cost report calculations', type: :feature, js: true do
context 'as user with all permissions' do
let(:current_user) { user }
let!(:permissions) do
- %i(view_own_hourly_rate view_hourly_rates view_cost_rates
+ %i(view_own_hourly_rate view_hourly_rates view_cost_rates
view_own_time_entries view_own_cost_entries view_cost_entries
view_time_entries)
end
@@ -102,7 +102,7 @@ describe 'Cost report calculations', type: :feature, js: true do
context 'as user with own permissions' do
let(:current_user) { user }
let!(:permissions) do
- %i(view_own_hourly_rate view_own_time_entries view_own_cost_entries)
+ %i(view_own_hourly_rate view_own_time_entries view_own_cost_entries)
end
it 'shows his own costs' do
diff --git a/modules/reporting/spec/features/project_context_spec.rb b/modules/reporting/spec/features/project_context_spec.rb
index 21d0a06a19..265d38d0cc 100644
--- a/modules/reporting/spec/features/project_context_spec.rb
+++ b/modules/reporting/spec/features/project_context_spec.rb
@@ -21,4 +21,4 @@ describe 'Cost report project context', type: :feature, js: true do
visit cost_reports_path(project2)
expect(page).to have_selector('#project_id_arg_1_val option', text: project2.name)
end
-end
\ No newline at end of file
+end
diff --git a/modules/reporting/spec/features/saving_spec.rb b/modules/reporting/spec/features/saving_spec.rb
index 5a8e2d1f71..4a3a86b9b5 100644
--- a/modules/reporting/spec/features/saving_spec.rb
+++ b/modules/reporting/spec/features/saving_spec.rb
@@ -50,8 +50,8 @@ describe 'Cost report saving', type: :feature, js: true do
let(:role) { FactoryBot.create :role, permissions: %i(view_time_entries) }
let!(:user) do
FactoryBot.create :user,
- member_in_project: project,
- member_through_role: role
+ member_in_project: project,
+ member_through_role: role
end
it 'cannot save reports' do
diff --git a/modules/reporting/spec/features/subproject_spec.rb b/modules/reporting/spec/features/subproject_spec.rb
index ebc5fb5673..e27eef2999 100644
--- a/modules/reporting/spec/features/subproject_spec.rb
+++ b/modules/reporting/spec/features/subproject_spec.rb
@@ -7,8 +7,8 @@ describe 'Cost report in subproject', type: :feature, js: true do
let!(:role) { FactoryBot.create :role, permissions: %i(view_cost_entries view_own_cost_entries) }
let!(:user) do
FactoryBot.create :user,
- member_in_project: subproject,
- member_through_role: role
+ member_in_project: subproject,
+ member_through_role: role
end
before do
@@ -25,4 +25,4 @@ describe 'Cost report in subproject', type: :feature, js: true do
expect(page).to have_content 'New cost report'
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
index ffe40e1ad0..0b4c419d50 100644
--- a/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
+++ b/modules/reporting/spec/features/support/components/cost_reports_base_table.rb
@@ -26,7 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
module Components
class CostReportsBaseTable
include Capybara::DSL
diff --git a/modules/reporting/spec/lib/open_project/configuration_spec.rb b/modules/reporting/spec/lib/open_project/configuration_spec.rb
index e1b1ac2b16..e0579819f8 100644
--- a/modules/reporting/spec/lib/open_project/configuration_spec.rb
+++ b/modules/reporting/spec/lib/open_project/configuration_spec.rb
@@ -47,10 +47,8 @@ describe 'OpenProject::Configuration' do
expect(OpenProject::Configuration.cost_reporting_cache_filter_classes).to be_truthy
end
-
it 'is true by default via the hash' do
expect(OpenProject::Configuration['cost_reporting_cache_filter_classes']).to be_truthy
end
-
end
end
diff --git a/modules/reporting/spec/models/cost_query/cache_spec.rb b/modules/reporting/spec/models/cost_query/cache_spec.rb
index 4a13123cd8..f3a04fbbeb 100644
--- a/modules/reporting/spec/models/cost_query/cache_spec.rb
+++ b/modules/reporting/spec/models/cost_query/cache_spec.rb
@@ -33,10 +33,10 @@ describe CostQuery::Cache do
include OpenProject::Reporting::SpecHelper::ConfigurationHelper
def all_caches
- [ CostQuery::GroupBy::CustomFieldEntries,
- CostQuery::GroupBy,
- CostQuery::Filter::CustomFieldEntries,
- CostQuery::Filter ]
+ [CostQuery::GroupBy::CustomFieldEntries,
+ CostQuery::GroupBy,
+ CostQuery::Filter::CustomFieldEntries,
+ CostQuery::Filter]
end
def expect_reset_on_caches
@@ -76,7 +76,6 @@ describe CostQuery::Cache do
end
describe '.check' do
-
context 'with cache_classes configuration enabled' do
before do
mock_cache_classes_setting_with(true)
diff --git a/modules/reporting/spec/models/cost_query/chaining_spec.rb b/modules/reporting/spec/models/cost_query/chaining_spec.rb
index 8643fd0c86..f8f5036219 100644
--- a/modules/reporting/spec/models/cost_query/chaining_spec.rb
+++ b/modules/reporting/spec/models/cost_query/chaining_spec.rb
@@ -35,7 +35,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
describe '#chain' do
before do
- #FIXME: is there a better way to load all filter and groups?
+ # FIXME: is there a better way to load all filter and groups?
CostQuery::Filter.all && CostQuery::GroupBy.all
CostQuery.chain_initializer.clear
end
@@ -95,14 +95,14 @@ describe CostQuery, type: :model, reporting_query_helper: true do
@query.filter :project_id
@query.group_by :project_id
expect(@query.filters.size).to eq(2)
- expect(@query.filters.map {|f| f.class.underscore_name}).to include "project_id"
+ expect(@query.filters.map { |f| f.class.underscore_name }).to include "project_id"
end
it "should return all group_bys" do
@query.filter :project_id
@query.group_by :project_id
expect(@query.group_bys.size).to eq(1)
- expect(@query.group_bys.map {|g| g.class.underscore_name}).to include "project_id"
+ expect(@query.group_bys.map { |g| g.class.underscore_name }).to include "project_id"
end
it "should initialize the chain through a block" do
@@ -111,10 +111,10 @@ describe CostQuery, type: :model, reporting_query_helper: true do
CostQuery
end
end
- TestFilter.send(:initialize_query_with) {|query| query.filter(:project_id, value: project.id)}
+ TestFilter.send(:initialize_query_with) { |query| query.filter(:project_id, value: project.id) }
@query.build_new_chain
- expect(@query.filters.map {|f| f.class.underscore_name}).to include "project_id"
- expect(@query.filters.detect {|f| f.class.underscore_name == "project_id"}.values).to eq(Array(project.id))
+ expect(@query.filters.map { |f| f.class.underscore_name }).to include "project_id"
+ expect(@query.filters.detect { |f| f.class.underscore_name == "project_id" }.values).to eq(Array(project.id))
end
context "store and load" do
@@ -129,9 +129,9 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "should serialize the chain correctly" do
- [:filters, :group_bys].each do |type|
+ %i[filters group_bys].each do |type|
@query.send(type).each do |chainable|
- expect(@query.serialize[type].collect{|c| c[0]}).to include chainable.class.name.demodulize
+ expect(@query.serialize[type].collect { |c| c[0] }).to include chainable.class.name.demodulize
end
end
end
@@ -144,7 +144,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
@query.group_bys.each_with_index do |group_by, index|
# check for order
@new_query.group_bys.each_with_index do |g, ix|
- if g.class.name == group_by.class.name
+ if g.instance_of?(group_by.class)
expect(ix).to eq(index)
end
end
@@ -152,10 +152,10 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "should keep the right filter values" do
- @query.filters.each_with_index do |filter, index|
+ @query.filters.each_with_index do |filter, _index|
# check for presence
expect(@new_query.filters.any? do |f|
- f.class.name == filter.class.name && (filter.respond_to?(:values) ? f.values == filter.values : true)
+ f.instance_of?(filter.class) && (filter.respond_to?(:values) ? f.values == filter.values : true)
end).to be_truthy
end
end
@@ -180,7 +180,8 @@ describe CostQuery, type: :model, reporting_query_helper: true do
it "sets new top when prepending elements" do
current = @chain
10.times do
- old, current = current, Report::Chainable.new(current)
+ old = current
+ current = Report::Chainable.new(current)
expect(old.top).to eq(current)
expect(@chain.top).to eq(current)
end
@@ -215,7 +216,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it 'is able to map values' do
- @a.inherited_attribute :bar, map: proc { |x| x*2 }
+ @a.inherited_attribute :bar, map: proc { |x| x * 2 }
@a.bar 21
expect(@a.bar).to eq(42)
end
diff --git a/modules/reporting/spec/models/cost_query/cost_query_spec.rb b/modules/reporting/spec/models/cost_query/cost_query_spec.rb
index f56f1cd13c..d90f54fc1f 100644
--- a/modules/reporting/spec/models/cost_query/cost_query_spec.rb
+++ b/modules/reporting/spec/models/cost_query/cost_query_spec.rb
@@ -36,7 +36,6 @@ describe User, "#destroy", type: :model do
let(:user2) { FactoryBot.create(:user) }
describe "WHEN the user has saved private cost queries" do
-
before do
private_query.user.destroy
end
@@ -64,7 +63,7 @@ describe User, "#destroy", type: :model do
user.destroy
end
- it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any?{ |f| f.is_a?(filter) }).to be_falsey }
+ it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any? { |f| f.is_a?(filter) }).to be_falsey }
end
describe "WHEN the filter has another user as it's value" do
@@ -75,8 +74,12 @@ describe User, "#destroy", type: :model do
user.destroy
end
- it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any?{ |f| f.is_a?(filter) }).to be_truthy }
- it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.detect{ |f| f.is_a?(filter) }.values).to eq([user2.id.to_s]) }
+ it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any? { |f| f.is_a?(filter) }).to be_truthy }
+ it {
+ expect(CostQuery.find_by_id(public_query.id).deserialize.filters.detect do |f|
+ f.is_a?(filter)
+ end.values).to eq([user2.id.to_s])
+ }
end
describe "WHEN the filter has the deleted user and another user as it's value" do
@@ -87,8 +90,12 @@ describe User, "#destroy", type: :model do
user.destroy
end
- it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any?{ |f| f.is_a?(filter) }).to be_truthy }
- it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.detect{ |f| f.is_a?(filter) }.values).to eq([user2.id.to_s]) }
+ it { expect(CostQuery.find_by_id(public_query.id).deserialize.filters.any? { |f| f.is_a?(filter) }).to be_truthy }
+ it {
+ expect(CostQuery.find_by_id(public_query.id).deserialize.filters.detect do |f|
+ f.is_a?(filter)
+ end.values).to eq([user2.id.to_s])
+ }
end
end
diff --git a/modules/reporting/spec/models/cost_query/filter_spec.rb b/modules/reporting/spec/models/cost_query/filter_spec.rb
index 570ea791a7..5f5c9fea3d 100644
--- a/modules/reporting/spec/models/cost_query/filter_spec.rb
+++ b/modules/reporting/spec/models/cost_query/filter_spec.rb
@@ -35,8 +35,8 @@ describe CostQuery, type: :model, reporting_query_helper: true do
let!(:project) { FactoryBot.create(:project_with_types) }
let!(:user) { FactoryBot.create(:user, member_in_project: project) }
- def create_work_package_with_entry(entry_type, work_package_params={}, entry_params = {})
- work_package_params = {project: project}.merge!(work_package_params)
+ def create_work_package_with_entry(entry_type, work_package_params = {}, entry_params = {})
+ work_package_params = { project: project }.merge!(work_package_params)
work_package = FactoryBot.create(:work_package, work_package_params)
entry_params = { work_package: work_package,
project: work_package_params[:project],
@@ -46,7 +46,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
describe CostQuery::Filter do
- def create_work_package_with_time_entry(work_package_params={}, entry_params = {})
+ def create_work_package_with_time_entry(work_package_params = {}, entry_params = {})
create_work_package_with_entry(:time_entry, work_package_params, entry_params)
end
@@ -72,8 +72,8 @@ describe CostQuery, type: :model, reporting_query_helper: true do
[CostQuery::Filter::ProjectId, 'project', "project_id", 2],
[CostQuery::Filter::UserId, 'user', "user_id", 2],
[CostQuery::Filter::CostTypeId, 'cost_type', "cost_type_id", 1],
- [CostQuery::Filter::WorkPackageId, 'work_package', "work_package_id", 2],
- [CostQuery::Filter::ActivityId, 'activity', "activity_id", 1],
+ [CostQuery::Filter::WorkPackageId, 'work_package', "work_package_id", 2],
+ [CostQuery::Filter::ActivityId, 'activity', "activity_id", 1]
].each do |filter, object_name, field, expected_count|
describe filter do
let!(:non_matching_entry) { FactoryBot.create(:cost_entry) }
@@ -101,7 +101,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
activity: activity)
end
- it "should only return entries from the given #{filter.to_s}" do
+ it "should only return entries from the given #{filter}" do
@query.filter field, value: object.id
@query.result.each do |result|
expect(result[field].to_s).to eq(object.id.to_s)
@@ -206,15 +206,15 @@ describe CostQuery, type: :model, reporting_query_helper: true do
old_user = User.current
# create non-matching entry
anonymous = FactoryBot.create(:anonymous)
- create_work_package_with_time_entry({}, {user: anonymous})
+ create_work_package_with_time_entry({}, { user: anonymous })
# create matching entry
- create_work_package_with_time_entry()
+ create_work_package_with_time_entry
@query.filter :user_id, value: user.id, operator: '='
expect(@query.result.count).to eq(1)
end
describe "work_package-based filters" do
- def create_work_packages_and_time_entries(entry_count, work_package_params={}, entry_params={})
+ def create_work_packages_and_time_entries(entry_count, work_package_params = {}, entry_params = {})
entry_count.times do
create_work_package_with_entry(:cost_entry, work_package_params, entry_params)
end
@@ -222,7 +222,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
def create_matching_object_with_time_entries(factory, work_package_field, entry_count)
object = FactoryBot.create(factory)
- create_work_packages_and_time_entries(entry_count, {work_package_field => object})
+ create_work_packages_and_time_entries(entry_count, { work_package_field => object })
object
end
@@ -303,7 +303,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
end
- #filter for specific objects, which can't be null
+ # filter for specific objects, which can't be null
[
CostQuery::Filter::UserId,
CostQuery::Filter::CostTypeId,
@@ -317,7 +317,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
end
- #filter for specific objects, which might be null
+ # filter for specific objects, which might be null
[
CostQuery::Filter::AssignedToId,
CostQuery::Filter::CategoryId,
@@ -328,7 +328,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
end
- #filter for specific objects, which can only have the default operator
+ # filter for specific objects, which can only have the default operator
[
CostQuery::Filter::WorkPackageId
].each do |filter|
@@ -337,7 +337,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
end
- #filter for time/date
+ # filter for time/date
[
CostQuery::Filter::CreatedOn,
CostQuery::Filter::UpdatedOn,
@@ -380,7 +380,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
def update_work_package_custom_field(name, options)
fld = WorkPackageCustomField.find_by(name: name)
- options.each_pair {|k, v| fld.send(:"#{k}=", v) }
+ options.each_pair { |k, v| fld.send(:"#{k}=", v) }
fld.save!
clear_cache
end
@@ -426,14 +426,14 @@ describe CostQuery, type: :model, reporting_query_helper: true do
it "includes custom fields classes in CustomFieldEntries.all" do
custom_field
- expect(CostQuery::Filter::CustomFieldEntries.all).
- to include(filter_class_name_string(custom_field).constantize)
+ expect(CostQuery::Filter::CustomFieldEntries.all)
+ .to include(filter_class_name_string(custom_field).constantize)
end
it "includes custom fields classes in Filter.all" do
custom_field
- expect(CostQuery::Filter.all).
- to include(filter_class_name_string(custom_field).constantize)
+ expect(CostQuery::Filter.all)
+ .to include(filter_class_name_string(custom_field).constantize)
end
def create_searchable_fields_and_values
diff --git a/modules/reporting/spec/models/cost_query/group_by_spec.rb b/modules/reporting/spec/models/cost_query/group_by_spec.rb
index 63e9678675..c8f0b2eb80 100644
--- a/modules/reporting/spec/models/cost_query/group_by_spec.rb
+++ b/modules/reporting/spec/models/cost_query/group_by_spec.rb
@@ -31,34 +31,42 @@ require File.join(File.dirname(__FILE__), '..', '..', 'support', 'custom_field_f
describe CostQuery, type: :model, reporting_query_helper: true do
let!(:type) { FactoryBot.create(:type) }
- let!(:project1){ FactoryBot.create(:project_with_types, types: [type]) }
- let!(:work_package1) { FactoryBot.create(:work_package, project: project1, type: type)}
- let!(:time_entry1) { FactoryBot.create(:time_entry, work_package: work_package1, project: project1, spent_on: Date.new(2012, 1, 1)) }
+ let!(:project1) { FactoryBot.create(:project_with_types, types: [type]) }
+ let!(:work_package1) { FactoryBot.create(:work_package, project: project1, type: type) }
+ let!(:time_entry1) do
+ FactoryBot.create(:time_entry, work_package: work_package1, project: project1, spent_on: Date.new(2012, 1, 1))
+ end
let!(:time_entry2) do
time_entry2 = time_entry1.dup
time_entry2.save!
time_entry2
end
let!(:budget1) { FactoryBot.create(:budget, project: project1) }
- let!(:cost_entry1) { FactoryBot.create(:cost_entry, work_package: work_package1, project: project1, spent_on: Date.new(2013, 2, 3)) }
+ let!(:cost_entry1) do
+ FactoryBot.create(:cost_entry, work_package: work_package1, project: project1, spent_on: Date.new(2013, 2, 3))
+ end
let!(:cost_entry2) do
- cost_entry2 = cost_entry1.dup
+ cost_entry2 = cost_entry1.dup
cost_entry2.save!
cost_entry2
end
let!(:project2) { FactoryBot.create(:project_with_types, types: [type]) }
let!(:work_package2) { FactoryBot.create(:work_package, project: project2, type: type) }
- let!(:time_entry3) { FactoryBot.create(:time_entry, work_package: work_package2, project: project2, spent_on: Date.new(2013, 2, 3)) }
+ let!(:time_entry3) do
+ FactoryBot.create(:time_entry, work_package: work_package2, project: project2, spent_on: Date.new(2013, 2, 3))
+ end
let!(:time_entry4) do
time_entry4 = time_entry3.dup
time_entry4.save!
time_entry4
end
let!(:budget2) { FactoryBot.create(:budget, project: project2) }
- let!(:cost_entry3) { FactoryBot.create(:cost_entry, work_package: work_package2, project: project2, spent_on: Date.new(2012, 1, 1)) }
+ let!(:cost_entry3) do
+ FactoryBot.create(:cost_entry, work_package: work_package2, project: project2, spent_on: Date.new(2012, 1, 1))
+ end
let!(:cost_entry4) do
- cost_entry4 = cost_entry3.dup
+ cost_entry4 = cost_entry3.dup
cost_entry4.save!
cost_entry4
end
@@ -196,7 +204,6 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "should aggregate a third group_by which owns at least 2 sub results" do
-
@query.group_by :tweek
@query.group_by :project_id
@query.group_by :user_id
@@ -225,7 +232,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
describe CostQuery::GroupBy::CustomFieldEntries do
- let!(:project){ FactoryBot.create(:project_with_types) }
+ let!(:project) { FactoryBot.create(:project_with_types) }
let!(:custom_field) do
FactoryBot.create(:work_package_custom_field)
end
@@ -280,13 +287,13 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "includes custom fields classes in CustomFieldEntries.all" do
- expect(CostQuery::GroupBy::CustomFieldEntries.all).
- to include(group_by_class_name_string(custom_field).constantize)
+ expect(CostQuery::GroupBy::CustomFieldEntries.all)
+ .to include(group_by_class_name_string(custom_field).constantize)
end
it "includes custom fields classes in GroupBy.all" do
- expect(CostQuery::GroupBy.all).
- to include(group_by_class_name_string(custom_field).constantize)
+ expect(CostQuery::GroupBy.all)
+ .to include(group_by_class_name_string(custom_field).constantize)
end
it "is usable as filter" do
diff --git a/modules/reporting/spec/models/cost_query/integration_spec.rb b/modules/reporting/spec/models/cost_query/integration_spec.rb
index ccfc43ea1b..238f7aaf3d 100644
--- a/modules/reporting/spec/models/cost_query/integration_spec.rb
+++ b/modules/reporting/spec/models/cost_query/integration_spec.rb
@@ -31,7 +31,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe CostQuery, type: :model, reporting_query_helper: true do
minimal_query
- let!(:project1){ FactoryBot.create(:project_with_types) }
+ let!(:project1) { FactoryBot.create(:project_with_types) }
let!(:work_package1) { FactoryBot.create(:work_package, project: project1) }
let!(:time_entry1) { FactoryBot.create(:time_entry, work_package: work_package1, project: project1) }
let!(:time_entry2) { FactoryBot.create(:time_entry, work_package: work_package1, project: project1) }
@@ -52,10 +52,10 @@ describe CostQuery, type: :model, reporting_query_helper: true do
sql_result = @query.result
expect(sql_result.size).to eq(2)
- #for each project the number of entries should be correct
+ # for each project the number of entries should be correct
sql_count = []
sql_result.each do |sub_result|
- #project should be the outmost group_by
+ # project should be the outmost group_by
expect(sub_result.fields).to include(:project_id)
sql_count.push sub_result.count
end
@@ -69,10 +69,10 @@ describe CostQuery, type: :model, reporting_query_helper: true do
sql_result = @query.result
expect(sql_result.size).to eq(2)
- #for each user the number of entries should be correct
+ # for each user the number of entries should be correct
sql_count = []
sql_result.each do |sub_result|
- #project should be the outmost group_by
+ # project should be the outmost group_by
expect(sub_result.fields).to include(:user_id)
sql_count.push sub_result.count
end
diff --git a/modules/reporting/spec/models/cost_query/operator_spec.rb b/modules/reporting/spec/models/cost_query/operator_spec.rb
index ba86155b41..d124671175 100644
--- a/modules/reporting/spec/models/cost_query/operator_spec.rb
+++ b/modules/reporting/spec/models/cost_query/operator_spec.rb
@@ -118,7 +118,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "does w (this week)" do
- #somehow this test doesn't work on sundays
+ # somehow this test doesn't work on sundays
n = query('projects', 'created_at', 'w').size
day_in_this_week = Time.now.at_beginning_of_week + 1.day
FactoryBot.create(:project, created_at: day_in_this_week)
@@ -184,7 +184,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
expect(query('projects', 'created_at', 'd" do
- #assuming that all projects were created in the past
+ # assuming that all projects were created in the past
expect(query('projects', 'created_at', '>d', Time.now).size).to eq(0)
end
describe 'arity' do
- arities = {'t' => 0, 'w' => 0, '<>d' => 2, '>d' => 1}
- arities.each do |o,a|
+ arities = { 't' => 0, 'w' => 0, '<>d' => 2, '>d' => 1 }
+ arities.each do |o, a|
it("#{o} should take #{a} values") { expect(o.to_operator.arity).to eq(a) }
end
end
diff --git a/modules/reporting/spec/models/cost_query/result_spec.rb b/modules/reporting/spec/models/cost_query/result_spec.rb
index 9855daa458..49e3d91cd3 100644
--- a/modules/reporting/spec/models/cost_query/result_spec.rb
+++ b/modules/reporting/spec/models/cost_query/result_spec.rb
@@ -41,66 +41,66 @@ describe CostQuery, type: :model, reporting_query_helper: true do
describe CostQuery::Result do
def direct_results(quantity = 0)
- (1..quantity).map {|i| CostQuery::Result.new real_costs:i.to_f, count:1 ,units:i.to_f}
+ (1..quantity).map { |i| CostQuery::Result.new real_costs: i.to_f, count: 1, units: i.to_f }
end
- def wrapped_result(source, quantity=1)
- CostQuery::Result.new((1..quantity).map { |i| source})
+ def wrapped_result(source, quantity = 1)
+ CostQuery::Result.new((1..quantity).map { |_i| source })
end
it "should travel recursively depth-first" do
- #build a tree of wrapped and direct results
+ # build a tree of wrapped and direct results
w1 = wrapped_result((direct_results 5), 3)
w2 = wrapped_result wrapped_result((direct_results 3), 2)
w = wrapped_result [w1, w2]
previous_depth = -1
w.recursive_each_with_level do |level, result|
- #depth first, so we should get deeper into the hole, until we find a direct_result
+ # depth first, so we should get deeper into the hole, until we find a direct_result
expect(previous_depth).to eq(level - 1)
- previous_depth=level
+ previous_depth = level
break if result.is_a? CostQuery::Result::DirectResult
end
end
it "should travel recursively width-first" do
- #build a tree of wrapped and direct results
+ # build a tree of wrapped and direct results
w1 = wrapped_result((direct_results 5), 3)
w2 = wrapped_result wrapped_result((direct_results 3), 2)
w = wrapped_result [w1, w2]
previous_depth = -1
- w.recursive_each_with_level 0, false do |level, result|
- #width first, so we should get only deeper into the hole without ever coming up again
+ w.recursive_each_with_level 0, false do |level, _result|
+ # width first, so we should get only deeper into the hole without ever coming up again
expect(previous_depth).to be <= level
- previous_depth=level
+ previous_depth = level
end
end
it "should travel to all results width-first" do
- #build a tree of wrapped and direct results
+ # build a tree of wrapped and direct results
w1 = wrapped_result((direct_results 5), 3)
w2 = wrapped_result wrapped_result((direct_results 3), 2)
w = wrapped_result [w1, w2]
count = 0
- w.recursive_each_with_level 0, false do |level, result|
- #width first
+ w.recursive_each_with_level 0, false do |_level, result|
+ # width first
count = count + 1 if result.is_a? CostQuery::Result::DirectResult
end
expect(w.count).to eq(count)
end
it "should travel to all results width-first" do
- #build a tree of wrapped and direct results
+ # build a tree of wrapped and direct results
w1 = wrapped_result((direct_results 5), 3)
w2 = wrapped_result wrapped_result((direct_results 3), 2)
w = wrapped_result [w1, w2]
count = 0
- w.recursive_each_with_level do |level, result|
- #depth first
- count = count + 1 if result.is_a? CostQuery::Result::DirectResult
- end
+ w.recursive_each_with_level do |_level, result|
+ # depth first
+ count = count + 1 if result.is_a? CostQuery::Result::DirectResult
+ end
expect(w.count).to eq(count)
end
@@ -109,11 +109,11 @@ describe CostQuery, type: :model, reporting_query_helper: true do
end
it "should compute units correctly" do
- expect(@query.result.units).to eq(Entry.all.map { |e| e.units}.sum)
+ expect(@query.result.units).to eq(Entry.all.map { |e| e.units }.sum)
end
it "should compute real_costs correctly" do
- expect(@query.result.real_costs).to eq(Entry.all.map { |e| e.overridden_costs || e.costs}.sum)
+ expect(@query.result.real_costs).to eq(Entry.all.map { |e| e.overridden_costs || e.costs }.sum)
end
it "should compute count for DirectResults" do
@@ -122,8 +122,8 @@ describe CostQuery, type: :model, reporting_query_helper: true do
it "should compute units for DirectResults" do
id_sorted = @query.result.values.sort_by { |r| r[:id] }
- te_result = id_sorted.select { |r| r[:type]==TimeEntry.to_s }.first
- ce_result = id_sorted.select { |r| r[:type]==CostEntry.to_s }.first
+ te_result = id_sorted.select { |r| r[:type] == TimeEntry.to_s }.first
+ ce_result = id_sorted.select { |r| r[:type] == CostEntry.to_s }.first
expect(te_result.units.to_s).to eq("1.0")
expect(ce_result.units.to_s).to eq("1.0")
end
@@ -131,7 +131,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
it "should compute real_costs for DirectResults" do
id_sorted = @query.result.values.sort_by { |r| r[:id] }
[CostEntry].each do |type|
- result = id_sorted.select { |r| r[:type]==type.to_s }.first
+ result = id_sorted.select { |r| r[:type] == type.to_s }.first
first = type.all.first
expect(result.real_costs).to eq(first.overridden_costs || first.costs)
end
@@ -151,6 +151,5 @@ describe CostQuery, type: :model, reporting_query_helper: true do
@query.column :project_id
expect(@query.result.first.first.type).to eq(:direct)
end
-
end
end
diff --git a/modules/reporting/spec/models/cost_query/validation_spec.rb b/modules/reporting/spec/models/cost_query/validation_spec.rb
index 68057fb7ca..dacf699de9 100644
--- a/modules/reporting/spec/models/cost_query/validation_spec.rb
+++ b/modules/reporting/spec/models/cost_query/validation_spec.rb
@@ -45,7 +45,7 @@ describe "CostQuery::Validation", type: :model do
it "should allow for multiple validations" do
obj = CostQuery::SomeBase.new
- obj.register_validations([:integers, :dates])
+ obj.register_validations(%i[integers dates])
expect(obj.validations.size).to eq(2)
end
@@ -59,14 +59,14 @@ describe "CostQuery::Validation", type: :model do
it "should have no errors set when we try to validate something valid" do
obj = CostQuery::SomeBase.new
obj.register_validation(:integers)
- expect(obj.validate(1,2,3,4)).to be_truthy
+ expect(obj.validate(1, 2, 3, 4)).to be_truthy
expect(obj.errors[:int].size).to eq(0)
end
it "should validate integers correctly" do
obj = CostQuery::SomeBase.new
obj.register_validation(:integers)
- expect(obj.validate(1,2,3,4)).to be_truthy
+ expect(obj.validate(1, 2, 3, 4)).to be_truthy
expect(obj.errors[:int].size).to eq(0)
expect(obj.validate("I ain't gonna work on Maggies Farm no more")).to be_falsey
expect(obj.errors[:int].size).to eq(1)
diff --git a/modules/reporting/spec/models/cost_query/walker_spec.rb b/modules/reporting/spec/models/cost_query/walker_spec.rb
index 3e9ff8bec8..48e8a438b0 100644
--- a/modules/reporting/spec/models/cost_query/walker_spec.rb
+++ b/modules/reporting/spec/models/cost_query/walker_spec.rb
@@ -46,7 +46,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
@query.row :user_id
result = @query.transformer.row_first.values.first
- [:user_id, :project_id, :tweek].each do |field|
+ %i[user_id project_id tweek].each do |field|
expect(result.fields).to include(field)
result = result.values.first
end
@@ -59,7 +59,7 @@ describe CostQuery, type: :model, reporting_query_helper: true do
@query.row :user_id
result = @query.transformer.column_first.values.first
- [:tweek, :work_package_id].each do |field|
+ %i[tweek work_package_id].each do |field|
expect(result.fields).to include(field)
result = result.values.first
end
diff --git a/modules/reporting/spec/support/plugin_spec_helper.rb b/modules/reporting/spec/support/plugin_spec_helper.rb
index 6b22ab1090..bfea854b1c 100644
--- a/modules/reporting/spec/support/plugin_spec_helper.rb
+++ b/modules/reporting/spec/support/plugin_spec_helper.rb
@@ -32,8 +32,8 @@ module OpenProject::Reporting
role = FactoryBot.create(:role, permissions: permissions)
FactoryBot.create(:member, project: project,
- principal: user,
- roles: [role])
+ principal: user,
+ roles: [role])
end
end
end
diff --git a/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/row_cell.rb b/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/row_cell.rb
index a35d0deddb..98320a7a20 100644
--- a/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/row_cell.rb
+++ b/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/row_cell.rb
@@ -49,10 +49,10 @@ module ::TwoFactorAuthentication
def make_default_link
password_confirmation_form_for(
- device,
- url: { controller: table.target_controller, action: :make_default, device_id: device.id },
- method: :post,
- html: { id: 'two_factor_make_default_form', class: 'form--inline' }
+ device,
+ url: { controller: table.target_controller, action: :make_default, device_id: device.id },
+ method: :post,
+ html: { id: 'two_factor_make_default_form', class: 'form--inline' }
) do |f|
f.submit I18n.t(:button_make_default),
class: 'button--link two-factor--mark-default-button'
@@ -86,7 +86,7 @@ module ::TwoFactorAuthentication
device.default && table.enforced?
end
- def column_css_class(column)
+ def column_css_class(_column)
if device.default
'mobile-otp--device-default'
end
diff --git a/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/table_cell.rb b/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/table_cell.rb
index 327989a481..07a2a42410 100644
--- a/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/table_cell.rb
+++ b/modules/two_factor_authentication/app/cells/two_factor_authentication/devices/table_cell.rb
@@ -5,7 +5,7 @@ module ::TwoFactorAuthentication
columns :device_type, :default, :confirmed
def initial_sort
- [:login, :asc]
+ %i[login asc]
end
def self_table?
@@ -33,7 +33,7 @@ module ::TwoFactorAuthentication
link_to({ controller: target_controller, action: :new },
class: 'budget-add-row wp-inline-create--add-link',
title: I18n.t('two_factor_authentication.devices.add_new')) do
- op_icon('icon icon-add')
+ op_icon('icon icon-add')
end
end
end
@@ -56,9 +56,9 @@ module ::TwoFactorAuthentication
def headers
[
- ['device_type', caption: I18n.t('two_factor_authentication.label_device_type')],
- ['default', caption: I18n.t(:label_default)],
- ['confirmed', caption: I18n.t(:label_confirmed)],
+ ['device_type', { caption: I18n.t('two_factor_authentication.label_device_type') }],
+ ['default', { caption: I18n.t(:label_default) }],
+ ['confirmed', { caption: I18n.t(:label_confirmed) }]
]
end
end
diff --git a/modules/two_factor_authentication/app/controllers/concerns/two_factor_authentication/backup_codes.rb b/modules/two_factor_authentication/app/controllers/concerns/two_factor_authentication/backup_codes.rb
index b8af6698ae..b13833e99d 100644
--- a/modules/two_factor_authentication/app/controllers/concerns/two_factor_authentication/backup_codes.rb
+++ b/modules/two_factor_authentication/app/controllers/concerns/two_factor_authentication/backup_codes.rb
@@ -23,4 +23,4 @@ module ::TwoFactorAuthentication
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb
index af5015b821..b7c1beed9b 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/authentication_controller.rb
@@ -66,7 +66,6 @@ module ::TwoFactorAuthentication
render_login_otp(service)
end
-
##
# Create a token service for the current user
# with an optional override to use a non-default channel
@@ -81,8 +80,6 @@ module ::TwoFactorAuthentication
use_device =
if session[:two_factor_authentication_device_id]
user.otp_devices.find(session[:two_factor_authentication_device_id])
- else
- nil
end
otp_service(user, use_device: use_device)
rescue ActiveRecord::RecordNotFound
@@ -97,8 +94,6 @@ module ::TwoFactorAuthentication
device =
if params[:use_device].present?
@authenticated_user.otp_devices.find(params[:use_device])
- else
- nil
end
otp_service(@authenticated_user, use_channel: channel, use_device: device)
@@ -134,9 +129,9 @@ module ::TwoFactorAuthentication
@active_devices = @user.otp_devices.get_active
if params["back_url"]
- render :action => 'request_otp', :back_url => params["back_url"]
+ render action: 'request_otp', back_url: params["back_url"]
else
- render :action => 'request_otp'
+ render action: 'request_otp'
end
end
@@ -160,7 +155,7 @@ module ::TwoFactorAuthentication
unless request.post?
head(:method_not_allowed)
- return false
+ false
end
end
@@ -190,7 +185,7 @@ module ::TwoFactorAuthentication
def ensure_valid_configuration
if manager.invalid_configuration?
render_500 message: I18n.t('two_factor_authentication.error_is_enforced_not_active')
- return false
+ false
end
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/base_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/base_controller.rb
index c41be624b7..0d5c64a3c2 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/base_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/base_controller.rb
@@ -1,13 +1,12 @@
module ::TwoFactorAuthentication
class BaseController < ApplicationController
-
# Ensure 2FA authentication is enabled
before_action :ensure_enabled_2fa
# Locate the user we're editing
prepend_before_action :find_user
- before_action :find_device, only: [:confirm, :make_default, :destroy]
+ before_action :find_device, only: %i[confirm make_default destroy]
layout 'no_menu'
@@ -61,6 +60,7 @@ module ::TwoFactorAuthentication
request_device_confirmation_token
elsif request.post?
return unless ensure_token_parameter
+
validate_device_token
else
head 405
@@ -73,10 +73,10 @@ module ::TwoFactorAuthentication
# Request (if needed) the token for entering
def request_device_confirmation_token
request_token_for_device(
- @device,
- confirm_path: url_for(action: :confirm, device_id: @device.id),
- title: I18n.t('two_factor_authentication.devices.confirm_device'),
- message: I18n.t('two_factor_authentication.devices.text_confirm_to_complete_html', identifier: @device.identifier)
+ @device,
+ confirm_path: url_for(action: :confirm, device_id: @device.id),
+ title: I18n.t('two_factor_authentication.devices.confirm_device'),
+ message: I18n.t('two_factor_authentication.devices.text_confirm_to_complete_html', identifier: @device.identifier)
)
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
index 1a2271bfb2..7d02561729 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller.rb
@@ -30,7 +30,7 @@ module ::TwoFactorAuthentication
Rails.logger.info "User ##{target_user.id} forced to register a new (unconfirmed) device #{@device_type}."
redirect_to action: :confirm, device_id: @device.id
else
- Rails.logger.warn {"User ##{target_user.id} forced to register failed for #{@device_type}."}
+ Rails.logger.warn { "User ##{target_user.id} forced to register failed for #{@device_type}." }
render 'two_factor_authentication/two_factor_devices/new'
end
end
@@ -61,16 +61,17 @@ module ::TwoFactorAuthentication
# Ensure the authentication stage from the core provided the authenticated user
def require_authenticated_user
raise ArgumentError, 'Missing param' unless session[:authenticated_user_force_2fa]
+
@authenticated_user = User.find(session[:authenticated_user_id])
- return true
+ true
rescue ActiveRecord::RecordNotFound
Rails.logger.error "Failed to find authenticated_user for 2FA authentication."
redirect_to registration_failure_path
- return false
+ false
rescue ArgumentError
Rails.logger.error "User tried to access forced registration without registration session param set."
redirect_to registration_failure_path
- return false
+ false
end
end
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
index 9029c1ba8c..75cd358a86 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/my/two_factor_devices_controller.rb
@@ -6,7 +6,7 @@ module ::TwoFactorAuthentication
before_action :set_user_variables
- before_action :find_device, except: [:new, :index, :register]
+ before_action :find_device, except: %i[new index register]
# Remmeber token functionality
include ::TwoFactorAuthentication::RememberToken
@@ -14,7 +14,7 @@ module ::TwoFactorAuthentication
# Password confirmation helpers and actions
include PasswordConfirmation
before_action :check_password_confirmation,
- only: [:make_default, :destroy]
+ only: %i[make_default destroy]
# Delete remember token on destroy
before_action :clear_remember_token!, only: [:destroy]
@@ -39,7 +39,7 @@ module ::TwoFactorAuthentication
Rails.logger.info "User ##{current_user.id} registered a new (unconfirmed) device #{@device_type}."
redirect_to action: :confirm, device_id: @device.id
else
- Rails.logger.warn {"User ##{current_user.id} failed to register a device #{@device_type}."}
+ Rails.logger.warn { "User ##{current_user.id} failed to register a device #{@device_type}." }
render 'two_factor_authentication/two_factor_devices/new'
end
end
@@ -51,6 +51,7 @@ module ::TwoFactorAuthentication
request_device_confirmation_token
else
return unless ensure_token_parameter
+
validate_device_token
end
end
@@ -61,10 +62,10 @@ module ::TwoFactorAuthentication
# Request (if needed) the token for entering
def request_device_confirmation_token
request_token_for_device(
- @device,
- confirm_path: url_for(action: :confirm, device_id: @device.id),
- title: I18n.t('two_factor_authentication.devices.confirm_device'),
- message: I18n.t('two_factor_authentication.devices.text_confirm_to_complete_html', identifier: @device.identifier)
+ @device,
+ confirm_path: url_for(action: :confirm, device_id: @device.id),
+ title: I18n.t('two_factor_authentication.devices.confirm_device'),
+ message: I18n.t('two_factor_authentication.devices.text_confirm_to_complete_html', identifier: @device.identifier)
)
end
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/two_factor_settings_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/two_factor_settings_controller.rb
index 32c7ae8246..a12ad1e465 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/two_factor_settings_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/two_factor_settings_controller.rb
@@ -1,6 +1,5 @@
module ::TwoFactorAuthentication
class TwoFactorSettingsController < ApplicationController
-
before_action :require_admin
before_action :check_enabled
before_action :check_ee
diff --git a/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb b/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
index 177d366ce0..c9838af266 100644
--- a/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
+++ b/modules/two_factor_authentication/app/controllers/two_factor_authentication/users/two_factor_devices_controller.rb
@@ -62,6 +62,7 @@ module ::TwoFactorAuthentication
request_device_confirmation_token
else
return unless ensure_token_parameter
+
validate_device_token
end
end
@@ -108,8 +109,8 @@ module ::TwoFactorAuthentication
# Overrides the base controller to active the device
# without prior confirmation.
permitted_device_params.merge(
- user: @user,
- active: true
+ user: @user,
+ active: true
)
end
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication.rb b/modules/two_factor_authentication/app/models/two_factor_authentication.rb
index bff5348ef1..ece37388ac 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication.rb
@@ -2,4 +2,4 @@ module TwoFactorAuthentication
def self.table_name_prefix
'two_factor_authentication_'
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/backup_code.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/backup_code.rb
index 3a0f305276..ea8d46773e 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/backup_code.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/backup_code.rb
@@ -3,7 +3,6 @@ require_dependency 'token/hashed_token'
module TwoFactorAuthentication
class BackupCode < ::Token::HashedToken
class << self
-
def regenerate!(user)
backup_codes = []
@@ -33,4 +32,4 @@ module TwoFactorAuthentication
false
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
index 794c026381..2c2e56290f 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device.rb
@@ -37,11 +37,7 @@ module TwoFactorAuthentication
def identifier
value = read_attribute(:identifier)
- if value
- value
- else
- default_identifier
- end
+ value || default_identifier
end
def redacted_identifier
@@ -69,7 +65,7 @@ module TwoFactorAuthentication
Device.transaction do
Device.where(user_id: user_id).update_all(default: false)
- self.update_column(:default, true)
+ update_column(:default, true)
return true
end
end
@@ -91,7 +87,7 @@ module TwoFactorAuthentication
def self.available_channels_in_strategy
strategy_class = manager.get_strategy(device_type)
- strategy_class.supported_channels & self.supported_channels
+ strategy_class.supported_channels & supported_channels
end
private
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device/sms.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device/sms.rb
index c01a60a6a9..1794de03dc 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device/sms.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device/sms.rb
@@ -65,4 +65,4 @@ module TwoFactorAuthentication
super(number.try(:strip))
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/device/totp.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/device/totp.rb
index 047545492d..67259a948a 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/device/totp.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/device/totp.rb
@@ -65,4 +65,4 @@ module TwoFactorAuthentication
@totp ||= ::ROTP::TOTP.new otp_secret, issuer: (Setting.app_title.presence || 'OpenProject')
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/models/two_factor_authentication/login_token.rb b/modules/two_factor_authentication/app/models/two_factor_authentication/login_token.rb
index b93f9aab86..07f54a74bc 100644
--- a/modules/two_factor_authentication/app/models/two_factor_authentication/login_token.rb
+++ b/modules/two_factor_authentication/app/models/two_factor_authentication/login_token.rb
@@ -9,14 +9,11 @@ module TwoFactorAuthentication
15.minutes
end
- private
-
def self.generate_token_value
chars = ("0".."9").to_a
password = ''
- 6.times { |i| password << chars[rand(chars.size-1)] }
+ 6.times { |_i| password << chars[rand(chars.size - 1)] }
password
end
-
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/services/two_factor_authentication/token_service.rb b/modules/two_factor_authentication/app/services/two_factor_authentication/token_service.rb
index 57c3fecb6e..516a02415b 100644
--- a/modules/two_factor_authentication/app/services/two_factor_authentication/token_service.rb
+++ b/modules/two_factor_authentication/app/services/two_factor_authentication/token_service.rb
@@ -22,7 +22,7 @@ module TwoFactorAuthentication
return true if manager.enforced?
# Otherwise, only enabled if active and a device is present for the user
- return manager.enabled? && device.present?
+ manager.enabled? && device.present?
end
##
@@ -30,7 +30,8 @@ module TwoFactorAuthentication
# device during the login flow.
def needs_registration?
return false unless manager.enforced?
- return device.nil?
+
+ device.nil?
end
##
@@ -45,7 +46,7 @@ module TwoFactorAuthentication
strategy.transmit
ServiceResult.new(success: true, result: strategy.transmit_success_message)
- rescue => e
+ rescue StandardError => e
Rails.logger.error "[2FA plugin] Error during token request to user##{user.id}: #{e}"
result = ServiceResult.new(success: false)
@@ -65,7 +66,7 @@ module TwoFactorAuthentication
result = strategy.verify input_token
ServiceResult.new(success: result)
- rescue => e
+ rescue StandardError => e
Rails.logger.error "[2FA plugin] Error during token validation for user##{user.id}: #{e}"
result = ServiceResult.new(success: false)
@@ -100,4 +101,4 @@ module TwoFactorAuthentication
::OpenProject::TwoFactorAuthentication::TokenStrategyManager
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/app/services/two_factor_authentication/use_backup_code_service.rb b/modules/two_factor_authentication/app/services/two_factor_authentication/use_backup_code_service.rb
index b2a7ab4462..568ec43936 100644
--- a/modules/two_factor_authentication/app/services/two_factor_authentication/use_backup_code_service.rb
+++ b/modules/two_factor_authentication/app/services/two_factor_authentication/use_backup_code_service.rb
@@ -14,8 +14,9 @@ module TwoFactorAuthentication
token = user.otp_backup_codes.find_by_plaintext_value(code)
raise I18n.t('two_factor_authentication.error_invalid_backup_code') if token.nil?
+
use_valid_token! token
- rescue => e
+ rescue StandardError => e
Rails.logger.error "[2FA plugin] Error during backup code validation for user##{user.id}: #{e}"
result = ServiceResult.new(success: false)
@@ -33,4 +34,4 @@ module TwoFactorAuthentication
ServiceResult.new(success: true, result: token)
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/config/routes.rb b/modules/two_factor_authentication/config/routes.rb
index b007933eda..244e474e04 100644
--- a/modules/two_factor_authentication/config/routes.rb
+++ b/modules/two_factor_authentication/config/routes.rb
@@ -1,5 +1,4 @@
OpenProject::Application::routes.draw do
-
namespace 'two_factor_authentication' do
get :request, to: 'authentication#request_otp'
post :confirm, to: 'authentication#confirm_otp'
@@ -16,7 +15,7 @@ OpenProject::Application::routes.draw do
controller: 'two_factor_authentication/forced_registration/two_factor_devices' do
get :new, action: :new, as: 'new_forced_2fa_device'
post :register, action: :register, as: 'register_forced_2fa_device'
- match '/:device_id/confirm', action: :confirm, via: [:get, :post], as: 'confirm_forced_2fa_device'
+ match '/:device_id/confirm', action: :confirm, via: %i[get post], as: 'confirm_forced_2fa_device'
end
end
@@ -26,8 +25,7 @@ OpenProject::Application::routes.draw do
param: :device_id,
controller: 'two_factor_authentication/users/two_factor_devices',
as: 'user_2fa_devices',
- only: [:new, :create, :destroy] do
-
+ only: %i[new create destroy] do
# Register new device ( 'create' )
post :register, on: :collection
@@ -40,12 +38,11 @@ OpenProject::Application::routes.draw do
end
end
-
scope 'my' do
resource :backup_codes,
controller: 'two_factor_authentication/my/backup_codes',
as: 'my_2fa_backup_codes',
- only: [:show, :create]
+ only: %i[show create]
resource :remember_cookie,
controller: 'two_factor_authentication/my/remember_cookie',
@@ -56,7 +53,7 @@ OpenProject::Application::routes.draw do
controller: 'two_factor_authentication/my/two_factor_devices',
param: :device_id,
as: 'my_2fa_devices',
- only: [:index, :new, :destroy] do
+ only: %i[index new destroy] do
# Register new device ( 'create' )
post :register, on: :collection
diff --git a/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb b/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb
index 72836b1ccc..1f9e039257 100644
--- a/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb
+++ b/modules/two_factor_authentication/db/migrate/20120214103300_aggregated_mobile_otp_migrations.rb
@@ -20,7 +20,8 @@ class AggregatedMobileOtpMigrations < ActiveRecord::Migration[5.0]
add_column :users, :unverified_phone, :string
User.reset_column_information
end
- Migration::MigrationUtils::SettingRenamer.rename("plugin_redmine_two_factor_authentication_authentication","plugin_openproject_two_factor_authentication")
+ Migration::MigrationUtils::SettingRenamer.rename("plugin_redmine_two_factor_authentication_authentication",
+ "plugin_openproject_two_factor_authentication")
end
def down
diff --git a/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb b/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb
index 97a32278cf..238c1fc944 100644
--- a/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb
+++ b/modules/two_factor_authentication/db/migrate/20130214130336_add_default_otp_channel_to_user.rb
@@ -1,6 +1,6 @@
class AddDefaultOtpChannelToUser < ActiveRecord::Migration[5.0]
def self.up
- add_column :users, :default_otp_channel, :string, :default => 'text'
+ add_column :users, :default_otp_channel, :string, default: 'text'
end
def self.down
diff --git a/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb b/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb
index 9538ef717a..f14c2c8145 100644
--- a/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb
+++ b/modules/two_factor_authentication/db/migrate/20171023190036_model_reorganization.rb
@@ -2,7 +2,6 @@ class ModelReorganization < ActiveRecord::Migration[5.0]
def self.up
# Add devices table
create_table "two_factor_authentication_devices" do |t|
-
t.string "type"
# Whether this is the default strategy
@@ -19,7 +18,7 @@ class ModelReorganization < ActiveRecord::Migration[5.0]
t.string "phone_number", null: true
# User-given identifier for this device
- t.string "identifier", null: false
+ t.string "identifier", null: false
# Default rails timestamps
t.timestamps
@@ -69,7 +68,6 @@ class ModelReorganization < ActiveRecord::Migration[5.0]
.where(active: true)
.includes(:user)
.find_each do |device|
-
device.user.update_columns(unverified_phone: device.phone_number, default_otp_channel: device.channel)
end
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
index d6823ba0f3..cdde68dd62 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/engine.rb
@@ -54,7 +54,9 @@ module OpenProject::TwoFactorAuthentication
OpenProject::Authentication::Stage.register(:two_factor_authentication,
nil,
run_after_activation: true,
- active: -> { ::OpenProject::TwoFactorAuthentication::TokenStrategyManager.enabled? }) do
+ active: -> {
+ ::OpenProject::TwoFactorAuthentication::TokenStrategyManager.enabled?
+ }) do
two_factor_authentication_request_path
end
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/base.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/base.rb
index 0aae93deb0..51e0dbb0cc 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/base.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/base.rb
@@ -89,4 +89,4 @@ module OpenProject::TwoFactorAuthentication
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/developer.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/developer.rb
index 4c9892f36b..7d7e87b47d 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/developer.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/developer.rb
@@ -1,7 +1,6 @@
module OpenProject::TwoFactorAuthentication
module TokenStrategy
class Developer < Base
-
def self.validate!
if Rails.env.production?
raise "You're trying to use the developer strategy in production. Don't!"
@@ -13,7 +12,7 @@ module OpenProject::TwoFactorAuthentication
end
def self.supported_channels
- [:sms, :voice]
+ %i[sms voice]
end
def self.mobile_token?
@@ -35,4 +34,4 @@ module OpenProject::TwoFactorAuthentication
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
index 2481371d75..8d615cbfd3 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
@@ -7,6 +7,7 @@ module OpenProject::TwoFactorAuthentication
if configuration_params.nil?
raise ArgumentError, 'Missing configuration hash'
end
+
validate_params configuration_params
end
@@ -35,7 +36,7 @@ module OpenProject::TwoFactorAuthentication
validity: 720
raise "Failed to deliver SMS" if response.recipients['totalDeliveryFailedCount'] > 0
- rescue => e
+ rescue StandardError => e
Rails.logger.error("[2FA] MessageBird SMS delivery failed for user #{user.login}. Error: #{e} #{e.message}")
raise I18n.t('two_factor_authentication.message_bird.sms_delivery_failed')
end
@@ -56,7 +57,7 @@ module OpenProject::TwoFactorAuthentication
language: params[:language]
raise "Failed to initiate voice message" if response.recipients['totalDeliveryFailedCount'] > 0
- rescue => e
+ rescue StandardError => e
Rails.logger.error("[2FA] MessageBird VOICE delivery failed for user #{user.login}. Error: #{e} #{e.message}")
raise I18n.t('two_factor_authentication.message_bird.voice_delivery_failed')
end
@@ -138,7 +139,6 @@ module OpenProject::TwoFactorAuthentication
:"en-us"
end
-
##
# Checks whether the locale has a non-fallback
def has_localized_text?(locale_key)
@@ -172,7 +172,7 @@ module OpenProject::TwoFactorAuthentication
# Output format: xxyyyyyyyyyy
def build_recipients(params)
phone = device.phone_number
- phone.gsub!(/[\+\s]/, '')
+ phone.gsub!(/[+\s]/, '')
params[:recipients] = phone
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/restdt.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/restdt.rb
index deabc68b72..8de7133003 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/restdt.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/restdt.rb
@@ -7,6 +7,7 @@ module OpenProject::TwoFactorAuthentication
if configuration_params.nil?
raise ArgumentError, 'Missing configuration hash'
end
+
validate_params configuration_params
end
@@ -19,7 +20,7 @@ module OpenProject::TwoFactorAuthentication
end
def self.supported_channels
- [:sms, :voice]
+ %i[sms voice]
end
private
@@ -37,7 +38,6 @@ module OpenProject::TwoFactorAuthentication
}
end
-
def send_sms
Rails.logger.info { "[2FA] REST DT delivery sending SMS request for #{user.login}" }
submit(build_user_params(onlycall: '0'))
@@ -69,7 +69,7 @@ module OpenProject::TwoFactorAuthentication
# Stored format: +xx yyy yyy yyyy (optional whitespacing)
def build_user_phone
phone = device.phone_number
- phone.gsub!(/[\+]/, '00')
+ phone.gsub!(/\+/, '00')
phone.gsub!(/\s/, '')
phone
@@ -92,8 +92,10 @@ module OpenProject::TwoFactorAuthentication
return
end
- Rails.logger.error { "[2FA] REST DT delivery failed for user #{user.login} " \
- "(Error #{response.body})" }
+ Rails.logger.error do
+ "[2FA] REST DT delivery failed for user #{user.login} " \
+ "(Error #{response.body})"
+ end
raise I18n.t('two_factor_authentication.restdt.delivery_failed_with_code', code: code)
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/sns.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/sns.rb
index 52604fd8c6..96a01a360c 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/sns.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/sns.rb
@@ -55,7 +55,7 @@ module OpenProject::TwoFactorAuthentication
end
def submit
- aws_params = self.configuration_params.slice :region, :access_key_id, :secret_access_key
+ aws_params = configuration_params.slice :region, :access_key_id, :secret_access_key
sns = ::Aws::SNS::Client.new aws_params
sns.set_sms_attributes(
@@ -65,7 +65,7 @@ module OpenProject::TwoFactorAuthentication
'DefaultSMSType' => 'Transactional',
# Set sender ID name (may not be supported in all countries)
- 'DefaultSenderID' => self.configuration_params.fetch(:sender_id, 'OpenProject')
+ 'DefaultSenderID' => configuration_params.fetch(:sender_id, 'OpenProject')
}
)
@@ -80,9 +80,11 @@ module OpenProject::TwoFactorAuthentication
end
raise result
- rescue => e
- Rails.logger.error { "[2FA] SNS delivery failed for user #{user.login} " \
- "(Error: #{e})" }
+ rescue StandardError => e
+ Rails.logger.error do
+ "[2FA] SNS delivery failed for user #{user.login} " \
+ "(Error: #{e})"
+ end
raise I18n.t('two_factor_authentication.sns.delivery_failed')
end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/totp.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/totp.rb
index b6792cde77..4221c8cd5a 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/totp.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/totp.rb
@@ -1,9 +1,8 @@
require 'rotp'
module OpenProject::TwoFactorAuthentication
-module TokenStrategy
+ module TokenStrategy
class Totp < Base
-
def verify(input_token)
result = device.verify_token input_token
@@ -41,4 +40,4 @@ module TokenStrategy
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
index bf3034a031..7217c3f9a9 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy_manager.rb
@@ -8,7 +8,7 @@ module OpenProject::TwoFactorAuthentication
active_strategies.detect { |s| s.supported_channels.include? channel.to_sym }
end
- #validate_configuration
+ # validate_configuration
def validate_configuration!
validate_active_strategies!
end
@@ -134,7 +134,7 @@ module OpenProject::TwoFactorAuthentication
totp: I18n.t("activerecord.models.two_factor_authentication/device/totp"),
sns: I18n.t("activerecord.models.two_factor_authentication/device/sms"),
restdt: I18n.t("activerecord.models.two_factor_authentication/device/restdt"),
- message_bird: I18n.t("activerecord.models.two_factor_authentication/device/sms"),
+ message_bird: I18n.t("activerecord.models.two_factor_authentication/device/sms")
}
end
diff --git a/modules/two_factor_authentication/openproject-two_factor_authentication.gemspec b/modules/two_factor_authentication/openproject-two_factor_authentication.gemspec
index e57f165f96..a7c5ddf207 100644
--- a/modules/two_factor_authentication/openproject-two_factor_authentication.gemspec
+++ b/modules/two_factor_authentication/openproject-two_factor_authentication.gemspec
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
s.files = Dir["{app,config,db,lib}/**/*", "CHANGELOG.md", "README.rdoc"]
s.test_files = Dir["spec/**/*"]
- s.add_dependency 'rotp', '~> 6.1'
s.add_dependency 'messagebird-rest', '~> 1.4.2'
+ s.add_dependency 'rotp', '~> 6.1'
s.add_dependency 'aws-sdk-sns', '~> 1.37.0'
end
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_shared_examples.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_shared_examples.rb
index 024a403c34..07a369b6b6 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_shared_examples.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_shared_examples.rb
@@ -18,7 +18,8 @@ end
shared_examples '2FA forced registry' do
it "should not log in user" do
- expect(User.current).not_to eq(user) end
+ expect(User.current).not_to eq(user)
+ end
it "should set authenticated user" do
expect(session[:authenticated_user_force_2fa]).to be_truthy
@@ -106,7 +107,6 @@ shared_examples '2FA TOTP request success' do
# Can post to login_otp with pending and token
describe 'follow-up post of a login token' do
-
before do
# Assume the user is pending
session[:authenticated_user_id] = user.id
@@ -153,7 +153,6 @@ shared_examples '2FA SMS request success' do
post :confirm_otp, params: { otp: valid_token.value }
end
-
context 'when not expired' do
let(:expired) { false }
it_behaves_like 'immediate success login'
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_spec.rb
index 406c39a167..dff1ed2d48 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/authentication_controller_spec.rb
@@ -22,7 +22,8 @@ describe ::TwoFactorAuthentication::AuthenticationController, with_2fa_ee: true,
it_behaves_like 'immediate success login'
end
- describe 'with no active strategy, but 2FA enforced as configuration', with_config: { '2fa' => { active_strategies: [], enforced: true } } do
+ describe 'with no active strategy, but 2FA enforced as configuration',
+ with_config: { '2fa' => { active_strategies: [], enforced: true } } do
before do
allow(OpenProject::TwoFactorAuthentication::TokenStrategyManager)
.to receive(:add_default_strategy?)
@@ -81,7 +82,7 @@ describe ::TwoFactorAuthentication::AuthenticationController, with_2fa_ee: true,
end
end
- describe 'with two active strategy', with_config: { '2fa' => { active_strategies: [:developer, :totp] } } do
+ describe 'with two active strategy', with_config: { '2fa' => { active_strategies: %i[developer totp] } } do
context 'with a totp device' do
let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, channel: :totp }
it_behaves_like '2FA TOTP request success'
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
index cca6a58d5b..2b7f83fc7c 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/forced_registration/two_factor_devices_controller_spec.rb
@@ -134,7 +134,7 @@ describe ::TwoFactorAuthentication::ForcedRegistration::TwoFactorDevicesControll
describe 'and registered totp device' do
let(:active_strategies) { [:totp] }
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false }
it 'renders the confirmation page' do
get :confirm, params: { device_id: device.id }
@@ -145,7 +145,7 @@ describe ::TwoFactorAuthentication::ForcedRegistration::TwoFactorDevicesControll
end
describe 'with registered device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false }
it 'renders the confirmation page' do
get :confirm, params: { device_id: device.id }
@@ -173,7 +173,7 @@ describe ::TwoFactorAuthentication::ForcedRegistration::TwoFactorDevicesControll
describe 'and registered totp device' do
let(:active_strategies) { [:totp] }
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false }
it 'renders a 400 on missing token' do
post :confirm, params: { device_id: device.id }
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
index 4c6d15e227..9713512e30 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/my/two_factor_devices_controller_spec.rb
@@ -115,7 +115,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
describe 'and registered totp device' do
let(:active_strategies) { [:totp] }
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false }
it 'renders the confirmation page' do
get :confirm, params: { device_id: device.id }
@@ -126,7 +126,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
end
describe 'with registered device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: false, default: false }
it 'renders the confirmation page' do
get :confirm, params: { device_id: device.id }
@@ -154,7 +154,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
describe 'and registered totp device' do
let(:active_strategies) { [:totp] }
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: false, default: false }
it 'renders a 400 on missing token' do
post :confirm, params: { device_id: device.id }
@@ -187,7 +187,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
end
context 'with another default device present' do
- let!(:default_device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:default_device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
it 'activates the device when entered correctly' do
allow_any_instance_of(::TwoFactorAuthentication::TokenService)
@@ -220,7 +220,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
end
context 'with existing non-default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false }
it 'deletes it' do
delete :destroy, params: { device_id: device.id }
@@ -230,7 +230,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
end
context 'with existing default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
it 'deletes it' do
delete :destroy, params: { device_id: device.id }
@@ -240,7 +240,7 @@ describe ::TwoFactorAuthentication::My::TwoFactorDevicesController, with_2fa_ee:
end
context 'with existing default device AND enforced' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
let(:config) { { enforced: true } }
it 'cannot be deleted' do
diff --git a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
index 8c2b2482ba..cca615bf1f 100644
--- a/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
+++ b/modules/two_factor_authentication/spec/controllers/two_factor_authentication/users/two_factor_devices_controller_spec.rb
@@ -123,7 +123,7 @@ describe ::TwoFactorAuthentication::Users::TwoFactorDevicesController, with_2fa_
end
context 'with existing non-default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: false }
it 'deletes it' do
delete :destroy, params: { id: user.id, device_id: device.id }
@@ -133,7 +133,7 @@ describe ::TwoFactorAuthentication::Users::TwoFactorDevicesController, with_2fa_
end
context 'with existing default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
it 'deletes it' do
delete :destroy, params: { id: user.id, device_id: device.id }
@@ -143,7 +143,7 @@ describe ::TwoFactorAuthentication::Users::TwoFactorDevicesController, with_2fa_
end
context 'with existing default device AND enforced' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
let(:config) { { enforced: true } }
it 'cannot be deleted' do
diff --git a/modules/two_factor_authentication/spec/features/account_activation_spec.rb b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
index 9c723ada07..1c0e328092 100644
--- a/modules/two_factor_authentication/spec/features/account_activation_spec.rb
+++ b/modules/two_factor_authentication/spec/features/account_activation_spec.rb
@@ -5,14 +5,14 @@ describe 'activating an invited account',
with_2fa_ee: true,
type: :feature,
js: true,
- with_config: {:'2fa' => {active_strategies: [:developer]}} do
- let(:user) {
+ with_config: { '2fa': { active_strategies: [:developer] } } do
+ let(:user) do
user = FactoryBot.build :user, first_login: true
UserInvitation.invite_user! user
user
- }
- let(:token) {Token::Invitation.find_by(user_id: user.id)}
+ end
+ let(:token) { Token::Invitation.find_by(user_id: user.id) }
def activate!
visit url_for(controller: :account,
@@ -38,7 +38,7 @@ describe 'activating an invited account',
end
context 'when not enforced, but device present' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: true }
it 'requests a OTP' do
sms_token = nil
@@ -72,7 +72,7 @@ describe 'activating an invited account',
end
end
- context 'when enforced', with_config: {:'2fa' => {active_strategies: [:developer], enforced: true}} do
+ context 'when enforced', with_config: { '2fa': { active_strategies: [:developer], enforced: true } } do
before do
activate!
end
diff --git a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
index d5f0d23918..75d8384938 100644
--- a/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/features/admin_edit_two_factor_devices_spec.rb
@@ -1,19 +1,17 @@
require_relative '../spec_helper'
describe 'Admin 2FA management', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer, :totp]}},
- js: true do
+ with_config: { '2fa': { active_strategies: %i[developer totp] } },
+ js: true do
let(:dialog) { ::Components::PasswordConfirmationDialog.new }
- let(:user_password) {'admin!' * 4}
+ let(:user_password) { 'admin!' * 4 }
let(:other_user) { FactoryBot.create :user, login: 'bob' }
let(:admin) do
FactoryBot.create(:admin,
- password: user_password,
- password_confirmation: user_password,
- )
+ password: user_password,
+ password_confirmation: user_password)
end
-
before do
login_as admin
end
@@ -33,7 +31,8 @@ describe 'Admin 2FA management', with_2fa_ee: true, type: :feature,
visit edit_user_path(other_user, tab: :two_factor_authentication)
# Visit empty index
- expect(page).to have_selector('.generic-table--empty-row', text: I18n.t('two_factor_authentication.admin.no_devices_for_user'))
+ expect(page).to have_selector('.generic-table--empty-row',
+ text: I18n.t('two_factor_authentication.admin.no_devices_for_user'))
expect(page).to have_selector('.on-off-status.-disabled')
# Visit inline create
@@ -83,4 +82,3 @@ describe 'Admin 2FA management', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/backup_codes/generate_backup_codes.rb b/modules/two_factor_authentication/spec/features/backup_codes/generate_backup_codes.rb
index 9b7f7b936a..8c06059e8d 100644
--- a/modules/two_factor_authentication/spec/features/backup_codes/generate_backup_codes.rb
+++ b/modules/two_factor_authentication/spec/features/backup_codes/generate_backup_codes.rb
@@ -2,15 +2,14 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Generate 2FA backup codes', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer]}},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: [:developer] } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
let(:dialog) { ::Components::PasswordConfirmationDialog.new }
@@ -45,4 +44,3 @@ describe 'Generate 2FA backup codes', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
index cf8fb8f89f..baa6c8f832 100644
--- a/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
+++ b/modules/two_factor_authentication/spec/features/backup_codes/login_with_backup_code_spec.rb
@@ -2,17 +2,16 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Login with 2FA backup code', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer]}},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: [:developer] } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true }
context 'user has no backup code' do
it 'does not show the backup code link' do
@@ -70,4 +69,3 @@ describe 'Login with 2FA backup code', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
index 1b5c1d0c68..e83372d7b8 100644
--- a/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/login_enforced_2fa_spec.rb
@@ -2,19 +2,18 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Login with enforced 2FA', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer], enforced: true }},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: [:developer], enforced: true } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
context 'with a default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true }
it 'requests a 2FA' do
sms_token = nil
@@ -45,4 +44,3 @@ describe 'Login with enforced 2FA', with_2fa_ee: true, type: :feature,
it_behaves_like 'create enforced sms device'
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
index 12cd20d72e..7aea83bd27 100644
--- a/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/login_with_2fa_spec.rb
@@ -2,19 +2,18 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Login with 2FA device', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer]}},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: [:developer] } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
context 'with a default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true }
it 'requests a 2FA' do
sms_token = nil
@@ -37,4 +36,3 @@ describe 'Login with 2FA device', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/login/login_without_2fa_spec.rb b/modules/two_factor_authentication/spec/features/login/login_without_2fa_spec.rb
index 56d8ea1279..84c9d59748 100644
--- a/modules/two_factor_authentication/spec/features/login/login_without_2fa_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/login_without_2fa_spec.rb
@@ -2,26 +2,24 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Login with no required OTP', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer]}},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: [:developer] } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
context 'non-default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: false }
it_behaves_like 'login without 2FA'
end
context 'not enabled',
- with_config: {:'2fa' => {active_strategies: []}} do
-
+ with_config: { '2fa': { active_strategies: [] } } do
it_behaves_like 'login without 2FA'
end
@@ -29,4 +27,3 @@ describe 'Login with no required OTP', with_2fa_ee: true, type: :feature,
it_behaves_like 'login without 2FA'
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/login/switch_available_devices_spec.rb b/modules/two_factor_authentication/spec/features/login/switch_available_devices_spec.rb
index 20dceb9ff9..06a9163c80 100644
--- a/modules/two_factor_authentication/spec/features/login/switch_available_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/features/login/switch_available_devices_spec.rb
@@ -2,20 +2,19 @@ require_relative '../../spec_helper'
require_relative '../shared_2fa_examples'
describe 'Login by switching 2FA device', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer, :totp]}},
- js: true do
- let(:user_password) {'bob!' * 4}
+ with_config: { '2fa': { active_strategies: %i[developer totp] } },
+ js: true do
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
context 'with two default device' do
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true}
- let!(:device2) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: true, default: false}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true }
+ let!(:device2) { FactoryBot.create :two_factor_authentication_device_totp, user: user, active: true, default: false }
it 'requests a 2FA and allows switching' do
first_login_step
@@ -37,4 +36,3 @@ describe 'Login by switching 2FA device', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
index 7b6d7d94ec..3cdfa837b4 100644
--- a/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/features/my_two_factor_devices_spec.rb
@@ -1,16 +1,15 @@
require_relative '../spec_helper'
describe 'My Account 2FA configuration', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer, :totp]}},
- js: true do
+ with_config: { '2fa': { active_strategies: %i[developer totp] } },
+ js: true do
let(:dialog) { ::Components::PasswordConfirmationDialog.new }
- let(:user_password) {'bob!' * 4}
+ let(:user_password) { 'bob!' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
before do
@@ -18,7 +17,6 @@ describe 'My Account 2FA configuration', with_2fa_ee: true, type: :feature,
end
it 'allows 2FA device management' do
-
# Visit empty index
visit my_2fa_devices_path
expect(page).to have_selector('.generic-table--empty-row', text: I18n.t('two_factor_authentication.devices.not_existing'))
@@ -55,7 +53,8 @@ describe 'My Account 2FA configuration', with_2fa_ee: true, type: :feature,
expect(page).to have_selector('h2', text: I18n.t('two_factor_authentication.devices.confirm_device'))
expect(page).to have_selector('input#otp')
- expect(page).to have_selector('.flash.error', text: I18n.t('two_factor_authentication.devices.registration_failed_token_invalid'))
+ expect(page).to have_selector('.flash.error',
+ text: I18n.t('two_factor_authentication.devices.registration_failed_token_invalid'))
# Fill in correct token
fill_in 'otp', with: sms_token
@@ -136,4 +135,3 @@ describe 'My Account 2FA configuration', with_2fa_ee: true, type: :feature,
expect(user.otp_devices.count).to eq 0
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/password_change_spec.rb b/modules/two_factor_authentication/spec/features/password_change_spec.rb
index 5df2c60223..f54bc92ccb 100644
--- a/modules/two_factor_authentication/spec/features/password_change_spec.rb
+++ b/modules/two_factor_authentication/spec/features/password_change_spec.rb
@@ -1,19 +1,17 @@
require_relative '../spec_helper'
describe 'Password change with OTP', with_2fa_ee: true, type: :feature,
- with_config: {:'2fa' => {active_strategies: [:developer]}},
- js: true do
- let(:user_password) {'bob' * 4}
- let(:new_user_password) {'obb' * 4}
+ with_config: { '2fa': { active_strategies: [:developer] } },
+ js: true do
+ let(:user_password) { 'bob' * 4 }
+ let(:new_user_password) { 'obb' * 4 }
let(:user) do
FactoryBot.create(:user,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
- let(:expected_path_after_login) {my_page_path}
-
+ let(:expected_path_after_login) { my_page_path }
def handle_password_change(requires_otp: true)
visit signin_path
@@ -49,8 +47,7 @@ describe 'Password change with OTP', with_2fa_ee: true, type: :feature,
end
context 'when password is expired',
- with_settings: {password_days_valid: 7} do
-
+ with_settings: { password_days_valid: 7 } do
before do
user
end
@@ -89,18 +86,17 @@ describe 'Password change with OTP', with_2fa_ee: true, type: :feature,
end
context 'when force password change is set' do
- let(:user_password) {'bob' * 4}
- let(:new_user_password) {'obb' * 4}
+ let(:user_password) { 'bob' * 4 }
+ let(:new_user_password) { 'obb' * 4 }
let(:user) do
FactoryBot.create(:user,
- force_password_change: true,
- first_login: true,
- login: 'bob',
- password: user_password,
- password_confirmation: user_password,
- )
+ force_password_change: true,
+ first_login: true,
+ login: 'bob',
+ password: user_password,
+ password_confirmation: user_password)
end
- let(:expected_path_after_login) {home_path}
+ let(:expected_path_after_login) { home_path }
before do
user
@@ -123,4 +119,3 @@ describe 'Password change with OTP', with_2fa_ee: true, type: :feature,
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
index c12a638fd1..0c748486ea 100644
--- a/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
+++ b/modules/two_factor_authentication/spec/features/remember_cookie/login_with_remember_cookie_spec.rb
@@ -13,7 +13,7 @@ describe 'Login with 2FA remember cookie',
# Works because the user is not reloaded
user.password
end
- let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, active: true, default: true }
def login_with_cookie
page.driver.browser.manage.delete_all_cookies
@@ -42,8 +42,7 @@ describe 'Login with 2FA remember cookie',
end
context 'not enabled',
-
- with_config: {:'2fa' => {active_strategies: [:developer], allow_remember_for_days: 0 }} do
+ with_config: { '2fa': { active_strategies: [:developer], allow_remember_for_days: 0 } } do
it 'does not show the save form' do
first_login_step
expect(page).to have_no_selector('input#remember_me')
@@ -104,4 +103,3 @@ describe 'Login with 2FA remember cookie',
end
end
end
-
diff --git a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
index d30ba8e923..7c563ce118 100644
--- a/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
+++ b/modules/two_factor_authentication/spec/features/shared_2fa_examples.rb
@@ -35,7 +35,8 @@ end
shared_examples 'create enforced sms device' do
it do
- expect(page).to have_selector('.flash.info', text: I18n.t('two_factor_authentication.forced_registration.required_to_add_device'))
+ expect(page).to have_selector('.flash.info',
+ text: I18n.t('two_factor_authentication.forced_registration.required_to_add_device'))
SeleniumHubWaiter.wait
# Create SMS device
@@ -44,7 +45,6 @@ shared_examples 'create enforced sms device' do
fill_in 'device_phone_number', with: 'invalid'
click_on 'Continue'
-
# Expect error on invalid phone
expect(page).to have_selector('#errorExplanation', text: 'Phone number must be of format +XX XXXXXXXXX')
@@ -71,7 +71,8 @@ shared_examples 'create enforced sms device' do
expect(page).to have_selector('h2', text: I18n.t('two_factor_authentication.devices.confirm_device'))
expect(page).to have_selector('input#otp')
- expect(page).to have_selector('.flash.error', text: I18n.t('two_factor_authentication.devices.registration_failed_token_invalid'))
+ expect(page).to have_selector('.flash.error',
+ text: I18n.t('two_factor_authentication.devices.registration_failed_token_invalid'))
SeleniumHubWaiter.wait
# Fill in wrong token
diff --git a/modules/two_factor_authentication/spec/lib/token_strategy_manager_spec.rb b/modules/two_factor_authentication/spec/lib/token_strategy_manager_spec.rb
index 49343272e2..8b2d17f55a 100644
--- a/modules/two_factor_authentication/spec/lib/token_strategy_manager_spec.rb
+++ b/modules/two_factor_authentication/spec/lib/token_strategy_manager_spec.rb
@@ -174,4 +174,4 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategyManager do
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb b/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
index 85159fd0e2..43f390e3c9 100644
--- a/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
+++ b/modules/two_factor_authentication/spec/models/devices/default_device_spec.rb
@@ -31,4 +31,4 @@ describe 'Default device', with_2fa_ee: true, type: :model do
expect(user.otp_devices.get_default).to eq(subject)
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/two_factor_authentication/spec/models/devices/totp_spec.rb b/modules/two_factor_authentication/spec/models/devices/totp_spec.rb
index 626292681e..d7575ea285 100644
--- a/modules/two_factor_authentication/spec/models/devices/totp_spec.rb
+++ b/modules/two_factor_authentication/spec/models/devices/totp_spec.rb
@@ -27,7 +27,7 @@ describe ::TwoFactorAuthentication::Device::Totp, with_2fa_ee: true, type: :mode
describe 'token validation' do
let(:totp) { subject.send :totp }
- context 'drift', with_config: { :'2fa' => { otp_drift_window: 30 } } do
+ context 'drift', with_config: { '2fa': { otp_drift_window: 30 } } do
it 'uses the drift window from configuration' do
expect(subject.allowed_drift).to eq 30
end
diff --git a/modules/two_factor_authentication/spec/models/login_token_spec.rb b/modules/two_factor_authentication/spec/models/login_token_spec.rb
index 2b706f1a44..44ce4e4419 100644
--- a/modules/two_factor_authentication/spec/models/login_token_spec.rb
+++ b/modules/two_factor_authentication/spec/models/login_token_spec.rb
@@ -1,14 +1,13 @@
require_relative '../spec_helper'
describe TwoFactorAuthentication::LoginToken, with_2fa_ee: true do
-
before(:each) do
@user = FactoryBot.build_stubbed(:user, login: "john", password: "doe")
allow(@user).to receive(:new_record?).and_return(false)
allow(@user).to receive(:force_password_reset).and_return(false)
allow(@user).to receive(:password_expired?).and_return(false)
allow(@user).to receive(:phone_verified?).and_return(true)
- @token = described_class.new( :user => @user )
+ @token = described_class.new(user: @user)
@token.save
end
@@ -25,10 +24,9 @@ describe TwoFactorAuthentication::LoginToken, with_2fa_ee: true do
end
it "should delete previous tokens for the user on creation" do
- @new_token = described_class.new( :user => @user )
+ @new_token = described_class.new(user: @user)
@new_token.save
- expect(described_class.find_by_id( @token.id )).to eq(nil)
- expect(described_class.find( @new_token.id )).not_to eq(nil)
+ expect(described_class.find_by_id(@token.id)).to eq(nil)
+ expect(described_class.find(@new_token.id)).not_to eq(nil)
end
-
end
diff --git a/modules/two_factor_authentication/spec/models/user_spec.rb b/modules/two_factor_authentication/spec/models/user_spec.rb
index 368d1b86a0..604cd31068 100644
--- a/modules/two_factor_authentication/spec/models/user_spec.rb
+++ b/modules/two_factor_authentication/spec/models/user_spec.rb
@@ -9,11 +9,11 @@ module OpenProject::TwoFactorAuthentication::Patches
@password = @user.password
@user.auth_source_id = auth_source_id
@user.save!
- allow_any_instance_of(User).to receive_messages(:allowed_to? => true, :active? => true)
+ allow_any_instance_of(User).to receive_messages(allowed_to?: true, active?: true)
end
def create_user_with_auth_source
- auth_source = AuthSource.new :name => "test"
+ auth_source = AuthSource.new name: "test"
create_user auth_source.id
end
@@ -25,7 +25,7 @@ module OpenProject::TwoFactorAuthentication::Patches
login_with @username, @password + "INVALID"
end
- def login_with login, password
+ def login_with(login, password)
User.try_to_login(login, password)
end
diff --git a/modules/two_factor_authentication/spec/routing/two_factor_authentication/my/two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/routing/two_factor_authentication/my/two_factor_devices_spec.rb
index a15aa49e61..6595a77908 100644
--- a/modules/two_factor_authentication/spec/routing/two_factor_authentication/my/two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/routing/two_factor_authentication/my/two_factor_devices_spec.rb
@@ -61,7 +61,7 @@ describe 'users 2fa devices', type: :routing do
it 'route to DELETE destroy' do
expect(delete('/my/two_factor_devices/1')).to route_to(controller: 'two_factor_authentication/my/two_factor_devices',
- action: 'destroy',
- device_id: '1')
+ action: 'destroy',
+ device_id: '1')
end
end
diff --git a/modules/two_factor_authentication/spec/routing/two_factor_authentication/users/two_factor_devices_spec.rb b/modules/two_factor_authentication/spec/routing/two_factor_authentication/users/two_factor_devices_spec.rb
index d13c2f4130..ec0d21b377 100644
--- a/modules/two_factor_authentication/spec/routing/two_factor_authentication/users/two_factor_devices_spec.rb
+++ b/modules/two_factor_authentication/spec/routing/two_factor_authentication/users/two_factor_devices_spec.rb
@@ -31,8 +31,8 @@ require 'spec_helper'
describe 'users 2fa devices', type: :routing do
it 'route to GET new' do
expect(get('/users/2/two_factor_devices/new')).to route_to(controller: 'two_factor_authentication/users/two_factor_devices',
- action: 'new',
- id: '2')
+ action: 'new',
+ id: '2')
end
it 'route to POST register' do
@@ -43,21 +43,21 @@ describe 'users 2fa devices', type: :routing do
it 'route to POST confirm' do
expect(post('/users/2/two_factor_devices/1/make_default')).to route_to(controller: 'two_factor_authentication/users/two_factor_devices',
- action: 'make_default',
- id: '2',
- device_id: '1')
+ action: 'make_default',
+ id: '2',
+ device_id: '1')
end
it 'route to POST delete_all' do
expect(post('/users/2/two_factor_devices/delete_all')).to route_to(controller: 'two_factor_authentication/users/two_factor_devices',
- action: 'delete_all',
- id: '2')
+ action: 'delete_all',
+ id: '2')
end
it 'route to DELETE destroy' do
expect(delete('/users/2/two_factor_devices/1')).to route_to(controller: 'two_factor_authentication/users/two_factor_devices',
- action: 'destroy',
- id: '2',
- device_id: '1')
+ action: 'destroy',
+ id: '2',
+ device_id: '1')
end
end
diff --git a/modules/two_factor_authentication/spec/services/token_delivery/message_bird_spec.rb b/modules/two_factor_authentication/spec/services/token_delivery/message_bird_spec.rb
index 9785c8fc85..1747d728b9 100644
--- a/modules/two_factor_authentication/spec/services/token_delivery/message_bird_spec.rb
+++ b/modules/two_factor_authentication/spec/services/token_delivery/message_bird_spec.rb
@@ -8,11 +8,11 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird, wit
let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel }
let(:service_url) { 'https://example.org/foobar' }
- let(:params) {
+ let(:params) do
{
- apikey: 'whatever'
+ apikey: 'whatever'
}
- }
+ end
before do
allow(OpenProject::Configuration)
diff --git a/modules/two_factor_authentication/spec/services/token_delivery/restdt_spec.rb b/modules/two_factor_authentication/spec/services/token_delivery/restdt_spec.rb
index 1b1c1bc0d3..c7fe2e4c1c 100644
--- a/modules/two_factor_authentication/spec/services/token_delivery/restdt_spec.rb
+++ b/modules/two_factor_authentication/spec/services/token_delivery/restdt_spec.rb
@@ -6,15 +6,15 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Restdt, with_2fa
let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel }
let(:service_url) { 'https://example.org/foobar' }
- let(:params) {
+ let(:params) do
{
service_url: service_url,
username: 'foobar',
password: 'password!'
}
- }
+ end
- let(:base_request) {
+ let(:base_request) do
{
user: 'foobar',
pass: 'password!',
@@ -23,7 +23,7 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Restdt, with_2fa
txt: '1234',
output: 'plain'
}
- }
+ end
before do
allow(OpenProject::Configuration)
diff --git a/modules/two_factor_authentication/spec/services/token_delivery/sns_spec.rb b/modules/two_factor_authentication/spec/services/token_delivery/sns_spec.rb
index 0c4619dc64..6862cfce4f 100644
--- a/modules/two_factor_authentication/spec/services/token_delivery/sns_spec.rb
+++ b/modules/two_factor_authentication/spec/services/token_delivery/sns_spec.rb
@@ -7,13 +7,13 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Sns, with_2fa_ee
let!(:device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, channel: channel }
let(:channel) { :sms }
- let(:params) {
+ let(:params) do
{
region: 'eu-west-1',
access_key_id: 'foobar',
secret_access_key: 'foobar key'
}
- }
+ end
before do
allow(OpenProject::Configuration)
@@ -66,7 +66,8 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Sns, with_2fa_ee
expect(api)
.to receive(:publish)
.with(phone_number: phone.gsub(' ', ''),
- message: I18n.t('two_factor_authentication.text_otp_delivery_message_sms', app_title: Setting.app_title, token: 1234))
+ message: I18n.t('two_factor_authentication.text_otp_delivery_message_sms', app_title: Setting.app_title,
+ token: 1234))
.and_return(api_result)
end
diff --git a/modules/two_factor_authentication/spec/services/token_delivery/totp_spec.rb b/modules/two_factor_authentication/spec/services/token_delivery/totp_spec.rb
index 5ac4e7cacb..0a447ff718 100644
--- a/modules/two_factor_authentication/spec/services/token_delivery/totp_spec.rb
+++ b/modules/two_factor_authentication/spec/services/token_delivery/totp_spec.rb
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::Totp, with_2fa_ee: true do
describe 'sending messages' do
let!(:user) { FactoryBot.create :user }
- let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true}
+ let!(:device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
before do
allow(OpenProject::Configuration)
diff --git a/modules/two_factor_authentication/spec/services/token_service_spec.rb b/modules/two_factor_authentication/spec/services/token_service_spec.rb
index a4af599203..9f90b5f898 100644
--- a/modules/two_factor_authentication/spec/services/token_service_spec.rb
+++ b/modules/two_factor_authentication/spec/services/token_service_spec.rb
@@ -93,7 +93,7 @@ describe ::TwoFactorAuthentication::TokenService, with_2fa_ee: true do
end
context 'when developer and totp strategies are set' do
- let(:active_strategies) { [:developer, :totp] }
+ let(:active_strategies) { %i[developer totp] }
let!(:totp_device) { FactoryBot.create :two_factor_authentication_device_totp, user: user, default: true }
let!(:sms_device) { FactoryBot.create :two_factor_authentication_device_sms, user: user, default: false }
diff --git a/modules/two_factor_authentication/spec/spec_helper.rb b/modules/two_factor_authentication/spec/spec_helper.rb
index d170945a80..ccee9f71c2 100644
--- a/modules/two_factor_authentication/spec/spec_helper.rb
+++ b/modules/two_factor_authentication/spec/spec_helper.rb
@@ -14,4 +14,4 @@ RSpec.configure do |config|
.with(:two_factor_authentication)
.and_return true
end
-end
\ No newline at end of file
+end
diff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb b/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb
index 8314c9a3ca..b2d92b0b5d 100644
--- a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb
+++ b/modules/webhooks/app/cells/webhooks/outgoing/deliveries/row_cell.rb
@@ -19,4 +19,4 @@ module ::Webhooks
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb b/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb
index 66bab5a586..2aa5321148 100644
--- a/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb
+++ b/modules/webhooks/app/cells/webhooks/outgoing/deliveries/table_cell.rb
@@ -14,11 +14,11 @@ module ::Webhooks
def headers
[
- ['id', caption: I18n.t('attributes.id')],
- ['event_name', caption: ::Webhooks::Log.human_attribute_name('event_name')],
- ['time', caption: I18n.t('webhooks.outgoing.deliveries.time')],
- ['response_code', caption: ::Webhooks::Log.human_attribute_name('response_code')],
- ['response_body', caption: ::Webhooks::Log.human_attribute_name('response_body')],
+ ['id', { caption: I18n.t('attributes.id') }],
+ ['event_name', { caption: ::Webhooks::Log.human_attribute_name('event_name') }],
+ ['time', { caption: I18n.t('webhooks.outgoing.deliveries.time') }],
+ ['response_code', { caption: ::Webhooks::Log.human_attribute_name('response_code') }],
+ ['response_body', { caption: ::Webhooks::Log.human_attribute_name('response_body') }]
]
end
end
diff --git a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb b/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb
index 53628da9ee..fc99ada650 100644
--- a/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb
+++ b/modules/webhooks/app/cells/webhooks/outgoing/webhooks/table_cell.rb
@@ -5,7 +5,7 @@ module ::Webhooks
columns :name, :enabled, :selected_projects, :events, :description
def initial_sort
- [:id, :asc]
+ %i[id asc]
end
def target_controller
@@ -20,7 +20,7 @@ module ::Webhooks
link_to({ controller: target_controller, action: :new },
class: 'webhooks--add-row wp-inline-create--add-link',
title: I18n.t('webhooks.outgoing.label_add_new')) do
- op_icon('icon icon-add')
+ op_icon('icon icon-add')
end
end
@@ -30,14 +30,14 @@ module ::Webhooks
def headers
[
- ['name', caption: I18n.t('attributes.name')],
- ['enabled', caption: I18n.t(:label_active)],
- ['selected_projects', caption: ::Webhooks::Webhook.human_attribute_name('projects')],
- ['events', caption: I18n.t('webhooks.outgoing.label_event_resources')],
- ['description', caption: I18n.t('attributes.description')]
+ ['name', { caption: I18n.t('attributes.name') }],
+ ['enabled', { caption: I18n.t(:label_active) }],
+ ['selected_projects', { caption: ::Webhooks::Webhook.human_attribute_name('projects') }],
+ ['events', { caption: I18n.t('webhooks.outgoing.label_event_resources') }],
+ ['description', { caption: I18n.t('attributes.description') }]
]
end
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
index 5dad2791d0..01beea6a3b 100644
--- a/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
+++ b/modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb b/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
index c692241574..ce903e0438 100644
--- a/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
+++ b/modules/webhooks/app/controllers/webhooks/outgoing/admin_controller.rb
@@ -4,7 +4,7 @@ module Webhooks
layout 'admin'
before_action :require_admin
- before_action :find_webhook, only: [:show, :edit, :update, :destroy]
+ before_action :find_webhook, only: %i[show edit update destroy]
menu_item :plugin_webhooks
@@ -13,6 +13,7 @@ module Webhooks
end
def show; end
+
def edit; end
def new
@@ -70,7 +71,6 @@ module Webhooks
.require(:webhook)
.permit(:name, :description, :url, :secret, :enabled,
:project_ids, selected_project_ids: [], events: [])
-
end
def show_local_breadcrumb
diff --git a/modules/webhooks/app/models/webhooks.rb b/modules/webhooks/app/models/webhooks.rb
index aac358193c..03e7ca3512 100644
--- a/modules/webhooks/app/models/webhooks.rb
+++ b/modules/webhooks/app/models/webhooks.rb
@@ -2,4 +2,4 @@ module Webhooks
def self.table_name_prefix
'webhooks_'
end
-end
\ No newline at end of file
+end
diff --git a/modules/webhooks/app/services/webhooks/outgoing/update_webhook_service.rb b/modules/webhooks/app/services/webhooks/outgoing/update_webhook_service.rb
index 7350ea58d7..3dbdfc8d0d 100644
--- a/modules/webhooks/app/services/webhooks/outgoing/update_webhook_service.rb
+++ b/modules/webhooks/app/services/webhooks/outgoing/update_webhook_service.rb
@@ -1,8 +1,7 @@
module Webhooks
module Outgoing
class UpdateWebhookService
- attr_reader :current_user
- attr_reader :webhook
+ attr_reader :current_user, :webhook
def initialize(webhook, current_user:)
@current_user = current_user
@@ -12,10 +11,10 @@ module Webhooks
def call(attributes: {})
::Webhooks::Webhook.transaction do
set_attributes attributes
- raise ActiveRecord::Rollback unless (webhook.errors.empty? && webhook.save)
+ raise ActiveRecord::Rollback unless webhook.errors.empty? && webhook.save
end
- ServiceResult.new success: webhook.errors.empty? , errors: webhook.errors, result: webhook
+ ServiceResult.new success: webhook.errors.empty?, errors: webhook.errors, result: webhook
end
private
diff --git a/modules/webhooks/app/workers/webhook_job.rb b/modules/webhooks/app/workers/webhook_job.rb
index 2c6c4bd181..e39b93849e 100644
--- a/modules/webhooks/app/workers/webhook_job.rb
+++ b/modules/webhooks/app/workers/webhook_job.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/modules/webhooks/lib/open_project/webhooks/engine.rb b/modules/webhooks/lib/open_project/webhooks/engine.rb
index bf08d9b83a..80c69395d6 100644
--- a/modules/webhooks/lib/open_project/webhooks/engine.rb
+++ b/modules/webhooks/lib/open_project/webhooks/engine.rb
@@ -37,13 +37,13 @@ module OpenProject::Webhooks
register 'openproject-webhooks',
bundled: true,
author_url: 'https://github.com/opf/openproject-webhooks' do
- menu :admin_menu,
- :plugin_webhooks,
- { controller: 'webhooks/outgoing/admin', action: :index },
- if: Proc.new { User.current.admin? },
- after: :plugins,
- caption: ->(*) { I18n.t('webhooks.plural') },
- icon: 'icon2 icon-relations'
+ menu :admin_menu,
+ :plugin_webhooks,
+ { controller: 'webhooks/outgoing/admin', action: :index },
+ if: Proc.new { User.current.admin? },
+ after: :plugins,
+ caption: ->(*) { I18n.t('webhooks.plural') },
+ icon: 'icon2 icon-relations'
end
config.before_configuration do |app|
diff --git a/modules/webhooks/lib/open_project/webhooks/event_resources.rb b/modules/webhooks/lib/open_project/webhooks/event_resources.rb
index a19e31e6c8..7aa065f358 100644
--- a/modules/webhooks/lib/open_project/webhooks/event_resources.rb
+++ b/modules/webhooks/lib/open_project/webhooks/event_resources.rb
@@ -24,12 +24,10 @@ module OpenProject::Webhooks
def resource_modules
@resource_modules ||= begin
resources.map do |name|
- begin
- require_relative "./event_resources/#{name}"
- "OpenProject::Webhooks::EventResources::#{name.to_s.camelize}".constantize
- rescue LoadError, NameError => e
- raise ArgumentError, "Failed to initialize resources module for #{name}: #{e}"
- end
+ require_relative "./event_resources/#{name}"
+ "OpenProject::Webhooks::EventResources::#{name.to_s.camelize}".constantize
+ rescue LoadError, NameError => e
+ raise ArgumentError, "Failed to initialize resources module for #{name}: #{e}"
end
end
end
diff --git a/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb b/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
index 1e51d7bc10..bab430a0ff 100644
--- a/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
+++ b/modules/webhooks/lib/open_project/webhooks/event_resources/base.rb
@@ -18,7 +18,7 @@ module OpenProject::Webhooks::EventResources
##
# Return a mapping of event key to its localized name
def available_events_map
- Hash[available_actions.map { |symbol| [ prefixed_event_name(symbol), localize_event_name(symbol) ] }]
+ Hash[available_actions.map { |symbol| [prefixed_event_name(symbol), localize_event_name(symbol)] }]
end
##
@@ -70,4 +70,4 @@ module OpenProject::Webhooks::EventResources
end
end
end
-end
\ No newline at end of file
+end
diff --git a/modules/webhooks/lib/open_project/webhooks/hook.rb b/modules/webhooks/lib/open_project/webhooks/hook.rb
index fddd1564a3..52c09e8888 100644
--- a/modules/webhooks/lib/open_project/webhooks/hook.rb
+++ b/modules/webhooks/lib/open_project/webhooks/hook.rb
@@ -43,6 +43,5 @@ module OpenProject::Webhooks
def handle(request = Hash.new, params = Hash.new, user = nil)
callback.call self, request, params, user
end
-
end
end
diff --git a/modules/webhooks/spec/controllers/outgoing/admin_controller_spec.rb b/modules/webhooks/spec/controllers/outgoing/admin_controller_spec.rb
index 27f3630d57..107a6666b3 100644
--- a/modules/webhooks/spec/controllers/outgoing/admin_controller_spec.rb
+++ b/modules/webhooks/spec/controllers/outgoing/admin_controller_spec.rb
@@ -94,9 +94,9 @@ describe ::Webhooks::Outgoing::AdminController, type: :controller do
expect(service)
.to receive(:call)
- .and_return(ServiceResult.new success: success)
+ .and_return(ServiceResult.new(success: success))
- post :create, params: { webhook: webhook_params}
+ post :create, params: { webhook: webhook_params }
end
context 'when success' do
@@ -174,9 +174,9 @@ describe ::Webhooks::Outgoing::AdminController, type: :controller do
expect(service)
.to receive(:call)
- .and_return(ServiceResult.new success: success)
+ .and_return(ServiceResult.new(success: success))
- put :update, params: { webhook_id: '1234', webhook: webhook_params}
+ put :update, params: { webhook_id: '1234', webhook: webhook_params }
end
context 'when success' do
diff --git a/modules/webhooks/spec/controllers/webhooks_controller_spec.rb b/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
index b9ce4ab720..446334ec88 100644
--- a/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
+++ b/modules/webhooks/spec/controllers/webhooks_controller_spec.rb
@@ -26,10 +26,9 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __dir__)
-
-describe Webhooks::Incoming::HooksController, :type => :controller do
+describe Webhooks::Incoming::HooksController, type: :controller do
let(:hook) { double(OpenProject::Webhooks::Hook) }
let(:user) { double(User).as_null_object }
@@ -53,12 +52,11 @@ describe Webhooks::Incoming::HooksController, :type => :controller do
end
it 'should call the hook with a user' do
- expect(hook).to receive(:handle) { |env, params, user|
+ expect(hook).to receive(:handle) { |_env, _params, user|
expect(user).to equal(user)
}
post :handle_hook, params: { hook_name: 'testhook' }
end
-
end
end
diff --git a/modules/webhooks/spec/lib/hook_spec.rb b/modules/webhooks/spec/lib/hook_spec.rb
index 99c6f781d0..d74367baf5 100644
--- a/modules/webhooks/spec/lib/hook_spec.rb
+++ b/modules/webhooks/spec/lib/hook_spec.rb
@@ -26,11 +26,11 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../spec_helper', __dir__)
describe OpenProject::Webhooks::Hook do
describe '#relative_url' do
- let(:hook) { OpenProject::Webhooks::Hook.new('myhook')}
+ let(:hook) { OpenProject::Webhooks::Hook.new('myhook') }
it "should return the correct URL" do
expect(hook.relative_url).to eql('webhooks/myhook')
@@ -38,7 +38,7 @@ describe OpenProject::Webhooks::Hook do
end
describe '#handle' do
- let(:probe) { lambda{} }
+ let(:probe) { lambda {} }
let(:hook) { OpenProject::Webhooks::Hook.new('myhook', &probe) }
before do
diff --git a/modules/webhooks/spec/lib/webhooks_spec.rb b/modules/webhooks/spec/lib/webhooks_spec.rb
index 712e476db6..7c7a8d0b02 100644
--- a/modules/webhooks/spec/lib/webhooks_spec.rb
+++ b/modules/webhooks/spec/lib/webhooks_spec.rb
@@ -26,8 +26,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require File.expand_path('../../spec_helper', __FILE__)
-
+require File.expand_path('../spec_helper', __dir__)
describe OpenProject::Webhooks do
describe '.register_hook' do
@@ -53,11 +52,10 @@ describe OpenProject::Webhooks do
end
describe '.unregister_hook' do
- let(:probe) { lambda{} }
+ let(:probe) { lambda {} }
before do
OpenProject::Webhooks.register_hook('testhook2', &probe)
-
end
it 'should result in the hook no longer being found' do
@@ -65,5 +63,4 @@ describe OpenProject::Webhooks do
expect(OpenProject::Webhooks.find('testhook2')).to be_nil
end
end
-
end
diff --git a/modules/webhooks/spec/routing/webhooks/outgoing/admin_controller_spec.rb b/modules/webhooks/spec/routing/webhooks/outgoing/admin_controller_spec.rb
index 9a009ff745..d147d80b44 100644
--- a/modules/webhooks/spec/routing/webhooks/outgoing/admin_controller_spec.rb
+++ b/modules/webhooks/spec/routing/webhooks/outgoing/admin_controller_spec.rb
@@ -39,20 +39,20 @@ describe 'Outgoing webhooks administration', type: :routing do
it 'route to show' do
expect(get('/admin/webhooks/1')).to route_to(controller: 'webhooks/outgoing/admin',
- action: 'show',
- webhook_id: '1')
+ action: 'show',
+ webhook_id: '1')
end
it 'route to edit' do
expect(get('/admin/webhooks/1/edit')).to route_to(controller: 'webhooks/outgoing/admin',
- action: 'edit',
- webhook_id: '1')
+ action: 'edit',
+ webhook_id: '1')
end
it 'route to PUT update' do
expect(put('/admin/webhooks/1')).to route_to(controller: 'webhooks/outgoing/admin',
- action: 'update',
- webhook_id: '1')
+ action: 'update',
+ webhook_id: '1')
end
it 'route to DELETE destroy' do
diff --git a/modules/webhooks/spec/workers/project_webhook_job.rb b/modules/webhooks/spec/workers/project_webhook_job.rb
index f1e9d597df..4d0f1e107c 100644
--- a/modules/webhooks/spec/workers/project_webhook_job.rb
+++ b/modules/webhooks/spec/workers/project_webhook_job.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -71,12 +72,10 @@ describe ProjectWebhookJob, type: :job, webmock: true do
end
subject do
- begin
- job
- rescue
- # ignoring it as it's expected to throw exceptions in certain scenarios
- nil
- end
+ job
+ rescue StandardError
+ # ignoring it as it's expected to throw exceptions in certain scenarios
+ nil
end
before do
diff --git a/modules/webhooks/spec/workers/time_entry_webhook_job.rb b/modules/webhooks/spec/workers/time_entry_webhook_job.rb
index e8c527ba51..a5be81336e 100644
--- a/modules/webhooks/spec/workers/time_entry_webhook_job.rb
+++ b/modules/webhooks/spec/workers/time_entry_webhook_job.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -71,12 +72,10 @@ describe TimeEntryWebhookJob, type: :job, webmock: true do
end
subject do
- begin
- job
- rescue
- # ignoring it as it's expected to throw exceptions in certain scenarios
- nil
- end
+ job
+ rescue StandardError
+ # ignoring it as it's expected to throw exceptions in certain scenarios
+ nil
end
before do
diff --git a/modules/webhooks/spec/workers/work_package_webhook_job.rb b/modules/webhooks/spec/workers/work_package_webhook_job.rb
index 185dc021ee..12c9edd8e2 100644
--- a/modules/webhooks/spec/workers/work_package_webhook_job.rb
+++ b/modules/webhooks/spec/workers/work_package_webhook_job.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -72,12 +73,10 @@ describe WorkPackageWebhookJob, type: :model, webmock: true do
end
subject do
- begin
- job.perform
- rescue
- # ignoring it as it's expected to throw exceptions in certain scenarios
- nil
- end
+ job.perform
+ rescue StandardError
+ # ignoring it as it's expected to throw exceptions in certain scenarios
+ nil
end
before do
diff --git a/modules/xls_export/lib/open_project/xls_export/engine.rb b/modules/xls_export/lib/open_project/xls_export/engine.rb
index 21b38df93f..53723534af 100644
--- a/modules/xls_export/lib/open_project/xls_export/engine.rb
+++ b/modules/xls_export/lib/open_project/xls_export/engine.rb
@@ -19,9 +19,9 @@ module OpenProject::XlsExport
initializer 'xls_export.register_hooks' do
# don't use require_dependency to not reload hooks in development mode
- require 'open_project/xls_export/hooks/cost_report_hook.rb'
+ require 'open_project/xls_export/hooks/cost_report_hook'
- require 'open_project/xls_export/hooks/work_package_hook.rb'
+ require 'open_project/xls_export/hooks/work_package_hook'
end
initializer 'xls_export.register_mimetypes' do
diff --git a/modules/xls_export/lib/open_project/xls_export/formatters.rb b/modules/xls_export/lib/open_project/xls_export/formatters.rb
index f86efcc4c0..80ed5c292f 100644
--- a/modules/xls_export/lib/open_project/xls_export/formatters.rb
+++ b/modules/xls_export/lib/open_project/xls_export/formatters.rb
@@ -1,7 +1,7 @@
module OpenProject::XlsExport
module Formatters
def self.all
- self.constants.map do |const|
+ constants.map do |const|
Kernel.const_get("OpenProject::XlsExport::Formatters::#{const}")
end.select do |const|
const.is_a?(Class) && const != DefaultFormatter
@@ -15,7 +15,7 @@ module OpenProject::XlsExport
##
# Returns a Hash mapping columns to formatters to be used.
def self.for_columns(columns)
- formatters = self.all
+ formatters = all
entries = columns.map do |column|
formatter = formatters.find { |formatter| formatter.apply? column }
[column, (formatter || DefaultFormatter).new]
@@ -27,7 +27,7 @@ module OpenProject::XlsExport
##
# Takes a QueryColumn and returns true if this formatter should be used to handle it.
def self.apply?(column)
- column.xls_formatter == self.key
+ column.xls_formatter == key
end
def self.key
@@ -49,20 +49,20 @@ module OpenProject::XlsExport
##
# Takes a QueryColumn and returns format options for it.
- def format_options(column)
+ def format_options(_column)
{}
end
end
class TimeFormatter < DefaultFormatter
- def format_options(column)
- { :number_format => '0.0 "h"' }
+ def format_options(_column)
+ { number_format: '0.0 "h"' }
end
end
class CostFormatter < DefaultFormatter
- def format_options(column)
- { :number_format => number_format_string }
+ def format_options(_column)
+ { number_format: number_format_string }
end
def number_format_string
diff --git a/modules/xls_export/lib/open_project/xls_export/patches/cost_reports_controller_patch.rb b/modules/xls_export/lib/open_project/xls_export/patches/cost_reports_controller_patch.rb
index 6a76c68dde..e7e78d6329 100644
--- a/modules/xls_export/lib/open_project/xls_export/patches/cost_reports_controller_patch.rb
+++ b/modules/xls_export/lib/open_project/xls_export/patches/cost_reports_controller_patch.rb
@@ -42,4 +42,4 @@ module OpenProject::XlsExport::Patches
end
end
-CostReportsController.send(:include, OpenProject::XlsExport::Patches::CostReportsControllerPatch)
+CostReportsController.include OpenProject::XlsExport::Patches::CostReportsControllerPatch
diff --git a/modules/xls_export/lib/open_project/xls_export/spreadsheet_builder.rb b/modules/xls_export/lib/open_project/xls_export/spreadsheet_builder.rb
index 3ac9718099..308d585896 100644
--- a/modules/xls_export/lib/open_project/xls_export/spreadsheet_builder.rb
+++ b/modules/xls_export/lib/open_project/xls_export/spreadsheet_builder.rb
@@ -53,8 +53,8 @@ module OpenProject::XlsExport
# Get the approximate width of a value as seen in the excel sheet
def get_value_width(value)
- if ['Time', 'Date'].include?(value.class.name)
- return 18 unless value.to_s.length < 18
+ if ['Time', 'Date'].include?(value.class.name) && !(value.to_s.length < 18)
+ return 18
end
tot_w = [Float(0)]
@@ -93,7 +93,7 @@ module OpenProject::XlsExport
value_width = get_value_width(arr_or_str[0] * 2)
@column_widths[0] = value_width if (@column_widths[0] || 0) < value_width
end
- title_format = Spreadsheet::Format.new(:weight => :bold, :size => 18)
+ title_format = Spreadsheet::Format.new(weight: :bold, size: 18)
@sheet.row(0).set_format(0, title_format)
end
@@ -139,7 +139,7 @@ module OpenProject::XlsExport
arr.each_with_index do |c, i|
value = if %w(Time Date Fixnum Float Integer).include?(c.class.name)
c
- elsif c.class == BigDecimal
+ elsif c.instance_of?(BigDecimal)
c.to_f
else
c.to_s.gsub("\r\n", "\n").gsub("\r", "\n")
diff --git a/modules/xls_export/spec/lib/custom_field_xls_export_spec.rb b/modules/xls_export/spec/lib/custom_field_xls_export_spec.rb
index 4b5164a448..eca96cbc37 100644
--- a/modules/xls_export/spec/lib/custom_field_xls_export_spec.rb
+++ b/modules/xls_export/spec/lib/custom_field_xls_export_spec.rb
@@ -7,12 +7,12 @@ describe "WorkPackageXlsExport Custom Fields" do
let!(:custom_field) do
FactoryBot.create(
- :list_wp_custom_field,
- name: "Ingredients",
- multi_value: true,
- types: [type],
- projects: [project],
- possible_values: ["ham", "onions", "pineapple", "mushrooms"]
+ :list_wp_custom_field,
+ name: "Ingredients",
+ multi_value: true,
+ types: [type],
+ projects: [project],
+ possible_values: ["ham", "onions", "pineapple", "mushrooms"]
)
end
diff --git a/modules/xls_export/spec/patches/cost_reports_controller_patch_spec.rb b/modules/xls_export/spec/patches/cost_reports_controller_patch_spec.rb
index ead956322b..83f2ec2e15 100644
--- a/modules/xls_export/spec/patches/cost_reports_controller_patch_spec.rb
+++ b/modules/xls_export/spec/patches/cost_reports_controller_patch_spec.rb
@@ -5,18 +5,17 @@ describe 'CostReportsController', "rendering to xls" do
it "should respond with the xls if requested in the index" do
skip
- render :action => :index
+ render action: :index
expect(response).to be_redirect
end
it "should not respond with the xls if requested in a detail view" do
skip
- render :action => :show
+ render action: :show
expect(response).to be_redirect
end
it "should generate xls from issues" do
skip
end
-
end
diff --git a/packaging/scripts/send-test-email b/packaging/scripts/send-test-email
index 6a71a92820..9a9d9471aa 100755
--- a/packaging/scripts/send-test-email
+++ b/packaging/scripts/send-test-email
@@ -10,25 +10,25 @@ smtp_domain = ENV.fetch('SMTP_DOMAIN') { "example.net" }
from = "no-reply@#{smtp_domain}"
delivery_method = ENV.fetch('EMAIL_DELIVERY_METHOD') { "sendmail" }
-msgstr = <
-To: #{admin_email}
-Subject: Test message
-Date: #{Time.now.httpdate}
-Message-Id: <#{SecureRandom.hex}@#{smtp_domain}>
-
-This is a test message to verify your OpenProject settings.
-If you see this, this means OpenProject email settings are working properly.
+msgstr = <<~END_OF_MESSAGE
+ From: OpenProject <#{from}>
+ To: #{admin_email}
+ Subject: Test message
+ Date: #{Time.now.httpdate}
+ Message-Id: <#{SecureRandom.hex}@#{smtp_domain}>
+ #{' '}
+ This is a test message to verify your OpenProject settings.
+ If you see this, this means OpenProject email settings are working properly.
END_OF_MESSAGE
if delivery_method == "sendmail"
puts "sending test email using sendmail..."
tmpfile = Tempfile.new("mail-test")
- File.open(tmpfile.path, "w+") {|f| f << msgstr}
+ File.open(tmpfile.path, "w+") { |f| f << msgstr }
system("cat #{tmpfile.path} | sendmail -i -t") || exit(1)
else
smtp_authentication = ENV.fetch('SMTP_AUTHENTICATION', "none").to_sym
- #set authentication to nil because :none is not supported by SMTP module
+ # set authentication to nil because :none is not supported by SMTP module
smtp_authentication = nil if smtp_authentication == :none
puts "sending test email using SMTP..."
smtp = Net::SMTP.new(
@@ -38,11 +38,10 @@ else
smtp.enable_starttls_auto if ENV.fetch('SMTP_ENABLE_STARTTLS_AUTO', 'false') == 'true'
smtp.start(
ENV.fetch('SMTP_DOMAIN'),
- ENV.fetch('SMTP_USERNAME',nil),
- ENV.fetch('SMTP_PASSWORD',nil),
+ ENV.fetch('SMTP_USERNAME', nil),
+ ENV.fetch('SMTP_PASSWORD', nil),
smtp_authentication
)
smtp.send_message msgstr, from, admin_email
smtp.finish
end
-
diff --git a/script/travis_pr_errors b/script/travis_pr_errors
index b0dd9a12ed..d531714ee9 100755
--- a/script/travis_pr_errors
+++ b/script/travis_pr_errors
@@ -15,7 +15,7 @@ begin
response = RestClient.get "https://api.github.com/repos/opf/openproject/pulls?state=open&head=opf:#{branch_name}"
json = JSON.parse(response)
pr_number = json.first['number']
-rescue => e
+rescue StandardError => e
warn "Failed to get PR number from #{branch_name}: #{e} #{e.message}"
end
@@ -46,4 +46,3 @@ end
specs = results.flatten.join(" ")
puts "Errors\n\n#{specs}"
-
diff --git a/spec/contracts/authentication/omniauth_auth_hash_contract_spec.rb b/spec/contracts/authentication/omniauth_auth_hash_contract_spec.rb
index fea77ed875..16efc285c5 100644
--- a/spec/contracts/authentication/omniauth_auth_hash_contract_spec.rb
+++ b/spec/contracts/authentication/omniauth_auth_hash_contract_spec.rb
@@ -38,8 +38,7 @@ describe Authentication::OmniauthAuthHashContract do
info: { name: 'foo',
email: 'foo@bar.com',
first_name: 'foo',
- last_name: 'bar'
- }
+ last_name: 'bar' }
)
end
@@ -100,7 +99,7 @@ describe Authentication::OmniauthAuthHashContract do
end
describe '#validate_authorization_callback' do
- let(:auth_double) { double('Authorization', approve?: authorized, message: message)}
+ let(:auth_double) { double('Authorization', approve?: authorized, message: message) }
before do
allow(OpenProject::OmniAuth::Authorization)
diff --git a/spec/contracts/custom_actions/cu_contract_spec.rb b/spec/contracts/custom_actions/cu_contract_spec.rb
index cf17240b41..30ae61b4e3 100644
--- a/spec/contracts/custom_actions/cu_contract_spec.rb
+++ b/spec/contracts/custom_actions/cu_contract_spec.rb
@@ -95,7 +95,7 @@ describe CustomActions::CuContract do
allow(status_action)
.to receive(:allowed_values)
.and_return([{ value: nil, label: '-' },
- { value: 1, label: 'some status'}])
+ { value: 1, label: 'some status' }])
action.actions = [status_action]
@@ -128,7 +128,7 @@ describe CustomActions::CuContract do
allow(status_condition)
.to receive(:allowed_values)
.and_return([{ value: nil, label: '-' },
- { value: 1, label: 'some status'}])
+ { value: 1, label: 'some status' }])
action.conditions = [status_condition]
diff --git a/spec/contracts/projects/delete_contract_spec.rb b/spec/contracts/projects/delete_contract_spec.rb
index 91f3ce3135..6e86c5964a 100644
--- a/spec/contracts/projects/delete_contract_spec.rb
+++ b/spec/contracts/projects/delete_contract_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/contracts/queries/update_contract_spec.rb b/spec/contracts/queries/update_contract_spec.rb
index 2a0c817773..71f273836b 100644
--- a/spec/contracts/queries/update_contract_spec.rb
+++ b/spec/contracts/queries/update_contract_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/contracts/users/create_contract_spec.rb b/spec/contracts/users/create_contract_spec.rb
index baa8464b85..eb70f56387 100644
--- a/spec/contracts/users/create_contract_spec.rb
+++ b/spec/contracts/users/create_contract_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/contracts/wiki_pages/shared_contract_examples.rb b/spec/contracts/wiki_pages/shared_contract_examples.rb
index 53a24fa8e8..7aed59d7c6 100644
--- a/spec/contracts/wiki_pages/shared_contract_examples.rb
+++ b/spec/contracts/wiki_pages/shared_contract_examples.rb
@@ -39,8 +39,8 @@ shared_examples_for 'wiki page contract' do
end
let(:page_wiki) { FactoryBot.build_stubbed(:wiki) }
let(:page_author) { current_user }
- let(:page_title) { 'Wiki title'}
- let(:page_slug) { 'wiki slug'}
+ let(:page_title) { 'Wiki title' }
+ let(:page_slug) { 'wiki slug' }
let(:page_protected) { false }
let(:page_parent) { nil }
let(:page_text) { 'Wiki text' }
diff --git a/spec/contracts/work_packages/create_contract_spec.rb b/spec/contracts/work_packages/create_contract_spec.rb
index 26d680aaee..9a814c013e 100644
--- a/spec/contracts/work_packages/create_contract_spec.rb
+++ b/spec/contracts/work_packages/create_contract_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/contracts/work_packages/create_note_contract_spec.rb b/spec/contracts/work_packages/create_note_contract_spec.rb
index 13b52092af..13d164e1ca 100644
--- a/spec/contracts/work_packages/create_note_contract_spec.rb
+++ b/spec/contracts/work_packages/create_note_contract_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/contracts/work_packages/shared_base_contract.rb b/spec/contracts/work_packages/shared_base_contract.rb
index 07e61232cc..856af1ce39 100644
--- a/spec/contracts/work_packages/shared_base_contract.rb
+++ b/spec/contracts/work_packages/shared_base_contract.rb
@@ -35,11 +35,11 @@ shared_examples_for 'work package contract' do
subject(:contract) { described_class.new(work_package, user) }
- let(:validated_contract) {
+ let(:validated_contract) do
contract = subject
contract.validate
contract
- }
+ end
before do
allow(WorkPackagePolicy)
diff --git a/spec/controllers/account_controller_spec.rb b/spec/controllers/account_controller_spec.rb
index c8cb2f698b..162aa1353e 100644
--- a/spec/controllers/account_controller_spec.rb
+++ b/spec/controllers/account_controller_spec.rb
@@ -29,10 +29,8 @@
require 'spec_helper'
describe AccountController, type: :controller do
-
class UserHook < Redmine::Hook::ViewListener
- attr_reader :registered_user
- attr_reader :first_login_user
+ attr_reader :registered_user, :first_login_user
def user_registered(context)
@registered_user = context[:user]
@@ -323,7 +321,6 @@ describe AccountController, type: :controller do
context 'with direct login and redirecting callback',
with_settings: { login_required?: true },
with_config: { omniauth_direct_login_provider: 'foo' } do
-
it 'will still call the callback' do
# Set the previous session
session[:foo] = 'bar'
@@ -351,9 +348,9 @@ describe AccountController, type: :controller do
context 'with a no-op callback' do
it 'will redirect to default if the callback does nothing' do
was_called = false
- sso_provider[:single_sign_out_callback] = Proc.new {
+ sso_provider[:single_sign_out_callback] = Proc.new do
was_called = true
- }
+ end
get :logout
expect(was_called).to eq true
@@ -448,8 +445,7 @@ describe AccountController, type: :controller do
end
describe '#login with omniauth_direct_login enabled',
- with_config: { omniauth_direct_login_provider: 'some_provider' } do
-
+ with_config: { omniauth_direct_login_provider: 'some_provider' } do
describe 'GET' do
it 'redirects to some_provider' do
get :login
@@ -474,7 +470,6 @@ describe AccountController, type: :controller do
allow_any_instance_of(User).to receive(:change_password_allowed?).and_return(false)
end
-
describe "Missing flash data for user initiated password change" do
before do
post 'change_password',
@@ -810,7 +805,8 @@ describe AccountController, type: :controller do
it 'preserves the back url' do
expect(response).to redirect_to(
- '/login?back_url=https%3A%2F%2Fexample.net%2Fsome_back_url')
+ '/login?back_url=https%3A%2F%2Fexample.net%2Fsome_back_url'
+ )
end
it 'calls the user_registered callback' do
diff --git a/spec/controllers/activities_controller_spec.rb b/spec/controllers/activities_controller_spec.rb
index 048a0e6e11..924f3992fc 100644
--- a/spec/controllers/activities_controller_spec.rb
+++ b/spec/controllers/activities_controller_spec.rb
@@ -69,13 +69,13 @@ describe ActivitiesController, type: :controller do
render_views
it do
- assert_select 'h3',
- content: /#{3.day.ago.to_date.day}/,
- sibling: { tag: 'dl',
- child: { tag: 'dt',
- attributes: { class: /work_package/ },
- child: { tag: 'a',
- content: /#{ERB::Util.html_escape(work_package.subject)}/ } } }
+ assert_select 'h3',
+ content: /#{3.day.ago.to_date.day}/,
+ sibling: { tag: 'dl',
+ child: { tag: 'dt',
+ attributes: { class: /work_package/ },
+ child: { tag: 'a',
+ content: /#{ERB::Util.html_escape(work_package.subject)}/ } } }
end
end
@@ -139,9 +139,9 @@ describe ActivitiesController, type: :controller do
before { get 'index', format: 'atom' }
it do
- assert_select 'entry',
- child: { tag: 'link',
- attributes: { href: Regexp.new("/work_packages/#{wp_1.id}#") } }
+ assert_select 'entry',
+ child: { tag: 'link',
+ attributes: { href: Regexp.new("/work_packages/#{wp_1.id}#") } }
end
end
diff --git a/spec/controllers/categories_controller_spec.rb b/spec/controllers/categories_controller_spec.rb
index 75f7e0a2d2..c0b5af2777 100644
--- a/spec/controllers/categories_controller_spec.rb
+++ b/spec/controllers/categories_controller_spec.rb
@@ -31,16 +31,16 @@ require 'spec_helper'
describe CategoriesController, type: :controller do
let(:user) { FactoryBot.create(:user) }
let(:project) { FactoryBot.create(:project) }
- let(:role) {
+ let(:role) do
FactoryBot.create(:role,
- permissions: [:manage_categories])
- }
- let(:member) {
+ permissions: [:manage_categories])
+ end
+ let(:member) do
FactoryBot.create(:member,
- project: project,
- principal: user,
- roles: [role])
- }
+ project: project,
+ principal: user,
+ roles: [role])
+ end
before do
member
@@ -92,17 +92,16 @@ describe CategoriesController, type: :controller do
end
describe '#edit' do
- let(:category) {
+ let(:category) do
FactoryBot.create(:category,
- project: project)
- }
+ project: project)
+ end
subject { response }
before do
get :edit, params: { id: category_id }
end
-
context 'valid category' do
let(:category_id) { category.id }
it { is_expected.to be_successful }
@@ -119,10 +118,10 @@ describe CategoriesController, type: :controller do
let(:name) { 'Testing' }
context 'valid category' do
- let(:category) {
+ let(:category) do
FactoryBot.create(:category,
- project: project)
- }
+ project: project)
+ end
before do
post :update,
@@ -161,17 +160,17 @@ describe CategoriesController, type: :controller do
end
describe '#destroy' do
- let(:category) {
+ let(:category) do
FactoryBot.create(:category,
- project: project)
- }
- let(:work_package) {
+ project: project)
+ end
+ let(:work_package) do
FactoryBot.create(:work_package,
- project: project,
- category: category)
- }
+ project: project,
+ category: category)
+ end
- before do category end
+ before { category }
shared_examples_for :delete do
subject { Category.find_by(id: category.id) }
@@ -210,10 +209,10 @@ describe CategoriesController, type: :controller do
end
describe '#reassign' do
- let(:target) {
+ let(:target) do
FactoryBot.create(:category,
- project: project)
- }
+ project: project)
+ end
before do
work_package
diff --git a/spec/controllers/concerns/auth_source_sso_spec.rb b/spec/controllers/concerns/auth_source_sso_spec.rb
index 3fd311a7d7..282fdddc24 100644
--- a/spec/controllers/concerns/auth_source_sso_spec.rb
+++ b/spec/controllers/concerns/auth_source_sso_spec.rb
@@ -110,9 +110,9 @@ describe MyController, type: :controller do
end
context 'when the user is invited' do
- let!(:user) {
+ let!(:user) do
FactoryBot.create :user, login: login, status: Principal.statuses[:invited], auth_source_id: auth_source.id
- }
+ end
it "should log in given user and activate it" do
expect(response.body.squish).to have_content("Username h.wurst")
diff --git a/spec/controllers/concerns/omniauth_login_spec.rb b/spec/controllers/concerns/omniauth_login_spec.rb
index 69fa04dc9b..1aa0c8f03e 100644
--- a/spec/controllers/concerns/omniauth_login_spec.rb
+++ b/spec/controllers/concerns/omniauth_login_spec.rb
@@ -34,7 +34,7 @@ describe AccountController, type: :controller do
User.current = nil
end
- context 'GET #omniauth_login', with_settings: { self_registration: Setting::SelfRegistration.automatic} do
+ context 'GET #omniauth_login', with_settings: { self_registration: Setting::SelfRegistration.automatic } do
describe 'with on-the-fly registration' do
context 'providing all required fields' do
let(:omniauth_hash) do
@@ -44,8 +44,7 @@ describe AccountController, type: :controller do
info: { name: 'foo',
email: 'foo@bar.com',
first_name: 'foo',
- last_name: 'bar'
- }
+ last_name: 'bar' }
)
end
@@ -109,8 +108,7 @@ describe AccountController, type: :controller do
uid: 'foo',
info: { email: 'whattheheck@example.com',
first_name: 'what',
- last_name: 'theheck'
- },
+ last_name: 'theheck' },
extra: { raw_info: {
real_uid: 'bar@example.org',
first_name: 'foo',
@@ -164,7 +162,7 @@ describe AccountController, type: :controller do
provider: 'google',
uid: '123545',
info: { name: 'foo', email: 'foo@bar.com' }
- # first_name and last_name not set
+ # first_name and last_name not set
)
end
@@ -184,7 +182,8 @@ describe AccountController, type: :controller do
auth_source_registration = omniauth_hash.merge(
omniauth: true,
- timestamp: Time.new)
+ timestamp: Time.new
+ )
session[:auth_source_registration] = auth_source_registration
post :register,
params: {
@@ -208,7 +207,8 @@ describe AccountController, type: :controller do
before do
session[:auth_source_registration] = omniauth_hash.merge(
omniauth: true,
- timestamp: Time.new - 42.days)
+ timestamp: Time.new - 42.days
+ )
end
it 'does not register the user when providing all the missing fields' do
@@ -252,8 +252,7 @@ describe AccountController, type: :controller do
info: { name: 'foo',
email: 'foo@bar.com',
first_name: 'foo',
- last_name: 'bar'
- }
+ last_name: 'bar' }
)
end
@@ -281,14 +280,13 @@ describe AccountController, type: :controller do
uid: '123545',
info: { name: 'foo',
last_name: 'bar',
- email: 'foo@bar.com'
- }
+ email: 'foo@bar.com' }
)
end
let(:user) do
FactoryBot.build(:user, force_password_change: false,
- identity_url: 'google:123545')
+ identity_url: 'google:123545')
end
before do
@@ -502,8 +500,7 @@ describe AccountController, type: :controller do
provider: 'google',
# id is deliberately missing here to make the auth_hash invalid
info: { name: 'foo',
- email: 'foo@bar.com'
- }
+ email: 'foo@bar.com' }
)
end
diff --git a/spec/controllers/concerns/user_invitation_spec.rb b/spec/controllers/concerns/user_invitation_spec.rb
index 30bc07b389..25900a3751 100644
--- a/spec/controllers/concerns/user_invitation_spec.rb
+++ b/spec/controllers/concerns/user_invitation_spec.rb
@@ -52,7 +52,7 @@ describe UserInvitation do
let!(:token) { FactoryBot.create :invitation_token, user: user }
it 'notifies listeners of the re-invite' do
- expect(OpenProject::Notifications).to receive(:send) do |event, new_token|
+ expect(OpenProject::Notifications).to receive(:send) do |event, _new_token|
expect(event).to eq 'user_reinvited'
end
diff --git a/spec/controllers/copy_projects_controller_spec.rb b/spec/controllers/copy_projects_controller_spec.rb
index f6103303a1..f60f662cd5 100644
--- a/spec/controllers/copy_projects_controller_spec.rb
+++ b/spec/controllers/copy_projects_controller_spec.rb
@@ -87,7 +87,10 @@ describe CopyProjectsController, type: :controller do
end
shared_examples_for 'successful copy' do
- it { expect(flash[:notice]).to eq(I18n.t('copy_project.started', source_project_name: source_project.name, target_project_name: target_project_name)) }
+ it {
+ expect(flash[:notice]).to eq(I18n.t('copy_project.started', source_project_name: source_project.name,
+ target_project_name: target_project_name))
+ }
end
def copy_project(project)
@@ -136,7 +139,7 @@ describe CopyProjectsController, type: :controller do
true
end
- let(:permission) { [:copy_projects, :add_project] }
+ let(:permission) { %i[copy_projects add_project] }
let(:project) { FactoryBot.create(:project, public: false) }
it_should_behave_like 'a controller action which needs project permissions'
diff --git a/spec/controllers/enumerations_controller.rb b/spec/controllers/enumerations_controller.rb
index e5c13495c8..11dee32023 100644
--- a/spec/controllers/enumerations_controller.rb
+++ b/spec/controllers/enumerations_controller.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
describe EnumerationsController, type: :controller do
- before do allow(controller).to receive(:require_admin).and_return(true) end
+ before { allow(controller).to receive(:require_admin).and_return(true) }
describe '#destroy' do
describe '#priority' do
@@ -51,10 +51,10 @@ describe EnumerationsController, type: :controller do
describe 'in use' do
let!(:enum_to_reassign) { FactoryBot.create(:priority_high) }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package,
- priority: enum_to_delete)
- }
+ priority: enum_to_delete)
+ end
describe 'no reassign' do
before do
diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb
index 2a26027239..a89cc3377d 100644
--- a/spec/controllers/forums_controller_spec.rb
+++ b/spec/controllers/forums_controller_spec.rb
@@ -38,7 +38,6 @@ describe ForumsController, type: :controller do
end
describe '#index' do
-
context 'public project' do
let(:project) { FactoryBot.create(:public_project) }
let!(:role) { FactoryBot.create(:non_member) }
@@ -160,16 +159,16 @@ describe ForumsController, type: :controller do
describe '#move' do
let(:project) { FactoryBot.create(:project) }
- let!(:forum_1) {
+ let!(:forum_1) do
FactoryBot.create(:forum,
- project: project,
- position: 1)
- }
- let!(:forum_2) {
+ project: project,
+ position: 1)
+ end
+ let!(:forum_2) do
FactoryBot.create(:forum,
- project: project,
- position: 2)
- }
+ project: project,
+ position: 2)
+ end
before do
allow(@controller).to receive(:authorize).and_return(true)
@@ -198,10 +197,10 @@ describe ForumsController, type: :controller do
end
describe '#update' do
- let!(:forum) {
+ let!(:forum) do
FactoryBot.create(:forum, name: 'Forum name',
- description: 'Forum description')
- }
+ description: 'Forum description')
+ end
before do
expect(@controller).to receive(:authorize)
@@ -257,22 +256,22 @@ describe ForumsController, type: :controller do
describe '#sticky' do
let!(:message1) { FactoryBot.create(:message, forum: forum) }
let!(:message2) { FactoryBot.create(:message, forum: forum) }
- let!(:sticked_message1) {
+ let!(:sticked_message1) do
FactoryBot.create(:message, forum_id: forum.id,
- subject: 'How to',
- content: 'How to install this cool app',
- sticky: '1',
- sticked_on: Time.now - 2.minute)
- }
+ subject: 'How to',
+ content: 'How to install this cool app',
+ sticky: '1',
+ sticked_on: Time.now - 2.minute)
+ end
- let!(:sticked_message2) {
+ let!(:sticked_message2) do
FactoryBot.create(:message, forum_id: forum.id,
- subject: 'FAQ',
- content: 'Frequestly asked question',
- sticky: '1',
- sticked_on:
+ subject: 'FAQ',
+ content: 'Frequestly asked question',
+ sticky: '1',
+ sticked_on:
Time.now - 1.minute)
- }
+ end
describe 'all sticky messages' do
before do
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 5f46e39d73..457a00a4be 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -177,9 +177,9 @@ describe GroupsController, type: :controller do
end
it 'should forbid create' do
- expect {
+ expect do
post :create, params: { group: { lastname: 'New group' } }
- }.not_to change { Group.count }
+ end.not_to change { Group.count }
expect(response).not_to be_successful
expect(response.status).to eq 403
diff --git a/spec/controllers/homescreen_controller_spec.rb b/spec/controllers/homescreen_controller_spec.rb
index 89334e6fad..0e439067e9 100644
--- a/spec/controllers/homescreen_controller_spec.rb
+++ b/spec/controllers/homescreen_controller_spec.rb
@@ -38,9 +38,9 @@ describe HomescreenController, type: :controller do
get :index
end
- let(:all_blocks) {
+ let(:all_blocks) do
%w(administration community my_account projects users)
- }
+ end
let(:show_welcome) { false }
diff --git a/spec/controllers/journals_controller_spec.rb b/spec/controllers/journals_controller_spec.rb
index 90420c0ecc..f5ead1ff4f 100644
--- a/spec/controllers/journals_controller_spec.rb
+++ b/spec/controllers/journals_controller_spec.rb
@@ -32,22 +32,22 @@ describe JournalsController, type: :controller do
let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) }
let(:project) { FactoryBot.create(:project_with_types) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
- let(:member) {
+ let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role],
- principal: user)
- }
- let(:work_package) {
+ roles: [role],
+ principal: user)
+ end
+ let(:work_package) do
FactoryBot.build(:work_package, type: project.types.first,
- author: user,
- project: project,
- description: '')
- }
- let(:journal) {
+ author: user,
+ project: project,
+ description: '')
+ end
+ let(:journal) do
FactoryBot.create(:work_package_journal,
- journable: work_package,
- user: user)
- }
+ journable: work_package,
+ user: user)
+ end
let(:permissions) { [:view_work_packages] }
before do
diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb
index 8fe1144dfb..cb874b7fe4 100644
--- a/spec/controllers/members_controller_spec.rb
+++ b/spec/controllers/members_controller_spec.rb
@@ -33,11 +33,11 @@ describe MembersController, type: :controller do
let(:user) { FactoryBot.create(:user) }
let(:project) { FactoryBot.create(:project, identifier: 'pet_project') }
let(:role) { FactoryBot.create(:role) }
- let(:member) {
+ let(:member) do
FactoryBot.create(:member, project: project,
- user: user,
- roles: [role])
- }
+ user: user,
+ roles: [role])
+ end
before do
allow(User).to receive(:current).and_return(admin)
@@ -67,9 +67,9 @@ describe MembersController, type: :controller do
u.reload
expect(u.memberships.size).to be >= 1
- expect(u.memberships.find { |m|
+ expect(u.memberships.find do |m|
expect(m.roles).to include(role)
- }).not_to be_nil
+ end).not_to be_nil
end
end
end
@@ -84,7 +84,8 @@ describe MembersController, type: :controller do
:member,
project: project_2,
user: admin,
- roles: [role_1])
+ roles: [role_1]
+ )
end
before do
@@ -211,13 +212,13 @@ describe MembersController, type: :controller do
end
describe '#update' do
- let(:action) {
+ let(:action) do
post :update,
params: {
id: member.id,
member: { role_ids: [role2.id], user_id: user.id }
}
- }
+ end
let(:role2) { FactoryBot.create(:role) }
before do
diff --git a/spec/controllers/my_controller_spec.rb b/spec/controllers/my_controller_spec.rb
index adb9dee8ad..13c8c110fc 100644
--- a/spec/controllers/my_controller_spec.rb
+++ b/spec/controllers/my_controller_spec.rb
@@ -169,7 +169,6 @@ describe MyController, type: :controller do
expect(request.path).to eq(my_settings_path)
expect(flash[:notice]).to eql I18n.t(:notice_account_updated)
-
end
context 'when user is invalid' do
diff --git a/spec/controllers/news/comments_controller_spec.rb b/spec/controllers/news/comments_controller_spec.rb
index 5112afc832..6afd0b532d 100644
--- a/spec/controllers/news/comments_controller_spec.rb
+++ b/spec/controllers/news/comments_controller_spec.rb
@@ -51,10 +51,10 @@ describe News::CommentsController, type: :controller do
end
it "doesn't create a comment when it is invalid" do
- expect {
+ expect do
post :create, params: { news_id: news.id, comment: { comments: '' } }
expect(response).to redirect_to news_path(news)
- }.not_to change { Comment.count }
+ end.not_to change { Comment.count }
end
end
@@ -62,9 +62,9 @@ describe News::CommentsController, type: :controller do
it 'deletes the comment and redirects to the news page' do
comment = FactoryBot.create :comment, commented: news
- expect {
+ expect do
delete :destroy, params: { id: comment.id }
- }.to change { Comment.count }.by -1
+ end.to change { Comment.count }.by -1
expect(response).to redirect_to news_path(news)
expect { comment.reload }.to raise_error ActiveRecord::RecordNotFound
diff --git a/spec/controllers/news_controller_spec.rb b/spec/controllers/news_controller_spec.rb
index 673578744d..e635f465ac 100644
--- a/spec/controllers/news_controller_spec.rb
+++ b/spec/controllers/news_controller_spec.rb
@@ -125,7 +125,6 @@ describe NewsController, type: :controller do
expect(news.author).to eq user
expect(news.project).to eq project
-
perform_enqueued_jobs
expect(ActionMailer::Base.deliveries.size).to eq(1)
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 9164618291..7ac4501901 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -113,7 +113,6 @@ describe ProjectsController, type: :controller do
context 'with default modules',
with_settings: { default_projects_modules: %w(work_package_tracking repository) } do
-
it 'should create should preserve modules on validation failure' do
expect do
post :create,
@@ -192,7 +191,7 @@ describe ProjectsController, type: :controller do
# We need at least one givable role to make the user member
let!(:role) { FactoryBot.create :role, permissions: [:view_project] }
before do
- non_member.update_attribute :permissions, [:add_project, :view_work_packages]
+ non_member.update_attribute :permissions, %i[add_project view_work_packages]
login_as non_member_user
end
@@ -565,8 +564,8 @@ describe ProjectsController, type: :controller do
it 'sets flash[:error]' do
expect(flash[:error]).to include(
- "You cannot update the project's available custom fields. The project is invalid:"
- )
+ "You cannot update the project's available custom fields. The project is invalid:"
+ )
end
end
end
@@ -594,7 +593,7 @@ describe ProjectsController, type: :controller do
params: {
id: project.id,
project: {
- name: 'Test changed name',
+ name: 'Test changed name'
}
}
diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb
index 3ee7543240..3f6799e981 100644
--- a/spec/controllers/repositories_controller_spec.rb
+++ b/spec/controllers/repositories_controller_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -37,7 +38,7 @@ describe RepositoriesController, type: :controller do
end
let(:user) do
FactoryBot.create(:user, member_in_project: project,
- member_through_role: role)
+ member_through_role: role)
end
let(:role) { FactoryBot.create(:role, permissions: []) }
let (:url) { 'file:///tmp/something/does/not/exist.svn' }
@@ -45,9 +46,9 @@ describe RepositoriesController, type: :controller do
let(:repository) do
allow(Setting).to receive(:enabled_scm).and_return(['subversion'])
repo = FactoryBot.build_stubbed(:repository_subversion,
- scm_type: 'local',
- url: url,
- project: project)
+ scm_type: 'local',
+ url: url,
+ project: project)
allow(repo).to receive(:default_branch).and_return('master')
allow(repo).to receive(:branches).and_return(['master'])
allow(repo).to receive(:save).and_return(true)
@@ -127,14 +128,13 @@ describe RepositoriesController, type: :controller do
context 'with #show and checkout' do
render_views
- let(:checkout_hash) {
+ let(:checkout_hash) do
{
'subversion' => { 'enabled' => '1',
'text' => 'foo',
- 'base_url' => 'http://localhost'
- }
+ 'base_url' => 'http://localhost' }
}
- }
+ end
before do
allow(Setting).to receive(:repository_checkout_data).and_return(checkout_hash)
@@ -154,9 +154,9 @@ describe RepositoriesController, type: :controller do
let(:root_url) { repo_dir }
let(:url) { "file://#{root_url}" }
- let(:repository) {
+ let(:repository) do
FactoryBot.create(:repository_subversion, project: project, url: url, root_url: url)
- }
+ end
describe 'commits per author graph' do
before do
@@ -164,10 +164,10 @@ describe RepositoriesController, type: :controller do
end
context 'requested by an authorized user' do
- let(:role) {
- FactoryBot.create(:role, permissions: [:browse_repository,
- :view_commit_author_statistics])
- }
+ let(:role) do
+ FactoryBot.create(:role, permissions: %i[browse_repository
+ view_commit_author_statistics])
+ end
it 'should be successful' do
expect(response).to be_successful
@@ -221,10 +221,10 @@ describe RepositoriesController, type: :controller do
end
describe 'requested by a user with view_commit_author_statistics permission' do
- let(:role) {
- FactoryBot.create(:role, permissions: [:browse_repository,
- :view_commit_author_statistics])
- }
+ let(:role) do
+ FactoryBot.create(:role, permissions: %i[browse_repository
+ view_commit_author_statistics])
+ end
it 'show the commits per author graph' do
expect(assigns(:show_commits_per_author)).to eq(true)
@@ -290,14 +290,13 @@ describe RepositoriesController, type: :controller do
render_views
let(:role) { FactoryBot.create(:role, permissions: [:browse_repository]) }
- let(:checkout_hash) {
+ let(:checkout_hash) do
{
'subversion' => { 'enabled' => '1',
'text' => 'foo',
- 'base_url' => 'http://localhost'
- }
+ 'base_url' => 'http://localhost' }
}
- }
+ end
before do
allow(Setting).to receive(:repository_checkout_data).and_return(checkout_hash)
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index cac8d07335..53df0fca7c 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -206,7 +206,7 @@ describe SearchController, type: :controller do
end
before do
- get :index, params: { q: 'note'}
+ get :index, params: { q: 'note' }
end
it_behaves_like 'successful search'
diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb
index 96a41a0e5a..cf2808c2d0 100644
--- a/spec/controllers/statuses_controller_spec.rb
+++ b/spec/controllers/statuses_controller_spec.rb
@@ -91,7 +91,7 @@ describe StatusesController, type: :controller do
context 'default' do
let!(:status_default) do
FactoryBot.create(:status,
- is_default: true)
+ is_default: true)
end
before do
@@ -156,7 +156,7 @@ describe StatusesController, type: :controller do
shared_examples_for :destroyed do
subject { Status.find_by(name: name) }
- it { is_expected.to be_nil}
+ it { is_expected.to be_nil }
end
context 'unused' do
diff --git a/spec/controllers/sys_controller_spec.rb b/spec/controllers/sys_controller_spec.rb
index 529cc19257..d46a5878a4 100644
--- a/spec/controllers/sys_controller_spec.rb
+++ b/spec/controllers/sys_controller_spec.rb
@@ -29,18 +29,18 @@
require 'spec_helper'
describe SysController, type: :controller do
- let(:commit_role) {
+ let(:commit_role) do
FactoryBot.create(:role, permissions: %i[commit_access browse_repository])
- }
+ end
let(:browse_role) { FactoryBot.create(:role, permissions: [:browse_repository]) }
let(:guest_role) { FactoryBot.create(:role, permissions: []) }
let(:valid_user_password) { 'Top Secret Password' }
- let(:valid_user) {
+ let(:valid_user) do
FactoryBot.create(:user,
login: 'johndoe',
password: valid_user_password,
password_confirmation: valid_user_password)
- }
+ end
let(:api_key) { '12345678' }
@@ -76,9 +76,9 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: 'without-access',
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: 'without-access',
+ method: 'GET' }
end
it 'should respond 403 not allowed' do
@@ -102,17 +102,17 @@ describe SysController, type: :controller do
end
it 'should respond 200 okay dokay for GET' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET' }
expect(response.code).to eq('200')
end
it 'should respond 403 not allowed for POST' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'POST'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'POST' }
expect(response.code).to eq('403')
end
@@ -133,17 +133,17 @@ describe SysController, type: :controller do
end
it 'should respond 200 okay dokay for GET' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET' }
expect(response.code).to eq('200')
end
it 'should respond 200 okay dokay for POST' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'POST'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'POST' }
expect(response.code).to eq('200')
end
@@ -161,9 +161,9 @@ describe SysController, type: :controller do
valid_user_password + 'made invalid'
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET' }
end
it 'should respond 401 auth required' do
@@ -179,9 +179,9 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET' }
end
it 'should respond 403 not allowed' do
@@ -205,9 +205,9 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET' }
end
it 'should respond 200 OK' do
@@ -217,9 +217,9 @@ describe SysController, type: :controller do
context 'for invalid credentials' do
before(:each) do
- post 'repo_auth', params: {key: api_key,
- repository: 'any-repo',
- method: 'GET'}
+ post 'repo_auth', params: { key: api_key,
+ repository: 'any-repo',
+ method: 'GET' }
end
it 'should respond 401 auth required' do
@@ -235,9 +235,9 @@ describe SysController, type: :controller do
valid_user.login,
valid_user_password
)
- post 'repo_auth', params: {key: 'not_the_api_key',
- repository: 'any-repo',
- method: 'GET'}
+ post 'repo_auth', params: { key: 'not_the_api_key',
+ repository: 'any-repo',
+ method: 'GET' }
expect(response.code).to eq('403')
expect(response.body)
@@ -251,9 +251,9 @@ describe SysController, type: :controller do
'invalid'
)
- post 'repo_auth', params: {key: 'not_the_api_key',
- repository: 'any-repo',
- method: 'GET'}
+ post 'repo_auth', params: { key: 'not_the_api_key',
+ repository: 'any-repo',
+ method: 'GET' }
expect(response.code).to eq('403')
expect(response.body)
@@ -274,12 +274,12 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: 'without-access',
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: 'without-access',
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
end
it 'should respond 403 not allowed' do
@@ -303,23 +303,23 @@ describe SysController, type: :controller do
end
it 'should respond 200 okay dokay for read-only access' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
expect(response.code).to eq('200')
end
it 'should respond 403 not allowed for write (push)' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'POST',
- git_smart_http: '1',
- uri: "/git/#{project.identifier}/git-receive-pack",
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'POST',
+ git_smart_http: '1',
+ uri: "/git/#{project.identifier}/git-receive-pack",
+ location: '/git' }
expect(response.code).to eq('403')
end
@@ -341,23 +341,23 @@ describe SysController, type: :controller do
end
it 'should respond 200 okay dokay for GET' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
expect(response.code).to eq('200')
end
it 'should respond 200 okay dokay for POST' do
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'POST',
- git_smart_http: '1',
- uri: "/git/#{project.identifier}/git-receive-pack",
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'POST',
+ git_smart_http: '1',
+ uri: "/git/#{project.identifier}/git-receive-pack",
+ location: '/git' }
expect(response.code).to eq('200')
end
@@ -376,12 +376,12 @@ describe SysController, type: :controller do
valid_user_password + 'made invalid'
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
end
it 'should respond 401 auth required' do
@@ -398,12 +398,12 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
end
it 'should respond 403 not allowed' do
@@ -425,12 +425,12 @@ describe SysController, type: :controller do
valid_user.login,
valid_user_password
)
- post 'repo_auth', params: {key: api_key,
- repository: project.identifier,
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: project.identifier,
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
end
it 'should respond 200 OK' do
@@ -440,12 +440,12 @@ describe SysController, type: :controller do
context 'for invalid credentials' do
before(:each) do
- post 'repo_auth', params: {key: api_key,
- repository: 'any-repo',
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: api_key,
+ repository: 'any-repo',
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
end
it 'should respond 401 auth required' do
@@ -462,12 +462,12 @@ describe SysController, type: :controller do
valid_user_password
)
- post 'repo_auth', params: {key: 'not_the_api_key',
- repository: 'any-repo',
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: 'not_the_api_key',
+ repository: 'any-repo',
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
expect(response.code).to eq('403')
expect(response.body)
@@ -481,12 +481,12 @@ describe SysController, type: :controller do
'invalid'
)
- post 'repo_auth', params: {key: 'not_the_api_key',
- repository: 'any-repo',
- method: 'GET',
- git_smart_http: '1',
- uri: '/git',
- location: '/git'}
+ post 'repo_auth', params: { key: 'not_the_api_key',
+ repository: 'any-repo',
+ method: 'GET',
+ git_smart_http: '1',
+ uri: '/git',
+ location: '/git' }
expect(response.code).to eq('403')
expect(response.body)
@@ -497,10 +497,10 @@ describe SysController, type: :controller do
end
describe '#cached_user_login' do
- let(:cache_key) {
+ let(:cache_key) do
OpenProject::RepositoryAuthentication::CACHE_PREFIX +
Digest::SHA1.hexdigest("#{valid_user.login}#{valid_user_password}")
- }
+ end
let(:cache_expiry) { OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER }
it 'should call user_login only once when called twice' do
@@ -546,9 +546,9 @@ describe SysController, type: :controller do
let(:last_updated) { nil }
def request_storage
- get 'update_required_storage', params: {key: apikey,
- id: id,
- force: force}
+ get 'update_required_storage', params: { key: apikey,
+ id: id,
+ force: force }
end
context 'missing project' do
@@ -578,9 +578,9 @@ describe SysController, type: :controller do
context 'stubbed repository' do
let(:project) { FactoryBot.build_stubbed(:project) }
let(:id) { project.id }
- let(:repository) {
+ let(:repository) do
FactoryBot.build_stubbed(:repository_subversion, url: url, root_url: url)
- }
+ end
before do
allow(Project).to receive(:find).and_return(project)
@@ -619,9 +619,9 @@ describe SysController, type: :controller do
let(:project) { FactoryBot.create(:project) }
let(:id) { project.id }
- let(:repository) {
+ let(:repository) do
FactoryBot.create(:repository_subversion, project: project, url: url, root_url: url)
- }
+ end
before do
allow(Project).to receive(:find).and_return(project)
diff --git a/spec/controllers/types_controller_spec.rb b/spec/controllers/types_controller_spec.rb
index dfa1090b24..8843d50962 100644
--- a/spec/controllers/types_controller_spec.rb
+++ b/spec/controllers/types_controller_spec.rb
@@ -31,12 +31,12 @@ require 'spec_helper'
describe TypesController, type: :controller do
let(:project) do
FactoryBot.create(:project,
- work_package_custom_fields: [custom_field_2])
+ work_package_custom_fields: [custom_field_2])
end
let(:custom_field_1) do
FactoryBot.create(:work_package_custom_field,
- field_format: 'string',
- is_for_all: true)
+ field_format: 'string',
+ is_for_all: true)
end
let(:custom_field_2) { FactoryBot.create(:work_package_custom_field) }
let(:status_0) { FactoryBot.create(:status) }
@@ -168,9 +168,9 @@ describe TypesController, type: :controller do
let!(:existing_type) { FactoryBot.create(:type, name: 'Existing type') }
let!(:workflow) do
FactoryBot.create(:workflow,
- old_status: status_0,
- new_status: status_1,
- type_id: existing_type.id)
+ old_status: status_0,
+ new_status: status_1,
+ type_id: existing_type.id)
end
let(:params) do
@@ -200,8 +200,8 @@ describe TypesController, type: :controller do
render_views
let(:type) do
FactoryBot.create(:type, name: 'My type',
- is_milestone: true,
- projects: [project])
+ is_milestone: true,
+ projects: [project])
end
before do
@@ -219,8 +219,8 @@ describe TypesController, type: :controller do
render_views
let(:type) do
FactoryBot.create(:type, name: 'My type',
- is_milestone: true,
- projects: [project])
+ is_milestone: true,
+ projects: [project])
end
before do
@@ -230,15 +230,17 @@ describe TypesController, type: :controller do
it { expect(response).to be_successful }
it { expect(response).to render_template 'edit' }
it { expect(response).to render_template 'types/form/_projects' }
- it { expect(response.body).to have_selector "input[@name='type[project_ids][]'][@value='#{project.id}'][@checked='checked']" }
+ it {
+ expect(response.body).to have_selector "input[@name='type[project_ids][]'][@value='#{project.id}'][@checked='checked']"
+ }
end
describe 'POST update' do
let(:project2) { FactoryBot.create(:project) }
let(:type) do
FactoryBot.create(:type, name: 'My type',
- is_milestone: true,
- projects: [project, project2])
+ is_milestone: true,
+ projects: [project, project2])
end
describe 'WITH type rename' do
@@ -327,14 +329,14 @@ describe TypesController, type: :controller do
describe 'detroy type in use should fail' do
let(:project2) do
FactoryBot.create(:project,
- work_package_custom_fields: [custom_field_2],
- types: [type2])
+ work_package_custom_fields: [custom_field_2],
+ types: [type2])
end
let!(:work_package) do
FactoryBot.create(:work_package,
- author: current_user,
- type: type2,
- project: project2)
+ author: current_user,
+ type: type2,
+ project: project2)
end
let(:params) { { 'id' => type2.id } }
diff --git a/spec/controllers/users/memberships_controller_spec.rb b/spec/controllers/users/memberships_controller_spec.rb
index 42b43929c2..c0acaa9cf6 100644
--- a/spec/controllers/users/memberships_controller_spec.rb
+++ b/spec/controllers/users/memberships_controller_spec.rb
@@ -54,9 +54,9 @@ describe Users::MembershipsController, type: :controller do
expect(response).to redirect_to(controller: '/users', action: 'edit', id: user.id, tab: 'memberships')
- is_member = user.reload.memberships.any? { |m|
+ is_member = user.reload.memberships.any? do |m|
m.project_id == project.id && m.role_ids.include?(role.id)
- }
+ end
expect(is_member).to eql(true)
end
end
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 796f15ff8b..d5d235a18c 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -86,7 +86,7 @@ describe UsersController, type: :controller do
describe 'GET deletion_info' do
describe "WHEN the current user is the requested user
WHEN the setting users_deletable_by_self is set to true" do
- let(:params) { {'id' => user.id.to_s} }
+ let(:params) { { 'id' => user.id.to_s } }
before do
allow(Setting).to receive(:users_deletable_by_self?).and_return(true)
@@ -107,7 +107,7 @@ describe UsersController, type: :controller do
describe "WHEN the current user is the requested user
WHEN the setting users_deletable_by_self is set to false" do
- let(:params) { {'id' => user.id.to_s} }
+ let(:params) { { 'id' => user.id.to_s } }
before do
allow(Setting).to receive(:users_deletable_by_self?).and_return(false)
@@ -121,7 +121,7 @@ describe UsersController, type: :controller do
end
describe 'WHEN the current user is the anonymous user' do
- let(:params) { {'id' => anonymous.id.to_s} }
+ let(:params) { { 'id' => anonymous.id.to_s } }
before do
as_logged_in_user anonymous do
@@ -139,7 +139,7 @@ describe UsersController, type: :controller do
describe "WHEN the current user is admin
WHEN the setting users_deletable_by_admins is set to true" do
- let(:params) { {'id' => user.id.to_s} }
+ let(:params) { { 'id' => user.id.to_s } }
before do
allow(Setting).to receive(:users_deletable_by_admins?).and_return(true)
@@ -160,7 +160,7 @@ describe UsersController, type: :controller do
describe "WHEN the current user is admin
WHEN the setting users_deletable_by_admins is set to false" do
- let(:params) { {'id' => user.id.to_s} }
+ let(:params) { { 'id' => user.id.to_s } }
before do
allow(Setting).to receive(:users_deletable_by_admins?).and_return(false)
@@ -182,7 +182,7 @@ describe UsersController, type: :controller do
before do
as_logged_in_user normal_user do
- post :resend_invitation, params: {id: invited_user.id}
+ post :resend_invitation, params: { id: invited_user.id }
end
end
@@ -197,7 +197,7 @@ describe UsersController, type: :controller do
as_logged_in_user admin do
perform_enqueued_jobs do
- post :resend_invitation, params: {id: invited_user.id}
+ post :resend_invitation, params: { id: invited_user.id }
end
end
end
@@ -217,7 +217,7 @@ describe UsersController, type: :controller do
end
describe 'POST destroy' do
- let(:base_params) { {'id' => user.id.to_s, back_url: my_account_path} }
+ let(:base_params) { { 'id' => user.id.to_s, back_url: my_account_path } }
context 'WHEN the password confirmation is missing' do
before do
disable_flash_sweep
@@ -236,7 +236,7 @@ describe UsersController, type: :controller do
context 'WHEN password confirmation is present' do
let(:base_params) do
- {'id' => user.id.to_s, :'_password_confirmation' => user_password, back_url: my_account_path}
+ { 'id' => user.id.to_s, :_password_confirmation => user_password, back_url: my_account_path }
end
describe "WHEN the current user is the requested one
@@ -258,7 +258,6 @@ describe UsersController, type: :controller do
describe "WHEN the current user is the requested one
WHEN the setting users_deletable_by_self is set to false" do
-
before do
disable_flash_sweep
allow(Setting).to receive(:users_deletable_by_self?).and_return(false)
@@ -273,7 +272,6 @@ describe UsersController, type: :controller do
describe "WHEN the current user is the anonymous user
EVEN when the setting login_required is set to false" do
-
before do
allow(@controller).to receive(:find_current_user).and_return(anonymous)
allow(Setting).to receive(:login_required?).and_return(false)
@@ -311,13 +309,12 @@ describe UsersController, type: :controller do
describe "WHEN the current user is the admin
WHEN the given password does match
WHEN the setting users_deletable_by_admins is set to true" do
-
before do
disable_flash_sweep
allow(Setting).to receive(:users_deletable_by_admins?).and_return(true)
as_logged_in_user admin do
- post :destroy, params: base_params.merge(:'_password_confirmation' => 'adminADMIN!')
+ post :destroy, params: base_params.merge('_password_confirmation': 'adminADMIN!')
end
end
@@ -354,8 +351,8 @@ describe UsersController, type: :controller do
as_logged_in_user admin do
get :change_status_info,
params: {
- id: registered_user.id,
- change_action: change_action
+ id: registered_user.id,
+ change_action: change_action
}
end
end
@@ -395,13 +392,13 @@ describe UsersController, type: :controller do
describe '#change_status',
with_settings: {
- available_languages: %i(en de),
- bcc_recipients: 1
+ available_languages: %i(en de),
+ bcc_recipients: 1
} do
describe 'WHEN activating a registered user' do
let!(:registered_user) do
FactoryBot.create(:user, status: User.statuses[:registered],
- language: 'de')
+ language: 'de')
end
let(:user_limit_reached) { false }
@@ -412,9 +409,9 @@ describe UsersController, type: :controller do
as_logged_in_user admin do
post :change_status,
params: {
- id: registered_user.id,
- user: {status: User.statuses[:active]},
- activate: '1'
+ id: registered_user.id,
+ user: { status: User.statuses[:active] },
+ activate: '1'
}
end
end
@@ -467,7 +464,8 @@ describe UsersController, type: :controller do
shared_examples_for 'index action with enabled session lifetime and inactivity exceeded' do
it 'logs out the user and redirects with a warning that he has been locked out' do
- expect(response.redirect_url).to eq(signin_url + '?back_url=' + CGI::escape(@controller.url_for(controller: 'users', action: 'index')))
+ expect(response.redirect_url).to eq(signin_url + '?back_url=' + CGI::escape(@controller.url_for(controller: 'users',
+ action: 'index')))
expect(User.current).not_to eq(admin)
expect(flash[:warning]).to eq(I18n.t(:notice_forced_logout, ttl_time: Setting.session_ttl))
end
@@ -553,25 +551,25 @@ describe UsersController, type: :controller do
context 'fields' do
let(:user) do
FactoryBot.create(:user, firstname: 'Firstname',
- admin: true,
- login: 'testlogin',
- mail_notification: 'all',
- force_password_change: false)
+ admin: true,
+ login: 'testlogin',
+ mail_notification: 'all',
+ force_password_change: false)
end
let(:params) do
{
- id: user.id,
- user: {
- admin: false,
- firstname: 'Changed',
- login: 'changedlogin',
- mail_notification: 'only_assigned',
- force_password_change: true
- },
- pref: {
- hide_mail: '1',
- comments_sorting: 'desc'
- }
+ id: user.id,
+ user: {
+ admin: false,
+ firstname: 'Changed',
+ login: 'changedlogin',
+ mail_notification: 'only_assigned',
+ force_password_change: true
+ },
+ pref: {
+ hide_mail: '1',
+ comments_sorting: 'desc'
+ }
}
end
@@ -606,7 +604,7 @@ describe UsersController, type: :controller do
before do
as_logged_in_user(admin) do
- put :update, params: {id: user.id, user: {force_password_change: 'true'}}
+ put :update, params: { id: user.id, user: { force_password_change: 'true' } }
end
user.reload
end
@@ -624,9 +622,9 @@ describe UsersController, type: :controller do
as_logged_in_user admin do
put :update,
params: {
- id: user.id,
- user: {auth_source_id: '', password: 'newpassPASS!',
- password_confirmation: 'newpassPASS!'}
+ id: user.id,
+ user: { auth_source_id: '', password: 'newpassPASS!',
+ password_confirmation: 'newpassPASS!' }
}
end
@@ -644,8 +642,8 @@ describe UsersController, type: :controller do
as_logged_in_user(admin) do
put :update,
params: {
- id: user.id,
- user: {password: 'changedpass!', password_confirmation: 'changedpass!'}
+ id: user.id,
+ user: { password: 'changedpass!', password_confirmation: 'changedpass!' }
}
end
@@ -658,13 +656,13 @@ describe UsersController, type: :controller do
it 'should redirect to the login page' do
post :create,
params: {
- user: {
- login: 'psmith',
- firstname: 'Paul',
- lastname: 'Smith'
- },
- password: 'psmithPSMITH09',
- password_confirmation: 'psmithPSMITH09'
+ user: {
+ login: 'psmith',
+ firstname: 'Paul',
+ lastname: 'Smith'
+ },
+ password: 'psmithPSMITH09',
+ password_confirmation: 'psmithPSMITH09'
}
expect(response).to redirect_to '/login?back_url=http%3A%2F%2Ftest.host%2Fusers'
end
@@ -674,7 +672,7 @@ describe UsersController, type: :controller do
describe 'general' do
before do
as_logged_in_user user do
- get :show, params: {id: user.id}
+ get :show, params: { id: user.id }
end
end
@@ -732,7 +730,7 @@ describe UsersController, type: :controller do
allow(User).to receive(:current).and_return(user.reload)
allow_any_instance_of(User).to receive(:reported_work_package_count).and_return(42)
- get :show, params: {id: user.id}
+ get :show, params: { id: user.id }
end
it 'should include the number of reported work packages' do
diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb
index 08d5bec4da..36081c60be 100644
--- a/spec/controllers/versions_controller_spec.rb
+++ b/spec/controllers/versions_controller_spec.rb
@@ -174,7 +174,7 @@ describe VersionsController, type: :controller do
it { expect(response).to be_successful }
it { expect(response).to render_template('show') }
- it {assert_select 'h2', content: version2.name }
+ it { assert_select 'h2', content: version2.name }
subject { assigns(:version) }
it { is_expected.to eq(version2) }
diff --git a/spec/controllers/wiki_controller_spec.rb b/spec/controllers/wiki_controller_spec.rb
index 35acd66bb8..300601029d 100644
--- a/spec/controllers/wiki_controller_spec.rb
+++ b/spec/controllers/wiki_controller_spec.rb
@@ -237,7 +237,7 @@ describe WikiController, type: :controller do
end
end
end
- end # describe 'actions'
+ end
describe 'view related stuff' do
render_views
@@ -472,7 +472,9 @@ describe WikiController, type: :controller do
# Expect to set back ref id
expect(flash[:_related_wiki_page_id]).to eq @page_with_content.id
- assert_select "#content a[href='#{new_child_project_wiki_path(project_id: @project, id: @page_with_content.slug)}']", 'Wiki page'
+ path = new_child_project_wiki_path(project_id: @project, id: @page_with_content.slug)
+
+ assert_select "#content a[href='#{path}']", 'Wiki page'
end
end
@@ -512,7 +514,8 @@ describe WikiController, type: :controller do
expect(response).to be_successful
- assert_select ".toolbar-items a[href='#{new_child_project_wiki_path(project_id: @project, id: 'wiki')}']", 'Wiki page'
+ assert_select ".toolbar-items a[href='#{new_child_project_wiki_path(project_id: @project, id: 'wiki')}']",
+'Wiki page'
end
end
diff --git a/spec/controllers/wiki_menu_items_controller_spec.rb b/spec/controllers/wiki_menu_items_controller_spec.rb
index 02ae68b2b7..128ffc8ab1 100644
--- a/spec/controllers/wiki_menu_items_controller_spec.rb
+++ b/spec/controllers/wiki_menu_items_controller_spec.rb
@@ -36,7 +36,9 @@ describe WikiMenuItemsController, type: :controller do
let(:wiki) { project.wiki }
let(:wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki) } # first wiki page without child pages
- let!(:top_level_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, :with_menu_item_options, wiki: wiki, name: wiki_page.slug) }
+ let!(:top_level_wiki_menu_item) do
+ FactoryBot.create(:wiki_menu_item, :with_menu_item_options, wiki: wiki, name: wiki_page.slug)
+ end
before :each do
# log in user
@@ -46,20 +48,24 @@ describe WikiMenuItemsController, type: :controller do
describe '#edit' do
# more wiki pages with menu items
let(:another_wiki_page) { FactoryBot.create(:wiki_page, wiki: wiki) } # second wiki page with two child pages
- let!(:another_wiki_page_top_level_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_wiki_page.slug) }
+ let!(:another_wiki_page_top_level_wiki_menu_item) do
+ FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_wiki_page.slug)
+ end
# child pages of another_wiki_page
let(:child_page) { FactoryBot.create(:wiki_page, parent: another_wiki_page, wiki: wiki) }
let!(:child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: child_page.slug) }
let(:another_child_page) { FactoryBot.create(:wiki_page, parent: another_wiki_page, wiki: wiki) }
- let!(:another_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_child_page.slug, parent: top_level_wiki_menu_item) }
+ let!(:another_child_page_wiki_menu_item) do
+ FactoryBot.create(:wiki_menu_item, wiki: wiki, name: another_child_page.slug, parent: top_level_wiki_menu_item)
+ end
let(:grand_child_page) { FactoryBot.create(:wiki_page, parent: child_page, wiki: wiki) }
let!(:grand_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) }
context 'when no parent wiki menu item has been configured yet' do
context 'and it is a child page' do
- before do get :edit, params: { project_id: project.id, id: child_page.slug } end
+ before { get :edit, params: { project_id: project.id, id: child_page.slug } }
subject { response }
it 'preselects the wiki menu item of the parent page as parent wiki menu item option' do
@@ -84,7 +90,7 @@ describe WikiMenuItemsController, type: :controller do
end
context 'when a parent wiki menu item has already been configured' do
- before do get :edit, params: { project_id: project.id, id: another_child_page.slug } end
+ before { get :edit, params: { project_id: project.id, id: another_child_page.slug } }
subject { response }
it 'preselects the parent wiki menu item that is already assigned' do
@@ -103,7 +109,7 @@ describe WikiMenuItemsController, type: :controller do
describe '#select_main_menu_item' do
include_context 'when there is one more wiki page with a child page'
- before do get :select_main_menu_item, params: { project_id: project, id: wiki_page.id } end
+ before { get :select_main_menu_item, params: { project_id: project, id: wiki_page.id } }
subject { assigns['possible_wiki_pages'] }
context 'when selecting a new wiki page to replace the current main menu item' do
diff --git a/spec/controllers/work_packages/bulk_controller_spec.rb b/spec/controllers/work_packages/bulk_controller_spec.rb
index 6456cf4bd1..99fe99e7d4 100644
--- a/spec/controllers/work_packages/bulk_controller_spec.rb
+++ b/spec/controllers/work_packages/bulk_controller_spec.rb
@@ -180,7 +180,9 @@ describe WorkPackages::BulkController, type: :controller do
end
describe '#project' do
- it { assert_select 'select', { attributes: { name: "work_package[custom_field_values][#{custom_field_2.id}]" } }, false }
+ it {
+ assert_select 'select', { attributes: { name: "work_package[custom_field_values][#{custom_field_2.id}]" } }, false
+ }
end
end
end
@@ -223,7 +225,9 @@ describe WorkPackages::BulkController, type: :controller do
context 'when updating two work packages with differing whitelisted params' do
let!(:work_package_ids) { [work_package_1.id, work_package_3.id] }
- let!(:role_with_permission_to_add_watchers) { FactoryBot.create(:role, permissions: role.permissions + [:add_work_package_watchers]) }
+ let!(:role_with_permission_to_add_watchers) do
+ FactoryBot.create(:role, permissions: role.permissions + [:add_work_package_watchers])
+ end
let!(:other_user) { FactoryBot.create :user }
let!(:other_member_1) do
@@ -673,7 +677,8 @@ describe WorkPackages::BulkController, type: :controller do
describe 'w/o the cleanup being successful' do
before do
- expect(WorkPackage).to receive(:cleanup_associated_before_destructing_if_required).with([stub_work_package], user, params['to_do']).and_return false
+ expect(WorkPackage).to receive(:cleanup_associated_before_destructing_if_required).with([stub_work_package], user,
+ params['to_do']).and_return false
as_logged_in_user(user) do
delete :destroy, params: params
diff --git a/spec/controllers/work_packages/moves_controller_spec.rb b/spec/controllers/work_packages/moves_controller_spec.rb
index 8cf4ee735c..f7fd424a40 100644
--- a/spec/controllers/work_packages/moves_controller_spec.rb
+++ b/spec/controllers/work_packages/moves_controller_spec.rb
@@ -33,11 +33,11 @@ describe WorkPackages::MovesController, type: :controller do
let(:role) do
FactoryBot.create :role,
permissions: %i(move_work_packages
- view_work_packages
- add_work_packages
- edit_work_packages
- assign_versions
- manage_subtasks)
+ view_work_packages
+ add_work_packages
+ edit_work_packages
+ assign_versions
+ manage_subtasks)
end
let(:type) { FactoryBot.create :type }
let(:type_2) { FactoryBot.create :type }
@@ -120,12 +120,12 @@ describe WorkPackages::MovesController, type: :controller do
let!(:source_member) { FactoryBot.create(:member, user: current_user, project: project, roles: [role]) }
let!(:target_member) { FactoryBot.create(:member, user: current_user, project: target_project, roles: [role]) }
let(:target_project) { FactoryBot.create(:project, public: false) }
- let(:work_package_2) {
+ let(:work_package_2) do
FactoryBot.create(:work_package,
project_id: project.id,
type: type_2,
priority: priority)
- }
+ end
describe 'an issue to another project' do
context 'w/o following' do
@@ -242,7 +242,7 @@ describe WorkPackages::MovesController, type: :controller do
shared_examples_for 'single note for moved work package' do
it { expect(moved_work_package.journals.count).to eq(2) }
- it { expect(moved_work_package.journals.sort_by(&:id).last.notes).to eq(note) }
+ it { expect(moved_work_package.journals.max_by(&:id).notes).to eq(note) }
end
describe 'move with given note' do
@@ -447,7 +447,7 @@ describe WorkPackages::MovesController, type: :controller do
params: {
ids: [work_package.id, child_wp.id],
copy: '',
- new_project_id: to_project.id,
+ new_project_id: to_project.id
}
it 'reports the one child work package' do
@@ -468,13 +468,13 @@ describe WorkPackages::MovesController, type: :controller do
.not_to receive(:new)
.with(child_wp, current_user)
- expect {
+ expect do
post :create,
params: {
ids: [work_package.id, child_wp.id],
- copy: '',
+ copy: ''
}
- }.to change(WorkPackage, :count).by(2)
+ end.to change(WorkPackage, :count).by(2)
expect(flash[:notice]).to eq(I18n.t(:notice_successful_create))
end
diff --git a/spec/controllers/work_packages/reports_controller_spec.rb b/spec/controllers/work_packages/reports_controller_spec.rb
index 5ab89a32a2..8f981e218a 100644
--- a/spec/controllers/work_packages/reports_controller_spec.rb
+++ b/spec/controllers/work_packages/reports_controller_spec.rb
@@ -31,33 +31,33 @@ require 'spec_helper'
describe WorkPackages::ReportsController, type: :controller do
let(:user) { FactoryBot.create(:user) }
let(:project) { FactoryBot.create(:project) }
- let(:role) {
+ let(:role) do
FactoryBot.create(:role,
- permissions: [:view_work_packages])
- }
- let(:member) {
+ permissions: [:view_work_packages])
+ end
+ let(:member) do
FactoryBot.create(:member,
- project: project,
- principal: user,
- roles: [role])
- }
- let(:work_package_1) {
+ project: project,
+ principal: user,
+ roles: [role])
+ end
+ let(:work_package_1) do
FactoryBot.create(:work_package,
- id: 21,
- subject: "Can't print recipes",
- project: project)
- }
- let(:work_package_2) {
+ id: 21,
+ subject: "Can't print recipes",
+ project: project)
+ end
+ let(:work_package_2) do
FactoryBot.create(:work_package,
- id: 2101,
- subject: 'Error 281 when updating a recipe',
- project: project)
- }
- let(:work_package_3) {
+ id: 2101,
+ subject: 'Error 281 when updating a recipe',
+ project: project)
+ end
+ let(:work_package_3) do
FactoryBot.create(:work_package,
- id: 2102,
- project: project)
- }
+ id: 2102,
+ project: project)
+ end
before do
member
diff --git a/spec/decorators/single_spec.rb b/spec/decorators/single_spec.rb
index b1a357d7db..357b89d784 100644
--- a/spec/decorators/single_spec.rb
+++ b/spec/decorators/single_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/factories/category_factory.rb b/spec/factories/category_factory.rb
index 82bf8218f4..248a3d6aaf 100644
--- a/spec/factories/category_factory.rb
+++ b/spec/factories/category_factory.rb
@@ -28,7 +28,7 @@
FactoryBot.define do
factory :category do
- sequence(:name) do |n| "Issue category #{n}" end
+ sequence(:name) { |n| "Issue category #{n}" }
project
callback(:after_build) do |issue|
diff --git a/spec/factories/changeset_factory.rb b/spec/factories/changeset_factory.rb
index c8d5e19803..4a6d95f488 100644
--- a/spec/factories/changeset_factory.rb
+++ b/spec/factories/changeset_factory.rb
@@ -28,7 +28,7 @@
FactoryBot.define do
factory :changeset do
- sequence(:revision) { |n| "#{n}" }
+ sequence(:revision) { |n| n.to_s }
committed_on { Time.now }
commit_date { Date.today }
end
diff --git a/spec/factories/color_factory.rb b/spec/factories/color_factory.rb
index ba032db2e4..2676dc7d8f 100644
--- a/spec/factories/color_factory.rb
+++ b/spec/factories/color_factory.rb
@@ -28,28 +28,28 @@
FactoryBot.define do
factory(:color, class: Color) do
- sequence(:name) do |n| "Color No. #{n}" end
- hexcode do ('#%0.6x' % rand(0xFFFFFF)).upcase end
+ sequence(:name) { |n| "Color No. #{n}" }
+ hexcode { ('#%0.6x' % rand(0xFFFFFF)).upcase }
end
end
-{ 'maroon' => '#800000',
- 'red' => '#FF0000',
- 'orange' => '#FFA500',
- 'yellow' => '#FFFF00',
- 'olive' => '#808000',
- 'purple' => '#800080',
+{ 'maroon' => '#800000',
+ 'red' => '#FF0000',
+ 'orange' => '#FFA500',
+ 'yellow' => '#FFFF00',
+ 'olive' => '#808000',
+ 'purple' => '#800080',
'fuchsia' => '#FF00FF',
- 'white' => '#FFFFFF',
- 'lime' => '#00FF00',
- 'green' => '#008000',
- 'navy' => '#000080',
- 'blue' => '#0000FF',
- 'aqua' => '#00FFFF',
- 'teal' => '#008080',
- 'black' => '#000000',
- 'silver' => '#C0C0C0',
- 'gray' => '#808080' }.each do |name, code|
+ 'white' => '#FFFFFF',
+ 'lime' => '#00FF00',
+ 'green' => '#008000',
+ 'navy' => '#000080',
+ 'blue' => '#0000FF',
+ 'aqua' => '#00FFFF',
+ 'teal' => '#008080',
+ 'black' => '#000000',
+ 'silver' => '#C0C0C0',
+ 'gray' => '#808080' }.each do |name, code|
FactoryBot.define do
factory(:"color_#{name}", parent: :color) do
name { name }
diff --git a/spec/factories/comment_factory.rb b/spec/factories/comment_factory.rb
index 9720d73d6d..a5b120f5e1 100644
--- a/spec/factories/comment_factory.rb
+++ b/spec/factories/comment_factory.rb
@@ -29,7 +29,7 @@
FactoryBot.define do
factory :comment do
author factory: :user
- sequence(:comments) do |n| "I am a comment No. #{n}" end
+ sequence(:comments) { |n| "I am a comment No. #{n}" }
commented factory: :news
end
end
diff --git a/spec/factories/enumerations_factory.rb b/spec/factories/enumerations_factory.rb
index 2257b3f799..303f4fc9a3 100644
--- a/spec/factories/enumerations_factory.rb
+++ b/spec/factories/enumerations_factory.rb
@@ -39,7 +39,7 @@ FactoryBot.define do
end
factory :activity, class: TimeEntryActivity do
- sequence(:name) do |i| "Activity #{i}" end
+ sequence(:name) { |i| "Activity #{i}" }
active { true }
is_default { false }
@@ -52,7 +52,7 @@ FactoryBot.define do
end
factory :priority, class: IssuePriority do
- sequence(:name) do |i| "Priority #{i}" end
+ sequence(:name) { |i| "Priority #{i}" }
active { true }
factory :priority_low do
@@ -60,7 +60,7 @@ FactoryBot.define do
# reuse existing priority with the given name
# this prevents a validation error (name has to be unique)
- initialize_with do IssuePriority.find_or_create_by(name: name) end
+ initialize_with { IssuePriority.find_or_create_by(name: name) }
factory :priority_normal do
name { 'Normal' }
diff --git a/spec/factories/file_factory.rb b/spec/factories/file_factory.rb
index 089069be00..abc6c9fb3b 100644
--- a/spec/factories/file_factory.rb
+++ b/spec/factories/file_factory.rb
@@ -51,10 +51,11 @@ FactoryBot.define do
initialize_with do
FileHelpers.mock_uploaded_file(
- name: name,
- content: content,
+ name: name,
+ content: content,
content_type: content_type,
- binary: binary)
+ binary: binary
+ )
end
factory :uploaded_jpg do
diff --git a/spec/factories/forum_factory.rb b/spec/factories/forum_factory.rb
index 7d8612d32e..066a903ec9 100644
--- a/spec/factories/forum_factory.rb
+++ b/spec/factories/forum_factory.rb
@@ -29,7 +29,7 @@
FactoryBot.define do
factory :forum do
project
- sequence(:name) do |n| "Forum No. #{n}" end
+ sequence(:name) { |n| "Forum No. #{n}" }
sequence(:description) { |n| "I am the Forum No. #{n}" }
end
end
diff --git a/spec/factories/menu_item_factory.rb b/spec/factories/menu_item_factory.rb
index 1ae1567086..1541ad0631 100644
--- a/spec/factories/menu_item_factory.rb
+++ b/spec/factories/menu_item_factory.rb
@@ -28,13 +28,13 @@
FactoryBot.define do
factory :menu_item do
- sequence(:name) do |n| "Item No. #{n}" end
- sequence(:title) do |n| "Menu item Title #{n}" end
+ sequence(:name) { |n| "Item No. #{n}" }
+ sequence(:title) { |n| "Menu item Title #{n}" }
factory :wiki_menu_item, class: MenuItems::WikiMenuItem do
wiki
- sequence(:title) do |n| "Wiki Title #{n}" end
+ sequence(:title) { |n| "Wiki Title #{n}" }
trait :with_menu_item_options do
index_page { true }
@@ -53,8 +53,8 @@ FactoryBot.define do
factory :query_menu_item, class: MenuItems::QueryMenuItem do
query
- name do query.normalized_name end
- title do query.name end
+ name { query.normalized_name }
+ title { query.name }
navigatable_id { query.id }
end
diff --git a/spec/factories/message_factory.rb b/spec/factories/message_factory.rb
index 214db7637c..512ab7d4e0 100644
--- a/spec/factories/message_factory.rb
+++ b/spec/factories/message_factory.rb
@@ -29,7 +29,7 @@
FactoryBot.define do
factory :message do
forum
- sequence(:content) do |n| "Message content #{n}" end
+ sequence(:content) { |n| "Message content #{n}" }
sequence(:subject) { |n| "Message subject #{n}" }
end
end
diff --git a/spec/factories/news_factory.rb b/spec/factories/news_factory.rb
index e40601dd74..e64ab0b201 100644
--- a/spec/factories/news_factory.rb
+++ b/spec/factories/news_factory.rb
@@ -28,9 +28,9 @@
FactoryBot.define do
factory :news do
- sequence(:title) do |n| "News title#{n}" end
- sequence(:summary) do |n| "News summary#{n}" end
- sequence(:description) do |n| "News description#{n}" end
+ sequence(:title) { |n| "News title#{n}" }
+ sequence(:summary) { |n| "News summary#{n}" }
+ sequence(:description) { |n| "News description#{n}" }
author factory: :user
project
end
diff --git a/spec/factories/principal_factory.rb b/spec/factories/principal_factory.rb
index a9336bc2cd..b167d8cc09 100644
--- a/spec/factories/principal_factory.rb
+++ b/spec/factories/principal_factory.rb
@@ -47,7 +47,10 @@ FactoryBot.define do
(projects = evaluator.member_in_projects || [])
projects << evaluator.member_in_project if evaluator.member_in_project
if !projects.empty?
- role = evaluator.member_through_role || FactoryBot.build(:role, permissions: evaluator.member_with_permissions || [:view_work_packages, :edit_work_packages])
+ role = evaluator.member_through_role || FactoryBot.build(:role,
+ permissions: evaluator.member_with_permissions || %i[
+ view_work_packages edit_work_packages
+ ])
projects.each do |project|
project.add_member! principal, role if project
end
diff --git a/spec/factories/project_factory.rb b/spec/factories/project_factory.rb
index 08110b7816..b553b6722a 100644
--- a/spec/factories/project_factory.rb
+++ b/spec/factories/project_factory.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/factories/project_status.rb b/spec/factories/project_status.rb
index 3fc43cc039..d8b07d63fd 100644
--- a/spec/factories/project_status.rb
+++ b/spec/factories/project_status.rb
@@ -1,4 +1,5 @@
# encoding: utf-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/factories/role_factory.rb b/spec/factories/role_factory.rb
index 57299550b4..862dc51380 100644
--- a/spec/factories/role_factory.rb
+++ b/spec/factories/role_factory.rb
@@ -31,7 +31,7 @@ require 'digest'
FactoryBot.define do
factory :role do
permissions { [] }
- sequence(:name) do |n| "role_#{n}" end
+ sequence(:name) { |n| "role_#{n}" }
assignable { true }
factory :non_member do
diff --git a/spec/factories/status_factory.rb b/spec/factories/status_factory.rb
index b3a3be00d7..e6c4fffccc 100644
--- a/spec/factories/status_factory.rb
+++ b/spec/factories/status_factory.rb
@@ -28,7 +28,7 @@
FactoryBot.define do
factory :status do
- sequence(:name) do |n| "status #{n}" end
+ sequence(:name) { |n| "status #{n}" }
is_closed { false }
is_readonly { false }
diff --git a/spec/factories/type_factory.rb b/spec/factories/type_factory.rb
index 203a5f89ee..901f92bb02 100644
--- a/spec/factories/type_factory.rb
+++ b/spec/factories/type_factory.rb
@@ -49,7 +49,8 @@ FactoryBot.define do
query = FactoryBot.create(:query)
query.add_filter(evaluator.relation_filter.to_s, '=', [::Queries::Filters::TemplatedValue::KEY])
query.save
- t.attribute_groups = t.default_attribute_groups + [["Embedded table for #{evaluator.relation_filter.to_s}", ["query_#{query.id}".to_sym]]]
+ t.attribute_groups = t.default_attribute_groups + [["Embedded table for #{evaluator.relation_filter}",
+ ["query_#{query.id}".to_sym]]]
end
end
end
diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb
index 222b2298d6..b849ac86b5 100644
--- a/spec/factories/user_factory.rb
+++ b/spec/factories/user_factory.rb
@@ -44,9 +44,9 @@ FactoryBot.define do
factory :admin do
firstname { 'OpenProject' }
- sequence(:lastname) do |n| "Admin#{n}" end
- sequence(:login) do |n| "admin#{n}" end
- sequence(:mail) do |n| "admin#{n}@example.com" end
+ sequence(:lastname) { |n| "Admin#{n}" }
+ sequence(:login) { |n| "admin#{n}" }
+ sequence(:mail) { |n| "admin#{n}@example.com" }
admin { true }
first_login { false if User.table_exists? and User.columns.map(&:name).include? 'first_login' }
end
@@ -56,10 +56,10 @@ FactoryBot.define do
factory :locked_user do
firstname { 'Locked' }
lastname { 'User' }
- sequence(:login) do |n| "bob#{n}" end
- sequence(:mail) do |n| "bob#{n}.bobbit@bob.com" end
+ sequence(:login) { |n| "bob#{n}" }
+ sequence(:mail) { |n| "bob#{n}.bobbit@bob.com" }
password { 'adminADMIN!' }
- password_confirmation { 'adminADMIN!'}
+ password_confirmation { 'adminADMIN!' }
status { User.statuses[:locked] }
end
diff --git a/spec/factories/user_session_factory.rb b/spec/factories/user_session_factory.rb
index 03eb8b9e2f..e70d951b20 100644
--- a/spec/factories/user_session_factory.rb
+++ b/spec/factories/user_session_factory.rb
@@ -28,7 +28,7 @@
FactoryBot.define do
factory :user_session do
- sequence(:session_id) do |n| "session_#{n}" end
+ sequence(:session_id) { |n| "session_#{n}" }
association :user
callback(:after_build) do |session|
diff --git a/spec/factories/work_package_custom_field_factory.rb b/spec/factories/work_package_custom_field_factory.rb
index 01298dd0ac..1fe67db96d 100644
--- a/spec/factories/work_package_custom_field_factory.rb
+++ b/spec/factories/work_package_custom_field_factory.rb
@@ -32,7 +32,7 @@ FactoryBot.define do
default_locales { nil }
end
- sequence(:name) do |n| "Custom Field Nr. #{n}" end
+ sequence(:name) { |n| "Custom Field Nr. #{n}" }
regexp { '' }
is_required { false }
min_length { false }
diff --git a/spec/factories/work_packags_export_factory.rb b/spec/factories/work_packags_export_factory.rb
index 04517a9849..3f60d90d9d 100644
--- a/spec/factories/work_packags_export_factory.rb
+++ b/spec/factories/work_packags_export_factory.rb
@@ -28,6 +28,5 @@
FactoryBot.define do
factory :work_packages_export, class: WorkPackages::Export do
-
end
end
diff --git a/spec/features/accessibility/work_packages/work_package_query_spec.rb b/spec/features/accessibility/work_packages/work_package_query_spec.rb
index 46ecf716b0..6c8fbfcfc3 100644
--- a/spec/features/accessibility/work_packages/work_package_query_spec.rb
+++ b/spec/features/accessibility/work_packages/work_package_query_spec.rb
@@ -52,7 +52,7 @@ describe 'Work package index accessibility', type: :feature, selenium: true do
end
describe 'Sort link', js: true do
- before do visit_index_page end
+ before { visit_index_page }
def click_sort_ascending_link
expect(page).to have_selector(sort_ascending_selector)
@@ -84,9 +84,8 @@ describe 'Work package index accessibility', type: :feature, selenium: true do
it_behaves_like 'sort column'
end
-
shared_examples_for 'sortable column' do
- before do expect(page).to have_selector(column_header_selector) end
+ before { expect(page).to have_selector(column_header_selector) }
describe 'Initial sort' do
it_behaves_like 'unsorted column'
@@ -155,10 +154,10 @@ describe 'Work package index accessibility', type: :feature, selenium: true do
end
describe 'hotkeys', js: true do
- let!(:another_work_package) {
+ let!(:another_work_package) do
FactoryBot.create(:work_package,
- project: project)
- }
+ project: project)
+ end
before do
visit_index_page
end
@@ -229,14 +228,14 @@ describe 'Work package index accessibility', type: :feature, selenium: true do
it_behaves_like 'context menu' do
let(:target_link) { '#work-package-context-menu a.detailsViewMenuItem' }
let(:source_link) { '.work-package-table--container tr.issue td.id a' }
- let(:keys) { [:shift, :alt, :f10] }
+ let(:keys) { %i[shift alt f10] }
let(:sets_focus) { true }
end
it_behaves_like 'context menu' do
let(:target_link) { '#work-package-context-menu a.openFullScreenView' }
let(:source_link) { '.work-package-table--container tr.issue td.id a' }
- let(:keys) { [:shift, :alt, :f10] }
+ let(:keys) { %i[shift alt f10] }
let(:sets_focus) { false }
end
end
diff --git a/spec/features/admin/enterprise/enterprise_trial_spec.rb b/spec/features/admin/enterprise/enterprise_trial_spec.rb
index 400df7d9ac..7c0e02a518 100644
--- a/spec/features/admin/enterprise/enterprise_trial_spec.rb
+++ b/spec/features/admin/enterprise/enterprise_trial_spec.rb
@@ -31,7 +31,6 @@ require 'spec_helper'
describe 'Enterprise trial management',
type: :feature,
driver: :chrome_billy do
-
let(:admin) { FactoryBot.create(:admin) }
let(:trial_id) { '1b6486b4-5a30-4042-8714-99d7c8e6b637' }
diff --git a/spec/features/auth/auth_stages_spec.rb b/spec/features/auth/auth_stages_spec.rb
index 9a5f04ef10..b43b4ac599 100644
--- a/spec/features/auth/auth_stages_spec.rb
+++ b/spec/features/auth/auth_stages_spec.rb
@@ -77,7 +77,7 @@ describe 'Authentication Stages', type: :feature do
end
# this shouldn't influence the specs as it is active
- OpenProject::Authentication::Stage.register :inactive, '/foo/bar', active: ->() { false }
+ OpenProject::Authentication::Stage.register :inactive, '/foo/bar', active: -> { false }
end
after do
diff --git a/spec/features/auth/login_spec.rb b/spec/features/auth/login_spec.rb
index 5b3a43a05e..2987b0ddc9 100644
--- a/spec/features/auth/login_spec.rb
+++ b/spec/features/auth/login_spec.rb
@@ -134,7 +134,6 @@ describe 'Login', type: :feature do
with_settings: {
autologin: 1
} do
-
def fake_browser_closed
page.driver.browser.set_cookie(OpenProject::Configuration['session_cookie_name'])
end
diff --git a/spec/features/auth/omniauth_spec.rb b/spec/features/auth/omniauth_spec.rb
index e0aef9d220..58719a3232 100644
--- a/spec/features/auth/omniauth_spec.rb
+++ b/spec/features/auth/omniauth_spec.rb
@@ -38,13 +38,12 @@ describe 'Omniauth authentication', type: :feature do
let(:user) do
FactoryBot.create(:user,
- force_password_change: false,
- identity_url: 'developer:omnibob@example.com',
- login: 'omnibob',
- mail: 'omnibob@example.com',
- firstname: 'omni',
- lastname: 'bob'
- )
+ force_password_change: false,
+ identity_url: 'developer:omnibob@example.com',
+ login: 'omnibob',
+ mail: 'omnibob@example.com',
+ firstname: 'omni',
+ lastname: 'bob')
end
before do
@@ -96,7 +95,6 @@ describe 'Omniauth authentication', type: :feature do
context 'with direct login',
with_config: { omniauth_direct_login_provider: 'developer' } do
-
it 'should go directly to the developer sign in and then redirect to the back url' do
visit my_account_path
# requires login, redirects to developer login which is why we see the login form now
@@ -115,7 +113,6 @@ describe 'Omniauth authentication', type: :feature do
describe 'sign out a user with direct login and login required',
with_config: { omniauth_direct_login_provider: 'developer' },
with_settings: { login_required?: true } do
-
it 'shows a notice that the user has been logged out' do
visit signout_path
@@ -143,7 +140,7 @@ describe 'Omniauth authentication', type: :feature do
shared_examples 'omniauth user registration' do
it 'should register new user' do
visit '/'
- click_link("Omniauth Developer", :match => :first)
+ click_link("Omniauth Developer", match: :first)
SeleniumHubWaiter.wait
# login form developer strategy
@@ -166,12 +163,11 @@ describe 'Omniauth authentication', type: :feature do
end
context 'register on the fly',
- with_settings: {
+ with_settings: {
self_registration?: true,
self_registration: '3',
available_languages: [:en]
- } do
-
+ } do
let(:user) do
User.new(force_password_change: false,
identity_url: 'developer:omnibob@example.com',
@@ -185,7 +181,7 @@ describe 'Omniauth authentication', type: :feature do
it 'should redirect to homesceen' do
visit account_lost_password_path
- click_link("Omniauth Developer", :match => :first)
+ click_link("Omniauth Developer", match: :first)
SeleniumHubWaiter.wait
# login form developer strategy
@@ -206,7 +202,6 @@ describe 'Omniauth authentication', type: :feature do
context 'with password login disabled',
with_config: { disable_password_login: 'true' } do
-
it_behaves_like 'omniauth user registration'
end
end
@@ -216,7 +211,6 @@ describe 'Omniauth authentication', type: :feature do
self_registration?: true,
self_registration: Setting::SelfRegistration.by_email.to_s
} do
-
shared_examples 'registration with registration by email' do
it 'shows a note explaining that the account has to be activated' do
visit login_path
@@ -243,7 +237,6 @@ describe 'Omniauth authentication', type: :feature do
context 'with direct login enabled and login required',
with_config: { omniauth_direct_login_provider: 'developer' } do
-
before do
allow(Setting).to receive(:login_required?).and_return(true)
end
@@ -267,9 +260,9 @@ describe 'Omniauth authentication', type: :feature do
OmniAuth.config.mock_auth[:developer] = :invalid_credentials
# seems like this default behaviour is removed when running the full
# test suite, so let's set it back when running this test
- OmniAuth.config.on_failure = Proc.new { |env|
+ OmniAuth.config.on_failure = Proc.new do |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
- }
+ end
visit login_path
expect(page).to have_content(I18n.t(:error_external_authentication_failed))
@@ -285,7 +278,6 @@ describe 'Omniauth authentication', type: :feature do
context 'with direct login and login required',
with_config: { omniauth_direct_login_provider: 'developer' } do
-
before do
allow(Setting).to receive(:login_required?).and_return(true)
end
diff --git a/spec/features/categories/delete_spec.rb b/spec/features/categories/delete_spec.rb
index fe02c6a8ab..f6684549d3 100644
--- a/spec/features/categories/delete_spec.rb
+++ b/spec/features/categories/delete_spec.rb
@@ -36,7 +36,7 @@ describe 'Deletion', type: :feature do
let(:delete_button) { 'a.icon-delete' }
let(:confirm_deletion_button) { 'input[type="submit"]' }
- before do allow(User).to receive(:current).and_return current_user end
+ before { allow(User).to receive(:current).and_return current_user }
shared_context 'delete category' do
before do
@@ -61,11 +61,11 @@ describe 'Deletion', type: :feature do
end
describe 'with work package' do
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create :work_package,
- project: category.project,
- category: category
- }
+ project: category.project,
+ category: category
+ end
include_context 'delete category'
diff --git a/spec/features/custom_fields/create_long_text_spec.rb b/spec/features/custom_fields/create_long_text_spec.rb
index eb795daafc..13feb5359e 100644
--- a/spec/features/custom_fields/create_long_text_spec.rb
+++ b/spec/features/custom_fields/create_long_text_spec.rb
@@ -52,7 +52,6 @@ describe 'custom fields', js: true do
type.custom_fields << cf
type.save!
-
wp_page.visit!
wp_editor = TextEditorField.new(page, 'description', selector: ".inline-edit--container.customField#{cf.id}")
wp_editor.expect_active!
diff --git a/spec/features/custom_fields/multi_user_custom_field_spec.rb b/spec/features/custom_fields/multi_user_custom_field_spec.rb
index 196071954d..3d13bba28a 100644
--- a/spec/features/custom_fields/multi_user_custom_field_spec.rb
+++ b/spec/features/custom_fields/multi_user_custom_field_spec.rb
@@ -19,7 +19,6 @@ describe "multi select custom values", js: true do
)
end
-
let(:wp_page) { Pages::FullWorkPackage.new work_package }
let(:cf_edit_field) do
@@ -128,7 +127,6 @@ describe "multi select custom values", js: true do
member_through_role: role
end
-
context "with existing custom values" do
let(:work_package) do
wp = FactoryBot.build :work_package, project: project, type: type
@@ -141,7 +139,6 @@ describe "multi select custom values", js: true do
wp
end
-
it "should be shown and allowed to be updated" do
expect(page).to have_text custom_field.name
expect(page).to have_text "Billy Nobbler"
diff --git a/spec/features/custom_fields/multi_value_custom_field_spec.rb b/spec/features/custom_fields/multi_value_custom_field_spec.rb
index c9fd2e9b0a..3289af5f55 100644
--- a/spec/features/custom_fields/multi_value_custom_field_spec.rb
+++ b/spec/features/custom_fields/multi_value_custom_field_spec.rb
@@ -35,7 +35,7 @@ describe "multi select custom values", clear_cache: true, js: true do
let(:sort_by) { ::Components::WorkPackages::SortBy.new }
let(:user) { FactoryBot.create :admin }
- let(:cf_frontend) { "customField#{custom_field.id}"}
+ let(:cf_frontend) { "customField#{custom_field.id}" }
context "with existing custom values" do
let(:work_package_options) { %w[ham pineapple onions] }
diff --git a/spec/features/global_roles/global_role_assignment_spec.rb b/spec/features/global_roles/global_role_assignment_spec.rb
index fb90214f11..20e9ae620e 100644
--- a/spec/features/global_roles/global_role_assignment_spec.rb
+++ b/spec/features/global_roles/global_role_assignment_spec.rb
@@ -36,7 +36,7 @@ describe 'Global role: Global role assignment', type: :feature, js: true do
describe 'Going to the global role assignment page' do
before do
- mock_global_permissions [['global1', project_module: :global], ['global2', project_module: :global]]
+ mock_global_permissions [['global1', { project_module: :global }], ['global2', { project_module: :global }]]
end
let!(:global_role1) { FactoryBot.create :global_role, name: 'global_role1', permissions: %i[global1] }
let!(:global_role2) { FactoryBot.create :global_role, name: 'global_role2', permissions: %i[global2] }
diff --git a/spec/features/global_roles/global_role_crud_spec.rb b/spec/features/global_roles/global_role_crud_spec.rb
index ba11b20ec8..eecbbe8f8f 100644
--- a/spec/features/global_roles/global_role_crud_spec.rb
+++ b/spec/features/global_roles/global_role_crud_spec.rb
@@ -33,7 +33,7 @@ describe 'Global role: Global role CRUD', type: :feature, js: true do
# Scenario: Global Role creation
# Given there is the global permission "glob_test" of the module "global_group"
before do
- mock_global_permissions [['glob_test', project_module: 'global_group']]
+ mock_global_permissions [['glob_test', { project_module: 'global_group' }]]
login_as(current_user)
end
diff --git a/spec/features/global_roles/no_module_spec.rb b/spec/features/global_roles/no_module_spec.rb
index e62ca9eae7..3d839ca4ac 100644
--- a/spec/features/global_roles/no_module_spec.rb
+++ b/spec/features/global_roles/no_module_spec.rb
@@ -41,7 +41,7 @@ describe 'Global role: No module', type: :feature, js: true do
scenario 'Global Rights Modules do not exist as Project -> Settings -> Modules' do
# Scenario:
# Given there is the global permission "glob_test" of the module "global"
- mock_global_permissions [['global_perm1', project_module: :global]]
+ mock_global_permissions [['global_perm1', { project_module: :global }]]
# And there is 1 project with the following:
# | name | test |
diff --git a/spec/features/homescreen/robots_spec.rb b/spec/features/homescreen/robots_spec.rb
index 7ea11b2934..f71e9d594f 100644
--- a/spec/features/homescreen/robots_spec.rb
+++ b/spec/features/homescreen/robots_spec.rb
@@ -38,7 +38,7 @@ describe 'robots.txt', type: :feature do
it 'disallows global paths and paths from public project' do
expect(page).to have_content('Disallow: /work_packages/calendar')
expect(page).to have_content('Disallow: /activity')
-
+
expect(page).to have_content("Disallow: /projects/#{project.identifier}/repository")
expect(page).to have_content("Disallow: /projects/#{project.identifier}/work_packages")
expect(page).to have_content("Disallow: /projects/#{project.identifier}/activity")
diff --git a/spec/features/localization_spec.rb b/spec/features/localization_spec.rb
index dcb9324e96..98665fbd58 100644
--- a/spec/features/localization_spec.rb
+++ b/spec/features/localization_spec.rb
@@ -33,7 +33,6 @@ require 'spec_helper'
describe 'Localization', type: :feature, with_settings: { login_required?: false,
available_languages: %i[de en],
default_language: 'en' } do
-
it 'set localization' do
Capybara.current_session.driver.header('Accept-Language', 'de,de-de;q=0.8,en-us;q=0.5,en;q=0.3')
diff --git a/spec/features/members/invitation_spec.rb b/spec/features/members/invitation_spec.rb
index cfd1a23eb2..939a1e1e9c 100644
--- a/spec/features/members/invitation_spec.rb
+++ b/spec/features/members/invitation_spec.rb
@@ -67,16 +67,15 @@ feature 'invite user via email', type: :feature, js: true do
# Should show the invited user on the default filter as well
members_page.visit!
expect(members_page).to have_user 'finkelstein @openproject.com'
-
end
end
context 'with a registered user' do
let!(:user) do
FactoryBot.create :user, mail: 'hugo@openproject.com',
- login: 'hugo@openproject.com',
- firstname: 'Hugo',
- lastname: 'Hurried'
+ login: 'hugo@openproject.com',
+ firstname: 'Hugo',
+ lastname: 'Hurried'
end
scenario 'user lookup by email' do
diff --git a/spec/features/members/membership_filter_spec.rb b/spec/features/members/membership_filter_spec.rb
index 979804d0d6..5e218c80e3 100644
--- a/spec/features/members/membership_filter_spec.rb
+++ b/spec/features/members/membership_filter_spec.rb
@@ -39,7 +39,6 @@ feature 'group memberships through groups page', type: :feature, js: true do
mail: 'foo@example.org',
member_in_project: project,
member_through_role: role
-
end
let!(:hannibal) do
@@ -49,7 +48,6 @@ feature 'group memberships through groups page', type: :feature, js: true do
mail: 'foo@example.com',
member_in_project: project,
member_through_role: role
-
end
let(:role) { FactoryBot.create(:role, permissions: %i(add_work_packages)) }
let(:members_page) { Pages::Members.new project.identifier }
diff --git a/spec/features/my/my_notifications_spec.rb b/spec/features/my/my_notifications_spec.rb
index faf97b1073..6436110a29 100644
--- a/spec/features/my/my_notifications_spec.rb
+++ b/spec/features/my/my_notifications_spec.rb
@@ -34,8 +34,8 @@ describe 'My notifications spec', type: :feature, js: true do
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
@@ -62,7 +62,6 @@ describe 'My notifications spec', type: :feature, js: true do
expect(user.mail_notification).to eq(User::USER_MAIL_OPTION_SELECTED.first)
expect(user.notified_projects_ids).to eq [project.id]
-
select 'No events', from: 'Send email notifications'
click_on 'Save'
expect(page).to have_selector('.flash.notice')
diff --git a/spec/features/oauth/authorization_code_flow_spec.rb b/spec/features/oauth/authorization_code_flow_spec.rb
index 7bd3b0ee8c..f22a00ca71 100644
--- a/spec/features/oauth/authorization_code_flow_spec.rb
+++ b/spec/features/oauth/authorization_code_flow_spec.rb
@@ -130,7 +130,8 @@ describe 'OAuth authorization code flow',
login_with user.login, 'adminADMIN!', visit_signin_path: false
# But we got no further
- expect(page).to have_selector('.notification-box.-error', text: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.')
+ expect(page).to have_selector('.notification-box.-error',
+ text: 'Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method.')
# And also have no grant for this application
user.oauth_grants.reload
diff --git a/spec/features/onboarding/onboarding_tour_spec.rb b/spec/features/onboarding/onboarding_tour_spec.rb
index 8d5fb576ad..4f5fc00752 100644
--- a/spec/features/onboarding/onboarding_tour_spec.rb
+++ b/spec/features/onboarding/onboarding_tour_spec.rb
@@ -30,8 +30,14 @@ require 'spec_helper'
describe 'onboarding tour for new users', js: true do
let(:user) { FactoryBot.create :admin }
- let(:project) { FactoryBot.create :project, name: 'Demo project', identifier: 'demo-project', public: true, enabled_module_names: %w[work_package_tracking wiki] }
- let(:scrum_project) {FactoryBot.create :project, name: 'Scrum project', identifier: 'your-scrum-project', public: true, enabled_module_names: %w[work_package_tracking] }
+ let(:project) do
+ FactoryBot.create :project, name: 'Demo project', identifier: 'demo-project', public: true,
+ enabled_module_names: %w[work_package_tracking wiki]
+ end
+ let(:scrum_project) do
+ FactoryBot.create :project, name: 'Scrum project', identifier: 'your-scrum-project', public: true,
+ enabled_module_names: %w[work_package_tracking]
+ end
let!(:wp_1) { FactoryBot.create(:work_package, project: project) }
let(:next_button) { find('.enjoyhint_next_btn') }
@@ -48,7 +54,7 @@ describe 'onboarding tour for new users', js: true do
expect(page).to have_text 'Please select your language'
# SeleniumHubWaiter.wait
- select 'Deutsch', :from => 'user_language'
+ select 'Deutsch', from: 'user_language'
click_button 'Save'
expect(page).to have_text 'Projekt auswählen'
@@ -60,7 +66,7 @@ describe 'onboarding tour for new users', js: true do
visit home_path first_time_user: true
# SeleniumHubWaiter.wait
- select 'English', :from => 'user_language'
+ select 'English', from: 'user_language'
click_button 'Save'
end
@@ -76,7 +82,7 @@ describe 'onboarding tour for new users', js: true do
visit home_path first_time_user: true
# SeleniumHubWaiter.wait
- select 'English', :from => 'user_language'
+ select 'English', from: 'user_language'
click_button 'Save'
SeleniumHubWaiter.wait
end
@@ -121,5 +127,3 @@ describe 'onboarding tour for new users', js: true do
end
end
end
-
-
diff --git a/spec/features/page_objects/notification.rb b/spec/features/page_objects/notification.rb
index 46543cd291..29d2aabe58 100644
--- a/spec/features/page_objects/notification.rb
+++ b/spec/features/page_objects/notification.rb
@@ -38,6 +38,7 @@ module PageObjects
def expect_type(type, message)
raise "Unimplemented type #{type}." unless types.include?(type)
+
expect(page).to have_selector(".notification-box.-#{type}", text: message, wait: 10)
end
@@ -52,7 +53,7 @@ module PageObjects
private
def types
- [:success, :error]
+ %i[success error]
end
end
end
diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb
index 06a4fee1ac..2f3f3ce4a6 100644
--- a/spec/features/projects/projects_index_spec.rb
+++ b/spec/features/projects/projects_index_spec.rb
@@ -265,8 +265,8 @@ describe 'Projects index page',
# Results should be filtered and ordered ASC by name
expect(page).to have_text(development_project.name)
- expect(page).to have_no_text(project.name) # as it filtered away
- expect(page).to have_text('Next') # as the result set is larger than 1
+ expect(page).to have_no_text(project.name) # as it filtered away
+ expect(page).to have_text('Next') # as the result set is larger than 1
expect(page).to have_no_text(public_project.name) # as it is on the second page
# Changing the page size to 5 and back to 1 should not change the filters (which we test later on the second page)
@@ -302,7 +302,7 @@ describe 'Projects index page',
expect(page).to have_text(public_project.name)
expect(page).to have_no_text(development_project.name) # as it is on the second page
expect(page).to have_no_text(project.name) # as it filtered away
- expect(page).to have_text('Next') # as the result set is larger than 1
+ expect(page).to have_text('Next') # as the result set is larger than 1
end
end
@@ -508,7 +508,6 @@ describe 'Projects index page',
expect(page).to have_text(gray_project.name)
expect(page).to have_text(no_status_project.name)
end
-
end
feature 'other filter types' do
diff --git a/spec/features/projects/projects_spec.rb b/spec/features/projects/projects_spec.rb
index 65e2e99170..b58c5047c2 100644
--- a/spec/features/projects/projects_spec.rb
+++ b/spec/features/projects/projects_spec.rb
@@ -58,7 +58,7 @@ describe 'Projects', type: :feature do
end
context 'work_packages module disabled',
- with_settings: { default_projects_modules: %q(wiki) } do
+ with_settings: { default_projects_modules: 'wiki' } do
it 'creates a project and redirects to settings' do
click_on 'New project'
@@ -97,8 +97,6 @@ describe 'Projects', type: :feature do
expect(page).to have_content 'Identifier has already been taken'
expect(current_path).to eq '/projects'
end
-
-
end
describe 'project types' do
@@ -185,14 +183,14 @@ describe 'Projects', type: :feature do
let(:project) { FactoryBot.build(:project, name: 'Foo project', identifier: 'foo-project') }
let!(:optional_custom_field) do
FactoryBot.create(:custom_field, name: 'Optional Foo',
- type: ProjectCustomField,
- is_for_all: true)
+ type: ProjectCustomField,
+ is_for_all: true)
end
let!(:required_custom_field) do
FactoryBot.create(:custom_field, name: 'Required Foo',
- type: ProjectCustomField,
- is_for_all: true,
- is_required: true)
+ type: ProjectCustomField,
+ is_for_all: true,
+ is_required: true)
end
it 'seperates optional and required custom fields for new' do
diff --git a/spec/features/projects/template_spec.rb b/spec/features/projects/template_spec.rb
index ab1b356944..84d8f691ec 100644
--- a/spec/features/projects/template_spec.rb
+++ b/spec/features/projects/template_spec.rb
@@ -57,15 +57,17 @@ describe 'Project templates', type: :feature, js: true do
end
describe 'instantiating templates' do
- let!(:template) {
+ let!(:template) do
FactoryBot.create(:template_project, name: 'My template', enabled_module_names: %w[wiki work_package_tracking])
- }
+ end
let!(:template_status) { FactoryBot.create(:project_status, project: template, explanation: 'source') }
let!(:other_project) { FactoryBot.create(:project, name: 'Some other project') }
let!(:work_package) { FactoryBot.create :work_package, project: template }
let!(:wiki_page) { FactoryBot.create(:wiki_page_with_content, wiki: template.wiki) }
- let!(:role) { FactoryBot.create(:role, permissions: %i[view_project view_work_packages copy_projects add_subprojects add_project]) }
+ let!(:role) do
+ FactoryBot.create(:role, permissions: %i[view_project view_work_packages copy_projects add_subprojects add_project])
+ end
let!(:current_user) { FactoryBot.create(:user, member_in_projects: [template, other_project], member_through_role: role) }
let(:status_field_selector) { 'ckeditor-augmented-textarea[textarea-selector="#project_status_explanation"]' }
let(:status_description) { ::Components::WysiwygEditor.new status_field_selector }
@@ -145,4 +147,3 @@ describe 'Project templates', type: :feature, js: true do
end
end
end
-
diff --git a/spec/features/repositories/checkout_instructions_spec.rb b/spec/features/repositories/checkout_instructions_spec.rb
index 9b444ba01e..67af175b8a 100644
--- a/spec/features/repositories/checkout_instructions_spec.rb
+++ b/spec/features/repositories/checkout_instructions_spec.rb
@@ -44,16 +44,16 @@ describe 'Create repository', type: :feature, js: true do
context 'managed repositories' do
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
git: { manages: File.join(tmpdir, 'git') }
}
- }
- let(:checkout_data) {
+ end
+ let(:checkout_data) do
{ 'git' => { 'enabled' => '1', 'base_url' => 'http://localhost/git/' } }
- }
+ end
- let!(:repository) {
+ let!(:repository) do
repo = FactoryBot.build(:repository_git, scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
@@ -61,7 +61,7 @@ describe 'Create repository', type: :feature, js: true do
perform_enqueued_jobs
repo
- }
+ end
it 'toggles checkout instructions' do
visit project_repository_path(project)
diff --git a/spec/features/repositories/repository_settings_spec.rb b/spec/features/repositories/repository_settings_spec.rb
index 6befb377dd..a525f64695 100644
--- a/spec/features/repositories/repository_settings_spec.rb
+++ b/spec/features/repositories/repository_settings_spec.rb
@@ -103,12 +103,12 @@ describe 'Repository Settings', type: :feature, js: true do
end
end
- shared_examples 'manages the repository with' do |name, type, repository_type, project_name|
- let(:repository) {
+ shared_examples 'manages the repository with' do |name, type, _repository_type, _project_name|
+ let(:repository) do
FactoryBot.create("repository_#{name}".to_sym,
- scm_type: type,
- project: project)
- }
+ scm_type: type,
+ project: project)
+ end
it_behaves_like 'manages the repository', type
end
@@ -118,14 +118,14 @@ describe 'Repository Settings', type: :feature, js: true do
context 'managed repositories' do
context 'local' do
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
subversion: { manages: File.join(tmpdir, 'svn') },
git: { manages: File.join(tmpdir, 'git') }
}
- }
+ end
- let(:repository) {
+ let(:repository) do
repo = Repository.build(
project,
managed_vendor,
@@ -136,7 +136,7 @@ describe 'Repository Settings', type: :feature, js: true do
repo.save!
repo
- }
+ end
context 'Subversion' do
let(:managed_vendor) { :subversion }
@@ -151,13 +151,13 @@ describe 'Repository Settings', type: :feature, js: true do
context 'remote', webmock: true do
let(:url) { 'http://myreposerver.example.com/api/' }
- let(:config) {
+ let(:config) do
{
git: { manages: url }
}
- }
+ end
let(:managed_vendor) { :git }
- let(:repository) {
+ let(:repository) do
repo = Repository.build(
project,
managed_vendor,
@@ -172,17 +172,17 @@ describe 'Repository Settings', type: :feature, js: true do
repo.save!
repo
- }
+ end
it_behaves_like 'manages the repository', 'managed'
end
end
describe 'update repositories' do
- let(:repository) {
+ let(:repository) do
FactoryBot.create(:repository_subversion,
- scm_type: :existing,
- project: project)
- }
+ scm_type: :existing,
+ project: project)
+ end
it 'can set login and password' do
fill_in('repository[login]', with: 'foobar')
diff --git a/spec/features/security/expire_sessions_spec.rb b/spec/features/security/expire_sessions_spec.rb
index 0b4c169c68..6055ab8c9b 100644
--- a/spec/features/security/expire_sessions_spec.rb
+++ b/spec/features/security/expire_sessions_spec.rb
@@ -32,7 +32,7 @@ describe 'Expire old user sessions',
with_config: { session_store: :active_record_store },
type: :feature do
shared_let(:admin) { FactoryBot.create :admin }
- let(:admin_password) { 'adminADMIN!'}
+ let(:admin_password) { 'adminADMIN!' }
before do
login_with(admin.login, admin_password)
diff --git a/spec/features/security/session_ttl_spec.rb b/spec/features/security/session_ttl_spec.rb
index 9a7e36837d..ba59d2f6d3 100644
--- a/spec/features/security/session_ttl_spec.rb
+++ b/spec/features/security/session_ttl_spec.rb
@@ -32,7 +32,7 @@ describe 'Session TTL',
with_settings: { session_ttl_enabled?: true, session_ttl: '10' },
type: :feature do
shared_let(:admin) { FactoryBot.create :admin }
- let(:admin_password) { 'adminADMIN!'}
+ let(:admin_password) { 'adminADMIN!' }
let!(:work_package) { FactoryBot.create :work_package }
diff --git a/spec/features/support/components/time_logging_modal.rb b/spec/features/support/components/time_logging_modal.rb
index 417f21fd18..47dd7f4e89 100644
--- a/spec/features/support/components/time_logging_modal.rb
+++ b/spec/features/support/components/time_logging_modal.rb
@@ -114,8 +114,6 @@ module Components
'wp-new-inline-edit--field-spentOn'
when 'work_package'
'wp-new-inline-edit--field-workPackage'
- else
- nil
end
end
@@ -131,8 +129,6 @@ module Components
comment_field
when 'work_package'
work_package_field
- else
- nil
end
end
diff --git a/spec/features/types/form_configuration_query_spec.rb b/spec/features/types/form_configuration_query_spec.rb
index 0aa49f0343..6f5b516a90 100644
--- a/spec/features/types/form_configuration_query_spec.rb
+++ b/spec/features/types/form_configuration_query_spec.rb
@@ -97,7 +97,6 @@ describe 'form query configuration', type: :feature, js: true do
form.save_changes
expect(page).to have_selector('.flash.notice', text: 'Successful update.', wait: 10)
-
# Visit wp_table
wp_table.visit!
wp_table.expect_work_package_listed work_package, related_task, related_bug
diff --git a/spec/features/types/reset_form_configuration_spec.rb b/spec/features/types/reset_form_configuration_spec.rb
index 8a1d246c08..22c40d4ebb 100644
--- a/spec/features/types/reset_form_configuration_spec.rb
+++ b/spec/features/types/reset_form_configuration_spec.rb
@@ -77,10 +77,10 @@ describe 'Reset form configuration', type: :feature, js: true do
expect(type.custom_field_ids).to be_empty
- new_group = type.attribute_groups.detect { |g| g.key == 'New Group'}
+ new_group = type.attribute_groups.detect { |g| g.key == 'New Group' }
expect(new_group).not_to be_present
- other_group = type.attribute_groups.detect { |g| g.key == :other}
+ other_group = type.attribute_groups.detect { |g| g.key == :other }
expect(other_group).not_to be_present
end
end
diff --git a/spec/features/users/brute_force_spec.rb b/spec/features/users/brute_force_spec.rb
index 535868a1dd..f23b8e54d6 100644
--- a/spec/features/users/brute_force_spec.rb
+++ b/spec/features/users/brute_force_spec.rb
@@ -98,7 +98,6 @@ describe 'Loggin (with brute force protection)', type: :feature do
it 'does not block if brute force is disabled',
with_settings: { brute_force_block_minutes: 5, brute_force_block_after_failed_logins: 0 } do
-
login_with login, invalid_password
expect(page)
diff --git a/spec/features/users/create_spec.rb b/spec/features/users/create_spec.rb
index 30d4bc585e..bb85d50207 100644
--- a/spec/features/users/create_spec.rb
+++ b/spec/features/users/create_spec.rb
@@ -107,7 +107,6 @@ describe 'create users', type: :feature, selenium: true do
login: 'bob',
auth_source: auth_source.name
-
perform_enqueued_jobs do
new_user_page.submit!
end
diff --git a/spec/features/users/delete_spec.rb b/spec/features/users/delete_spec.rb
index b2de04fe81..6d5cd57b73 100644
--- a/spec/features/users/delete_spec.rb
+++ b/spec/features/users/delete_spec.rb
@@ -36,11 +36,11 @@ describe 'user deletion: ', type: :feature, js: true do
end
context 'regular user' do
- let(:user_password) {'bob!' * 4}
+ let(:user_password) { 'bob!' * 4 }
let(:current_user) do
FactoryBot.create(:user,
- password: user_password,
- password_confirmation: user_password)
+ password: user_password,
+ password_confirmation: user_password)
end
it 'can delete their own account', js: true do
@@ -87,8 +87,8 @@ describe 'user deletion: ', type: :feature, js: true do
let(:user_password) { 'admin! * 4' }
let(:current_user) do
FactoryBot.create(:admin,
- password: user_password,
- password_confirmation: user_password)
+ password: user_password,
+ password_confirmation: user_password)
end
it 'can delete other users if the setting permitts it', selenium: true do
@@ -104,7 +104,7 @@ describe 'user deletion: ', type: :feature, js: true do
click_on 'Delete'
dialog.confirm_flow_with 'wrong', should_fail: true
-
+
SeleniumHubWaiter.wait
fill_in 'login_verification', with: user.login
click_on 'Delete'
@@ -131,7 +131,7 @@ describe 'user deletion: ', type: :feature, js: true do
find(:css, "#settings_users_deletable_by_admins").set(true)
find(:css, "#settings_users_deletable_by_self").set(true)
- click_on 'Save'
+ click_on 'Save'
expect(Setting.users_deletable_by_admins?).to eq true
expect(Setting.users_deletable_by_self?).to eq true
diff --git a/spec/features/users/password_change_spec.rb b/spec/features/users/password_change_spec.rb
index 209fc2fdd8..8a8ffcc412 100644
--- a/spec/features/users/password_change_spec.rb
+++ b/spec/features/users/password_change_spec.rb
@@ -186,7 +186,6 @@ describe 'random password generation',
password_min_length: 4
},
js: true do
-
it 'enforces those rules' do
# Change to valid password according to spec
user_page.change_password(old_password, 'password')
diff --git a/spec/features/users/self_registration_spec.rb b/spec/features/users/self_registration_spec.rb
index fd5b524725..22689df5a8 100644
--- a/spec/features/users/self_registration_spec.rb
+++ b/spec/features/users/self_registration_spec.rb
@@ -34,7 +34,6 @@ describe 'user self registration', type: :feature, js: true do
context 'with "manual account activation"',
with_settings: { self_registration: Setting::SelfRegistration.manual.to_s } do
-
it 'allows self registration on login page (Regression #28076)' do
visit signin_path
diff --git a/spec/features/versions/create_spec.rb b/spec/features/versions/create_spec.rb
index 94da116250..8cbcbc1f2c 100644
--- a/spec/features/versions/create_spec.rb
+++ b/spec/features/versions/create_spec.rb
@@ -33,7 +33,7 @@ describe 'version create', type: :feature, js: false do
FactoryBot.create(:user,
member_in_project: project,
member_with_permissions: %i[manage_versions view_work_packages])
- end
+ end
let(:project) { FactoryBot.create(:project) }
let(:new_version_name) { 'A new version name' }
@@ -52,7 +52,6 @@ describe 'version create', type: :feature, js: false do
expect(page).to have_content new_version_name
end
-
it 'and redirect back to where you started' do
visit project_roadmap_path(project)
click_on 'New version'
diff --git a/spec/features/watching/toggle_watching_spec.rb b/spec/features/watching/toggle_watching_spec.rb
index 0cf2e25851..3d730ef2dc 100644
--- a/spec/features/watching/toggle_watching_spec.rb
+++ b/spec/features/watching/toggle_watching_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
describe 'Toggle watching', type: :feature, js: true do
let(:project) { FactoryBot.create(:project) }
- let(:role) { FactoryBot.create(:role, permissions: [:view_messages, :view_wiki_pages]) }
+ let(:role) { FactoryBot.create(:role, permissions: %i[view_messages view_wiki_pages]) }
let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) }
let(:news) { FactoryBot.create(:news, project: project) }
let(:forum) { FactoryBot.create(:forum, project: project) }
diff --git a/spec/features/wiki/attachment_upload_spec.rb b/spec/features/wiki/attachment_upload_spec.rb
index 0da661caaf..c521bc10af 100644
--- a/spec/features/wiki/attachment_upload_spec.rb
+++ b/spec/features/wiki/attachment_upload_spec.rb
@@ -127,7 +127,7 @@ describe 'Upload attachment to wiki page', js: true do
expect(page).to have_selector('#errorExplanation', text: "Title can't be blank.")
expect(page).to have_selector('.work-package--attachments--filename', text: 'image.png')
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
editable.send_keys 'hello there.'
end
diff --git a/spec/features/wiki/child_pages_spec.rb b/spec/features/wiki/child_pages_spec.rb
index 40c66253e1..68a0d7003e 100644
--- a/spec/features/wiki/child_pages_spec.rb
+++ b/spec/features/wiki/child_pages_spec.rb
@@ -65,7 +65,7 @@ describe 'wiki child pages', type: :feature, js: true do
# hierarchy displayed in the breadcrumb
expect(page).to have_selector('#breadcrumb .breadcrumb',
- text: "#{parent_page.title}")
+ text: parent_page.title.to_s)
# hierarchy displayed in the sidebar
expect(page).to have_selector('.pages-hierarchy',
diff --git a/spec/features/work_package_show_spec.rb b/spec/features/work_package_show_spec.rb
index 9b0a8374db..851cc59fb0 100644
--- a/spec/features/work_package_show_spec.rb
+++ b/spec/features/work_package_show_spec.rb
@@ -33,9 +33,9 @@ RSpec.feature 'Work package show page', selenium: true do
let(:project) { FactoryBot.create(:project) }
let(:work_package) do
FactoryBot.build(:work_package,
- project: project,
- assigned_to: user,
- responsible: user)
+ project: project,
+ assigned_to: user,
+ responsible: user)
end
before do
diff --git a/spec/features/work_packages/attachments/attachment_upload_spec.rb b/spec/features/work_packages/attachments/attachment_upload_spec.rb
index 4f1f9d88c3..86883d7778 100644
--- a/spec/features/work_packages/attachments/attachment_upload_spec.rb
+++ b/spec/features/work_packages/attachments/attachment_upload_spec.rb
@@ -102,7 +102,7 @@ describe 'Upload attachment to work package', js: true do
sleep 2
expect(page).not_to have_selector('notification-upload-progress')
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_selector('img[src*="/api/v3/attachments/"]', wait: 20)
expect(editable).not_to have_selector('.ck-upload-placeholder-loader')
end
diff --git a/spec/features/work_packages/bulk/copy_work_package_spec.rb b/spec/features/work_packages/bulk/copy_work_package_spec.rb
index c41784ac61..86ab0f0326 100644
--- a/spec/features/work_packages/bulk/copy_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/copy_work_package_spec.rb
@@ -4,25 +4,26 @@ require 'features/page_objects/notification'
describe 'Copy work packages through Rails view', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages]
+ permissions: %i[view_work_packages]
end
let(:mover_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks assign_versions add_work_packages]
+ permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks assign_versions
+ add_work_packages]
end
let(:dev) do
FactoryBot.create :user,
- firstname: 'Dev',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: dev_role
+ firstname: 'Dev',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: dev_role
end
let(:mover) do
FactoryBot.create :admin,
- firstname: 'Manager',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: mover_role
+ firstname: 'Manager',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: mover_role
end
let(:type) { FactoryBot.create :type, name: 'Bug' }
@@ -31,28 +32,28 @@ describe 'Copy work packages through Rails view', js: true do
let!(:project) { FactoryBot.create(:project, name: 'Source', types: [type, type2]) }
let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type, type2]) }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package,
- author: dev,
- project: project,
- type: type)
- }
- let!(:work_package2) {
+ author: dev,
+ project: project,
+ type: type)
+ end
+ let!(:work_package2) do
FactoryBot.create(:work_package,
- author: dev,
- project: project,
- type: type)
- }
+ author: dev,
+ project: project,
+ type: type)
+ end
let(:status) { work_package.status }
let!(:version) { FactoryBot.create :version, project: project2 }
let!(:status2) { FactoryBot.create :default_status }
let!(:workflow) do
FactoryBot.create :workflow,
- type_id: type2.id,
- old_status: work_package.status,
- new_status: status2,
- role: mover_role
+ type_id: type2.id,
+ old_status: work_package.status,
+ new_status: status2,
+ role: mover_role
end
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
diff --git a/spec/features/work_packages/bulk/move_work_package_spec.rb b/spec/features/work_packages/bulk/move_work_package_spec.rb
index f5689bc388..b42df0763f 100644
--- a/spec/features/work_packages/bulk/move_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/move_work_package_spec.rb
@@ -4,25 +4,25 @@ require 'features/page_objects/notification'
describe 'Moving a work package through Rails view', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages add_work_packages]
+ permissions: %i[view_work_packages add_work_packages]
end
let(:mover_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages move_work_packages manage_subtasks add_work_packages]
+ permissions: %i[view_work_packages move_work_packages manage_subtasks add_work_packages]
end
let(:dev) do
FactoryBot.create :user,
- firstname: 'Dev',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: dev_role
+ firstname: 'Dev',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: dev_role
end
let(:mover) do
FactoryBot.create :admin,
- firstname: 'Manager',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: mover_role
+ firstname: 'Manager',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: mover_role
end
let(:type) { FactoryBot.create :type, name: 'Bug' }
@@ -31,28 +31,28 @@ describe 'Moving a work package through Rails view', js: true do
let!(:project) { FactoryBot.create(:project, name: 'Source', types: [type, type2]) }
let!(:project2) { FactoryBot.create(:project, name: 'Target', types: [type, type2]) }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package,
- author: dev,
- project: project,
- type: type)
- }
- let!(:child_wp) {
+ author: dev,
+ project: project,
+ type: type)
+ end
+ let!(:child_wp) do
FactoryBot.create(:work_package,
- author: dev,
- parent: work_package,
- project: project,
- type: type)
- }
+ author: dev,
+ parent: work_package,
+ project: project,
+ type: type)
+ end
let(:status) { work_package.status }
let!(:status2) { FactoryBot.create :default_status }
let!(:workflow) do
FactoryBot.create :workflow,
- type_id: type2.id,
- old_status: work_package.status,
- new_status: status2,
- role: mover_role
+ type_id: type2.id,
+ old_status: work_package.status,
+ new_status: status2,
+ role: mover_role
end
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
@@ -82,7 +82,6 @@ describe 'Moving a work package through Rails view', js: true do
click_on 'Move and follow'
end
-
it 'moves parent and child wp to a new project' do
expect_angular_frontend_initialized
expect(page).to have_selector('.inline-edit--container.subject', text: work_package.subject, wait: 10)
diff --git a/spec/features/work_packages/bulk/update_work_package_spec.rb b/spec/features/work_packages/bulk/update_work_package_spec.rb
index 99f7998f4f..084d7bae58 100644
--- a/spec/features/work_packages/bulk/update_work_package_spec.rb
+++ b/spec/features/work_packages/bulk/update_work_package_spec.rb
@@ -4,25 +4,25 @@ require 'features/page_objects/notification'
describe 'Bulk update work packages through Rails view', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages]
+ permissions: %i[view_work_packages]
end
let(:mover_role) do
FactoryBot.create :role,
- permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks add_work_packages]
+ permissions: %i[view_work_packages copy_work_packages move_work_packages manage_subtasks add_work_packages]
end
let(:dev) do
FactoryBot.create :user,
- firstname: 'Dev',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: dev_role
+ firstname: 'Dev',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: dev_role
end
let(:mover) do
FactoryBot.create :admin,
- firstname: 'Manager',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: mover_role
+ firstname: 'Manager',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: mover_role
end
let(:type) { FactoryBot.create :type, name: 'Bug' }
@@ -31,28 +31,28 @@ describe 'Bulk update work packages through Rails view', js: true do
let!(:status) { FactoryBot.create :status }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package,
- author: dev,
- status: status,
- project: project,
- type: type)
- }
- let!(:work_package2) {
+ author: dev,
+ status: status,
+ project: project,
+ type: type)
+ end
+ let!(:work_package2) do
FactoryBot.create(:work_package,
- author: dev,
- status: status,
- project: project,
- type: type)
- }
+ author: dev,
+ status: status,
+ project: project,
+ type: type)
+ end
let!(:status2) { FactoryBot.create :default_status }
let!(:workflow) do
FactoryBot.create :workflow,
- type_id: type.id,
- old_status: work_package.status,
- new_status: status2,
- role: mover_role
+ type_id: type.id,
+ old_status: work_package.status,
+ new_status: status2,
+ role: mover_role
end
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
diff --git a/spec/features/work_packages/cancel_editing_spec.rb b/spec/features/work_packages/cancel_editing_spec.rb
index af7457bda7..5926c145c3 100644
--- a/spec/features/work_packages/cancel_editing_spec.rb
+++ b/spec/features/work_packages/cancel_editing_spec.rb
@@ -35,14 +35,14 @@ describe 'Cancel editing work package', js: true do
let(:work_package2) { FactoryBot.create(:work_package, project: project) }
let(:wp_page) { ::Pages::AbstractWorkPackage.new(work_package) }
let(:wp_table) { ::Pages::WorkPackagesTable.new }
- let(:paths) {
+ let(:paths) do
[
new_work_packages_path,
new_split_work_packages_path,
new_project_work_packages_path(project),
new_split_project_work_packages_path(project)
]
- }
+ end
before do
work_package
diff --git a/spec/features/work_packages/cards/wp_card_status_spec.rb b/spec/features/work_packages/cards/wp_card_status_spec.rb
index 315bcae1a7..489222250b 100644
--- a/spec/features/work_packages/cards/wp_card_status_spec.rb
+++ b/spec/features/work_packages/cards/wp_card_status_spec.rb
@@ -44,13 +44,13 @@ describe 'Update status from WP card', type: :feature, js: true do
let(:type) { FactoryBot.create :type }
let!(:project) { FactoryBot.create(:project, types: [type]) }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package,
project: project,
type: type,
status: status1,
subject: 'Foobar')
- }
+ end
let!(:workflow) do
FactoryBot.create :workflow,
diff --git a/spec/features/work_packages/copy_spec.rb b/spec/features/work_packages/copy_spec.rb
index ff5c058cbe..3aabefc15c 100644
--- a/spec/features/work_packages/copy_spec.rb
+++ b/spec/features/work_packages/copy_spec.rb
@@ -178,7 +178,6 @@ RSpec.feature 'Work package copy', js: true, selenium: true do
work_package_page.expect_activity user, number: 1
work_package_page.expect_current_path
-
work_package_page.visit_tab!('relations')
expect_angular_frontend_initialized
expect(page).to have_selector('.relation-group--header', text: 'RELATED TO', wait: 20)
diff --git a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
index d64334f619..41153392f1 100644
--- a/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
+++ b/spec/features/work_packages/details/custom_fields/custom_field_spec.rb
@@ -101,8 +101,8 @@ describe 'custom field inplace editor', js: true do
message: I18n.t('js.notice_successful_update'),
field: field2
- wp_page.expect_attributes :"customField#{custom_field1.id}" => 'bar',
- :"customField#{custom_field2.id}" => 'Y'
+ wp_page.expect_attributes "customField#{custom_field1.id}": 'bar',
+ "customField#{custom_field2.id}": 'Y'
field1.activate!
expect(field1.input_element).to have_text 'bar'
@@ -116,8 +116,8 @@ describe 'custom field inplace editor', js: true do
message: I18n.t('js.notice_successful_update'),
field: field2
- wp_page.expect_attributes :"customField#{custom_field1.id}" => 'bar',
- :"customField#{custom_field2.id}" => 'X'
+ wp_page.expect_attributes "customField#{custom_field1.id}": 'bar',
+ "customField#{custom_field2.id}": 'X'
end
end
diff --git a/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb b/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb
index d0a4a05380..48c0d5a60f 100644
--- a/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb
+++ b/spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb
@@ -11,7 +11,7 @@ describe 'subject inplace editor', js: true, selenium: true do
let(:property_title) { 'Subject' }
let(:work_package) { FactoryBot.create :work_package, project: project }
let(:user) { FactoryBot.create :admin }
- let(:work_packages_page) { Pages::SplitWorkPackage.new(work_package,project) }
+ let(:work_packages_page) { Pages::SplitWorkPackage.new(work_package, project) }
let(:field) { work_packages_page.edit_field(property_name) }
let(:notification) { ::PageObjects::Notifications.new(page) }
diff --git a/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb b/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
index b3912b1a57..a5c734fb84 100644
--- a/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
@@ -36,10 +36,11 @@ describe 'creating a child directly after the wp itself was created', js: true d
let!(:status) { FactoryBot.create(:status, is_default: true) }
let!(:priority) { FactoryBot.create(:priority, is_default: true) }
let(:type) { FactoryBot.create(:type, custom_fields: [custom_field]) }
- let(:custom_field) { FactoryBot.create :work_package_custom_field,
- field_format: 'int',
- is_for_all: true
- }
+ let(:custom_field) do
+ FactoryBot.create :work_package_custom_field,
+ field_format: 'int',
+ is_for_all: true
+ end
let(:relations_tab) { find('.tabrow li', text: 'RELATIONS') }
before do
diff --git a/spec/features/work_packages/details/relations/relations_spec.rb b/spec/features/work_packages/details/relations/relations_spec.rb
index ae45cd1afc..0fcda9ccdd 100644
--- a/spec/features/work_packages/details/relations/relations_spec.rb
+++ b/spec/features/work_packages/details/relations/relations_spec.rb
@@ -69,15 +69,15 @@ describe 'Work package relations tab', js: true, selenium: true do
let!(:relation_1) do
FactoryBot.create :relation,
- from: work_package,
- to: to_1,
- relation_type: Relation::TYPE_FOLLOWS
+ from: work_package,
+ to: to_1,
+ relation_type: Relation::TYPE_FOLLOWS
end
let!(:relation_2) do
FactoryBot.create :relation,
- from: work_package,
- to: to_2,
- relation_type: Relation::TYPE_RELATES
+ from: work_package,
+ to: to_2,
+ relation_type: Relation::TYPE_RELATES
end
let(:toggle_btn_selector) { '#wp-relation-group-by-toggle' }
@@ -154,8 +154,8 @@ describe 'Work package relations tab', js: true, selenium: true do
let(:user) do
FactoryBot.create :user,
- member_in_project: project,
- member_through_role: user_role
+ member_in_project: project,
+ member_through_role: user_role
end
context 'as view-only user, with parent set' do
@@ -257,7 +257,7 @@ describe 'Work package relations tab', js: true, selenium: true do
relations.hover_action(relatable, :info)
created_row = relations.find_row(relatable)
- find'.wp-relation--description-read-value'
+ find '.wp-relation--description-read-value'
end
created_row.find('.wp-relation--description-read-value',
diff --git a/spec/features/work_packages/display_fields/date_field_display_spec.rb b/spec/features/work_packages/display_fields/date_field_display_spec.rb
index b5813c943c..fc1a6372e3 100644
--- a/spec/features/work_packages/display_fields/date_field_display_spec.rb
+++ b/spec/features/work_packages/display_fields/date_field_display_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
describe 'Show the date of a Work Package', type: :feature, js: true do
let(:project) { FactoryBot.create :project }
- let(:admin) { FactoryBot.create :admin}
+ let(:admin) { FactoryBot.create :admin }
let(:work_package) do
FactoryBot.create :work_package,
project: project,
diff --git a/spec/features/work_packages/edit_work_package_spec.rb b/spec/features/work_packages/edit_work_package_spec.rb
index f08295e45f..509b297d22 100644
--- a/spec/features/work_packages/edit_work_package_spec.rb
+++ b/spec/features/work_packages/edit_work_package_spec.rb
@@ -4,8 +4,8 @@ require 'features/page_objects/notification'
describe 'edit work package', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: [:view_work_packages,
- :add_work_packages]
+ permissions: %i[view_work_packages
+ add_work_packages]
end
let(:dev) do
FactoryBot.create :user,
@@ -16,8 +16,8 @@ describe 'edit work package', js: true do
end
let(:manager_role) do
FactoryBot.create :role,
- permissions: [:view_work_packages,
- :edit_work_packages]
+ permissions: %i[view_work_packages
+ edit_work_packages]
end
let(:manager) do
FactoryBot.create :admin,
@@ -198,8 +198,8 @@ describe 'edit work package', js: true do
:work_package_custom_field,
field_format: 'string',
default_value: nil,
- is_required: true,
- is_for_all: true
+ is_required: true,
+ is_for_all: true
)
end
let!(:type2) { FactoryBot.create(:type, custom_fields: [custom_field]) }
diff --git a/spec/features/work_packages/export_spec.rb b/spec/features/work_packages/export_spec.rb
index ee7fea38ef..d0a680cc57 100644
--- a/spec/features/work_packages/export_spec.rb
+++ b/spec/features/work_packages/export_spec.rb
@@ -77,7 +77,7 @@ describe 'work package export', type: :feature do
begin
perform_enqueued_jobs
- rescue
+ rescue StandardError
# nothing
end
diff --git a/spec/features/work_packages/highlighting_spec.rb b/spec/features/work_packages/highlighting_spec.rb
index e10040c341..11a408386b 100644
--- a/spec/features/work_packages/highlighting_spec.rb
+++ b/spec/features/work_packages/highlighting_spec.rb
@@ -10,7 +10,9 @@ describe 'Work Package highlighting fields',
let(:status1) { FactoryBot.create :status, color: FactoryBot.create(:color, hexcode: '#FF0000') } # rgba(255, 0, 0, 1)
let(:status2) { FactoryBot.create :status, color: FactoryBot.create(:color, hexcode: '#F0F0F0') } # rgba(240, 240, 240, 1)
- let(:priority1) { FactoryBot.create :issue_priority, color: FactoryBot.create(:color, hexcode: '#123456') } #rgba(18, 52, 86, 1)
+ let(:priority1) do
+ FactoryBot.create :issue_priority, color: FactoryBot.create(:color, hexcode: '#123456')
+ end
let(:priority_no_color) { FactoryBot.create :issue_priority, color: nil }
let!(:wp_1) do
@@ -47,7 +49,6 @@ describe 'Work Package highlighting fields',
end
before do
-
# Ensure Rails and Capybara caches are cleared
Rails.cache.clear
Capybara.reset!
diff --git a/spec/features/work_packages/navigation_spec.rb b/spec/features/work_packages/navigation_spec.rb
index 8b90570307..340fd90836 100644
--- a/spec/features/work_packages/navigation_spec.rb
+++ b/spec/features/work_packages/navigation_spec.rb
@@ -97,7 +97,6 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
project_work_packages.expect_work_package_listed(work_package)
project_html_title.expect_first_segment 'All open'
-
# Visit query with project wp
project_work_packages.visit_query query
project_work_packages.expect_work_package_listed(work_package)
@@ -154,7 +153,6 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
page404.expect_and_dismiss_notification type: :error, message: I18n.t('api_v3.errors.code_404')
end
-
# Regression #29994
scenario 'access the work package views directly from a non-angular view' do
visit project_path(project)
@@ -203,7 +201,7 @@ RSpec.feature 'Work package navigation', js: true, selenium: true do
# Click on All open
find('.collapsible-menu--item-link', text: 'All open').click
-
+
if OpenProject::Configuration.bim?
wp_display.expect_state 'Cards'
else
diff --git a/spec/features/work_packages/new/new_work_package_spec.rb b/spec/features/work_packages/new/new_work_package_spec.rb
index 3f55f76646..7500ae6a0b 100644
--- a/spec/features/work_packages/new/new_work_package_spec.rb
+++ b/spec/features/work_packages/new/new_work_package_spec.rb
@@ -44,7 +44,7 @@ describe 'new work package', js: true do
end
end
- def create_work_package(type, project)
+ def create_work_package(type, _project)
loading_indicator_saveguard
wp_page.click_create_wp_button(type)
@@ -435,7 +435,7 @@ describe 'new work package', js: true do
# The dates are taken over from the parent by default
date_field = split_create_page.edit_field(:combinedDate)
- date_field.expect_value("#{parent.start_date} - #{parent.due_date}" )
+ date_field.expect_value("#{parent.start_date} - #{parent.due_date}")
date_field.input_element.click
sleep 1
diff --git a/spec/features/work_packages/pagination_spec.rb b/spec/features/work_packages/pagination_spec.rb
index 747dee5bed..140b5b5701 100644
--- a/spec/features/work_packages/pagination_spec.rb
+++ b/spec/features/work_packages/pagination_spec.rb
@@ -73,7 +73,6 @@ RSpec.feature 'Work package pagination', js: true do
expect(page).to have_content(work_package_2.subject)
end
end
-
end
context 'with project scope' do
diff --git a/spec/features/work_packages/project_context_switch_spec.rb b/spec/features/work_packages/project_context_switch_spec.rb
index f06685f0a0..bb82276ff0 100644
--- a/spec/features/work_packages/project_context_switch_spec.rb
+++ b/spec/features/work_packages/project_context_switch_spec.rb
@@ -6,7 +6,7 @@ describe 'Project context switching spec', js: true do
let(:project) { FactoryBot.create(:project) }
let(:work_package) { FactoryBot.create(:work_package, project: project) }
- let(:wp_table) { Pages::WorkPackagesTable.new }
+ let(:wp_table) { Pages::WorkPackagesTable.new }
let(:wp_page) { Pages::FullWorkPackage.new(work_package, project) }
before do
diff --git a/spec/features/work_packages/shared_contexts.rb b/spec/features/work_packages/shared_contexts.rb
index 89ef8bb2f2..96940f807a 100644
--- a/spec/features/work_packages/shared_contexts.rb
+++ b/spec/features/work_packages/shared_contexts.rb
@@ -30,8 +30,10 @@
# The status filter is loaded very late in the page setup.
shared_context 'ensure wp details pane update done' do
after do
- raise "Expect to have a let called 'update_user' defining which user \
- is doing the update".squish unless update_user
+ unless update_user
+ raise "Expect to have a let called 'update_user' defining which user \
+ is doing the update".squish
+ end
# safeguard to ensure all backend queries
# have been answered before starting a new spec
diff --git a/spec/features/work_packages/sorting/table_sorting_spec.rb b/spec/features/work_packages/sorting/table_sorting_spec.rb
index 99704b17a1..30f3bcc7ea 100644
--- a/spec/features/work_packages/sorting/table_sorting_spec.rb
+++ b/spec/features/work_packages/sorting/table_sorting_spec.rb
@@ -45,11 +45,11 @@ describe 'Select work package row', type: :feature, js: true do
let(:version_1) do
FactoryBot.create(:version, project: project,
- name: 'aaa_version')
+ name: 'aaa_version')
end
let(:version_2) do
FactoryBot.create(:version, project: project,
- name: 'zzz_version')
+ name: 'zzz_version')
end
let(:columns) { ::Components::WorkPackages::Columns.new }
let(:sort_by) { ::Components::WorkPackages::SortBy.new }
@@ -107,32 +107,32 @@ describe 'Select work package row', type: :feature, js: true do
let(:parent) do
FactoryBot.create :work_package,
- project: project
+ project: project
end
let(:child1) do
FactoryBot.create :work_package,
- project: project,
- parent: parent
+ project: project,
+ parent: parent
end
let(:child2) do
FactoryBot.create :work_package,
- project: project,
- parent: parent
+ project: project,
+ parent: parent
end
let(:grand_child1) do
FactoryBot.create :work_package,
- project: project,
- parent: child1
+ project: project,
+ parent: child1
end
let(:grand_child2) do
FactoryBot.create :work_package,
- project: project,
- parent: child2
+ project: project,
+ parent: child2
end
let(:grand_child3) do
FactoryBot.create :work_package,
- project: project,
- parent: child1
+ project: project,
+ parent: child1
end
before do
diff --git a/spec/features/work_packages/table/configuration_modal/column_spec.rb b/spec/features/work_packages/table/configuration_modal/column_spec.rb
index 14cdea9494..a583250148 100644
--- a/spec/features/work_packages/table/configuration_modal/column_spec.rb
+++ b/spec/features/work_packages/table/configuration_modal/column_spec.rb
@@ -46,7 +46,6 @@ describe 'Work Package table configuration modal columns spec', js: true do
context 'When seeing the table' do
it_behaves_like 'add and remove columns'
-
context 'with three columns', driver: :firefox_de do
let!(:query) do
query = FactoryBot.build(:query, user: user, project: project)
diff --git a/spec/features/work_packages/table/context_menu_spec.rb b/spec/features/work_packages/table/context_menu_spec.rb
index fcb5cb1866..d362d72501 100644
--- a/spec/features/work_packages/table/context_menu_spec.rb
+++ b/spec/features/work_packages/table/context_menu_spec.rb
@@ -11,7 +11,7 @@ describe 'Work package table context menu', js: true do
let(:time_logging_modal) { Components::TimeLoggingModal.new }
let(:display_representation) { ::Components::WorkPackages::DisplayRepresentation.new }
- def goto_context_menu list_view = true
+ def goto_context_menu(list_view = true)
# Go to table
wp_table.visit!
wp_table.expect_work_package_listed(work_package)
@@ -58,9 +58,9 @@ describe 'Work package table context menu', js: true do
goto_context_menu list_view
menu.choose('Copy')
# Split view open in copy state
- expect(page).
- to have_selector('.wp-new-top-row',
- text: "#{work_package.status.name.capitalize}\n#{work_package.type.name.upcase}")
+ expect(page)
+ .to have_selector('.wp-new-top-row',
+ text: "#{work_package.status.name.capitalize}\n#{work_package.type.name.upcase}")
expect(page).to have_field('wp-new-inline-edit--field-subject', with: work_package.subject)
# Open Delete
@@ -74,7 +74,7 @@ describe 'Work package table context menu', js: true do
menu.choose('Create new child')
expect(page).to have_selector('.inline-edit--container.subject input')
expect(page).to have_selector('.inline-edit--field.type')
- expect(current_url).to match(/.*\/create_new\?.*(\&)*parent_id=#{work_package.id.to_s}/)
+ expect(current_url).to match(/.*\/create_new\?.*(&)*parent_id=#{work_package.id}/)
find('#work-packages--edit-actions-cancel').click
expect(page).to have_no_selector('.inline-edit--container.subject input')
@@ -143,7 +143,7 @@ describe 'Work package table context menu', js: true do
goto_context_menu true
menu.choose('Create new child')
expect(page).to have_selector('.inline-edit--container.subject input')
- expect(current_url).to match(/.*\/create_new\?.*(\&)*parent_id=#{work_package.id.to_s}/)
+ expect(current_url).to match(/.*\/create_new\?.*(&)*parent_id=#{work_package.id}/)
split_view = ::Pages::SplitWorkPackageCreate.new project: work_package.project
subject = split_view.edit_field(:subject)
diff --git a/spec/features/work_packages/table/delete_work_packages_spec.rb b/spec/features/work_packages/table/delete_work_packages_spec.rb
index 1df250379f..2c2bba5877 100644
--- a/spec/features/work_packages/table/delete_work_packages_spec.rb
+++ b/spec/features/work_packages/table/delete_work_packages_spec.rb
@@ -101,7 +101,7 @@ describe 'Delete work package', js: true do
describe 'when deleting it within a project context' do
let(:project) { FactoryBot.create(:project) }
- let(:work_package) { FactoryBot.create(:work_package, project:project) }
+ let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:split_view) { Pages::SplitWorkPackage.new(work_package, project.identifier) }
let(:wp_table) { Pages::WorkPackagesTable.new(project.identifier) }
diff --git a/spec/features/work_packages/table/edit_work_packages_spec.rb b/spec/features/work_packages/table/edit_work_packages_spec.rb
index 68ff00be89..8d2ce95763 100644
--- a/spec/features/work_packages/table/edit_work_packages_spec.rb
+++ b/spec/features/work_packages/table/edit_work_packages_spec.rb
@@ -3,37 +3,37 @@ require 'spec_helper'
describe 'Inline editing work packages', js: true do
let(:manager_role) do
FactoryBot.create :role,
- permissions: [:view_work_packages,
- :edit_work_packages]
+ permissions: %i[view_work_packages
+ edit_work_packages]
end
let(:manager) do
FactoryBot.create :user,
- firstname: 'Manager',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: manager_role
+ firstname: 'Manager',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: manager_role
end
let(:type) { FactoryBot.create :type }
let(:status1) { FactoryBot.create :status }
let(:status2) { FactoryBot.create :status }
let(:project) { FactoryBot.create(:project, types: [type]) }
- let(:work_package) {
+ let(:work_package) do
FactoryBot.create(:work_package,
- project: project,
- type: type,
- status: status1,
- subject: 'Foobar')
- }
+ project: project,
+ type: type,
+ status: status1,
+ subject: 'Foobar')
+ end
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
let(:workflow) do
FactoryBot.create :workflow,
- type_id: type.id,
- old_status: status1,
- new_status: status2,
- role: manager_role
+ type_id: type.id,
+ old_status: status1,
+ new_status: status2,
+ role: manager_role
end
let(:version) { FactoryBot.create :version, project: project }
let(:category) { FactoryBot.create :category, project: project }
@@ -116,34 +116,34 @@ describe 'Inline editing work packages', js: true do
end
context 'custom field' do
- let(:custom_fields) {
+ let(:custom_fields) do
fields = [
FactoryBot.create(
:work_package_custom_field,
- field_format: 'list',
+ field_format: 'list',
possible_values: %w(foo bar xyz),
- is_required: true,
- is_for_all: false
+ is_required: true,
+ is_for_all: false
),
FactoryBot.create(
:work_package_custom_field,
field_format: 'string',
- is_required: true,
- is_for_all: false
+ is_required: true,
+ is_for_all: false
)
]
fields
- }
+ end
let(:type) { FactoryBot.create(:type_task, custom_fields: custom_fields) }
let(:project) { FactoryBot.create(:project, types: [type]) }
- let(:work_package) {
+ let(:work_package) do
FactoryBot.create(:work_package,
- subject: 'Foobar',
- status: status1,
- type: type,
- project: project)
- }
+ subject: 'Foobar',
+ status: status1,
+ type: type,
+ project: project)
+ end
before do
work_package
@@ -169,7 +169,7 @@ describe 'Inline editing work packages', js: true do
cf_list_name = custom_fields.first.name
cf_text_name = custom_fields.last.name
wp_table.expect_notification(
- type: :error,
+ type: :error,
message: "#{cf_list_name} can't be blank.\n#{cf_text_name} can't be blank."
)
diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb
index 76751a75ce..28edaaf8d6 100644
--- a/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb
+++ b/spec/features/work_packages/table/hierarchy/hierarchy_parent_below_spec.rb
@@ -65,7 +65,6 @@ describe 'Work Package table hierarchy parent below', js: true do
wp_table.visit_query query
wp_table.expect_work_package_listed(child, parent, grandparent)
-
# Double order result from regression
# wp_table.expect_work_package_order(child.id, parent.id, grandparent.id, grandparent.id)
wp_table.expect_work_package_order(grandparent.id, parent.id, child.id)
@@ -157,12 +156,12 @@ describe 'Work Package table hierarchy parent below', js: true do
wp_table.expect_work_package_listed(child, parent)
expect(page).to have_selector('.wp-table--hierarchy-indicator-icon')
-
+
split_page = wp_table.open_split_view(parent)
split_page.visit_tab!("relations")
relations.remove_child(child)
loading_indicator_saveguard
-
+
expect(page).to have_no_selector('.wp-table--hierarchy-indicator-icon')
end
end
diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb
index 8133302436..d165a17409 100644
--- a/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb
+++ b/spec/features/work_packages/table/hierarchy/hierarchy_spec.rb
@@ -176,8 +176,8 @@ describe 'Work Package table hierarchy', js: true do
let(:user) do
FactoryBot.create :user,
- member_in_project: project,
- member_through_role: role
+ member_in_project: project,
+ member_through_role: role
end
let(:permissions) { %i(view_work_packages add_work_packages save_queries) }
let(:role) { FactoryBot.create :role, permissions: permissions }
@@ -250,7 +250,7 @@ describe 'Work Package table hierarchy', js: true do
hierarchy.toggle_row(root_assigned)
# Sort descending
- sort_by.update_criteria([ 'Assignee', descending: true])
+ sort_by.update_criteria(['Assignee', { descending: true }])
loading_indicator_saveguard
wp_table.expect_work_package_listed(root, root_assigned)
diff --git a/spec/features/work_packages/table/hierarchy/parent_column_spec.rb b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb
index 40ccba32d4..e7fc38a712 100644
--- a/spec/features/work_packages/table/hierarchy/parent_column_spec.rb
+++ b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb
@@ -10,7 +10,6 @@ describe 'Work Package table parent column', js: true do
login_as(user)
end
-
let!(:parent) { FactoryBot.create(:work_package, project: project) }
let!(:child) { FactoryBot.create(:work_package, project: project, parent: parent) }
diff --git a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
index d5fbbd1c0f..0fbae4a66a 100644
--- a/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
+++ b/spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
@@ -151,7 +151,7 @@ describe 'inline create work package', js: true do
it_behaves_like 'inline create work package' do
let(:callback) do
- ->() {
+ -> {
# Set project
project_field = wp_table.edit_field(nil, :project)
project_field.expect_active!
@@ -179,7 +179,7 @@ describe 'inline create work package', js: true do
it_behaves_like 'inline create work package' do
let(:callback) do
- ->() {}
+ -> {}
end
end
diff --git a/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb b/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb
index 58efcf83b1..df34e15233 100644
--- a/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb
+++ b/spec/features/work_packages/table/inline_create/inline_create_refresh_spec.rb
@@ -22,7 +22,6 @@ describe 'Refreshing in inline-create row', flaky: true, js: true do
wp_table.visit_query(query)
end
-
it 'correctly updates the set of active columns' do
expect(page).to have_selector('.wp--row', count: 0)
diff --git a/spec/features/work_packages/table/queries/assignee_filter_spec.rb b/spec/features/work_packages/table/queries/assignee_filter_spec.rb
index b0f3d674f1..0710fae5c5 100644
--- a/spec/features/work_packages/table/queries/assignee_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/assignee_filter_spec.rb
@@ -32,7 +32,7 @@ describe 'Work package filtering by assignee', js: true do
let(:project) { FactoryBot.create :project }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
let(:filters) { ::Components::WorkPackages::Filters.new }
- let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages, :save_queries]) }
+ let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages save_queries]) }
let(:other_user) do
FactoryBot.create :user,
firstname: 'Other',
diff --git a/spec/features/work_packages/table/queries/filter_spec.rb b/spec/features/work_packages/table/queries/filter_spec.rb
index d11e2820c8..0be2319be4 100644
--- a/spec/features/work_packages/table/queries/filter_spec.rb
+++ b/spec/features/work_packages/table/queries/filter_spec.rb
@@ -73,7 +73,9 @@ describe 'filter work packages', js: true do
context 'by version in project' do
let(:version) { FactoryBot.create :version, project: project }
- let(:work_package_with_version) { FactoryBot.create :work_package, project: project, subject: 'With version', version: version }
+ let(:work_package_with_version) do
+ FactoryBot.create :work_package, project: project, subject: 'With version', version: version
+ end
let(:work_package_without_version) { FactoryBot.create :work_package, subject: 'Without version', project: project }
before do
@@ -214,7 +216,6 @@ describe 'filter work packages', js: true do
end
it 'allows filtering, saving and retrieving the saved filter' do
-
# Wait for form to load
filters.expect_loaded
@@ -293,7 +294,6 @@ describe 'filter work packages', js: true do
end
it 'allows filtering, saving and retrieving the saved filter' do
-
# Wait for form to load
filters.expect_loaded
@@ -337,7 +337,6 @@ describe 'filter work packages', js: true do
loading_indicator_saveguard
wp_table.expect_work_package_listed work_package_and
wp_table.ensure_work_package_not_listed! work_package_plus
-
end
end
@@ -512,26 +511,26 @@ describe 'filter work packages', js: true do
end
describe 'add parent WP filter' do
- let(:wp_parent) { FactoryBot.create :work_package, project: project, subject: 'project' }
- let(:wp_child1) { FactoryBot.create :work_package, project: project, subject: 'child 1', parent: wp_parent }
- let(:wp_child2) { FactoryBot.create :work_package, project: project, subject: 'child 2', parent: wp_parent }
- let(:wp_default) { FactoryBot.create :work_package, project: project, subject: 'default' }
-
- it do
- wp_parent
- wp_child1
- wp_child2
- wp_default
- wp_table.visit!
- loading_indicator_saveguard
- filters.expect_loaded
- filters.open
- filters.add_filter_by 'Parent', 'is', [wp_parent.subject]
- loading_indicator_saveguard
-
- # It should show the children of the selected parent
- wp_table.expect_work_package_listed wp_child1, wp_child2
- wp_table.ensure_work_package_not_listed! wp_default
+ let(:wp_parent) { FactoryBot.create :work_package, project: project, subject: 'project' }
+ let(:wp_child1) { FactoryBot.create :work_package, project: project, subject: 'child 1', parent: wp_parent }
+ let(:wp_child2) { FactoryBot.create :work_package, project: project, subject: 'child 2', parent: wp_parent }
+ let(:wp_default) { FactoryBot.create :work_package, project: project, subject: 'default' }
+
+ it do
+ wp_parent
+ wp_child1
+ wp_child2
+ wp_default
+ wp_table.visit!
+ loading_indicator_saveguard
+ filters.expect_loaded
+ filters.open
+ filters.add_filter_by 'Parent', 'is', [wp_parent.subject]
+ loading_indicator_saveguard
+
+ # It should show the children of the selected parent
+ wp_table.expect_work_package_listed wp_child1, wp_child2
+ wp_table.ensure_work_package_not_listed! wp_default
+ end
end
end
-end
diff --git a/spec/features/work_packages/table/queries/me_filter_spec.rb b/spec/features/work_packages/table/queries/me_filter_spec.rb
index b89e68bfd5..c00d3a43ec 100644
--- a/spec/features/work_packages/table/queries/me_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/me_filter_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
describe 'filter me value', js: true do
- let(:status) { FactoryBot.create :default_status}
+ let(:status) { FactoryBot.create :default_status }
let!(:priority) { FactoryBot.create :default_priority }
let(:project) { FactoryBot.create :project, public: true }
let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] }
@@ -51,9 +51,9 @@ describe 'filter me value', js: true do
context 'as anonymous', with_settings: { login_required?: false } do
let(:assignee_query) do
query = FactoryBot.create(:query,
- name: 'Assignee Query',
- project: project,
- user: user)
+ name: 'Assignee Query',
+ project: project,
+ user: user)
query.add_filter('assigned_to_id', '=', ['me'])
query.save!(validate: false)
@@ -131,32 +131,32 @@ describe 'filter me value', js: true do
let(:type_task) { FactoryBot.create(:type_task, custom_fields: [custom_field]) }
let(:project) do
FactoryBot.create(:project,
- types: [type_task],
- work_package_custom_fields: [custom_field])
+ types: [type_task],
+ work_package_custom_fields: [custom_field])
end
let(:cf_accessor) { "cf_#{custom_field.id}" }
let(:cf_accessor_frontend) { "customField#{custom_field.id}" }
let(:wp_admin) do
FactoryBot.create :work_package,
- type: type_task,
- project: project,
- custom_field_values: { custom_field.id => admin.id }
+ type: type_task,
+ project: project,
+ custom_field_values: { custom_field.id => admin.id }
end
let(:wp_user) do
FactoryBot.create :work_package,
- type: type_task,
- project: project,
- custom_field_values: { custom_field.id => user.id }
+ type: type_task,
+ project: project,
+ custom_field_values: { custom_field.id => user.id }
end
context 'as anonymous', with_settings: { login_required?: false } do
let(:assignee_query) do
query = FactoryBot.create(:query,
- name: 'CF user Query',
- project: project,
- user: user)
+ name: 'CF user Query',
+ project: project,
+ user: user)
query.add_filter(cf_accessor, '=', ['me'])
query.save!(validate: false)
diff --git a/spec/features/work_packages/table/queries/query_history_spec.rb b/spec/features/work_packages/table/queries/query_history_spec.rb
index af4c2d62e5..cd35543e77 100644
--- a/spec/features/work_packages/table/queries/query_history_spec.rb
+++ b/spec/features/work_packages/table/queries/query_history_spec.rb
@@ -31,43 +31,43 @@ require 'spec_helper'
describe 'Going back and forth through the browser history', type: :feature, js: true do
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let(:project) { FactoryBot.create(:project) }
let(:type) { project.types.first }
let(:role) do
FactoryBot.create(:role,
- permissions: [:view_work_packages,
- :save_queries])
+ permissions: %i[view_work_packages
+ save_queries])
end
let(:work_package_1) do
FactoryBot.create(:work_package,
- project: project,
- type: type)
+ project: project,
+ type: type)
end
let(:work_package_2) do
FactoryBot.create(:work_package,
- project: project,
- type: type,
- assigned_to: user)
+ project: project,
+ type: type,
+ assigned_to: user)
end
let(:version) do
FactoryBot.create(:version,
- project: project)
+ project: project)
end
let(:work_package_3) do
FactoryBot.create(:work_package,
- project: project,
- type: type,
- version: version)
+ project: project,
+ type: type,
+ version: version)
end
let(:assignee_query) do
query = FactoryBot.create(:query,
- name: 'Assignee Query',
- project: project,
- user: user)
+ name: 'Assignee Query',
+ project: project,
+ user: user)
query.add_filter('assigned_to_id', '=', [user.id])
query.save!
@@ -76,9 +76,9 @@ describe 'Going back and forth through the browser history', type: :feature, js:
end
let(:version_query) do
query = FactoryBot.create(:query,
- name: 'Version Query',
- project: project,
- user: user)
+ name: 'Version Query',
+ project: project,
+ user: user)
query.add_filter('version_id', '=', [version.id])
query.save!
diff --git a/spec/features/work_packages/table/queries/query_name_inline_edit_spec.rb b/spec/features/work_packages/table/queries/query_name_inline_edit_spec.rb
index c8d2381889..c29c6d839d 100644
--- a/spec/features/work_packages/table/queries/query_name_inline_edit_spec.rb
+++ b/spec/features/work_packages/table/queries/query_name_inline_edit_spec.rb
@@ -38,8 +38,8 @@ describe 'Query name inline edit', js: true do
let(:type) { project.types.first }
let(:role) do
FactoryBot.create(:role,
- permissions: [:view_work_packages,
- :save_queries])
+ permissions: %i[view_work_packages
+ save_queries])
end
let(:work_package) do
diff --git a/spec/features/work_packages/table/queries/responsible_filter_spec.rb b/spec/features/work_packages/table/queries/responsible_filter_spec.rb
index 3caec00530..46f71f69a3 100644
--- a/spec/features/work_packages/table/queries/responsible_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/responsible_filter_spec.rb
@@ -32,7 +32,7 @@ describe 'Work package filtering by responsible', js: true do
let(:project) { FactoryBot.create :project }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
let(:filters) { ::Components::WorkPackages::Filters.new }
- let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages, :save_queries]) }
+ let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages save_queries]) }
let(:other_user) do
FactoryBot.create :user,
firstname: 'Other',
diff --git a/spec/features/work_packages/table/queries/summary_spec.rb b/spec/features/work_packages/table/queries/summary_spec.rb
index 5b3e7200cb..ac24b6889c 100644
--- a/spec/features/work_packages/table/queries/summary_spec.rb
+++ b/spec/features/work_packages/table/queries/summary_spec.rb
@@ -36,7 +36,7 @@ describe 'Work package query summary item', type: :feature, js: true do
let(:wp_page) { ::Pages::WorkPackagesTable.new project }
let(:current_user) do
FactoryBot.create :user, member_in_project: project,
- member_through_role: role
+ member_through_role: role
end
before do
diff --git a/spec/features/work_packages/table/queries/user_cf_filter_spec.rb b/spec/features/work_packages/table/queries/user_cf_filter_spec.rb
index bd61c0852d..c40d8ca1ad 100644
--- a/spec/features/work_packages/table/queries/user_cf_filter_spec.rb
+++ b/spec/features/work_packages/table/queries/user_cf_filter_spec.rb
@@ -38,7 +38,6 @@ describe 'Work package filtering by user custom field', js: true do
type.custom_fields << cf
project.work_package_custom_fields << cf
end
-
end
let(:role) { FactoryBot.create(:role, permissions: %i[view_work_packages save_queries]) }
let(:other_user) do
diff --git a/spec/features/work_packages/table/relations_spec.rb b/spec/features/work_packages/table/relations_spec.rb
index 9f4e28638e..73dbe16b48 100644
--- a/spec/features/work_packages/table/relations_spec.rb
+++ b/spec/features/work_packages/table/relations_spec.rb
@@ -18,15 +18,15 @@ describe 'Work Package table relations', js: true do
let!(:relation) do
FactoryBot.create(:relation,
- from: wp_from,
- to: wp_to,
- relation_type: Relation::TYPE_FOLLOWS)
+ from: wp_from,
+ to: wp_to,
+ relation_type: Relation::TYPE_FOLLOWS)
end
let!(:relation2) do
FactoryBot.create(:relation,
- from: wp_from,
- to: wp_to2,
- relation_type: Relation::TYPE_FOLLOWS)
+ from: wp_from,
+ to: wp_to2,
+ relation_type: Relation::TYPE_FOLLOWS)
end
let!(:query) do
query = FactoryBot.build(:query, user: user, project: project)
diff --git a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
index b93bf76d2f..4e0d5b8d16 100644
--- a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
+++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb
@@ -70,7 +70,6 @@ describe 'Manual scheduling', js: true do
expect(page).to have_selector('input[name="endDate"]:not([disabled])')
expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Cancel')
expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Save')
-
end
start_date.cancel_by_click
@@ -95,7 +94,6 @@ describe 'Manual scheduling', js: true do
expect(page).to have_selector('input[name=endDate][disabled]')
expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Cancel')
expect(page).to have_selector('.datepicker-modal--action[disabled]', text: 'Save')
-
end
start_date.toggle_scheduling_mode
diff --git a/spec/features/work_packages/tabs/activity_revisions_spec.rb b/spec/features/work_packages/tabs/activity_revisions_spec.rb
index 9290f391a1..4780af67ac 100644
--- a/spec/features/work_packages/tabs/activity_revisions_spec.rb
+++ b/spec/features/work_packages/tabs/activity_revisions_spec.rb
@@ -93,14 +93,14 @@ describe 'Activity tab', js: true, selenium: true do
end
date_selector = ".work-package-details-activities-activity:nth-of-type(#{actual_index}) " +
- '.activity-date'
+ '.activity-date'
# Do not use :long format to match the printed date without double spaces
# on the first 9 days of the month
expected_date = if activity.is_a?(Journal)
- activity.created_at
- else
- activity.committed_on
- end.to_date.strftime("%B %-d, %Y")
+ activity.created_at
+ else
+ activity.committed_on
+ end.to_date.strftime("%B %-d, %Y")
expect(page).to have_selector(date_selector,
text: expected_date)
diff --git a/spec/features/work_packages/tabs/watcher_tab_spec.rb b/spec/features/work_packages/tabs/watcher_tab_spec.rb
index d4125f7ed1..f8ee72e8d6 100644
--- a/spec/features/work_packages/tabs/watcher_tab_spec.rb
+++ b/spec/features/work_packages/tabs/watcher_tab_spec.rb
@@ -8,12 +8,12 @@ describe 'Watcher tab', js: true, selenium: true do
let(:tabs) { ::Components::WorkPackages::Tabs.new(work_package) }
let(:user) { FactoryBot.create(:user, member_in_project: project, member_through_role: role) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
- let(:permissions) {
+ let(:permissions) do
%i(view_work_packages
view_work_package_watchers
delete_work_package_watchers
add_work_package_watchers)
- }
+ end
let(:watch_button) { find '#watch-button' }
let(:watchers_tab) { find('.tabrow li.selected', text: 'WATCHERS') }
@@ -83,12 +83,12 @@ describe 'Watcher tab', js: true, selenium: true do
end
context 'with a user with arbitrary characters' do
- let!(:html_user) {
+ let!(:html_user) do
FactoryBot.create :user,
- firstname: 'foo ',
- member_in_project: project,
- member_through_role: role
- }
+ firstname: 'foo ',
+ member_in_project: project,
+ member_through_role: role
+ end
it 'escapes the user name' do
autocomplete = find('.wp-watcher--autocomplete')
@@ -119,7 +119,7 @@ describe 'Watcher tab', js: true, selenium: true do
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
it_behaves_like 'watchers tab'
end
-
+
context 'when the work package has a watcher' do
let(:watchers) { FactoryBot.create(:watcher, watchable: work_package, user: user) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
@@ -129,11 +129,11 @@ describe 'Watcher tab', js: true, selenium: true do
login_as(user)
wp_table.visit!
wp_table.expect_work_package_listed work_package
- end
-
+ end
+
it 'should show the number of watchers [#33685]' do
wp_table.open_full_screen_by_doubleclick(work_package)
- expect(page).to have_selector('.wp-tabs-count', text: 1)
+ expect(page).to have_selector('.wp-tabs-count', text: 1)
end
end
diff --git a/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb b/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb
index 4d2b50cc2a..1e109c5fbf 100644
--- a/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb
+++ b/spec/features/work_packages/timeline/timeline_hierarchy_spec.rb
@@ -43,15 +43,15 @@ RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do
let!(:wp_root) do
FactoryBot.create :work_package,
- project: project
+ project: project
end
let!(:wp_leaf) do
FactoryBot.create :work_package,
- project: project,
- parent: wp_root,
- start_date: Date.today,
- due_date: (Date.today + 5.days)
+ project: project,
+ parent: wp_root,
+ start_date: Date.today,
+ due_date: (Date.today + 5.days)
end
let!(:query) do
@@ -91,15 +91,15 @@ RSpec.feature 'Work package timeline hierarchies', js: true, selenium: true do
context 'with a relation being rendered to a hidden row' do
let!(:wp_other) do
FactoryBot.create :work_package,
- project: project,
- start_date: Date.today + 5.days,
- due_date: (Date.today + 10.days)
+ project: project,
+ start_date: Date.today + 5.days,
+ due_date: (Date.today + 10.days)
end
let!(:relation) do
FactoryBot.create(:relation,
- from: wp_leaf,
- to: wp_other,
- relation_type: Relation::TYPE_FOLLOWS)
+ from: wp_leaf,
+ to: wp_other,
+ relation_type: Relation::TYPE_FOLLOWS)
end
it 'does not render the relation when hierarchy is collapsed' do
diff --git a/spec/features/work_packages/timeline/timeline_labels_spec.rb b/spec/features/work_packages/timeline/timeline_labels_spec.rb
index 6d4227e8fd..6ee6a07c40 100644
--- a/spec/features/work_packages/timeline/timeline_labels_spec.rb
+++ b/spec/features/work_packages/timeline/timeline_labels_spec.rb
@@ -57,27 +57,27 @@ RSpec.feature 'Work package timeline labels',
end
let(:today) { Date.today.iso8601 }
- let(:tomorrow) { Date.tomorrow.iso8601 }
- let(:future) { (Date.today + 5).iso8601 }
+ let(:tomorrow) { Date.tomorrow.iso8601 }
+ let(:future) { (Date.today + 5).iso8601 }
let(:work_package) do
FactoryBot.create :work_package,
- project: project,
- type: type,
- assigned_to: user,
- start_date: today,
- due_date: tomorrow,
- subject: 'My subject',
- custom_field_values: { custom_field.id => custom_value_for('onions') }
+ project: project,
+ type: type,
+ assigned_to: user,
+ start_date: today,
+ due_date: tomorrow,
+ subject: 'My subject',
+ custom_field_values: { custom_field.id => custom_value_for('onions') }
end
let(:milestone_work_package) do
FactoryBot.create :work_package,
- project: project,
- type: milestone_type,
- start_date: future,
- due_date: future,
- subject: 'My milestone'
+ project: project,
+ type: milestone_type,
+ start_date: future,
+ due_date: future,
+ subject: 'My milestone'
end
before do
@@ -177,6 +177,5 @@ RSpec.feature 'Work package timeline labels',
row.expect_labels left: nil,
right: future,
farRight: milestone_work_package.subject
-
end
end
diff --git a/spec/features/work_packages/timeline/timeline_navigation_spec.rb b/spec/features/work_packages/timeline/timeline_navigation_spec.rb
index e62c8932b6..b14c61fb3b 100644
--- a/spec/features/work_packages/timeline/timeline_navigation_spec.rb
+++ b/spec/features/work_packages/timeline/timeline_navigation_spec.rb
@@ -120,7 +120,6 @@ RSpec.feature 'Work package timeline navigation', js: true, selenium: true do
wp_timeline.expect_work_package_listed work_package2
wp_timeline.ensure_work_package_not_listed! work_package
-
retry_block do
find(".wp-row-#{work_package2.id}-timeline").right_click
find('.menu-item', text: 'Add predecessor')
diff --git a/spec/features/work_packages/work_package_workflow_form_spec.rb b/spec/features/work_packages/work_package_workflow_form_spec.rb
index 36951674ed..bc05a4ce57 100644
--- a/spec/features/work_packages/work_package_workflow_form_spec.rb
+++ b/spec/features/work_packages/work_package_workflow_form_spec.rb
@@ -34,50 +34,50 @@ require 'features/page_objects/notification'
describe 'Work package transitive status workflows', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: [:view_work_packages,
- :edit_work_packages]
+ permissions: %i[view_work_packages
+ edit_work_packages]
end
let(:dev) do
FactoryBot.create :user,
- firstname: 'Dev',
- lastname: 'Guy',
- member_in_project: project,
- member_through_role: dev_role
+ firstname: 'Dev',
+ lastname: 'Guy',
+ member_in_project: project,
+ member_through_role: dev_role
end
let(:type) { FactoryBot.create :type }
let(:project) { FactoryBot.create(:project, types: [type]) }
- let(:work_package) {
+ let(:work_package) do
work_package = FactoryBot.create :work_package,
- project: project,
- type: type,
- created_at: 5.days.ago.to_date.to_s(:db)
+ project: project,
+ type: type,
+ created_at: 5.days.ago.to_date.to_s(:db)
note_journal = work_package.journals.last
note_journal.update(created_at: 5.days.ago.to_date.to_s)
work_package
- }
+ end
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
let(:status_from) { work_package.status }
let(:status_intermediate) { FactoryBot.create :status }
let(:status_to) { FactoryBot.create :status }
- let(:workflows) {
+ let(:workflows) do
FactoryBot.create :workflow,
- type_id: type.id,
- old_status: status_from,
- new_status: status_intermediate,
- role: dev_role
+ type_id: type.id,
+ old_status: status_from,
+ new_status: status_intermediate,
+ role: dev_role
FactoryBot.create :workflow,
- type_id: type.id,
- old_status: status_intermediate,
- new_status: status_to,
- role: dev_role
- }
+ type_id: type.id,
+ old_status: status_intermediate,
+ new_status: status_to,
+ role: dev_role
+ end
before do
login_as(dev)
diff --git a/spec/features/work_packages/zen_mode_spec.rb b/spec/features/work_packages/zen_mode_spec.rb
index 9d573dabd6..156c8d583c 100644
--- a/spec/features/work_packages/zen_mode_spec.rb
+++ b/spec/features/work_packages/zen_mode_spec.rb
@@ -3,8 +3,8 @@ require 'spec_helper'
describe 'Zen mode', js: true do
let(:dev_role) do
FactoryBot.create :role,
- permissions: [:view_work_packages,
- :edit_work_packages]
+ permissions: %i[view_work_packages
+ edit_work_packages]
end
let(:dev) do
FactoryBot.create :user,
diff --git a/spec/features/workflows/copy_spec.rb b/spec/features/workflows/copy_spec.rb
index 6e1748f726..bc06fec7b3 100644
--- a/spec/features/workflows/copy_spec.rb
+++ b/spec/features/workflows/copy_spec.rb
@@ -33,14 +33,14 @@ describe 'Workflow copy', type: :feature do
let(:type) { FactoryBot.create(:type) }
let(:admin) { FactoryBot.create(:admin) }
let(:statuses) { (1..2).map { |_i| FactoryBot.create(:status) } }
- let(:workflow) {
+ let(:workflow) do
FactoryBot.create(:workflow, role_id: role.id,
- type_id: type.id,
- old_status_id: statuses[0].id,
- new_status_id: statuses[1].id,
- author: false,
- assignee: false)
- }
+ type_id: type.id,
+ old_status_id: statuses[0].id,
+ new_status_id: statuses[1].id,
+ author: false,
+ assignee: false)
+ end
before do
allow(User).to receive(:current).and_return(admin)
diff --git a/spec/features/wysiwyg/custom_css_classes_spec.rb b/spec/features/wysiwyg/custom_css_classes_spec.rb
index 1d26946d4d..ba58d4fcea 100644
--- a/spec/features/wysiwyg/custom_css_classes_spec.rb
+++ b/spec/features/wysiwyg/custom_css_classes_spec.rb
@@ -34,7 +34,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
let(:project) { FactoryBot.create(:project, enabled_module_names: %w[wiki]) }
let(:editor) { ::Components::WysiwygEditor.new }
- let(:wiki_page) {
+ let(:wiki_page) do
page = FactoryBot.build :wiki_page_with_content
page.content.text = <<~MARKDOWN
paragraph
@@ -100,7 +100,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
MARKDOWN
page
- }
+ end
before do
login_as(user)
@@ -111,7 +111,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
end
it 'custom classes are placed correctly' do
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_css('p.op-uc-p', count: 5)
expect(editable).to have_css('h1.op-uc-h1', count: 1)
expect(editable).to have_css('h2.op-uc-h2', count: 1)
diff --git a/spec/features/wysiwyg/linking_spec.rb b/spec/features/wysiwyg/linking_spec.rb
index fb83f35ad3..53664f1b2b 100644
--- a/spec/features/wysiwyg/linking_spec.rb
+++ b/spec/features/wysiwyg/linking_spec.rb
@@ -56,7 +56,7 @@ describe 'Wysiwyg linking',
expect(wiki_page.content.text).to eq(
"[http://example.org/link with spaces](http://example.org/link%20with%20spaces)"
- )
+ )
expect(page).to have_selector('a[href="http://example.org/link%20with%20spaces"]')
end
diff --git a/spec/features/wysiwyg/macros/attribute_macros_spec.rb b/spec/features/wysiwyg/macros/attribute_macros_spec.rb
index 0222e6b51a..06b8ac526f 100644
--- a/spec/features/wysiwyg/macros/attribute_macros_spec.rb
+++ b/spec/features/wysiwyg/macros/attribute_macros_spec.rb
@@ -35,7 +35,7 @@ describe 'Wysiwyg attribute macros', type: :feature, js: true do
let!(:work_package) { FactoryBot.create(:work_package, subject: "Foo Bar", project: project) }
let(:editor) { ::Components::WysiwygEditor.new }
- let(:markdown) {
+ let(:markdown) do
<<~MD
# My headline
@@ -62,7 +62,7 @@ describe 'Wysiwyg attribute macros', type: :feature, js: true do
MD
- }
+ end
before do
login_as(user)
diff --git a/spec/features/wysiwyg/macros/child_pages_spec.rb b/spec/features/wysiwyg/macros/child_pages_spec.rb
index 0dfd5a52ce..bcd14a5c67 100644
--- a/spec/features/wysiwyg/macros/child_pages_spec.rb
+++ b/spec/features/wysiwyg/macros/child_pages_spec.rb
@@ -32,33 +32,32 @@ require 'spec_helper'
describe 'Wysiwyg child pages spec',
type: :feature, js: true do
-
- let(:project) {
+ let(:project) do
FactoryBot.create :project,
enabled_module_names: %w[wiki]
- }
+ end
let(:role) { FactoryBot.create(:role, permissions: %i[view_wiki_pages edit_wiki_pages]) }
- let(:user) {
+ let(:user) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
- }
+ end
- let(:wiki_page) {
+ let(:wiki_page) do
FactoryBot.create :wiki_page,
title: 'Test',
content: FactoryBot.build(:wiki_content, text: '# My page')
- }
+ end
- let(:parent_page) {
+ let(:parent_page) do
FactoryBot.create :wiki_page,
title: 'Parent page',
content: FactoryBot.build(:wiki_content, text: '# parent page')
- }
+ end
- let(:child_page) {
+ let(:child_page) do
FactoryBot.create :wiki_page,
title: 'Child page',
content: FactoryBot.build(:wiki_content, text: '# child page')
- }
+ end
before do
login_as(user)
@@ -71,7 +70,6 @@ describe 'Wysiwyg child pages spec',
project.wiki.save!
end
-
let(:editor) { ::Components::WysiwygEditor.new }
before do
diff --git a/spec/features/wysiwyg/macros/code_block_macro_spec.rb b/spec/features/wysiwyg/macros/code_block_macro_spec.rb
index 0fe7bfe788..8754c734c1 100644
--- a/spec/features/wysiwyg/macros/code_block_macro_spec.rb
+++ b/spec/features/wysiwyg/macros/code_block_macro_spec.rb
@@ -36,21 +36,21 @@ describe 'Wysiwyg code block macro',
let(:project) { FactoryBot.create(:project, enabled_module_names: %w[wiki]) }
let(:editor) { ::Components::WysiwygEditor.new }
- let(:snippet) {
+ let(:snippet) do
<<~RUBY
def foobar
'some ruby code'
end
RUBY
- }
+ end
- let(:expected) {
+ let(:expected) do
<<~EXPECTED
```ruby
#{snippet.strip}
```
EXPECTED
- }
+ end
before do
login_as(user)
diff --git a/spec/features/wysiwyg/macros/embedded_tables_spec.rb b/spec/features/wysiwyg/macros/embedded_tables_spec.rb
index fa2238c17f..4d8b53de8c 100644
--- a/spec/features/wysiwyg/macros/embedded_tables_spec.rb
+++ b/spec/features/wysiwyg/macros/embedded_tables_spec.rb
@@ -34,7 +34,9 @@ describe 'Wysiwyg embedded work package tables',
let(:user) { admin }
let(:type_task) { FactoryBot.create :type_task }
let(:type_bug) { FactoryBot.create :type_bug }
- let(:project) { FactoryBot.create(:project, types: [type_task, type_bug], enabled_module_names: %w[wiki work_package_tracking]) }
+ let(:project) do
+ FactoryBot.create(:project, types: [type_task, type_bug], enabled_module_names: %w[wiki work_package_tracking])
+ end
let(:editor) { ::Components::WysiwygEditor.new }
let!(:wp_task) { FactoryBot.create(:work_package, project: project, type: type_task) }
let!(:wp_bug) { FactoryBot.create(:work_package, project: project, type: type_bug) }
diff --git a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
index 7cdab5385c..98cfae8e57 100644
--- a/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
+++ b/spec/features/wysiwyg/macros/quicklink_macros_spec.rb
@@ -32,12 +32,12 @@ describe 'Wysiwyg work package quicklink macros', type: :feature, js: true do
shared_let(:admin) { FactoryBot.create :admin }
let(:user) { admin }
let!(:project) { FactoryBot.create(:project, identifier: 'some-project', enabled_module_names: %w[wiki work_package_tracking]) }
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create(:work_package, subject: "Foo Bar", project: project, start_date: '2020-01-01', due_date: '2020-02-01')
- }
+ end
let(:editor) { ::Components::WysiwygEditor.new }
- let(:markdown) {
+ let(:markdown) do
<<~MD
# My headline
@@ -45,7 +45,7 @@ describe 'Wysiwyg work package quicklink macros', type: :feature, js: true do
####{work_package.id}
MD
- }
+ end
before do
login_as(user)
@@ -77,7 +77,7 @@ describe 'Wysiwyg work package quicklink macros', type: :feature, js: true do
# Dates are being rendered in two nested spans
expect(page).to have_selector('span', text: '01/01/2020', count: 2)
expect(page).to have_selector('span', text: '02/01/2020', count: 2)
- expect(page).to have_selector('.work-package--quickinfo.preview-trigger', text: "##{work_package.id}", count: 2)
+ expect(page).to have_selector('.work-package--quickinfo.preview-trigger', text: "##{work_package.id}", count: 2)
end
# Edit page again
diff --git a/spec/features/wysiwyg/macros/work_package_button_spec.rb b/spec/features/wysiwyg/macros/work_package_button_spec.rb
index 86a2bf2e2f..7ec30c4c42 100644
--- a/spec/features/wysiwyg/macros/work_package_button_spec.rb
+++ b/spec/features/wysiwyg/macros/work_package_button_spec.rb
@@ -55,7 +55,7 @@ describe 'Wysiwyg work package button spec',
end
it 'can add and edit an embedded table widget' do
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
editor.insert_macro 'Insert create work package button'
expect(page).to have_selector('.op-modal--macro-modal')
diff --git a/spec/features/wysiwyg/non_breaking_spaces_spec.rb b/spec/features/wysiwyg/non_breaking_spaces_spec.rb
index 64ab2fc91d..f6902862fa 100644
--- a/spec/features/wysiwyg/non_breaking_spaces_spec.rb
+++ b/spec/features/wysiwyg/non_breaking_spaces_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
describe 'Wysiwyg behavior',
type: :feature, js: true do
shared_let(:admin) { FactoryBot.create :admin }
- let(:user) { admin}
+ let(:user) { admin }
let(:project) { FactoryBot.create(:project, enabled_module_names: %w[wiki]) }
let(:editor) { ::Components::WysiwygEditor.new }
diff --git a/spec/features/wysiwyg/paragraphs_in_lists_spec.rb b/spec/features/wysiwyg/paragraphs_in_lists_spec.rb
index 9a245ac10e..b1e58baf3d 100644
--- a/spec/features/wysiwyg/paragraphs_in_lists_spec.rb
+++ b/spec/features/wysiwyg/paragraphs_in_lists_spec.rb
@@ -34,7 +34,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
let(:project) { FactoryBot.create(:project, enabled_module_names: %w[wiki]) }
let(:editor) { ::Components::WysiwygEditor.new }
- let(:wiki_page) {
+ let(:wiki_page) do
page = FactoryBot.build :wiki_page_with_content
page.content.text = <<~MARKDOWN
1. Step 1
@@ -48,7 +48,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
MARKDOWN
page
- }
+ end
before do
login_as(user)
@@ -59,7 +59,7 @@ describe 'Wysiwyg paragraphs in lists behavior (Regression #28765)',
end
it 'shows the list correctly' do
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_selector('ol li', count: 3)
expect(editable).to have_no_selector('ol li p')
end
diff --git a/spec/features/wysiwyg/tables_spec.rb b/spec/features/wysiwyg/tables_spec.rb
index 6c9b498936..2a29cb30cf 100644
--- a/spec/features/wysiwyg/tables_spec.rb
+++ b/spec/features/wysiwyg/tables_spec.rb
@@ -130,7 +130,7 @@ describe 'Wysiwyg tables',
# Edit again
click_on 'Edit'
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
# Table should still have header
expect(editable).to have_selector('th', count: 2)
expect(editable).to have_selector('td', count: 2)
@@ -194,7 +194,7 @@ describe 'Wysiwyg tables',
# Edit again
click_on 'Edit'
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_selector('td[style*="background-color:#123456"]')
# Change table styles
@@ -250,7 +250,7 @@ describe 'Wysiwyg tables',
click_on 'Edit'
# Expect all previous changes to be there
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_selector('td[style*="background-color:#123456"]')
# table height and width is set on figure
@@ -295,7 +295,6 @@ describe 'Wysiwyg tables',
find('.ck-button-save').click
expect(editable).to have_selector('td[style*="width:250px"]')
-
end
# Save wiki page
@@ -311,14 +310,14 @@ describe 'Wysiwyg tables',
# Edit again
click_on 'Edit'
- editor.in_editor do |container, editable|
+ editor.in_editor do |_container, editable|
expect(editable).to have_selector('td[style*="width:250px"]')
end
end
end
describe 'editing a wiki page with tables' do
- let(:wiki_page) {
+ let(:wiki_page) do
page = FactoryBot.build :wiki_page_with_content,
title: 'Wiki page with titles'
page.content.text = <<~MARKDOWN
@@ -346,7 +345,7 @@ describe 'Wysiwyg tables',
MARKDOWN
page
- }
+ end
before do
project.wiki.pages << wiki_page
diff --git a/spec/features/wysiwyg/work_package_linking_spec.rb b/spec/features/wysiwyg/work_package_linking_spec.rb
index 440f0dde9f..14f50469ea 100644
--- a/spec/features/wysiwyg/work_package_linking_spec.rb
+++ b/spec/features/wysiwyg/work_package_linking_spec.rb
@@ -45,7 +45,6 @@ describe 'Wysiwyg work package linking',
end
it 'can reference work packages' do
-
# single hash autocomplete
editor.click_and_type_slowly "##{work_package.id}"
editor.click_autocomplete work_package.subject
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 5b4ed9f2f2..926112f2c3 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -57,7 +57,9 @@ describe ApplicationHelper, type: :helper do
OpenProject::Footer.content = nil
end
- it { expect(footer_content).to eq(I18n.t(:text_powered_by, link: link_to(OpenProject::Info.app_name, OpenProject::Info.url))) }
+ it {
+ expect(footer_content).to eq(I18n.t(:text_powered_by, link: link_to(OpenProject::Info.app_name, OpenProject::Info.url)))
+ }
end
context 'string as additional footer content' do
@@ -66,8 +68,11 @@ describe ApplicationHelper, type: :helper do
OpenProject::Footer.add_content('openproject', 'footer')
end
- it { expect(footer_content.include?(I18n.t(:text_powered_by, link: link_to(OpenProject::Info.app_name, OpenProject::Info.url)))).to be_truthy }
- it { expect(footer_content.include?("")).to be_truthy }
+ it {
+ expect(footer_content.include?(I18n.t(:text_powered_by,
+ link: link_to(OpenProject::Info.app_name, OpenProject::Info.url)))).to be_truthy
+ }
+ it { expect(footer_content.include?("")).to be_truthy }
end
context 'proc as additional footer content' do
@@ -76,7 +81,9 @@ describe ApplicationHelper, type: :helper do
OpenProject::Footer.add_content('openproject', Proc.new { Date.parse(Time.now.to_s) })
end
- it { expect(footer_content.include?("")).to be_truthy }
+ it {
+ expect(footer_content.include?("")).to be_truthy
+ }
end
context 'proc which returns nothing' do
@@ -91,19 +98,19 @@ describe ApplicationHelper, type: :helper do
describe '.link_to_if_authorized' do
let(:project) { FactoryBot.create :valid_project }
- let(:project_member) {
+ let(:project_member) do
FactoryBot.create :user,
- member_in_project: project,
- member_through_role: FactoryBot.create(:role,
- permissions: [:view_work_packages, :edit_work_packages,
- :browse_repository, :view_changesets, :view_wiki_pages])
- }
- let(:issue) {
+ member_in_project: project,
+ member_through_role: FactoryBot.create(:role,
+ permissions: %i[view_work_packages edit_work_packages
+ browse_repository view_changesets view_wiki_pages])
+ end
+ let(:issue) do
FactoryBot.create :work_package,
- project: project,
- author: project_member,
- type: project.types.first
- }
+ project: project,
+ author: project_member,
+ type: project.types.first
+ end
context 'if user is authorized' do
before do
@@ -111,7 +118,8 @@ describe ApplicationHelper, type: :helper do
@response = link_to_if_authorized('link_content', {
controller: 'work_packages',
action: 'show',
- id: issue },
+ id: issue
+ },
class: 'fancy_css_class')
end
@@ -128,7 +136,8 @@ describe ApplicationHelper, type: :helper do
@response = link_to_if_authorized('link_content', {
controller: 'work_packages',
action: 'show',
- id: issue },
+ id: issue
+ },
class: 'fancy_css_class')
end
@@ -157,7 +166,9 @@ describe ApplicationHelper, type: :helper do
before do
@links = other_formats_links { |f| f.link_to 'Atom', url: { controller: :projects, action: :index } }
end
- it { expect(@links).to be_html_eql("Also available in:Atom
") }
+ it {
+ expect(@links).to be_html_eql("Also available in:Atom
")
+ }
end
context 'link given but disabled' do
@@ -184,19 +195,19 @@ describe ApplicationHelper, type: :helper do
context 'right now' do
let(:time) { Time.now }
- it { is_expected.to match /^\token and another token .' }
+ let(:expected_title) do
+ 'This is a token and another token .'
+ end
it { is_expected.to eq expected_title }
end
@@ -78,7 +80,9 @@ describe 'search/index', type: :helper do
context 'with multibyte title' do
let(:tokens) { %w(token) }
let(:title) { ('й' * 200) + ' token ' + ('й' * 200) }
- let(:expected_title) { ('й' * 45) + ' ... ' + ('й' * 44) + ' token ' + ('й' * 44) + ' ... ' + ('й' * 45) }
+ let(:expected_title) do
+ ('й' * 45) + ' ... ' + ('й' * 44) + ' token ' + ('й' * 44) + ' ... ' + ('й' * 45)
+ end
it { is_expected.to eq expected_title }
end
diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb
index 9522c91a4a..390a32eda9 100644
--- a/spec/helpers/settings_helper_spec.rb
+++ b/spec/helpers/settings_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -40,9 +41,9 @@ describe SettingsHelper, type: :helper do
expect(Setting).to receive(:field).and_return('2')
end
- subject(:output) {
+ subject(:output) do
helper.setting_select :field, [['Popsickle', '1'], ['Jello', '2'], ['Ice Cream', '3']], options
- }
+ end
it_behaves_like 'labelled by default'
it_behaves_like 'wrapped in field-container by default'
@@ -59,9 +60,9 @@ describe SettingsHelper, type: :helper do
expect(Setting).to receive(:field).at_least(:once).and_return('1')
end
- subject(:output) {
+ subject(:output) do
helper.setting_multiselect :field, [['Popsickle', '1'], ['Jello', '2'], ['Ice Cream', '3']], options
- }
+ end
it_behaves_like 'wrapped in container' do
let(:container_count) { 3 }
@@ -86,8 +87,8 @@ describe SettingsHelper, type: :helper do
expect(Setting).to receive(:field_b).at_least(:once).and_return('3')
end
- subject(:output) {
- settings = [:field_a, :field_b]
+ subject(:output) do
+ settings = %i[field_a field_b]
choices = [
{
caption: 'Popsickle',
@@ -106,7 +107,7 @@ describe SettingsHelper, type: :helper do
}
]
helper.settings_matrix settings, choices
- }
+ end
it_behaves_like 'not wrapped in container'
@@ -159,9 +160,9 @@ describe SettingsHelper, type: :helper do
expect(Setting).to receive(:field).and_return('important value')
end
- subject(:output) {
+ subject(:output) do
helper.setting_text_field :field, options
- }
+ end
it_behaves_like 'labelled by default'
it_behaves_like 'wrapped in field-container by default'
@@ -180,9 +181,9 @@ describe SettingsHelper, type: :helper do
expect(Setting).to receive(:field).and_return('important text')
end
- subject(:output) {
+ subject(:output) do
helper.setting_text_area :field, options
- }
+ end
it_behaves_like 'labelled by default'
it_behaves_like 'wrapped in field-container by default'
@@ -197,9 +198,9 @@ important text
end
describe '#setting_check_box' do
- subject(:output) {
+ subject(:output) do
helper.setting_check_box :field, options
- }
+ end
context 'when setting is true' do
before do
@@ -233,9 +234,9 @@ important text
end
describe '#setting_label' do
- subject(:output) {
+ subject(:output) do
helper.setting_label :field
- }
+ end
it_behaves_like 'labelled'
it_behaves_like 'not wrapped in container'
@@ -246,9 +247,9 @@ important text
expect(Setting).to receive(:notified_events).and_return(%w(interesting_stuff))
end
- subject(:output) {
+ subject(:output) do
helper.notification_field(notifiable, options)
- }
+ end
context 'when setting includes option' do
let(:notifiable) { OpenStruct.new(name: 'interesting_stuff') }
diff --git a/spec/helpers/sort_helper_spec.rb b/spec/helpers/sort_helper_spec.rb
index 0ed0881169..fd57324b8c 100644
--- a/spec/helpers/sort_helper_spec.rb
+++ b/spec/helpers/sort_helper_spec.rb
@@ -30,16 +30,16 @@ require 'spec_helper'
describe SortHelper, type: :helper do
describe '#sort_header_tag' do
- let(:output) {
+ let(:output) do
helper.sort_header_tag('id')
- }
+ end
let(:sort_key) { '' }
let(:sort_asc) { true }
- let(:sort_criteria) {
+ let(:sort_criteria) do
double('sort_criteria', first_key: sort_key,
first_asc?: sort_asc,
to_param: 'sort_criteria_params').as_null_object
- }
+ end
before do
# helper relies on this instance var
diff --git a/spec/helpers/tabs_helper_spec.rb b/spec/helpers/tabs_helper_spec.rb
index c518d58c8b..ccf1b14255 100644
--- a/spec/helpers/tabs_helper_spec.rb
+++ b/spec/helpers/tabs_helper_spec.rb
@@ -31,31 +31,31 @@ require 'spec_helper'
describe TabsHelper, type: :helper do
include TabsHelper
- let(:given_tab) {
+ let(:given_tab) do
{ name: 'avatar',
partial: 'avatars/users/avatar_tab',
path: ->(params) { tab_edit_user_path(params[:user], tab: :avatar) },
label: :label_avatar }
- }
+ end
- let(:expected_tab) {
+ let(:expected_tab) do
{ name: 'avatar',
partial: 'avatars/users/avatar_tab',
path: '/users/2/edit/avatar',
label: :label_avatar }
- }
+ end
describe 'render_extensible_tabs' do
before do
allow_any_instance_of(TabsHelper)
.to receive(:render_tabs)
- .with([ expected_tab ])
- .and_return [ expected_tab ]
+ .with([expected_tab])
+ .and_return [expected_tab]
allow(::OpenProject::Ui::ExtensibleTabs)
.to receive(:enabled_tabs)
.with(:user)
- .and_return [ given_tab ]
+ .and_return [given_tab]
user = FactoryBot.build(:user, id: 2)
@tabs = render_extensible_tabs(:user, user: user)
@@ -63,7 +63,7 @@ describe TabsHelper, type: :helper do
it "should return an evaluated path" do
expect(response.status).to eq 200
- expect(@tabs).to eq([ expected_tab ])
+ expect(@tabs).to eq([expected_tab])
end
end
end
diff --git a/spec/helpers/text_formatting_helper_spec.rb b/spec/helpers/text_formatting_helper_spec.rb
index 004824f237..7bb26c100f 100644
--- a/spec/helpers/text_formatting_helper_spec.rb
+++ b/spec/helpers/text_formatting_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/helpers/toolbar_helper_spec.rb b/spec/helpers/toolbar_helper_spec.rb
index 428d743add..d4480ee08b 100644
--- a/spec/helpers/toolbar_helper_spec.rb
+++ b/spec/helpers/toolbar_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/helpers/versions_helper_spec.rb b/spec/helpers/versions_helper_spec.rb
index 4e14bf65a6..e377ac9137 100644
--- a/spec/helpers/versions_helper_spec.rb
+++ b/spec/helpers/versions_helper_spec.rb
@@ -98,7 +98,8 @@ describe VersionsHelper, type: :helper do
end
it 'generates an option tag' do
- expect(version_options_for_select([], version)).to eq("#{version.name} ")
+ expect(version_options_for_select([],
+ version)).to eq("#{version.name} ")
end
end
end
diff --git a/spec/helpers/work_packages_helper_spec.rb b/spec/helpers/work_packages_helper_spec.rb
index 418324326a..e495ab7801 100644
--- a/spec/helpers/work_packages_helper_spec.rb
+++ b/spec/helpers/work_packages_helper_spec.rb
@@ -45,14 +45,18 @@ describe WorkPackagesHelper, type: :helper do
describe 'without parameters' do
it 'should return a link to the work package with the id as the text' do
link_text = Regexp.new("^##{stub_work_package.id}$")
- expect(helper.link_to_work_package(stub_work_package)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package)).to have_selector(
+ "a[href='#{work_package_path(stub_work_package)}']", text: link_text
+ )
end
it 'should return a link to the work package with type and id as the text if type is set' do
stub_work_package.type = stub_type
link_text = Regexp.new("^#{stub_type.name} ##{stub_work_package.id}$")
- expect(helper.link_to_work_package(stub_work_package)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package)).to have_selector(
+ "a[href='#{work_package_path(stub_work_package)}']", text: link_text
+ )
end
it 'should additionally return the subject' do
@@ -72,7 +76,10 @@ describe WorkPackagesHelper, type: :helper do
stub_work_package.type = stub_type
link_text = Regexp.new("^#{stub_type} ##{stub_work_package.id}: #{stub_work_package.subject}$")
- expect(helper.link_to_work_package(stub_work_package, all_link: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package,
+ all_link: true)).to have_selector(
+ "a[href='#{work_package_path(stub_work_package)}']", text: link_text
+ )
end
end
@@ -103,7 +110,9 @@ describe WorkPackagesHelper, type: :helper do
stub_work_package.type = stub_type
link_text = Regexp.new("^##{stub_work_package.id}$")
- expect(helper.link_to_work_package(stub_work_package, type: false)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package,
+ type: false)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
+ text: link_text)
end
end
@@ -128,7 +137,9 @@ describe WorkPackagesHelper, type: :helper do
stub_work_package.type = stub_type
link_text = Regexp.new("^##{stub_work_package.id}$")
- expect(helper.link_to_work_package(stub_work_package, id_only: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package,
+ id_only: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
+ text: link_text)
end
it 'should not have the subject as text' do
@@ -139,7 +150,10 @@ describe WorkPackagesHelper, type: :helper do
describe 'when only wanting the subject' do
it 'should return a link with the subject as text' do
link_text = Regexp.new("^#{stub_work_package.subject}$")
- expect(helper.link_to_work_package(stub_work_package, subject_only: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package,
+ subject_only: true)).to have_selector(
+ "a[href='#{work_package_path(stub_work_package)}']", text: link_text
+ )
end
end
@@ -148,7 +162,9 @@ describe WorkPackagesHelper, type: :helper do
stub_work_package.type = stub_type
link_text = Regexp.new("^#{stub_type.name} ##{stub_work_package.id} #{stub_work_package.status}$")
- expect(helper.link_to_work_package(stub_work_package, status: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']", text: link_text)
+ expect(helper.link_to_work_package(stub_work_package,
+ status: true)).to have_selector("a[href='#{work_package_path(stub_work_package)}']",
+ text: link_text)
end
end
end
@@ -157,11 +173,11 @@ describe WorkPackagesHelper, type: :helper do
let(:statuses) { (1..5).map { |_i| FactoryBot.build_stubbed(:status) } }
let(:priority) { FactoryBot.build_stubbed :priority, is_default: true }
let(:status) { statuses[0] }
- let(:stub_work_package) {
+ let(:stub_work_package) do
FactoryBot.build_stubbed(:work_package,
- status: status,
- priority: priority)
- }
+ status: status,
+ priority: priority)
+ end
it 'should always have the work_package class' do
expect(helper.work_package_css_classes(stub_work_package)).to include('work_package')
diff --git a/spec/lib/acts_as_watchable/lib/acts_as_watchable/routes_spec.rb b/spec/lib/acts_as_watchable/lib/acts_as_watchable/routes_spec.rb
index c317bd2be3..53bdbd33b4 100644
--- a/spec/lib/acts_as_watchable/lib/acts_as_watchable/routes_spec.rb
+++ b/spec/lib/acts_as_watchable/lib/acts_as_watchable/routes_spec.rb
@@ -29,13 +29,13 @@
require 'spec_helper'
describe OpenProject::Acts::Watchable::Routes do
- let(:request) {
+ let(:request) do
Struct.new(:type, :id) do
def path_parameters
{ object_id: id, object_type: type }
end
end.new(type, id)
- }
+ end
describe 'matches?' do
shared_examples_for 'watched model' do
diff --git a/spec/lib/api/decorators/link_object_spec.rb b/spec/lib/api/decorators/link_object_spec.rb
index 73dc4d1b8b..bee8ef495b 100644
--- a/spec/lib/api/decorators/link_object_spec.rb
+++ b/spec/lib/api/decorators/link_object_spec.rb
@@ -50,11 +50,11 @@ describe ::API::Decorators::LinkObject do
describe 'parsing' do
subject { represented }
- let(:parsed_hash) {
+ let(:parsed_hash) do
{
'href' => '/api/v3/foos/42'
}
- }
+ end
it 'parses the id from the URL' do
representer.from_hash parsed_hash
@@ -62,29 +62,30 @@ describe ::API::Decorators::LinkObject do
end
context 'wrong namespace' do
- let(:parsed_hash) {
+ let(:parsed_hash) do
{
'href' => '/api/v3/bars/42'
}
- }
+ end
it 'throws an error' do
expect { representer.from_hash parsed_hash }.to raise_error(
- ::API::Errors::InvalidResourceLink)
+ ::API::Errors::InvalidResourceLink
+ )
end
end
end
end
context 'full constructor call' do
- let(:representer) {
+ let(:representer) do
described_class.new(represented,
property_name: :foo,
path: :foo_path,
namespace: 'fuhs',
getter: :getter,
setter: :'setter=')
- }
+ end
before do
represented.getter = 1
@@ -100,11 +101,11 @@ describe ::API::Decorators::LinkObject do
describe 'parsing' do
subject { represented }
- let(:parsed_hash) {
+ let(:parsed_hash) do
{
'href' => '/api/v3/fuhs/42'
}
- }
+ end
it 'parses the id from the URL' do
representer.from_hash parsed_hash
@@ -112,15 +113,16 @@ describe ::API::Decorators::LinkObject do
end
context 'wrong namespace' do
- let(:parsed_hash) {
+ let(:parsed_hash) do
{
'href' => '/api/v3/foos/42'
}
- }
+ end
it 'throws an error' do
expect { representer.from_hash parsed_hash }.to raise_error(
- ::API::Errors::InvalidResourceLink)
+ ::API::Errors::InvalidResourceLink
+ )
end
end
end
diff --git a/spec/lib/api/utilities/page_size_helper.rb b/spec/lib/api/utilities/page_size_helper.rb
index d3e81ed870..c97b00ed9d 100644
--- a/spec/lib/api/utilities/page_size_helper.rb
+++ b/spec/lib/api/utilities/page_size_helper.rb
@@ -39,7 +39,6 @@ describe ::API::Utilities::PageSizeHelper do
describe '#maximum_page_size' do
context 'when small values in per_page_options',
with_settings: { per_page_options: '20,100' } do
-
it 'uses the magical number 500' do
expect(subject.maximum_page_size).to eq(500)
end
@@ -47,7 +46,6 @@ describe ::API::Utilities::PageSizeHelper do
context 'when larger values in per_page_options',
with_settings: { per_page_options: '20,100,1000' } do
-
it 'uses that value' do
expect(subject.maximum_page_size).to eq(1000)
end
diff --git a/spec/lib/api/utilities/resource_link_parser_spec.rb b/spec/lib/api/utilities/resource_link_parser_spec.rb
index 7f6c1f3734..7680c7b565 100644
--- a/spec/lib/api/utilities/resource_link_parser_spec.rb
+++ b/spec/lib/api/utilities/resource_link_parser_spec.rb
@@ -111,46 +111,46 @@ describe ::API::Utilities::ResourceLinkParser do
end
it 'accepts on matching version' do
- expect {
+ expect do
subject.parse_id('/api/v3/statuses/14', property: 'foo', expected_version: '3')
- }.not_to raise_error
+ end.not_to raise_error
end
it 'accepts on matching version as integer' do
- expect {
+ expect do
subject.parse_id('/api/v3/statuses/14', property: 'foo', expected_version: 3)
- }.not_to raise_error
+ end.not_to raise_error
end
it 'accepts on matching namespace' do
- expect {
+ expect do
subject.parse_id('/api/v3/statuses/14', property: 'foo', expected_namespace: 'statuses')
- }.not_to raise_error
+ end.not_to raise_error
end
it 'accepts on matching namespace as symbol' do
- expect {
+ expect do
subject.parse_id('/api/v3/statuses/14', property: 'foo', expected_namespace: :statuses)
- }.not_to raise_error
+ end.not_to raise_error
end
it 'raises on version mismatch' do
- expect {
+ expect do
subject.parse_id('/api/v4/statuses/14', property: 'foo', expected_version: '3')
- }.to raise_error(::API::Errors::InvalidResourceLink)
+ end.to raise_error(::API::Errors::InvalidResourceLink)
end
it 'raises on namespace mismatch' do
- expect {
+ expect do
subject.parse_id('/api/v3/types/14', property: 'foo', expected_namespace: 'statuses')
- }.to raise_error(::API::Errors::InvalidResourceLink)
+ end.to raise_error(::API::Errors::InvalidResourceLink)
end
it 'contains the property name in exception messages' do
property_name = 'My Property Name'
- expect {
+ expect do
subject.parse_id('/api/v4/statuses/14', property: property_name, expected_version: '3')
- }.to raise_error(Regexp.compile(property_name))
+ end.to raise_error(Regexp.compile(property_name))
end
end
end
diff --git a/spec/lib/api/v3/attachments/attachment_metadata_representer_spec.rb b/spec/lib/api/v3/attachments/attachment_metadata_representer_spec.rb
index 1f8ea1ac4d..1ea8f18f73 100644
--- a/spec/lib/api/v3/attachments/attachment_metadata_representer_spec.rb
+++ b/spec/lib/api/v3/attachments/attachment_metadata_representer_spec.rb
@@ -68,7 +68,7 @@ describe ::API::V3::Attachments::AttachmentMetadataRepresenter do
end
describe 'parsing' do
- let(:parsed_hash) {
+ let(:parsed_hash) do
{
'fileName' => 'the parsed name',
'description' => { 'raw' => 'the parsed description' },
@@ -76,7 +76,7 @@ describe ::API::V3::Attachments::AttachmentMetadataRepresenter do
'fileSize' => 43,
'digest' => '0x00'
}
- }
+ end
subject { metadata }
diff --git a/spec/lib/api/v3/categories/category_collection_representer_spec.rb b/spec/lib/api/v3/categories/category_collection_representer_spec.rb
index 530e2e2167..9bf18db55e 100644
--- a/spec/lib/api/v3/categories/category_collection_representer_spec.rb
+++ b/spec/lib/api/v3/categories/category_collection_representer_spec.rb
@@ -30,11 +30,11 @@ require 'spec_helper'
describe ::API::V3::Categories::CategoryCollectionRepresenter do
let(:categories) { FactoryBot.build_list(:category, 3) }
- let(:representer) {
+ let(:representer) do
described_class.new(categories,
self_link: '/api/v3/projects/1/categories',
current_user: double('current_user'))
- }
+ end
context 'generation' do
subject(:collection) { representer.to_json }
diff --git a/spec/lib/api/v3/categories/category_representer_spec.rb b/spec/lib/api/v3/categories/category_representer_spec.rb
index cf212c14c2..3cfe6f8024 100644
--- a/spec/lib/api/v3/categories/category_representer_spec.rb
+++ b/spec/lib/api/v3/categories/category_representer_spec.rb
@@ -66,9 +66,9 @@ describe ::API::V3::Categories::CategoryRepresenter do
end
context 'default assignee set' do
- let(:category) {
+ let(:category) do
FactoryBot.build_stubbed(:category, assigned_to: user)
- }
+ end
it_behaves_like 'category has core values'
it 'should link to its default assignee' do
diff --git a/spec/lib/api/v3/posts/post_representer_rendering_spec.rb b/spec/lib/api/v3/posts/post_representer_rendering_spec.rb
index 8f176c7153..a34ada8a44 100644
--- a/spec/lib/api/v3/posts/post_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/posts/post_representer_rendering_spec.rb
@@ -50,7 +50,7 @@ describe ::API::V3::Posts::PostRepresenter, 'rendering' do
before do
allow(user)
- .to receive(:allowed_to?) do |permission, project|
+ .to receive(:allowed_to?) do |permission, _project|
permissions.include?(permission)
end
end
diff --git a/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb b/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb
index e168b52d39..e130b5e235 100644
--- a/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb
+++ b/spec/lib/api/v3/priorities/priority_collection_representer_spec.rb
@@ -30,9 +30,9 @@ require 'spec_helper'
describe ::API::V3::Priorities::PriorityCollectionRepresenter do
let(:priorities) { FactoryBot.build_list(:priority, 3) }
- let(:representer) {
+ let(:representer) do
described_class.new(priorities, self_link: '/api/v3/priorities', current_user: double('current_user'))
- }
+ end
context 'generation' do
subject(:collection) { representer.to_json }
diff --git a/spec/lib/api/v3/projects/project_collection_representer_spec.rb b/spec/lib/api/v3/projects/project_collection_representer_spec.rb
index 720e41418e..0d54b0e2c7 100644
--- a/spec/lib/api/v3/projects/project_collection_representer_spec.rb
+++ b/spec/lib/api/v3/projects/project_collection_representer_spec.rb
@@ -32,9 +32,9 @@ describe ::API::V3::Projects::ProjectCollectionRepresenter do
let(:self_link) { '/api/v3/versions/1/projects' }
let(:projects) { FactoryBot.build_list(:project, 3) }
let(:current_user) { FactoryBot.build(:user) }
- let(:representer) {
+ let(:representer) do
described_class.new(projects, self_link: self_link, current_user: current_user)
- }
+ end
context 'generation' do
subject(:collection) { representer.to_json }
diff --git a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
index 8eb7969165..2d6dc4e585 100644
--- a/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
+++ b/spec/lib/api/v3/queries/filters/query_filter_instance_representer_spec.rb
@@ -150,7 +150,6 @@ describe ::API::V3::Queries::Filters::QueryFilterInstanceRepresenter do
subproject
project.reload
-
f = Queries::WorkPackages::Filter::SubprojectFilter.create!(context: project)
f.operator = '='
f.values = [subproject.id]
diff --git a/spec/lib/api/v3/queries/query_representer_generation_spec.rb b/spec/lib/api/v3/queries/query_representer_generation_spec.rb
index 98c1c5a922..5882ee6ecd 100644
--- a/spec/lib/api/v3/queries/query_representer_generation_spec.rb
+++ b/spec/lib/api/v3/queries/query_representer_generation_spec.rb
@@ -90,7 +90,8 @@ describe ::API::V3::Queries::QueryRepresenter do
context 'with params' do
let(:representer) do
- described_class.new(query, current_user: user, embed_links: embed_links, params: { "filters" => "something", "id" => "234" })
+ described_class.new(query, current_user: user, embed_links: embed_links,
+ params: { "filters" => "something", "id" => "234" })
end
it_behaves_like 'has a titled link' do
@@ -462,7 +463,7 @@ describe ::API::V3::Queries::QueryRepresenter do
context 'with sort_by' do
let(:query) do
FactoryBot.build_stubbed(:query,
- sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']])
+ sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']])
end
it 'has an array of sortBy' do
@@ -764,7 +765,7 @@ describe ::API::V3::Queries::QueryRepresenter do
describe 'with sort criteria' do
let(:query) do
FactoryBot.build_stubbed(:query,
- sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']])
+ sort_criteria: [['subject', 'asc'], ['assigned_to', 'desc']])
end
it 'has the sort criteria embedded' do
diff --git a/spec/lib/api/v3/queries/schemas/project_filter_dependency_representer_spec.rb b/spec/lib/api/v3/queries/schemas/project_filter_dependency_representer_spec.rb
index 1f5a1b8a7c..960a9c27be 100644
--- a/spec/lib/api/v3/queries/schemas/project_filter_dependency_representer_spec.rb
+++ b/spec/lib/api/v3/queries/schemas/project_filter_dependency_representer_spec.rb
@@ -48,7 +48,7 @@ describe ::API::V3::Queries::Schemas::ProjectFilterDependencyRepresenter, clear_
let(:path) { 'values' }
let(:type) { '[]Project' }
let(:filters) { "?filters=%5B%7B%22active%22%3A%7B%22operator%22%3A%22%3D%22%2C%22values%22%3A%5B%22t%22%5D%7D%7D%5D" }
- let(:href) { api_v3_paths.projects + filters}
+ let(:href) { api_v3_paths.projects + filters }
context "for operator 'Queries::Operators::Equals'" do
let(:operator) { Queries::Operators::Equals }
diff --git a/spec/lib/api/v3/relations/relation_collection_representer_spec.rb b/spec/lib/api/v3/relations/relation_collection_representer_spec.rb
index cc5bd5abf3..1e5c5143e7 100644
--- a/spec/lib/api/v3/relations/relation_collection_representer_spec.rb
+++ b/spec/lib/api/v3/relations/relation_collection_representer_spec.rb
@@ -36,8 +36,8 @@ describe ::API::V3::Relations::RelationCollectionRepresenter do
let(:relations) do
(1..3).map do
FactoryBot.build_stubbed(:relation,
- from: work_package,
- to: FactoryBot.build_stubbed(:work_package))
+ from: work_package,
+ to: FactoryBot.build_stubbed(:work_package))
end
end
diff --git a/spec/lib/api/v3/repositories/revision_representer_spec.rb b/spec/lib/api/v3/repositories/revision_representer_spec.rb
index a19e0ab578..3928d98b33 100644
--- a/spec/lib/api/v3/repositories/revision_representer_spec.rb
+++ b/spec/lib/api/v3/repositories/revision_representer_spec.rb
@@ -35,16 +35,15 @@ describe ::API::V3::Repositories::RevisionRepresenter do
let(:project) { FactoryBot.build :project }
let(:repository) { FactoryBot.build :repository_subversion, project: project }
- let(:revision) {
+ let(:revision) do
FactoryBot.build(:changeset,
- id: 42,
- revision: '1234',
- repository: repository,
- comments: commit_message,
- committer: 'foo bar ',
- committed_on: DateTime.now,
- )
- }
+ id: 42,
+ revision: '1234',
+ repository: repository,
+ comments: commit_message,
+ committer: 'foo bar ',
+ committed_on: DateTime.now)
+ end
let(:commit_message) { 'Some commit message' }
@@ -91,14 +90,14 @@ describe ::API::V3::Repositories::RevisionRepresenter do
context 'with referencing commit message' do
let(:work_package) { FactoryBot.build_stubbed(:work_package, project: project) }
let(:commit_message) { "Totally references ##{work_package.id}" }
- let(:html_reference) {
+ let(:html_reference) do
id = work_package.id
str = 'Totally references "
str << "##{id} "
- }
+ end
before do
allow(User).to receive(:current).and_return(FactoryBot.build_stubbed(:admin))
diff --git a/spec/lib/api/v3/statuses/status_collection_representer_spec.rb b/spec/lib/api/v3/statuses/status_collection_representer_spec.rb
index 12b8314533..4b62a48ab1 100644
--- a/spec/lib/api/v3/statuses/status_collection_representer_spec.rb
+++ b/spec/lib/api/v3/statuses/status_collection_representer_spec.rb
@@ -31,10 +31,10 @@ require 'spec_helper'
describe ::API::V3::Statuses::StatusCollectionRepresenter do
include API::V3::Utilities::PathHelper
- let(:statuses) { FactoryBot.build_list(:status, 3) }
- let(:representer) {
+ let(:statuses) { FactoryBot.build_list(:status, 3) }
+ let(:representer) do
described_class.new(statuses, self_link: api_v3_paths.statuses, current_user: double('current_user'))
- }
+ end
context 'generation' do
subject(:collection) { representer.to_json }
diff --git a/spec/lib/api/v3/support/api_v3_filter_dependency.rb b/spec/lib/api/v3/support/api_v3_filter_dependency.rb
index 93bbf5c431..d4da13a826 100644
--- a/spec/lib/api/v3/support/api_v3_filter_dependency.rb
+++ b/spec/lib/api/v3/support/api_v3_filter_dependency.rb
@@ -84,7 +84,6 @@ shared_examples_for 'filter dependency empty' do
end
end
-
shared_examples_for 'relation filter dependency' do
include ::API::V3::Utilities::PathHelper
diff --git a/spec/lib/api/v3/support/link_examples.rb b/spec/lib/api/v3/support/link_examples.rb
index e41e38ccb4..21a452b136 100644
--- a/spec/lib/api/v3/support/link_examples.rb
+++ b/spec/lib/api/v3/support/link_examples.rb
@@ -42,7 +42,7 @@ shared_examples_for 'action link' do
before do
login_as(user)
allow(user)
- .to receive(:allowed_to?) do |permission, project|
+ .to receive(:allowed_to?) do |permission, _project|
permissions.include?(permission)
end
end
@@ -81,12 +81,12 @@ shared_context 'action link shared' do
it 'indicates the desired method' do
verb = begin
- # the standard method #method on an object interferes
- # with the let named 'method' conditionally defined
- method
- rescue ArgumentError
- :get
- end
+ # the standard method #method on an object interferes
+ # with the let named 'method' conditionally defined
+ method
+ rescue ArgumentError
+ :get
+ end
if verb != :get
is_expected
diff --git a/spec/lib/api/v3/support/property_examples.rb b/spec/lib/api/v3/support/property_examples.rb
index 40c3a95833..45fd1f52d2 100644
--- a/spec/lib/api/v3/support/property_examples.rb
+++ b/spec/lib/api/v3/support/property_examples.rb
@@ -38,7 +38,7 @@ shared_examples_for 'formattable property' do |name|
it "has the #{name} property" do
is_expected
.to be_json_eql(value.to_json)
- .at_path("#{name.to_s}/raw")
+ .at_path("#{name}/raw")
end
end
diff --git a/spec/lib/api/v3/users/user_collection_representer_spec.rb b/spec/lib/api/v3/users/user_collection_representer_spec.rb
index 801c977a79..eab799dc09 100644
--- a/spec/lib/api/v3/users/user_collection_representer_spec.rb
+++ b/spec/lib/api/v3/users/user_collection_representer_spec.rb
@@ -29,15 +29,15 @@
require 'spec_helper'
describe ::API::V3::Users::UserCollectionRepresenter do
- let(:users) {
+ let(:users) do
FactoryBot.build_stubbed_list(:user,
- 3)
- }
- let(:representer) {
+ 3)
+ end
+ let(:representer) do
described_class.new(users,
self_link: '/api/v3/work_package/1/watchers',
current_user: users.first)
- }
+ end
context 'generation' do
subject(:collection) { representer.to_json }
diff --git a/spec/lib/api/v3/utilities/date_time_formatter_spec.rb b/spec/lib/api/v3/utilities/date_time_formatter_spec.rb
index b0191b7745..608535a44f 100644
--- a/spec/lib/api/v3/utilities/date_time_formatter_spec.rb
+++ b/spec/lib/api/v3/utilities/date_time_formatter_spec.rb
@@ -77,16 +77,16 @@ describe :DateTimeFormatter do
it 'rejects parsing non ISO date formats' do
bad_format = date.strftime('%d.%m.%Y')
- expect {
+ expect do
subject.parse_date(bad_format, 'prop')
- }.to raise_error(API::Errors::PropertyFormatError)
+ end.to raise_error(API::Errors::PropertyFormatError)
end
it 'rejects parsing ISO 8601 date + time formats' do
bad_format = datetime.iso8601
- expect {
+ expect do
subject.parse_date(bad_format, 'prop')
- }.to raise_error(API::Errors::PropertyFormatError)
+ end.to raise_error(API::Errors::PropertyFormatError)
end
it_behaves_like 'can parse nil' do
@@ -147,21 +147,21 @@ describe :DateTimeFormatter do
end
it 'rejects parsing non sense' do
- expect {
+ expect do
subject.parse_duration_to_hours('foo', 'prop')
- }.to raise_error(API::Errors::PropertyFormatError)
+ end.to raise_error(API::Errors::PropertyFormatError)
end
it 'rejects parsing pure number strings' do
- expect {
+ expect do
subject.parse_duration_to_hours('5', 'prop')
- }.to raise_error(API::Errors::PropertyFormatError)
+ end.to raise_error(API::Errors::PropertyFormatError)
end
it 'rejects parsing pure numbers' do
- expect {
+ expect do
subject.parse_duration_to_hours(5, 'prop')
- }.to raise_error(API::Errors::PropertyFormatError)
+ end.to raise_error(API::Errors::PropertyFormatError)
end
it_behaves_like 'can parse nil' do
diff --git a/spec/lib/api/v3/utilities/resource_link_generator_spec.rb b/spec/lib/api/v3/utilities/resource_link_generator_spec.rb
index 9ef9e98fc4..9485f39187 100644
--- a/spec/lib/api/v3/utilities/resource_link_generator_spec.rb
+++ b/spec/lib/api/v3/utilities/resource_link_generator_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -36,32 +37,32 @@ describe API::V3::Utilities::ResourceLinkGenerator do
describe ':make_link' do
it 'supports work packages' do
wp = FactoryBot.build_stubbed(:work_package)
- expect(subject.make_link wp).to eql api_v3_paths.work_package(wp.id)
+ expect(subject.make_link(wp)).to eql api_v3_paths.work_package(wp.id)
end
it 'supports priorities' do
prio = FactoryBot.build_stubbed(:priority)
- expect(subject.make_link prio).to eql api_v3_paths.priority(prio.id)
+ expect(subject.make_link(prio)).to eql api_v3_paths.priority(prio.id)
end
it 'supports statuses' do
status = FactoryBot.build_stubbed(:status)
- expect(subject.make_link status).to eql api_v3_paths.status(status.id)
+ expect(subject.make_link(status)).to eql api_v3_paths.status(status.id)
end
it 'supports the anonymous user' do
user = FactoryBot.build_stubbed(:anonymous)
- expect(subject.make_link user).to eql api_v3_paths.user(user.id)
+ expect(subject.make_link(user)).to eql api_v3_paths.user(user.id)
end
it 'returns nil for unsupported records' do
record = FactoryBot.create(:custom_field)
- expect(subject.make_link record).to be_nil
+ expect(subject.make_link(record)).to be_nil
end
it 'returns nil for non-AR types' do
record = Object.new
- expect(subject.make_link record).to be_nil
+ expect(subject.make_link(record)).to be_nil
end
end
end
diff --git a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb b/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
index 7560ec1bf2..107f507706 100644
--- a/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/versions/version_representer_rendering_spec.rb
@@ -44,7 +44,7 @@ describe ::API::V3::Versions::VersionRepresenter, 'rendering' do
.to receive(:allowed_to?) do |permission, project|
project == version.project && permissions.include?(permission)
end
- end
+ end
let(:permissions) { [:manage_versions] }
@@ -143,7 +143,7 @@ describe ::API::V3::Versions::VersionRepresenter, 'rendering' do
.and_return([custom_field])
allow(version)
- .to receive(:"custom_value_for")
+ .to receive(:custom_value_for)
.with(custom_field)
.and_return(custom_value)
end
@@ -270,7 +270,7 @@ describe ::API::V3::Versions::VersionRepresenter, 'rendering' do
context 'custom fields' do
let(:version) do
- FactoryBot.build_stubbed(:version).tap do |v|
+ FactoryBot.build_stubbed(:version).tap do |_v|
# Use this to force the custom field to be defined before the former_cache_key is calculated
custom_field
end
diff --git a/spec/lib/api/v3/wiki_pages/wiki_page_representer_rendering_spec.rb b/spec/lib/api/v3/wiki_pages/wiki_page_representer_rendering_spec.rb
index 9d3eacc592..deb427c17c 100644
--- a/spec/lib/api/v3/wiki_pages/wiki_page_representer_rendering_spec.rb
+++ b/spec/lib/api/v3/wiki_pages/wiki_page_representer_rendering_spec.rb
@@ -50,7 +50,7 @@ describe ::API::V3::WikiPages::WikiPageRepresenter, 'rendering' do
before do
allow(user)
- .to receive(:allowed_to?) do |permission, project|
+ .to receive(:allowed_to?) do |permission, _project|
permissions.include?(permission)
end
end
diff --git a/spec/lib/api/v3/work_packages/create_form_representer_spec.rb b/spec/lib/api/v3/work_packages/create_form_representer_spec.rb
index bb570fdf96..020e468f72 100644
--- a/spec/lib/api/v3/work_packages/create_form_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/create_form_representer_spec.rb
@@ -213,10 +213,10 @@ describe ::API::V3::WorkPackages::CreateFormRepresenter do
let(:type) { FactoryBot.build_stubbed(:type) }
let(:work_package) do
FactoryBot.build(:work_package,
- id: 42,
- created_at: DateTime.now,
- updated_at: DateTime.now,
- type: type)
+ id: 42,
+ created_at: DateTime.now,
+ updated_at: DateTime.now,
+ type: type)
end
before do
diff --git a/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb b/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb
index 9dccdb37f0..5f4ba80755 100644
--- a/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/create_project_form_representer_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -51,7 +52,8 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do
describe '_links' do
it do
is_expected.to be_json_eql(
- api_v3_paths.create_project_work_package_form(work_package.project_id).to_json)
+ api_v3_paths.create_project_work_package_form(work_package.project_id).to_json
+ )
.at_path('_links/self/href')
end
@@ -62,7 +64,8 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do
describe 'validate' do
it do
is_expected.to be_json_eql(
- api_v3_paths.create_project_work_package_form(work_package.project_id).to_json)
+ api_v3_paths.create_project_work_package_form(work_package.project_id).to_json
+ )
.at_path('_links/validate/href')
end
@@ -75,7 +78,9 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do
it do
is_expected.to be_json_eql(
api_v3_paths.render_markup(
- link: api_v3_paths.project(work_package.project_id)).to_json)
+ link: api_v3_paths.project(work_package.project_id)
+ ).to_json
+ )
.at_path('_links/previewMarkup/href')
end
@@ -95,7 +100,8 @@ describe ::API::V3::WorkPackages::CreateProjectFormRepresenter do
context 'valid work package' do
it do
is_expected.to be_json_eql(
- api_v3_paths.work_packages_by_project(work_package.project_id).to_json)
+ api_v3_paths.work_packages_by_project(work_package.project_id).to_json
+ )
.at_path('_links/commit/href')
end
diff --git a/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb b/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb
index 2381c1b0e9..99e4bb357e 100644
--- a/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb
+++ b/spec/lib/api/v3/work_packages/eager_loading/custom_value_integration_spec.rb
@@ -157,7 +157,6 @@ describe ::API::V3::WorkPackages::EagerLoading::CustomValue do
end
end
-
describe '#usages returning an is_for_all custom field within multiple projects (Regression #28452)' do
let!(:for_all_type_cf) do
FactoryBot.create(:list_wp_custom_field, is_for_all: true).tap do |cf|
diff --git a/spec/lib/api/v3/work_packages/form_representer_spec.rb b/spec/lib/api/v3/work_packages/form_representer_spec.rb
index c708d47096..b4d87b89a3 100644
--- a/spec/lib/api/v3/work_packages/form_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/form_representer_spec.rb
@@ -32,18 +32,18 @@ describe ::API::V3::WorkPackages::FormRepresenter do
include API::V3::Utilities::PathHelper
let(:errors) { [] }
- let(:work_package) {
+ let(:work_package) do
FactoryBot.build(:work_package,
- id: 42,
- created_at: DateTime.now,
- updated_at: DateTime.now)
- }
- let(:current_user) {
+ id: 42,
+ created_at: DateTime.now,
+ updated_at: DateTime.now)
+ end
+ let(:current_user) do
FactoryBot.build(:user, member_in_project: work_package.project)
- }
- let(:representer) {
+ end
+ let(:representer) do
described_class.new(work_package, current_user: current_user, errors: errors)
- }
+ end
context 'generation' do
subject(:generated) { representer.to_json }
diff --git a/spec/lib/api/v3/work_packages/update_form_representer_spec.rb b/spec/lib/api/v3/work_packages/update_form_representer_spec.rb
index 0afe02c49e..fd3350fd8e 100644
--- a/spec/lib/api/v3/work_packages/update_form_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/update_form_representer_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
index 2833cff257..0013a424fa 100644
--- a/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_collection_representer_spec.rb
@@ -466,6 +466,5 @@ describe ::API::V3::WorkPackages::WorkPackageCollectionRepresenter do
.at_path('_links/customFields')
end
end
-
end
end
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index 13c5387e1e..dbcf398137 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -716,13 +716,15 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
context 'when the user has the permission to add and remove watchers' do
it 'should have a link to add watcher' do
expect(subject).to be_json_eql(
- api_v3_paths.work_package_watchers(work_package.id).to_json)
+ api_v3_paths.work_package_watchers(work_package.id).to_json
+ )
.at_path('_links/addWatcher/href')
end
it 'should have a link to remove watcher' do
expect(subject).to be_json_eql(
- api_v3_paths.watcher('{user_id}', work_package.id).to_json)
+ api_v3_paths.watcher('{user_id}', work_package.id).to_json
+ )
.at_path('_links/removeWatcher/href')
end
end
@@ -801,7 +803,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it_behaves_like 'has a titled link' do
let(:link) { 'timeEntries' }
let(:href) do
- api_v3_paths.path_for(:time_entries, filters: [{ work_package_id: { operator: "=", values: [work_package.id.to_s] } }])
+ api_v3_paths.path_for(:time_entries,
+ filters: [{ work_package_id: { operator: "=", values: [work_package.id.to_s] } }])
end
let(:title) { 'Time entries' }
end
@@ -1120,7 +1123,7 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
it 'is based on the representer\'s cache_key' do
allow(OpenProject::Cache)
.to receive(:fetch)
- .and_return({_links: {}}.to_json)
+ .and_return({ _links: {} }.to_json)
expect(OpenProject::Cache)
.to receive(:fetch)
.with(representer.json_cache_key)
diff --git a/spec/lib/custom_field_form_builder_spec.rb b/spec/lib/custom_field_form_builder_spec.rb
index 5434a6a20b..ac2049a071 100644
--- a/spec/lib/custom_field_form_builder_spec.rb
+++ b/spec/lib/custom_field_form_builder_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -36,7 +37,7 @@ describe CustomFieldFormBuilder do
let(:builder) { described_class.new(:user, resource, helper, {}) }
describe '#custom_field' do
- let(:options) { {class: 'custom-class'} }
+ let(:options) { { class: 'custom-class' } }
let(:custom_field) do
FactoryBot.build_stubbed(:custom_field)
diff --git a/spec/lib/database_spec.rb b/spec/lib/database_spec.rb
index a81196c5f6..257764beb2 100644
--- a/spec/lib/database_spec.rb
+++ b/spec/lib/database_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/deprecated_alias_spec.rb b/spec/lib/deprecated_alias_spec.rb
index dfa6095912..8813b1707b 100644
--- a/spec/lib/deprecated_alias_spec.rb
+++ b/spec/lib/deprecated_alias_spec.rb
@@ -29,30 +29,34 @@
require 'spec_helper'
describe DeprecatedAlias do
- let(:clazz) {
+ let(:clazz) do
Class.new do
extend DeprecatedAlias
def secret_key
- @secret_key ||= 'happiness'
+ 'happiness'
end
deprecated_alias :special_key, :secret_key
end
- }
+ end
subject(:object) { clazz.new }
- let(:deprecation_warning) {
- 'special_key is deprecated and will be removed in a future OpenProject version. ' +
- 'Please use secret_key instead.'
- }
+ let(:deprecation_warning) do
+ <<~MSG
+ special_key is deprecated and will be removed in a future OpenProject version.
+
+ Please use secret_key instead.
+
+ MSG
+ end
before do
expect(ActiveSupport::Deprecation).to receive(:warn)
.with(deprecation_warning, an_instance_of(Array))
end
- it 'should alias the method' do
+ it 'aliases the method' do
expect(object.special_key).to eq('happiness')
end
end
diff --git a/spec/lib/journal_formatter/diff_spec.rb b/spec/lib/journal_formatter/diff_spec.rb
index f92fc75c12..03741a69a1 100644
--- a/spec/lib/journal_formatter/diff_spec.rb
+++ b/spec/lib/journal_formatter/diff_spec.rb
@@ -46,47 +46,47 @@ describe OpenProject::JournalFormatter::Diff do
let(:instance) { klass.new(journal) }
let(:key) { 'description' }
- let(:url) {
+ let(:url) do
url_helper.diff_journal_path(id: journal.id,
field: key.downcase)
- }
- let(:full_url) {
+ end
+ let(:full_url) do
url_helper.diff_journal_url(id: journal.id,
field: key.downcase,
protocol: Setting.protocol,
host: Setting.host_name)
- }
+ end
let(:link) { link_to(I18n.t(:label_details), url, class: 'description-details') }
let(:full_url_link) { link_to(I18n.t(:label_details), full_url, class: 'description-details') }
describe '#render' do
describe 'WITH the first value being nil, and the second a string' do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_set_with_diff,
label: "#{key.camelize} ",
link: link)
- }
+ end
it { expect(instance.render(key, [nil, 'new value'])).to eq(expected) }
end
describe 'WITH the first value being a string, and the second a string' do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_changed_with_diff,
label: "#{key.camelize} ",
link: link)
- }
+ end
it { expect(instance.render(key, ['old value', 'new value'])).to eq(expected) }
end
describe "WITH the first value being a string, and the second a string
WITH de as locale" do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_changed_with_diff,
label: 'Beschreibung ',
link: link)
- }
+ end
before do
I18n.locale = :de
@@ -100,54 +100,54 @@ describe OpenProject::JournalFormatter::Diff do
end
describe 'WITH the first value being a string, and the second nil' do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_deleted_with_diff,
label: "#{key.camelize} ",
link: link)
- }
+ end
it { expect(instance.render(key, ['old_value', nil])).to eq(expected) }
end
describe "WITH the first value being nil, and the second a string
WITH specifying not to output html" do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_set_with_diff,
label: key.camelize,
link: url)
- }
+ end
it { expect(instance.render(key, [nil, 'new value'], no_html: true)).to eq(expected) }
end
describe "WITH the first value being a string, and the second a string
WITH specifying not to output html" do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_changed_with_diff,
label: key.camelize,
link: url)
- }
+ end
it { expect(instance.render(key, ['old value', 'new value'], no_html: true)).to eq(expected) }
end
describe "WITH the first value being a string, and the second a string
WITH specifying to output a full url" do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_changed_with_diff,
label: "#{key.camelize} ",
link: full_url_link)
- }
+ end
it { expect(instance.render(key, ['old value', 'new value'], only_path: false)).to eq(expected) }
end
describe 'WITH the first value being a string, and the second nil' do
- let(:expected) {
+ let(:expected) do
I18n.t(:text_journal_deleted_with_diff,
label: key.camelize,
link: url)
- }
+ end
it { expect(instance.render(key, ['old_value', nil], no_html: true)).to eq(expected) }
end
diff --git a/spec/lib/open_project/access_control_spec.rb b/spec/lib/open_project/access_control_spec.rb
index b197a30998..2e09397d5c 100644
--- a/spec/lib/open_project/access_control_spec.rb
+++ b/spec/lib/open_project/access_control_spec.rb
@@ -29,7 +29,6 @@
require 'spec_helper'
describe OpenProject::AccessControl do
-
def stash_access_control_permissions
@stashed_permissions = OpenProject::AccessControl.permissions.dup
OpenProject::AccessControl.clear_caches
@@ -80,6 +79,7 @@ describe OpenProject::AccessControl do
after do
raise 'Test outdated' unless OpenProject::AccessControl.instance_variable_defined?(:@permissions)
+
OpenProject::AccessControl.instance_variable_set(:@permissions, all_former_permissions)
OpenProject::AccessControl.clear_caches
end
diff --git a/spec/lib/open_project/configuration/helpers_spec.rb b/spec/lib/open_project/configuration/helpers_spec.rb
index 3beaa7eb94..3c3a703a97 100644
--- a/spec/lib/open_project/configuration/helpers_spec.rb
+++ b/spec/lib/open_project/configuration/helpers_spec.rb
@@ -30,11 +30,11 @@ require 'spec_helper'
require 'open_project/configuration/helpers'
describe OpenProject::Configuration::Helpers do
- let(:config) {
+ let(:config) do
{}.tap do |config|
config.extend OpenProject::Configuration::Helpers
end
- }
+ end
describe '#array' do
def array(value)
diff --git a/spec/lib/open_project/configuration_spec.rb b/spec/lib/open_project/configuration_spec.rb
index 085b4fd022..446268d46f 100644
--- a/spec/lib/open_project/configuration_spec.rb
+++ b/spec/lib/open_project/configuration_spec.rb
@@ -60,7 +60,8 @@ describe OpenProject::Configuration do
'default' => { 'somesetting' => 'foo' },
'test' => {},
'someother' => { 'somesetting' => 'bar' }
- }, 'test') end
+ }, 'test')
+ end
it 'should load a default setting' do
expect(config['somesetting']).to eq('foo')
@@ -72,7 +73,8 @@ describe OpenProject::Configuration do
OpenProject::Configuration.send(:load_env_from_config, {
'default' => {},
'test' => { 'somesetting' => 'foo' }
- }, 'test') end
+ }, 'test')
+ end
it 'should load a setting' do
expect(config['somesetting']).to eq('foo')
@@ -84,7 +86,8 @@ describe OpenProject::Configuration do
OpenProject::Configuration.send(:load_env_from_config, {
'default' => { 'somesetting' => 'foo' },
'test' => { 'somesetting' => 'bar' }
- }, 'test') end
+ }, 'test')
+ end
it 'should load the overriding value' do
expect(config['somesetting']).to eq('bar')
@@ -203,7 +206,9 @@ describe OpenProject::Configuration do
'address' => 'smtp.example.net',
'port' => 25,
'domain' => 'example.net'
- } } }
+ }
+ }
+ }
end
context 'with delivery_method' do
diff --git a/spec/lib/open_project/content_type_detector_spec.rb b/spec/lib/open_project/content_type_detector_spec.rb
index e9dfcc9da9..0aad20acf2 100644
--- a/spec/lib/open_project/content_type_detector_spec.rb
+++ b/spec/lib/open_project/content_type_detector_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -69,20 +70,21 @@ describe OpenProject::ContentTypeDetector do
end
it 'returns content type of file if it is an acceptable type' do
- allow(MIME::Types).to receive(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'), MIME::Type.new('audio/mp4')])
+ allow(MIME::Types).to receive(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'),
+ MIME::Type.new('audio/mp4')])
allow(::Open3).to receive(:capture2).and_return(['video/mp4', 0])
@filename = 'my_file.mp4'
assert_equal 'video/mp4', OpenProject::ContentTypeDetector.new(@filename).detect
end
it 'returns the default when exitcode > 0' do
- allow(MIME::Types).to receive(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'), MIME::Type.new('audio/mp4')])
+ allow(MIME::Types).to receive(:type_for).and_return([MIME::Type.new('application/mp4'), MIME::Type.new('video/mp4'),
+ MIME::Type.new('audio/mp4')])
allow(::Open3).to receive(:capture2).and_return(['', 1])
@filename = 'my_file.mp4'
assert_equal 'application/binary', OpenProject::ContentTypeDetector.new(@filename).detect
end
-
it 'finds the right type in the list via the file command' do
@filename = "#{Dir.tmpdir}/something.hahalolnotreal"
File.open(@filename, 'w+') do |file|
diff --git a/spec/lib/open_project/file_command_content_type_detector_spec.rb b/spec/lib/open_project/file_command_content_type_detector_spec.rb
index ef8076c78a..ecce563d65 100644
--- a/spec/lib/open_project/file_command_content_type_detector_spec.rb
+++ b/spec/lib/open_project/file_command_content_type_detector_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/open_project/files_spec.rb b/spec/lib/open_project/files_spec.rb
index a28bb3516a..9b8f9931db 100644
--- a/spec/lib/open_project/files_spec.rb
+++ b/spec/lib/open_project/files_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -61,9 +62,9 @@ describe OpenProject::Files do
describe 'build_uploaded_file' do
let(:original_filename) { 'test.png' }
let(:content_type) { 'image/png' }
- let(:file) {
+ let(:file) do
OpenProject::Files.create_temp_file(name: original_filename)
- }
+ end
subject { OpenProject::Files.build_uploaded_file(file, content_type) }
diff --git a/spec/lib/open_project/form_tag_helper_spec.rb b/spec/lib/open_project/form_tag_helper_spec.rb
index 612cdc5ce1..3b7adcb383 100644
--- a/spec/lib/open_project/form_tag_helper_spec.rb
+++ b/spec/lib/open_project/form_tag_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -33,11 +34,11 @@ describe OpenProject::FormTagHelper, type: :helper do
let(:options) { {} }
describe '#styled_form_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_form_tag('/feedback', options) do
content_tag(:p, 'Form content')
end
- }
+ end
it_behaves_like 'not wrapped in container', 'form-container'
@@ -51,9 +52,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
describe '#styled_select_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_select_tag('field', 'FUN '.html_safe, options)
- }
+ end
it_behaves_like 'wrapped in container', 'select-container'
@@ -68,9 +69,9 @@ describe OpenProject::FormTagHelper, type: :helper do
describe '#styled_text_field_tag' do
let(:value) { 'Something to be seen' }
- subject(:output) {
+ subject(:output) do
helper.styled_text_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -84,11 +85,11 @@ describe OpenProject::FormTagHelper, type: :helper do
describe '#styled_label_tag' do
context 'with block' do
- subject(:output) {
+ subject(:output) do
helper.styled_label_tag('field', nil, options) do
'Label content'
end
- }
+ end
it_behaves_like 'not wrapped in container', 'label-container'
@@ -100,9 +101,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
context 'with content arg' do
- subject(:output) {
+ subject(:output) do
helper.styled_label_tag('field', 'Label content', options)
- }
+ end
it_behaves_like 'not wrapped in container', 'label-container'
@@ -129,9 +130,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
it 'should strip any given inline HTML from the title tag (with block)' do
- label = helper.styled_label_tag('field') {
+ label = helper.styled_label_tag('field') do
helper.content_tag :span, 'Sif'
- }
+ end
expect(label).to be_html_eql(%{
Sif
})
@@ -147,9 +148,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
describe '#styled_file_field_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_file_field_tag('file_field', options)
- }
+ end
it_behaves_like 'wrapped in container', 'file-field-container'
@@ -162,9 +163,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
describe '#styled_password_field_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_password_field_tag('password', 'nopE3king!', options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -177,9 +178,9 @@ describe OpenProject::FormTagHelper, type: :helper do
end
describe '#styled_text_area_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_text_area_tag('field', 'Words are important', options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-area-container'
@@ -192,9 +193,9 @@ Words are important
end
describe '#styled_check_box_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_check_box_tag('field', '1', false, options)
- }
+ end
it_behaves_like 'wrapped in container', 'check-box-container'
@@ -209,9 +210,9 @@ Words are important
describe '#styled_radio_button_tag' do
let(:value) { 'good choice' }
- subject(:output) {
+ subject(:output) do
helper.styled_radio_button_tag('field', value, false, options)
- }
+ end
it_behaves_like 'wrapped in container', 'radio-button-container'
@@ -224,12 +225,12 @@ Words are important
end
describe '#styled_submit_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_submit_tag('Save it!', options)
- }
- subject(:html) {
+ end
+ subject(:html) do
Capybara::Node::Simple.new(output)
- }
+ end
it_behaves_like 'not wrapped in container', 'submit-container'
@@ -239,11 +240,11 @@ Words are important
end
describe '#styled_button_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_button_tag(options) do
"Don't save!"
end
- }
+ end
it_behaves_like 'not wrapped in container', 'button-container'
@@ -255,11 +256,11 @@ Words are important
end
describe '#styled_field_set_tag' do
- subject(:output) {
+ subject(:output) do
helper.styled_field_set_tag('Fieldset Legend', options) do
content_tag(:p, 'Fieldset content')
end
- }
+ end
it_behaves_like 'not wrapped in container', 'fieldset-container'
@@ -275,9 +276,9 @@ Words are important
describe '#styled_search_field_tag' do
let(:value) { 'Find me' }
- subject(:output) {
+ subject(:output) do
helper.styled_search_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'search-field-container'
@@ -292,9 +293,9 @@ Words are important
describe '#styled_telephone_field_tag' do
let(:value) { '+49 555 111 999' }
- subject(:output) {
+ subject(:output) do
helper.styled_telephone_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -309,9 +310,9 @@ Words are important
describe '#styled_url_field_tag' do
let(:value) { 'https://blogger.org/' }
- subject(:output) {
+ subject(:output) do
helper.styled_url_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -326,9 +327,9 @@ Words are important
describe '#styled_email_field_tag' do
let(:value) { 'joe@blogger.com' }
- subject(:output) {
+ subject(:output) do
helper.styled_email_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -343,9 +344,9 @@ Words are important
describe '#styled_number_field_tag' do
let(:value) { 2 }
- subject(:output) {
+ subject(:output) do
helper.styled_number_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'text-field-container'
@@ -359,9 +360,9 @@ Words are important
describe '#styled_range_field_tag' do
let(:value) { 2 }
- subject(:output) {
+ subject(:output) do
helper.styled_range_field_tag('field', value, options)
- }
+ end
it_behaves_like 'wrapped in container', 'range-field-container'
diff --git a/spec/lib/open_project/notifications_spec.rb b/spec/lib/open_project/notifications_spec.rb
index e07599a013..51e0595dc7 100644
--- a/spec/lib/open_project/notifications_spec.rb
+++ b/spec/lib/open_project/notifications_spec.rb
@@ -51,9 +51,9 @@ describe OpenProject::Notifications do
describe '.subscribe' do
it 'throws an error when no callback is given' do
- expect {
+ expect do
OpenProject::Notifications.subscribe('notifications_spec_send')
- }.to raise_error ArgumentError, /provide a block as a callback/
+ end.to raise_error ArgumentError, /provide a block as a callback/
end
describe 'clear_subscriptions:' do
diff --git a/spec/lib/open_project/object_linking_spec.rb b/spec/lib/open_project/object_linking_spec.rb
index bb24087459..256e178d71 100644
--- a/spec/lib/open_project/object_linking_spec.rb
+++ b/spec/lib/open_project/object_linking_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/open_project/plugins/module_handler_spec.rb b/spec/lib/open_project/plugins/module_handler_spec.rb
index df430c9ae8..a8b80dad23 100644
--- a/spec/lib/open_project/plugins/module_handler_spec.rb
+++ b/spec/lib/open_project/plugins/module_handler_spec.rb
@@ -37,6 +37,7 @@ describe OpenProject::Plugins::ModuleHandler do
after do
raise 'Test outdated' unless OpenProject::AccessControl.instance_variable_defined?(:@permissions)
+
OpenProject::AccessControl.instance_variable_set(:@permissions, all_former_permissions)
OpenProject::AccessControl.clear_caches
end
diff --git a/spec/lib/open_project/scm/adapters/git_adapter_spec.rb b/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
index 72f2a7d037..85ebeb867c 100644
--- a/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
+++ b/spec/lib/open_project/scm/adapters/git_adapter_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -35,7 +36,7 @@ describe OpenProject::SCM::Adapters::Git do
let(:url) { protocol + Rails.root.join('/tmp/does/not/exist.git').to_s }
let(:config) { {} }
let(:encoding) { nil }
- let(:adapter) {
+ let(:adapter) do
OpenProject::SCM::Adapters::Git.new(
url,
nil,
@@ -44,7 +45,7 @@ describe OpenProject::SCM::Adapters::Git do
encoding,
"test-identifier"
)
- }
+ end
repos_dir = Dir.mktmpdir
diff --git a/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb b/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
index 586caaf0c6..fddc82db8f 100644
--- a/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
+++ b/spec/lib/open_project/scm/adapters/subversion_adapter_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/open_project/scm/manager_spec.rb b/spec/lib/open_project/scm/manager_spec.rb
index 861ebee687..878d9e0e3a 100644
--- a/spec/lib/open_project/scm/manager_spec.rb
+++ b/spec/lib/open_project/scm/manager_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/open_project/storage_spec.rb b/spec/lib/open_project/storage_spec.rb
index e7fcd6390e..e26e0f408b 100644
--- a/spec/lib/open_project/storage_spec.rb
+++ b/spec/lib/open_project/storage_spec.rb
@@ -73,11 +73,11 @@ describe OpenProject::Storage do
context 'with SCM configuration' do
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
git: { manages: File.join(tmpdir, 'git') }
}
- }
+ end
let(:enabled_scms) { %w[git] }
let(:returned_fs_info) { [{ id: 1, free: 1234 }] }
@@ -118,8 +118,7 @@ describe OpenProject::Storage do
.to eq(1 => { labels: [I18n.t(:label_managed_repositories_vendor, vendor: 'Git')],
data: returned_fs_info[0] },
2 => { labels: [I18n.t('attributes.attachments')],
- data: returned_fs_info[1] }
- )
+ data: returned_fs_info[1] })
end
end
end
diff --git a/spec/lib/open_project/text_formatting/markdown/child_pages_macro_spec.rb b/spec/lib/open_project/text_formatting/markdown/child_pages_macro_spec.rb
index 1962d73e40..afdc5b821d 100644
--- a/spec/lib/open_project/text_formatting/markdown/child_pages_macro_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/child_pages_macro_spec.rb
@@ -37,75 +37,75 @@ describe 'OpenProject child pages macro' do
# no-op
end
- let(:project) {
+ let(:project) do
FactoryBot.create :valid_project,
enabled_module_names: %w[wiki]
- }
- let(:member_project) {
+ end
+ let(:member_project) do
FactoryBot.create :valid_project,
identifier: 'member-project',
enabled_module_names: %w[wiki]
- }
- let(:invisible_project) {
+ end
+ let(:invisible_project) do
FactoryBot.create :valid_project,
identifier: 'other-project',
enabled_module_names: %w[wiki]
- }
+ end
let(:role) { FactoryBot.create(:role, permissions: [:view_wiki_pages]) }
- let(:user) {
+ let(:user) do
FactoryBot.create(:user, member_in_projects: [project, member_project], member_through_role: role)
- }
+ end
- let(:current_page) {
+ let(:current_page) do
FactoryBot.create :wiki_page,
title: 'Current page',
wiki: project.wiki,
content: FactoryBot.build(:wiki_content, text: input)
- }
+ end
- let(:middle_page) {
+ let(:middle_page) do
FactoryBot.create :wiki_page,
title: 'Node from same project',
wiki: project.wiki,
parent_id: current_page.id,
content: FactoryBot.build(:wiki_content, text: '# Node Page from same project')
- }
+ end
- let(:node_page_invisible_project) {
+ let(:node_page_invisible_project) do
FactoryBot.create :wiki_page,
title: 'Node page from invisible project',
wiki: invisible_project.wiki,
content: FactoryBot.build(:wiki_content, text: '# Page from invisible project')
- }
+ end
- let(:leaf_page) {
+ let(:leaf_page) do
FactoryBot.create :wiki_page,
title: 'Leaf page from same project',
parent_id: middle_page.id,
wiki: project.wiki,
content: FactoryBot.build(:wiki_content, text: '# Leaf page from same project')
- }
+ end
- let(:leaf_page_invisible_project) {
+ let(:leaf_page_invisible_project) do
FactoryBot.create :wiki_page,
title: 'Leaf page from invisible project',
parent_id: node_page_invisible_project.id,
wiki: invisible_project.wiki,
content: FactoryBot.build(:wiki_content, text: '# Leaf page from invisible project')
- }
+ end
- let(:leaf_page_member_project) {
+ let(:leaf_page_member_project) do
FactoryBot.create :wiki_page,
title: 'Leaf page from member project',
wiki: member_project.wiki,
content: FactoryBot.build(:wiki_content, text: '# Leaf page from member project')
- }
+ end
before do
login_as(user)
end
- let(:input) { }
+ let(:input) {}
subject { format_text(current_page.content, :text) }
before do
@@ -173,7 +173,9 @@ describe 'OpenProject child pages macro' do
end
context 'when referencing page from a member project' do
- let(:input) { ' ' }
+ let(:input) do
+ ' '
+ end
before { leaf_page_member_project }
it { is_expected.to match(leaf_page_member_project.title) }
end
diff --git a/spec/lib/open_project/text_formatting/markdown/code_spec.rb b/spec/lib/open_project/text_formatting/markdown/code_spec.rb
index a7438f79ea..a0b79eefd7 100644
--- a/spec/lib/open_project/text_formatting/markdown/code_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/code_spec.rb
@@ -149,6 +149,5 @@ describe OpenProject::TextFormatting,
EXPECTED
end
end
-
end
end
diff --git a/spec/lib/open_project/text_formatting/markdown/images_spec.rb b/spec/lib/open_project/text_formatting/markdown/images_spec.rb
index 96fe732b0d..7a08a80981 100644
--- a/spec/lib/open_project/text_formatting/markdown/images_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/images_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb b/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
index 98dbe26998..45d4d68f61 100644
--- a/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/in_tool_links_spec.rb
@@ -191,13 +191,19 @@ describe OpenProject::TextFormatting,
context 'Plain message' do
subject { format_text("message##{message1.id}") }
- it { is_expected.to be_html_eql("#{link_to(message1.subject, topic_path(message1), class: 'message op-uc-link')}
") }
+ it {
+ is_expected.to be_html_eql("#{link_to(message1.subject, topic_path(message1),
+ class: 'message op-uc-link')}
")
+ }
end
context 'Message with parent' do
subject { format_text("message##{message2.id}") }
- it { is_expected.to be_html_eql("#{link_to(message2.subject, topic_path(message1, anchor: "message-#{message2.id}", r: message2.id), class: 'message op-uc-link')}
") }
+ it {
+ is_expected.to be_html_eql("#{link_to(message2.subject,
+ topic_path(message1, anchor: "message-#{message2.id}", r: message2.id), class: 'message op-uc-link')}
")
+ }
end
end
@@ -211,7 +217,9 @@ describe OpenProject::TextFormatting,
context 'Plain work_package link' do
subject { format_text("##{work_package.id}, [##{work_package.id}], (##{work_package.id}) and ##{work_package.id}.") }
- it { is_expected.to be_html_eql("#{work_package_link}, [#{work_package_link}], (#{work_package_link}) and #{work_package_link}.
") }
+ it {
+ is_expected.to be_html_eql("#{work_package_link}, [#{work_package_link}], (#{work_package_link}) and #{work_package_link}.
")
+ }
end
context 'Plain work_package link with braces' do
@@ -294,19 +302,28 @@ describe OpenProject::TextFormatting,
context 'Plain project link' do
subject { format_text("project##{subproject.id}") }
- it { is_expected.to be_html_eql("#{link_to(subproject.name, project_url, class: 'project op-uc-link')}
") }
+ it {
+ is_expected.to be_html_eql("#{link_to(subproject.name, project_url,
+ class: 'project op-uc-link')}
")
+ }
end
context 'Plain project link via identifier' do
subject { format_text("project:#{subproject.identifier}") }
- it { is_expected.to be_html_eql("#{link_to(subproject.name, project_url, class: 'project op-uc-link')}
") }
+ it {
+ is_expected.to be_html_eql("#{link_to(subproject.name, project_url,
+ class: 'project op-uc-link')}
")
+ }
end
context 'Plain project link via name' do
subject { format_text("project:\"#{subproject.name}\"") }
- it { is_expected.to be_html_eql("#{link_to(subproject.name, project_url, class: 'project op-uc-link')}
") }
+ it {
+ is_expected.to be_html_eql("#{link_to(subproject.name, project_url,
+ class: 'project op-uc-link')}
")
+ }
end
end
@@ -357,86 +374,114 @@ describe OpenProject::TextFormatting,
context 'Plain wiki link' do
subject { format_text('[[CookBook documentation]]') }
- it { is_expected.to be_html_eql("CookBook documentation
") }
+ it {
+ is_expected.to be_html_eql("CookBook documentation
")
+ }
end
context 'Arbitrary wiki link' do
title = ''
subject { format_text("[[#{title}]]") }
- it { is_expected.to be_html_eql("#{h(title)}
") }
+ it {
+ is_expected.to be_html_eql("#{h(title)}
")
+ }
end
context 'Plain wiki page link' do
subject { format_text('[[Another page|Page]]') }
- it { is_expected.to be_html_eql("Page
") }
+ it {
+ is_expected.to be_html_eql("Page
")
+ }
end
context 'Wiki link with anchor' do
subject { format_text('[[CookBook documentation#One-section]]') }
- it { is_expected.to be_html_eql("CookBook documentation
") }
+ it {
+ is_expected.to be_html_eql("CookBook documentation
")
+ }
end
context 'Wiki page link with anchor' do
subject { format_text('[[Another page#anchor|Page]]') }
- it { is_expected.to be_html_eql("Page
") }
+ it {
+ is_expected.to be_html_eql("Page
")
+ }
end
context 'Wiki link to an unknown page' do
subject { format_text('[[Unknown page]]') }
- it { is_expected.to be_html_eql("Unknown page
") }
+ it {
+ is_expected.to be_html_eql("Unknown page
")
+ }
end
context 'Wiki page link to an unknown page' do
subject { format_text('[[Unknown page|404]]') }
- it { is_expected.to be_html_eql("404
") }
+ it {
+ is_expected.to be_html_eql("404
")
+ }
end
context "Link to another project's wiki" do
subject { format_text('[[onlinestore:]]') }
- it { is_expected.to be_html_eql("onlinestore
") }
+ it {
+ is_expected.to be_html_eql("onlinestore
")
+ }
end
context "Link to another project's wiki with label" do
subject { format_text('[[onlinestore:|Wiki]]') }
- it { is_expected.to be_html_eql("Wiki
") }
+ it {
+ is_expected.to be_html_eql("Wiki
")
+ }
end
context "Link to another project's wiki page" do
subject { format_text('[[onlinestore:Start page]]') }
- it { is_expected.to be_html_eql("Start Page
") }
+ it {
+ is_expected.to be_html_eql("Start Page
")
+ }
end
context "Link to another project's wiki page with label" do
subject { format_text('[[onlinestore:Start page|Text]]') }
- it { is_expected.to be_html_eql("Text
") }
+ it {
+ is_expected.to be_html_eql("Text
")
+ }
end
context 'Link to an unknown wiki page in another project' do
subject { format_text('[[onlinestore:Unknown page]]') }
- it { is_expected.to be_html_eql("Unknown page
") }
+ it {
+ is_expected.to be_html_eql("Unknown page
")
+ }
end
context 'Struck through link to wiki page' do
subject { format_text('~~[[Another page|Page]]~~') }
- it { is_expected.to be_html_eql("Page
") }
+ it {
+ is_expected.to be_html_eql("Page
")
+ }
end
context 'Named struck through link to wiki page' do
subject { format_text('~~[[Another page|Page]] link~~') }
- it { is_expected.to be_html_eql("Page link
") }
+ it {
+ is_expected.to be_html_eql("Page link
")
+ }
end
context 'Escaped link to wiki page' do
@@ -488,10 +533,13 @@ describe OpenProject::TextFormatting,
'source:"/some/file.ext". ' => link_to('source:/some/file.ext', source_url_with_ext, class: 'source op-uc-link') + '.',
'source:/some/file, ' => link_to('source:/some/file', source_url, class: 'source op-uc-link') + ',',
'source:/some/file@52' => link_to('source:/some/file@52', source_url(rev: 52), class: 'source op-uc-link'),
- 'source:"/some/file.ext@52"' => link_to('source:/some/file.ext@52', source_url_with_ext(rev: 52), class: 'source op-uc-link'),
+ 'source:"/some/file.ext@52"' => link_to('source:/some/file.ext@52', source_url_with_ext(rev: 52),
+ class: 'source op-uc-link'),
'source:"/some/file#L110"' => link_to('source:/some/file#L110', source_url(anchor: 'L110'), class: 'source op-uc-link'),
- 'source:"/some/file.ext#L110"' => link_to('source:/some/file.ext#L110', source_url_with_ext(anchor: 'L110'), class: 'source op-uc-link'),
- 'source:"/some/file@52#L110"' => link_to('source:/some/file@52#L110', source_url(rev: 52, anchor: 'L110'), class: 'source op-uc-link'),
+ 'source:"/some/file.ext#L110"' => link_to('source:/some/file.ext#L110', source_url_with_ext(anchor: 'L110'),
+ class: 'source op-uc-link'),
+ 'source:"/some/file@52#L110"' => link_to('source:/some/file@52#L110', source_url(rev: 52, anchor: 'L110'),
+ class: 'source op-uc-link'),
'export:/some/file' => link_to('export:/some/file', source_url(format: 'raw'), class: 'source download op-uc-link'),
# escaping
'!source:/some/file' => 'source:/some/file',
diff --git a/spec/lib/open_project/text_formatting/markdown/lists_spec.rb b/spec/lib/open_project/text_formatting/markdown/lists_spec.rb
index fd92e70377..95dde46bf5 100644
--- a/spec/lib/open_project/text_formatting/markdown/lists_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/lists_spec.rb
@@ -198,7 +198,7 @@ describe OpenProject::TextFormatting,
let(:expected) do
<<~EXPECTED
-
+ #{' '}
@@ -302,7 +302,7 @@ describe OpenProject::TextFormatting,
let(:expected) do
<<~EXPECTED
-
+ #{' '}
diff --git a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb
index 38d194b92d..f7ad76328e 100644
--- a/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/markdown_formatting_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -33,14 +34,14 @@ require_relative './expected_markdown'
describe OpenProject::TextFormatting::Formats::Markdown::Formatter do
it 'should modifiers' do
assert_html_output(
- '**bold**' => 'bold ',
- 'before **bold**' => 'before bold ',
- '**bold** after' => 'bold after',
- '**two words**' => 'two words ',
- '**two*words**' => 'two*words ',
- '**two * words**' => 'two * words ',
- '**two** **words**' => 'two words ',
- '**(two)** **(words)**' => '(two) (words) '
+ '**bold**' => 'bold ',
+ 'before **bold**' => 'before bold ',
+ '**bold** after' => 'bold after',
+ '**two words**' => 'two words ',
+ '**two*words**' => 'two*words ',
+ '**two * words**' => 'two * words ',
+ '**two** **words**' => 'two words ',
+ '**(two)** **(words)**' => '(two) (words) '
)
end
diff --git a/spec/lib/open_project/text_formatting/markdown/pandoc_wrapper_spec.rb b/spec/lib/open_project/text_formatting/markdown/pandoc_wrapper_spec.rb
index fe1a69be09..098eb7e7fd 100644
--- a/spec/lib/open_project/text_formatting/markdown/pandoc_wrapper_spec.rb
+++ b/spec/lib/open_project/text_formatting/markdown/pandoc_wrapper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -40,12 +41,12 @@ describe OpenProject::TextFormatting::Formats::Markdown::PandocWrapper do
context 'when wrap=preserve exists' do
let(:usage_string) do
<<~EOS
- --list-output-formats
- --list-highlight-languages
- --list-highlight-styles
- --wrap=auto|none|preserve
- -v --version
- -h --help
+ --list-output-formats#{' '}
+ --list-highlight-languages#{' '}
+ --list-highlight-styles#{' '}
+ --wrap=auto|none|preserve
+ -v --version#{' '}
+ -h --help
EOS
end
@@ -57,12 +58,12 @@ describe OpenProject::TextFormatting::Formats::Markdown::PandocWrapper do
context 'when only no-wrap exists' do
let(:usage_string) do
<<~EOS
- --list-output-formats
- --list-highlight-languages
- --list-highlight-styles
- --no-wrap
- -v --version
- -h --help
+ --list-output-formats#{' '}
+ --list-highlight-languages#{' '}
+ --list-highlight-styles#{' '}
+ --no-wrap
+ -v --version#{' '}
+ -h --help
EOS
end
it do
@@ -73,7 +74,9 @@ describe OpenProject::TextFormatting::Formats::Markdown::PandocWrapper do
context 'when neither exists' do
let(:usage_string) { 'wat?' }
it do
- expect { subject.wrap_mode }.to raise_error 'Your pandoc version has neither --no-wrap nor --wrap=preserve. Please install a recent version of pandoc.'
+ expect do
+ subject.wrap_mode
+ end.to raise_error 'Your pandoc version has neither --no-wrap nor --wrap=preserve. Please install a recent version of pandoc.'
end
end
end
diff --git a/spec/lib/open_project/text_formatting/plain_spec.rb b/spec/lib/open_project/text_formatting/plain_spec.rb
index aaafc32ea4..649b9ac0eb 100644
--- a/spec/lib/open_project/text_formatting/plain_spec.rb
+++ b/spec/lib/open_project/text_formatting/plain_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -46,7 +47,8 @@ describe OpenProject::TextFormatting::Formats::Plain::Formatter do
def assert_html_output(to_test, expect_paragraph = true)
to_test.each do |text, expected|
- assert_equal((expect_paragraph ? "#{expected}
" : expected), subject.to_html(text), "Formatting the following text failed:\n===\n#{text}\n===\n")
+ assert_equal((expect_paragraph ? "#{expected}
" : expected), subject.to_html(text),
+ "Formatting the following text failed:\n===\n#{text}\n===\n")
end
end
diff --git a/spec/lib/open_project/text_formatting/text_formatting_spec.rb b/spec/lib/open_project/text_formatting/text_formatting_spec.rb
index ce2603f2ee..1c65a84dba 100644
--- a/spec/lib/open_project/text_formatting/text_formatting_spec.rb
+++ b/spec/lib/open_project/text_formatting/text_formatting_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -42,17 +43,18 @@ describe OpenProject::TextFormatting do
end
it 'should link urls and email addresses' do
- raw = <<-DIFF
-This is a sample *text* with a link: http://www.redmine.org
-and an email address foo@example.net
-DIFF
+ raw = <<~DIFF
+ This is a sample *text* with a link: http://www.redmine.org
+ and an email address foo@example.net
+ DIFF
- expected = <<-EXPECTED
-This is a sample *text* with a link: http://www.redmine.org
-and an email address foo@example.net
-EXPECTED
+ expected = <<~EXPECTED
+ This is a sample *text* with a link: http://www.redmine.org
+ and an email address foo@example.net
+ EXPECTED
- assert_equal expected.gsub(%r{[\r\n\t]}, ''), OpenProject::TextFormatting::Formats::Plain::Formatter.new({}).to_html(raw).gsub(%r{[\r\n\t]}, '')
+ assert_equal expected.gsub(%r{[\r\n\t]}, ''),
+ OpenProject::TextFormatting::Formats::Plain::Formatter.new({}).to_html(raw).gsub(%r{[\r\n\t]}, '')
end
describe 'options' do
diff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rb
index 18c143753c..f2d9aba0b4 100644
--- a/spec/lib/redmine/i18n_spec.rb
+++ b/spec/lib/redmine/i18n_spec.rb
@@ -46,30 +46,30 @@ module OpenProject
end
it 'returns a date in the user timezone for a utc timestamp' do
Time.zone = 'UTC'
- time = Time.zone.local(2013, 06, 30, 23, 59)
+ time = Time.zone.local(2013, 0o6, 30, 23, 59)
expect(format_time_as_date(time, format)).to eq '01/07/2013'
end
it 'returns a date in the user timezone for a non-utc timestamp' do
Time.zone = 'Berlin'
- time = Time.zone.local(2013, 06, 30, 23, 59)
+ time = Time.zone.local(2013, 0o6, 30, 23, 59)
expect(format_time_as_date(time, format)).to eq '01/07/2013'
end
end
describe 'without user time zone' do
- before do allow(User.current).to receive(:time_zone).and_return(nil) end
+ before { allow(User.current).to receive(:time_zone).and_return(nil) }
it 'returns a date in the local system timezone for a utc timestamp' do
Time.zone = 'UTC'
- time = Time.zone.local(2013, 06, 30, 23, 59)
- allow(time).to receive(:localtime).and_return(ActiveSupport::TimeZone['Athens'].local(2013, 07, 01, 01, 59))
+ time = Time.zone.local(2013, 0o6, 30, 23, 59)
+ allow(time).to receive(:localtime).and_return(ActiveSupport::TimeZone['Athens'].local(2013, 0o7, 0o1, 0o1, 59))
expect(format_time_as_date(time, format)).to eq '01/07/2013'
end
it 'returns a date in the original timezone for a non-utc timestamp' do
Time.zone = 'Berlin'
- time = Time.zone.local(2013, 06, 30, 23, 59)
+ time = Time.zone.local(2013, 0o6, 30, 23, 59)
expect(format_time_as_date(time, format)).to eq '30/06/2013'
end
end
@@ -160,9 +160,9 @@ module OpenProject
describe 'link_translation' do
let(:locale) { :en }
- let(:urls) {
+ let(:urls) do
{ url_1: 'http://openproject.com/foobar', url_2: '/baz' }
- }
+ end
before do
allow(::I18n)
@@ -176,7 +176,8 @@ module OpenProject
expect(translated).to eq(
"There is a link in this translation!" +
- " Maybe even two ?")
+ " Maybe even two ?"
+ )
end
context 'with locale' do
@@ -186,7 +187,8 @@ module OpenProject
expect(translated).to eq(
"There is a link in this translation!" +
- " Maybe even two ?")
+ " Maybe even two ?"
+ )
end
end
end
diff --git a/spec/lib/redmine/unified_diff_spec.rb b/spec/lib/redmine/unified_diff_spec.rb
index 01eb46f4ab..52e471f149 100644
--- a/spec/lib/redmine/unified_diff_spec.rb
+++ b/spec/lib/redmine/unified_diff_spec.rb
@@ -31,14 +31,14 @@ require 'spec_helper'
module Redmine
describe UnifiedDiff do
before do
- @diff = Redmine::UnifiedDiff.new(<<-DIFF
---- old.js Thu May 11 14:24:58 2014
-+++ new.js Thu May 11 14:25:02 2014
-@@ -0,0 +1,1 @@
-+
-@@ -1,2 +1,2 @@
--text text
-+text modified
+ @diff = Redmine::UnifiedDiff.new(<<~DIFF
+ --- old.js Thu May 11 14:24:58 2014
+ +++ new.js Thu May 11 14:25:02 2014
+ @@ -0,0 +1,1 @@
+ +
+ @@ -1,2 +1,2 @@
+ -text text
+ +text modified
DIFF
)
end
@@ -70,12 +70,12 @@ module Redmine
Test 3
Test 4
DIFF
- )
+ )
end
subject do
[].tap do |lines|
- diff.first.each_line { |_,l| lines << [l.html_line_left, l.html_line_right] }
+ diff.first.each_line { |_, l| lines << [l.html_line_left, l.html_line_right] }
end
end
diff --git a/spec/lib/reminders/due_issues_reminder_spec.rb b/spec/lib/reminders/due_issues_reminder_spec.rb
index 755abf5956..d317624226 100644
--- a/spec/lib/reminders/due_issues_reminder_spec.rb
+++ b/spec/lib/reminders/due_issues_reminder_spec.rb
@@ -99,7 +99,7 @@ describe OpenProject::Reminders::DueIssuesReminder do
let(:user_ids) { [user.id] }
it 'does notify' do
expect(subject.notify_count).to eq 1
- expect(ActionMailer::Base.deliveries.count). to eq 1
+ expect(ActionMailer::Base.deliveries.count).to eq 1
mail = ActionMailer::Base.deliveries.last
expect(mail).to be_present
diff --git a/spec/lib/tabular_form_builder_spec.rb b/spec/lib/tabular_form_builder_spec.rb
index dc76fe8771..0a3dae0839 100644
--- a/spec/lib/tabular_form_builder_spec.rb
+++ b/spec/lib/tabular_form_builder_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -35,10 +36,10 @@ describe TabularFormBuilder do
let(:helper) { ActionView::Base.new(ActionView::LookupContext.new(''), {}, nil) }
let(:resource) do
FactoryBot.build(:user,
- firstname: 'JJ',
- lastname: 'Abrams',
- login: 'lost',
- mail: 'jj@lost-mail.com',
+ firstname: 'JJ',
+ lastname: 'Abrams',
+ login: 'lost',
+ mail: 'jj@lost-mail.com',
failed_login_count: 45)
end
let(:builder) { TabularFormBuilder.new(:user, resource, helper, {}) }
@@ -636,10 +637,10 @@ JJ Abrams
context 'with ActiveModel and without specified label' do
let(:resource) do
FactoryBot.build_stubbed(:user,
- firstname: 'JJ',
- lastname: 'Abrams',
- login: 'lost',
- mail: 'jj@lost-mail.com',
+ firstname: 'JJ',
+ lastname: 'Abrams',
+ login: 'lost',
+ mail: 'jj@lost-mail.com',
failed_login_count: 45)
end
diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb
index 7784139c2b..100aa56e88 100644
--- a/spec/mailers/user_mailer_spec.rb
+++ b/spec/mailers/user_mailer_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -508,9 +509,9 @@ describe UserMailer, type: :mailer do
describe 'html mail' do
let(:expected_translation) do
- I18n.t(:done_ratio, scope: [:activerecord,
- :attributes,
- :work_package])
+ I18n.t(:done_ratio, scope: %i[activerecord
+ attributes
+ work_package])
end
let(:expected_prefix) { "#{expected_translation} " }
@@ -519,7 +520,9 @@ describe UserMailer, type: :mailer do
end
context 'changed done ratio' do
- let(:expected) { "#{expected_prefix} changed from 40 to 100 " }
+ let(:expected) do
+ "#{expected_prefix} changed from 40 to 100 "
+ end
before do
allow(journal).to receive(:details).and_return('done_ratio' => [40, 100])
@@ -531,7 +534,9 @@ describe UserMailer, type: :mailer do
end
context 'new done ratio' do
- let(:expected) { "#{expected_prefix} changed from 0 to 100 " }
+ let(:expected) do
+ "#{expected_prefix} changed from 0 to 100 "
+ end
before do
allow(journal).to receive(:details).and_return('done_ratio' => [nil, 100])
diff --git a/spec/models/activities/fetcher_integration_spec.rb b/spec/models/activities/fetcher_integration_spec.rb
index 5d9dd25f4e..c154db4154 100644
--- a/spec/models/activities/fetcher_integration_spec.rb
+++ b/spec/models/activities/fetcher_integration_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/models/announcement_spec.rb b/spec/models/announcement_spec.rb
index 5e5d25f102..2d271db475 100644
--- a/spec/models/announcement_spec.rb
+++ b/spec/models/announcement_spec.rb
@@ -34,9 +34,9 @@ describe Announcement, type: :model do
end
describe 'WHEN the one announcement is active and today is before show_until' do
- let!(:announcement) {
+ let!(:announcement) do
FactoryBot.create(:active_announcement, show_until: Date.today + 14.days)
- }
+ end
it 'returns that announcement' do
expect(Announcement.active_and_current).to eql announcement
@@ -44,9 +44,9 @@ describe Announcement, type: :model do
end
describe 'WHEN the one announcement is active and today is after show_until' do
- let!(:announcement) {
+ let!(:announcement) do
FactoryBot.create(:active_announcement, show_until: Date.today - 14.days)
- }
+ end
it 'returns no announcement' do
expect(Announcement.active_and_current).to be_nil
@@ -54,9 +54,9 @@ describe Announcement, type: :model do
end
describe 'WHEN the one announcement is active and today equals show_until' do
- let!(:announcement) {
+ let!(:announcement) do
FactoryBot.create(:active_announcement, show_until: Date.today)
- }
+ end
it 'returns that announcement' do
expect(Announcement.active_and_current).to eql announcement
end
@@ -72,25 +72,25 @@ describe Announcement, type: :model do
end
describe 'WHEN the announcement is active and today is before show_until' do
- let(:announcement) {
+ let(:announcement) do
FactoryBot.build(:active_announcement, show_until: Date.today + 14.days)
- }
+ end
it { expect(announcement.active_and_current?).to be_truthy }
end
describe 'WHEN the announcement is active and today is after show_until' do
- let!(:announcement) {
+ let!(:announcement) do
FactoryBot.create(:active_announcement, show_until: Date.today - 14.days)
- }
+ end
it { expect(announcement.active_and_current?).to be_falsey }
end
describe 'WHEN the announcement is active and today equals show_until' do
- let!(:announcement) {
+ let!(:announcement) do
FactoryBot.build(:active_announcement, show_until: Date.today)
- }
+ end
it { expect(announcement.active_and_current?).to be_truthy }
end
diff --git a/spec/models/color_spec.rb b/spec/models/color_spec.rb
index fc84cebc23..828ff8cfd3 100644
--- a/spec/models/color_spec.rb
+++ b/spec/models/color_spec.rb
@@ -34,7 +34,7 @@ describe Color, type: :model do
it 'can read planning_element_types w/ the help of the has_many association' do
color = FactoryBot.create(:color)
planning_element_type = FactoryBot.create(:type,
- color_id: color.id)
+ color_id: color.id)
color.reload
@@ -45,7 +45,7 @@ describe Color, type: :model do
it 'nullifies dependent planning_element_types' do
color = FactoryBot.create(:color)
planning_element_type = FactoryBot.create(:type,
- color_id: color.id)
+ color_id: color.id)
color.reload
color.destroy
@@ -57,10 +57,10 @@ describe Color, type: :model do
end
describe '- Validations ' do
- let(:attributes) {
- { name: 'Color No. 1',
+ let(:attributes) do
+ { name: 'Color No. 1',
hexcode: '#FFFFFF' }
- }
+ end
describe 'name' do
it 'is invalid w/o a name' do
@@ -98,7 +98,7 @@ describe Color, type: :model do
it 'is invalid w/ malformed hexcodes' do
expect(Color.new(attributes.merge(hexcode: '0#FFFFFF'))).not_to be_valid
expect(Color.new(attributes.merge(hexcode: '#FFFFFF0'))).not_to be_valid
- expect(Color.new(attributes.merge(hexcode: 'white'))). not_to be_valid
+ expect(Color.new(attributes.merge(hexcode: 'white'))).not_to be_valid
end
it 'fixes some wrong formats of hexcode automatically' do
@@ -120,7 +120,7 @@ describe Color, type: :model do
end
it 'is valid w/ proper hexcodes' do
- expect(Color.new(attributes.merge(hexcode: '#FFFFFF'))). to be_valid
+ expect(Color.new(attributes.merge(hexcode: '#FFFFFF'))).to be_valid
expect(Color.new(attributes.merge(hexcode: '#FF00FF'))).to be_valid
end
end
diff --git a/spec/models/custom_actions/actions/custom_field_spec.rb b/spec/models/custom_actions/actions/custom_field_spec.rb
index 3249c819a2..31bd0a0a30 100644
--- a/spec/models/custom_actions/actions/custom_field_spec.rb
+++ b/spec/models/custom_actions/actions/custom_field_spec.rb
@@ -31,14 +31,14 @@ require_relative '../shared_expectations'
describe CustomActions::Actions::CustomField, type: :model do
let(:list_custom_field) do
FactoryBot.build_stubbed(:list_wp_custom_field,
- custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'),
- FactoryBot.build_stubbed(:custom_option, value: 'B')])
+ custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'),
+ FactoryBot.build_stubbed(:custom_option, value: 'B')])
end
let(:list_multi_custom_field) do
FactoryBot.build_stubbed(:list_wp_custom_field,
- custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'),
- FactoryBot.build_stubbed(:custom_option, value: 'B')],
- multi_value: true)
+ custom_options: [FactoryBot.build_stubbed(:custom_option, value: 'A'),
+ FactoryBot.build_stubbed(:custom_option, value: 'B')],
+ multi_value: true)
end
let(:version_custom_field) do
FactoryBot.build_stubbed(:version_wp_custom_field)
@@ -529,7 +529,6 @@ describe CustomActions::Actions::CustomField, type: :model do
string
date
list_multi].each do |type|
-
let(:custom_field) { send(:"#{type}_custom_field") }
it "sets the value for #{type} custom fields" do
diff --git a/spec/models/custom_actions/actions/responsible_spec.rb b/spec/models/custom_actions/actions/responsible_spec.rb
index 3c1b85729c..db4fe684cd 100644
--- a/spec/models/custom_actions/actions/responsible_spec.rb
+++ b/spec/models/custom_actions/actions/responsible_spec.rb
@@ -33,7 +33,7 @@ describe CustomActions::Actions::Responsible, type: :model do
let(:type) { :associated_property }
let(:allowed_values) do
principals = [FactoryBot.build_stubbed(:user),
- FactoryBot.build_stubbed(:group)]
+ FactoryBot.build_stubbed(:group)]
allow(User)
.to receive_message_chain(:not_locked, :select, :ordered_by_name)
diff --git a/spec/models/custom_field_spec.rb b/spec/models/custom_field_spec.rb
index 85a7fbfea1..3260327752 100644
--- a/spec/models/custom_field_spec.rb
+++ b/spec/models/custom_field_spec.rb
@@ -139,7 +139,6 @@ describe CustomField, type: :model do
describe "WITH a text field
WITH an invalid regexp" do
-
before do
field.field_format = 'text'
field.regexp = '[0-9}'
diff --git a/spec/models/custom_value/format_strategy_spec.rb b/spec/models/custom_value/format_strategy_spec.rb
index ea6863e191..9f99e1b8b7 100644
--- a/spec/models/custom_value/format_strategy_spec.rb
+++ b/spec/models/custom_value/format_strategy_spec.rb
@@ -29,10 +29,10 @@
require 'spec_helper'
describe CustomValue::FormatStrategy do
- let(:custom_value) {
+ let(:custom_value) do
double('CustomValue',
value: value)
- }
+ end
describe '#value_present?' do
subject { described_class.new(custom_value).value_present? }
diff --git a/spec/models/custom_value/list_strategy_integration_spec.rb b/spec/models/custom_value/list_strategy_integration_spec.rb
index 19d1ac9778..8155e2d748 100644
--- a/spec/models/custom_value/list_strategy_integration_spec.rb
+++ b/spec/models/custom_value/list_strategy_integration_spec.rb
@@ -42,12 +42,12 @@ describe CustomValue::ListStrategy, 'integration tests' do
)
end
- let!(:work_package) {
+ let!(:work_package) do
FactoryBot.create :work_package,
project: project,
type: type,
custom_values: { custom_field.id => custom_field.custom_options.find_by(value: 'A') }
- }
+ end
it 'can handle invalid CustomOptions (Regression test)' do
expect(work_package.public_send(:"custom_field_#{custom_field.id}")).to eq(%w(A))
diff --git a/spec/models/custom_value_spec.rb b/spec/models/custom_value_spec.rb
index 482da5990f..fc1a601b29 100644
--- a/spec/models/custom_value_spec.rb
+++ b/spec/models/custom_value_spec.rb
@@ -86,7 +86,7 @@ describe CustomValue do
describe 'date custom value' do
let(:format) { 'date' }
- let(:value) { Date.new(2016,12,1) }
+ let(:value) { Date.new(2016, 12, 1) }
it { expect(subject.typed_value).to eql(value) }
diff --git a/spec/models/enabled_module_spec.rb b/spec/models/enabled_module_spec.rb
index e38d742ffc..d578675b2e 100644
--- a/spec/models/enabled_module_spec.rb
+++ b/spec/models/enabled_module_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -44,14 +45,14 @@ describe EnabledModule, type: :model do
it 'should not create a separate wiki when one exists already' do
expect(project.wiki).to_not be_nil
- expect {
+ expect do
project.enabled_module_names = []
project.reload
- }.to_not change { Wiki.count }
+ end.to_not change { Wiki.count }
- expect {
+ expect do
project.enabled_module_names = ['wiki']
- }.to_not change { Wiki.count }
+ end.to_not change { Wiki.count }
expect(project.wiki).to_not be_nil
end
@@ -87,14 +88,14 @@ describe EnabledModule, type: :model do
project.reload
expect(project.repository).to_not be_nil
- expect {
+ expect do
project.enabled_module_names = []
project.reload
- }.to_not change { Repository.count }
+ end.to_not change { Repository.count }
- expect {
+ expect do
project.enabled_module_names = ['repository']
- }.to_not change { Repository.count }
+ end.to_not change { Repository.count }
expect(project.repository).to_not be_nil
end
@@ -114,11 +115,11 @@ describe EnabledModule, type: :model do
let(:vendor) { 'git' }
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
git: { manages: File.join(tmpdir, 'git') }
}
- }
+ end
before do
allow(Setting).to receive(:enabled_scm).and_return(['git'])
diff --git a/spec/models/global_role_spec.rb b/spec/models/global_role_spec.rb
index 162d055e5a..acfe39ea20 100644
--- a/spec/models/global_role_spec.rb
+++ b/spec/models/global_role_spec.rb
@@ -76,7 +76,7 @@ describe GlobalRole, type: :model do
end
describe 'WITH set permissions' do
- before { @role = GlobalRole.new permissions: [:perm1, :perm2, :perm3] }
+ before { @role = GlobalRole.new permissions: %i[perm1 perm2 perm3] }
describe '#has_permission?' do
it { expect(@role.has_permission?(:perm1)).to be_truthy }
diff --git a/spec/models/group_performance_spec.rb b/spec/models/group_performance_spec.rb
index 32c365b552..695814e5b8 100644
--- a/spec/models/group_performance_spec.rb
+++ b/spec/models/group_performance_spec.rb
@@ -54,7 +54,8 @@ describe Group, type: :model do
type: project.types.first,
author: user,
project: project,
- status: status)
+ status: status
+ )
work_packages.first.tap do |wp|
wp.assigned_to = group
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index f27eb5448d..bff8486259 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -39,9 +39,9 @@ describe Group, type: :model do
let(:status) { FactoryBot.create(:status) }
let(:package) do
FactoryBot.build(:work_package, type: project.types.first,
- author: user,
- project: project,
- status: status)
+ author: user,
+ project: project,
+ status: status)
end
it 'should create' do
@@ -79,7 +79,6 @@ describe Group, type: :model do
let!(:member) { FactoryBot.create :member, project: project, principal: group, role_ids: role_ids }
let!(:group) { FactoryBot.create(:group, members: user) }
-
it 'should roles removed when removing group membership' do
expect(user).to be_member_of project
member.destroy
@@ -101,7 +100,7 @@ describe Group, type: :model do
member = FactoryBot.build :member
roles = FactoryBot.create_list :role, 2
role_ids = roles.map(&:id)
- member.attributes = {principal: group, role_ids: role_ids}
+ member.attributes = { principal: group, role_ids: role_ids }
member.save!
member.role_ids = [role_ids.first]
@@ -184,7 +183,6 @@ describe Group, type: :model do
build_preference
create_preference
create_preference!}.each do |method|
-
it "should not respond to #{method}" do
expect(group).to_not respond_to method
end
diff --git a/spec/models/issue_priority_spec.rb b/spec/models/issue_priority_spec.rb
index 09e6192bdc..cb52ec4b49 100644
--- a/spec/models/issue_priority_spec.rb
+++ b/spec/models/issue_priority_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/models/journal/aggregated_journal_spec.rb b/spec/models/journal/aggregated_journal_spec.rb
index 0ed4ee6d65..9c7547c723 100644
--- a/spec/models/journal/aggregated_journal_spec.rb
+++ b/spec/models/journal/aggregated_journal_spec.rb
@@ -31,7 +31,7 @@
require 'spec_helper'
RSpec::Matchers.define :be_equivalent_to_journal do |expected|
- ignored_attributes = [:notes_id, :notes_version]
+ ignored_attributes = %i[notes_id notes_version]
match do |actual|
expected_attributes = get_normalized_attributes expected
@@ -130,10 +130,10 @@ describe Journal::AggregatedJournal, type: :model do
end
it 'returns the single journal for both original journals' do
- expect(described_class.containing_journal work_package.journals.first)
+ expect(described_class.containing_journal(work_package.journals.first))
.to be_equivalent_to_journal subject.first
- expect(described_class.containing_journal work_package.journals.second)
+ expect(described_class.containing_journal(work_package.journals.second))
.to be_equivalent_to_journal subject.first
end
@@ -173,15 +173,15 @@ describe Journal::AggregatedJournal, type: :model do
end
it 'returns the same aggregated journal for the first two originals' do
- expect(described_class.containing_journal work_package.journals.first)
+ expect(described_class.containing_journal(work_package.journals.first))
.to be_equivalent_to_journal subject.first
- expect(described_class.containing_journal work_package.journals.second)
+ expect(described_class.containing_journal(work_package.journals.second))
.to be_equivalent_to_journal subject.first
end
it 'returns a different aggregated journal for the last original' do
- expect(described_class.containing_journal work_package.journals.last)
+ expect(described_class.containing_journal(work_package.journals.last))
.to be_equivalent_to_journal subject.second
end
end
diff --git a/spec/models/ldap_auth_source_spec.rb b/spec/models/ldap_auth_source_spec.rb
index 4879c0955a..720614661c 100644
--- a/spec/models/ldap_auth_source_spec.rb
+++ b/spec/models/ldap_auth_source_spec.rb
@@ -30,7 +30,8 @@ require 'spec_helper'
describe LdapAuthSource, type: :model do
it 'should create' do
- a = LdapAuthSource.new(name: 'My LDAP', host: 'ldap.example.net', port: 389, base_dn: 'dc=example,dc=net', attr_login: 'sAMAccountName')
+ a = LdapAuthSource.new(name: 'My LDAP', host: 'ldap.example.net', port: 389, base_dn: 'dc=example,dc=net',
+ attr_login: 'sAMAccountName')
expect(a.save).to eq true
end
@@ -57,7 +58,8 @@ describe LdapAuthSource, type: :model do
describe 'with live LDAP' do
before(:all) do
ldif = Rails.root.join('spec/fixtures/ldap/users.ldif')
- @ldap_server = Ladle::Server.new(quiet: false, port: ParallelHelper.port_for_ldap.to_s, domain: 'dc=example,dc=com', ldif: ldif).start
+ @ldap_server = Ladle::Server.new(quiet: false, port: ParallelHelper.port_for_ldap.to_s, domain: 'dc=example,dc=com',
+ ldif: ldif).start
end
after(:all) do
@@ -67,7 +69,7 @@ describe LdapAuthSource, type: :model do
# Ldap has three users aa729, bb459, cc414
let(:ldap) do
FactoryBot.create :ldap_auth_source,
- port: ParallelHelper.port_for_ldap.to_s,
+ port: ParallelHelper.port_for_ldap.to_s,
account: 'uid=admin,ou=system',
account_password: 'secret',
base_dn: 'ou=people,dc=example,dc=com',
diff --git a/spec/models/mail_handler_spec.rb b/spec/models/mail_handler_spec.rb
index 1f4f5608b2..f0e6d841d9 100644
--- a/spec/models/mail_handler_spec.rb
+++ b/spec/models/mail_handler_spec.rb
@@ -28,7 +28,8 @@
require 'spec_helper'
-DEVELOPER_PERMISSIONS = [:view_messages, :delete_own_messages, :edit_own_messages, :add_project, :edit_project, :select_project_modules, :manage_members, :manage_versions, :manage_categories, :view_work_packages, :add_work_packages, :edit_work_packages, :manage_work_package_relations, :manage_subtasks, :add_work_package_notes, :move_work_packages, :delete_work_packages, :view_work_package_watchers, :add_work_package_watchers, :delete_work_package_watchers, :manage_public_queries, :save_queries, :view_gantt, :view_calendar, :log_time, :view_time_entries, :edit_time_entries, :delete_time_entries, :manage_news, :comment_news, :view_documents, :manage_documents, :view_wiki_pages, :export_wiki_pages, :view_wiki_edits, :edit_wiki_pages, :delete_wiki_pages_attachments, :protect_wiki_pages, :delete_wiki_pages, :rename_wiki_pages, :add_messages, :edit_messages, :delete_messages, :manage_forums, :view_files, :manage_files, :browse_repository, :manage_repository, :view_changesets, :manage_project_activities, :export_work_packages]
+DEVELOPER_PERMISSIONS = %i[view_messages delete_own_messages edit_own_messages add_project edit_project
+ select_project_modules manage_members manage_versions manage_categories view_work_packages add_work_packages edit_work_packages manage_work_package_relations manage_subtasks add_work_package_notes move_work_packages delete_work_packages view_work_package_watchers add_work_package_watchers delete_work_package_watchers manage_public_queries save_queries view_gantt view_calendar log_time view_time_entries edit_time_entries delete_time_entries manage_news comment_news view_documents manage_documents view_wiki_pages export_wiki_pages view_wiki_edits edit_wiki_pages delete_wiki_pages_attachments protect_wiki_pages delete_wiki_pages rename_wiki_pages add_messages edit_messages delete_messages manage_forums view_files manage_files browse_repository manage_repository view_changesets manage_project_activities export_work_packages]
describe MailHandler, type: :model do
let(:anno_user) { User.anonymous }
@@ -76,7 +77,7 @@ describe MailHandler, type: :model do
member_in_project: project,
member_with_permissions: permissions)
end
- let(:submit_options) { {allow_override: 'version'} }
+ let(:submit_options) { { allow_override: 'version' } }
subject do
submit_email('wp_on_given_project_case_insensitive.eml', **submit_options)
@@ -254,7 +255,7 @@ describe MailHandler, type: :model do
end
include_context 'wp_on_given_project' do
- let(:submit_options) { {issue: {type: default_type.name}} }
+ let(:submit_options) { { issue: { type: default_type.name } } }
end
it_behaves_like 'work package created'
@@ -270,7 +271,7 @@ describe MailHandler, type: :model do
Role.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :public, true
expect do
- work_package = submit_email('ticket_by_unknown_user.eml', issue: {project: 'onlinestore'}, unknown_user: 'create')
+ work_package = submit_email('ticket_by_unknown_user.eml', issue: { project: 'onlinestore' }, unknown_user: 'create')
work_package_created(work_package)
expect(work_package.author.active?).to be_truthy
expect(work_package.author.mail).to eq('john.doe@somenet.foo')
@@ -323,14 +324,14 @@ describe MailHandler, type: :model do
end
end
- context 'email from emission address', with_settings: {mail_from: 'openproject@example.net'} do
+ context 'email from emission address', with_settings: { mail_from: 'openproject@example.net' } do
before do
Role.non_member.add_permission!(:add_work_packages)
end
subject do
submit_email('ticket_from_emission_address.eml',
- issue: {project: public_project.identifier},
+ issue: { project: public_project.identifier },
unknown_user: 'create')
end
@@ -394,7 +395,7 @@ describe MailHandler, type: :model do
expect(WorkPackage).to receive(:find_by).with(id: 123).and_return(work_package)
# Mail with two attachemnts, one of which is skipped by signature.asc filename match
- submit_email 'update_ticket_with_attachment_and_sig.eml', issue: {project: 'onlinestore'}
+ submit_email 'update_ticket_with_attachment_and_sig.eml', issue: { project: 'onlinestore' }
work_package.reload
@@ -415,7 +416,7 @@ describe MailHandler, type: :model do
expect(WorkPackage).to receive(:find_by).with(id: 123).and_return(work_package)
# Mail with two attachemnts, one of which is skipped by signature.asc filename match
- submit_email 'update_ticket_with_attachment_and_sig.eml', issue: {project: 'onlinestore'}
+ submit_email 'update_ticket_with_attachment_and_sig.eml', issue: { project: 'onlinestore' }
expect(work_package.attachments.length).to eq 2
end
@@ -439,7 +440,7 @@ describe MailHandler, type: :model do
let(:custom_field) { FactoryBot.create :text_wp_custom_field, name: "Notes" }
before do
- submit_email 'work_package_with_text_custom_field.eml', issue: {project: project.identifier}
+ submit_email 'work_package_with_text_custom_field.eml', issue: { project: project.identifier }
work_package.reload
end
@@ -455,7 +456,7 @@ describe MailHandler, type: :model do
let(:custom_field) { FactoryBot.create :list_wp_custom_field, name: "Letters", possible_values: %w(A B C) }
before do
- submit_email 'work_package_with_list_custom_field.eml', issue: {project: project.identifier}
+ submit_email 'work_package_with_list_custom_field.eml', issue: { project: project.identifier }
work_package.reload
end
@@ -471,7 +472,7 @@ describe MailHandler, type: :model do
end
context 'truncate emails based on the Setting' do
- context 'with no setting', with_settings: {mail_handler_body_delimiters: ''} do
+ context 'with no setting', with_settings: { mail_handler_body_delimiters: '' } do
include_context 'wp_on_given_project'
it_behaves_like 'work package created'
@@ -485,7 +486,7 @@ describe MailHandler, type: :model do
end
end
- context 'with a single string', with_settings: {mail_handler_body_delimiters: '---'} do
+ context 'with a single string', with_settings: { mail_handler_body_delimiters: '---' } do
include_context 'wp_on_given_project'
it_behaves_like 'work package created'
@@ -506,7 +507,7 @@ describe MailHandler, type: :model do
end
context 'with a single quoted reply (e.g. reply to a OpenProject email notification)',
- with_settings: {mail_handler_body_delimiters: '--- Reply above. Do not remove this line. ---'} do
+ with_settings: { mail_handler_body_delimiters: '--- Reply above. Do not remove this line. ---' } do
include_context 'wp_update_with_quoted_reply_above'
it_behaves_like 'journal created'
@@ -524,7 +525,7 @@ describe MailHandler, type: :model do
end
context 'with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)',
- with_settings: {mail_handler_body_delimiters: '--- Reply above. Do not remove this line. ---'} do
+ with_settings: { mail_handler_body_delimiters: '--- Reply above. Do not remove this line. ---' } do
include_context 'wp_update_with_quoted_reply_above'
it_behaves_like 'journal created'
@@ -542,7 +543,7 @@ describe MailHandler, type: :model do
end
context 'with multiple strings',
- with_settings: {mail_handler_body_delimiters: "---\nBREAK"} do
+ with_settings: { mail_handler_body_delimiters: "---\nBREAK" } do
include_context 'wp_on_given_project'
it_behaves_like 'work package created'
@@ -575,7 +576,7 @@ describe MailHandler, type: :model do
project.update_attribute :public, true
work_package = submit_email 'ticket_with_category.eml',
- issue: {project: 'onlinestore'},
+ issue: { project: 'onlinestore' },
allow_override: ['category'],
unknown_user: 'create'
work_package_created(work_package)
diff --git a/spec/models/menu_items/query_menu_item_spec.rb b/spec/models/menu_items/query_menu_item_spec.rb
index 3546a8eabc..874c0c2df0 100644
--- a/spec/models/menu_items/query_menu_item_spec.rb
+++ b/spec/models/menu_items/query_menu_item_spec.rb
@@ -36,13 +36,13 @@ describe MenuItems::QueryMenuItem, type: :model do
describe 'it should destroy all items when destroying' do
before(:each) do
query_item = FactoryBot.create(:query_menu_item,
- query: query,
- name: 'Query Item',
- title: 'Query Item')
+ query: query,
+ name: 'Query Item',
+ title: 'Query Item')
another_query_item = FactoryBot.create(:query_menu_item,
- query: another_query,
- name: 'Another Query Item',
- title: 'Another Query Item')
+ query: another_query,
+ name: 'Another Query Item',
+ title: 'Another Query Item')
end
it 'the associated query' do
diff --git a/spec/models/menu_items/wiki_menu_item_spec.rb b/spec/models/menu_items/wiki_menu_item_spec.rb
index a1486fbf65..568f25cd3a 100644
--- a/spec/models/menu_items/wiki_menu_item_spec.rb
+++ b/spec/models/menu_items/wiki_menu_item_spec.rb
@@ -54,8 +54,8 @@ describe MenuItems::WikiMenuItem, type: :model do
wikipage = FactoryBot.create(:wiki_page, title: 'Oldtitle')
menu_item_1 = FactoryBot.create(:wiki_menu_item, navigatable_id: wikipage.wiki.id,
- title: 'Item 1',
- name: wikipage.slug)
+ title: 'Item 1',
+ name: wikipage.slug)
wikipage.title = 'Newtitle'
wikipage.save!
@@ -68,7 +68,8 @@ describe MenuItems::WikiMenuItem, type: :model do
wikipage = FactoryBot.create(:wiki_page, title: 'Parent Page')
parent = FactoryBot.create(
- :wiki_menu_item, navigatable_id: wikipage.wiki.id, title: 'Item 1', name: wikipage.slug)
+ :wiki_menu_item, navigatable_id: wikipage.wiki.id, title: 'Item 1', name: wikipage.slug
+ )
child_1 = parent.children.create name: "child-1", title: "Child 1"
child_2 = parent.children.build name: "child-1", title: "Child 2"
@@ -82,13 +83,13 @@ describe MenuItems::WikiMenuItem, type: :model do
@project.reload
@menu_item_1 = FactoryBot.create(:wiki_menu_item, wiki: @project.wiki,
- name: 'Item 1',
- title: 'Item 1')
+ name: 'Item 1',
+ title: 'Item 1')
@menu_item_2 = FactoryBot.create(:wiki_menu_item, wiki: @project.wiki,
- name: 'Item 2',
- parent_id: @menu_item_1.id,
- title: 'Item 2')
+ name: 'Item 2',
+ parent_id: @menu_item_1.id,
+ title: 'Item 2')
end
it 'all children when deleting the parent' do
diff --git a/spec/models/messages_spec.rb b/spec/models/messages_spec.rb
index abf88a7513..a050771a97 100644
--- a/spec/models/messages_spec.rb
+++ b/spec/models/messages_spec.rb
@@ -102,7 +102,7 @@ describe Message, type: :model do
let!(:message) { FactoryBot.create :message, forum: forum1 }
it 'should moving message should update counters' do
- expect {
+ expect do
forum1.reload
expect(forum1.topics_count).to eq 1
expect(forum1.messages_count).to eq 1
@@ -115,7 +115,7 @@ describe Message, type: :model do
expect(forum2.reload.topics_count).to eq 1
expect(forum1.messages_count).to eq 0
expect(forum2.messages_count).to eq 1
- }.not_to change { Message.count }
+ end.not_to change { Message.count }
end
end
@@ -134,7 +134,6 @@ describe Message, type: :model do
expect(message.sticky).to eq 1
end
-
describe 'with reply set' do
let!(:reply) do
FactoryBot.create :message, forum: message.forum, parent: message
diff --git a/spec/models/news_spec.rb b/spec/models/news_spec.rb
index 815329745a..bd19f2286c 100644
--- a/spec/models/news_spec.rb
+++ b/spec/models/news_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -27,18 +28,18 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
require 'spec_helper'
-require File.expand_path('../../support/shared/become_member', __FILE__)
+require File.expand_path('../support/shared/become_member', __dir__)
require 'support/shared/acts_as_watchable'
describe News, type: :model do
include BecomeMember
- let(:project) {
+ let(:project) do
project = FactoryBot.create(:public_project)
project.enabled_modules << EnabledModule.new(name: 'news')
project.reload
- }
+ end
let!(:news) { FactoryBot.create(:news, project: project) }
let(:permissions) { [] }
diff --git a/spec/models/permitted_params_spec.rb b/spec/models/permitted_params_spec.rb
index f991ea0081..e3054ef52a 100644
--- a/spec/models/permitted_params_spec.rb
+++ b/spec/models/permitted_params_spec.rb
@@ -507,15 +507,15 @@ describe PermittedParams, type: :model do
subject { PermittedParams.new(params, user).send(attribute, external_authentication, change_password_allowed).to_h }
all_permissions = ['admin',
- 'login',
- 'firstname',
- 'lastname',
- 'mail',
- 'mail_notification',
- 'language',
- 'custom_fields',
- 'auth_source_id',
- 'force_password_change']
+ 'login',
+ 'firstname',
+ 'lastname',
+ 'mail',
+ 'mail_notification',
+ 'language',
+ 'custom_fields',
+ 'auth_source_id',
+ 'force_password_change']
describe :user_create_as_admin do
let(:attribute) { :user_create_as_admin }
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 86140f3c09..be353a8eff 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/shared/become_member', __FILE__)
+require File.expand_path('../support/shared/become_member', __dir__)
describe Project, type: :model do
include BecomeMember
@@ -141,7 +141,7 @@ describe Project, type: :model do
end
describe 'name' do
- let(:project) { FactoryBot.build_stubbed :project, name: ' Hello World '}
+ let(:project) { FactoryBot.build_stubbed :project, name: ' Hello World ' }
before do
project.valid?
diff --git a/spec/models/projects/allowed_to_scope_spec.rb b/spec/models/projects/allowed_to_scope_spec.rb
index f4a4f6f78c..9f76f544e6 100644
--- a/spec/models/projects/allowed_to_scope_spec.rb
+++ b/spec/models/projects/allowed_to_scope_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -334,14 +335,14 @@ describe Project, 'allowed to', type: :model do
context 'w/ the non member role having the permission
w/o the project being active' do
- let(:project_status) { false}
+ let(:project_status) { false }
it_behaves_like 'is empty'
end
context 'w/ the permission being public and not module bound
w/o the project being active' do
- let(:project_status) { false}
+ let(:project_status) { false }
it 'is empty' do
expect(Project.allowed_to(user, public_non_module_action)).to be_empty
diff --git a/spec/models/projects/customizable_spec.rb b/spec/models/projects/customizable_spec.rb
index c5d5ac3b17..2c3de7fc7b 100644
--- a/spec/models/projects/customizable_spec.rb
+++ b/spec/models/projects/customizable_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
describe Project, 'customizable', type: :model do
let(:project) do
FactoryBot.build_stubbed(:project,
- custom_values: custom_values)
+ custom_values: custom_values)
end
let(:stub_available_custom_fields) do
custom_fields_stub = double('custom fields stub')
@@ -81,8 +81,8 @@ describe Project, 'customizable', type: :model do
context 'with a value set' do
let(:custom_value) do
FactoryBot.build_stubbed(:custom_value,
- custom_field: custom_field,
- value: true)
+ custom_field: custom_field,
+ value: true)
end
let(:custom_values) { [custom_value] }
@@ -98,13 +98,13 @@ describe Project, 'customizable', type: :model do
let(:available_custom_fields) { [bool_custom_field, list_custom_field, text_custom_field] }
let(:text_custom_value) do
FactoryBot.build_stubbed(:custom_value,
- custom_field: text_custom_field,
- value: 'blubs')
+ custom_field: text_custom_field,
+ value: 'blubs')
end
let(:bool_custom_value) do
FactoryBot.build_stubbed(:custom_value,
- custom_field: bool_custom_field,
- value: true)
+ custom_field: bool_custom_field,
+ value: true)
end
let(:custom_values) { [bool_custom_value, text_custom_value] }
diff --git a/spec/models/projects/scopes/activated_time_activity_spec.rb b/spec/models/projects/scopes/activated_time_activity_spec.rb
index 0ff08c874e..22686f308f 100644
--- a/spec/models/projects/scopes/activated_time_activity_spec.rb
+++ b/spec/models/projects/scopes/activated_time_activity_spec.rb
@@ -60,8 +60,8 @@ describe Projects::Scopes::ActivatedTimeActivity, type: :model do
context 'with project specific overrides' do
before do
- TimeEntryActivitiesProject.insert( { activity_id: activity.id, project_id: project.id, active: true } )
- TimeEntryActivitiesProject.insert( { activity_id: activity.id, project_id: other_project.id, active: false } )
+ TimeEntryActivitiesProject.insert({ activity_id: activity.id, project_id: project.id, active: true })
+ TimeEntryActivitiesProject.insert({ activity_id: activity.id, project_id: other_project.id, active: false })
end
context 'and being active' do
diff --git a/spec/models/projects/storage_spec.rb b/spec/models/projects/storage_spec.rb
index 9cc60bb33b..3a9f3892b0 100644
--- a/spec/models/projects/storage_spec.rb
+++ b/spec/models/projects/storage_spec.rb
@@ -29,10 +29,10 @@
require 'spec_helper'
describe Projects::Storage, type: :model do
- let(:project1) {
+ let(:project1) do
FactoryBot.create(:project)
.reload # Reload required for wiki association to be available
- }
+ end
let(:project2) { FactoryBot.create(:project) }
before do
@@ -51,7 +51,6 @@ describe Projects::Storage, type: :model do
describe '#with_required_storage' do
it 'counts projects correctly' do
-
# TODO Using storage.find(project1.id) here causes work_package_required_space
# to be nil or "2500" (Postgres only) occasionally with no definitive solution found.
# The returned "2500" were pre-Rails4 behavior, thus this might be a Rails bug.
diff --git a/spec/models/queries/work_packages/filter/estimated_hours_filter_spec.rb b/spec/models/queries/work_packages/filter/estimated_hours_filter_spec.rb
index 51efd76187..c381db99d7 100644
--- a/spec/models/queries/work_packages/filter/estimated_hours_filter_spec.rb
+++ b/spec/models/queries/work_packages/filter/estimated_hours_filter_spec.rb
@@ -48,9 +48,9 @@ describe Queries::WorkPackages::Filter::EstimatedHoursFilter, type: :model do
it_behaves_like 'non ar filter'
describe '#where' do
- let!(:work_package_zero_hour) {FactoryBot.create(:work_package, estimated_hours: 0)}
- let!(:work_package_no_hours) {FactoryBot.create(:work_package, estimated_hours: nil)}
- let!(:work_package_with_hours) {FactoryBot.create(:work_package, estimated_hours: 1)}
+ let!(:work_package_zero_hour) { FactoryBot.create(:work_package, estimated_hours: 0) }
+ let!(:work_package_no_hours) { FactoryBot.create(:work_package, estimated_hours: nil) }
+ let!(:work_package_with_hours) { FactoryBot.create(:work_package, estimated_hours: 1) }
context 'with the operator being "none"' do
before do
@@ -62,5 +62,4 @@ describe Queries::WorkPackages::Filter::EstimatedHoursFilter, type: :model do
end
end
end
-
end
diff --git a/spec/models/query/results_cf_sorting_integration_spec.rb b/spec/models/query/results_cf_sorting_integration_spec.rb
index d4828d2958..4c59bd8e8a 100644
--- a/spec/models/query/results_cf_sorting_integration_spec.rb
+++ b/spec/models/query/results_cf_sorting_integration_spec.rb
@@ -50,7 +50,7 @@ describe ::Query::Results, 'Sorting of custom field floats', type: :model, with_
FactoryBot.create :work_package,
type: type,
project: project,
- custom_values: {custom_field.id => "6.25"}
+ custom_values: { custom_field.id => "6.25" }
end
let(:work_package_without_float) do
diff --git a/spec/models/query_spec.rb b/spec/models/query_spec.rb
index c8078520f9..70a59a6ccb 100644
--- a/spec/models/query_spec.rb
+++ b/spec/models/query_spec.rb
@@ -651,7 +651,6 @@ describe Query, type: :model do
end
end
-
describe 'project limiting filter' do
def subproject_filter?(filter)
filter.is_a?(Queries::WorkPackages::Filter::SubprojectFilter)
diff --git a/spec/models/repository/git_spec.rb b/spec/models/repository/git_spec.rb
index 9083a1e034..b06684e743 100644
--- a/spec/models/repository/git_spec.rb
+++ b/spec/models/repository/git_spec.rb
@@ -55,7 +55,7 @@ describe Repository::Git, type: :model do
end
context 'with disabled types' do
- let(:config) { { disabled_types: [:local, :managed] } }
+ let(:config) { { disabled_types: %i[local managed] } }
it 'does not have any types' do
expect(instance.class.available_types).to be_empty
@@ -84,7 +84,7 @@ describe Repository::Git, type: :model do
it 'is manageable' do
expect(instance.manageable?).to be true
- expect(instance.class.available_types).to eq([:local, :managed])
+ expect(instance.class.available_types).to eq(%i[local managed])
end
context 'with disabled managed typed' do
@@ -107,7 +107,7 @@ describe Repository::Git, type: :model do
it 'is no longer manageable' do
expect(instance.class.available_types).to eq([])
- expect(instance.class.disabled_types).to eq([:managed, :local])
+ expect(instance.class.disabled_types).to eq(%i[managed local])
expect(instance.manageable?).to be false
end
end
@@ -178,12 +178,12 @@ describe Repository::Git, type: :model do
describe 'with an actual repository' do
with_git_repository do |repo_dir|
let(:url) { repo_dir }
- let(:instance) {
+ let(:instance) do
FactoryBot.create(:repository_git,
- path_encoding: encoding,
- url: url,
- root_url: url)
- }
+ path_encoding: encoding,
+ url: url,
+ root_url: url)
+ end
before do
instance.fetch_changesets
@@ -226,7 +226,7 @@ describe Repository::Git, type: :model do
it 'should fetch changesets from scratch' do
expect(instance.changesets.count).to eq(22)
# This test fails on macs since they count file changes to be 33, *nix system count 34
- expect(instance.file_changes.count).to be_between(33,34)
+ expect(instance.file_changes.count).to be_between(33, 34)
commit = instance.changesets.reorder(Arel.sql('committed_on ASC')).first
expect(commit.comments).to eq("Initial import.\nThe repository contains 3 files.")
@@ -239,7 +239,7 @@ describe Repository::Git, type: :model do
expect(commit.scmid).to eq('7234cb2750b63f47bff735edc50a1c0a433c2518')
expect(commit.file_changes.count).to eq(3)
- change = commit.file_changes.sort_by(&:path).first
+ change = commit.file_changes.min_by(&:path)
expect(change.path).to eq('README')
expect(change.action).to eq('A')
end
@@ -444,21 +444,23 @@ describe Repository::Git, type: :model do
instance.fetch_changesets
instance.reload
changesets = instance.latest_changesets(
- "latin-1-dir/test-#{char1_hex}-subdir", '1ca7f5ed')
+ "latin-1-dir/test-#{char1_hex}-subdir", '1ca7f5ed'
+ )
expect(changesets.map(&:revision))
.to eq(['1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127'])
end
it 'should browse changesets' do
changesets = instance.latest_changesets(
- "latin-1-dir/test-#{char1_hex}-2.txt", '64f1f3e89')
+ "latin-1-dir/test-#{char1_hex}-2.txt", '64f1f3e89'
+ )
expect(changesets.map(&:revision))
.to eq(['64f1f3e89ad1cb57976ff0ad99a107012ba3481d',
- '4fc55c43bf3d3dc2efb66145365ddc17639ce81e',
- ])
+ '4fc55c43bf3d3dc2efb66145365ddc17639ce81e'])
changesets = instance.latest_changesets(
- "latin-1-dir/test-#{char1_hex}-2.txt", '64f1f3e89', 1)
+ "latin-1-dir/test-#{char1_hex}-2.txt", '64f1f3e89', 1
+ )
expect(changesets.map(&:revision))
.to eq(['64f1f3e89ad1cb57976ff0ad99a107012ba3481d'])
end
@@ -468,7 +470,6 @@ describe Repository::Git, type: :model do
it_behaves_like 'is a countable repository' do
let(:repository) { instance }
end
-
end
end
diff --git a/spec/models/repository/subversion_spec.rb b/spec/models/repository/subversion_spec.rb
index ef07c5356c..8dc2c30f45 100644
--- a/spec/models/repository/subversion_spec.rb
+++ b/spec/models/repository/subversion_spec.rb
@@ -63,7 +63,7 @@ describe Repository::Subversion, type: :model do
end
context 'with disabled types' do
- let(:config) { { disabled_types: [:existing, :managed] } }
+ let(:config) { { disabled_types: %i[existing managed] } }
it 'does not have any types' do
expect(instance.class.available_types).to be_empty
@@ -89,7 +89,7 @@ describe Repository::Subversion, type: :model do
it 'is no longer manageable' do
expect(instance.class.available_types).to eq([:existing])
- expect(instance.class.disabled_types).to eq([:managed, :unknowntype])
+ expect(instance.class.disabled_types).to eq(%i[managed unknowntype])
expect(instance.manageable?).to be false
end
end
@@ -107,7 +107,7 @@ describe Repository::Subversion, type: :model do
it 'is manageable' do
expect(instance.manageable?).to be true
- expect(instance.class.available_types).to eq([:existing, :managed])
+ expect(instance.class.available_types).to eq(%i[existing managed])
end
context 'with disabled managed typed' do
@@ -148,11 +148,10 @@ describe Repository::Subversion, type: :model do
end
describe 'with a remote repository' do
- let(:instance) {
+ let(:instance) do
FactoryBot.build(:repository_subversion,
- url: 'https://somewhere.example.org/svn/foo'
- )
- }
+ url: 'https://somewhere.example.org/svn/foo')
+ end
it_behaves_like 'is not a countable repository' do
let(:repository) { instance }
@@ -181,7 +180,7 @@ describe Repository::Subversion, type: :model do
instance.fetch_changesets
# Remove changesets with revision > 5
- instance.changesets.each do |c| c.destroy if c.revision.to_i > 5 end
+ instance.changesets.each { |c| c.destroy if c.revision.to_i > 5 }
instance.reload
expect(instance.changesets.count).to eq(5)
@@ -278,8 +277,8 @@ describe Repository::Subversion, type: :model do
assert_equal s1.encode('UTF-8'), s2
end
c = Changeset.new(repository: instance,
- comments: s2,
- revision: '123',
+ comments: s2,
+ revision: '123',
committed_on: Time.now)
expect(c.save).to be true
expect(c.comments).to eq(s2)
diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb
index 06646c6803..9ffe51befd 100644
--- a/spec/models/role_spec.rb
+++ b/spec/models/role_spec.rb
@@ -29,7 +29,7 @@
require 'spec_helper'
describe Role, type: :model do
- let(:permissions) { [:permission1, :permission2] }
+ let(:permissions) { %i[permission1 permission2] }
let(:build_role) { FactoryBot.build(:role, permissions: permissions) }
let(:created_role) { FactoryBot.create(:role, permissions: permissions) }
diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb
index 3631ba803e..7c8f5438aa 100644
--- a/spec/models/setting_spec.rb
+++ b/spec/models/setting_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -220,9 +221,9 @@ describe Setting, type: :model do
end
context 'cache is not empty' do
- let(:cached_hash) {
+ let(:cached_hash) do
{ 'available_languages' => "---\n- en\n- de\n" }
- }
+ end
before do
Rails.cache.write(cache_key, cached_hash)
diff --git a/spec/models/system_user_spec.rb b/spec/models/system_user_spec.rb
index 37a966b0d8..2fd16d38fc 100644
--- a/spec/models/system_user_spec.rb
+++ b/spec/models/system_user_spec.rb
@@ -59,18 +59,18 @@ describe SystemUser, type: :model do
let(:project) { FactoryBot.create(:project_with_types, public: false) }
let(:user) { FactoryBot.build(:user) }
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
- let(:member) {
+ let(:member) do
FactoryBot.build(:member, project: project,
roles: [role],
principal: user)
- }
+ end
let(:status) { FactoryBot.create(:status) }
- let(:issue) {
+ let(:issue) do
FactoryBot.build(:work_package, type: project.types.first,
author: user,
project: project,
status: status)
- }
+ end
before do
issue.save!
diff --git a/spec/models/type_spec.rb b/spec/models/type_spec.rb
index 6eda37ec84..a1cfd22f0f 100644
--- a/spec/models/type_spec.rb
+++ b/spec/models/type_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -73,11 +74,11 @@ describe ::Type, type: :model do
let!(:type) { FactoryBot.create(:type) }
let!(:workflow_a) do
FactoryBot.create(:workflow, role_id: role.id,
- type_id: type.id,
- old_status_id: statuses[0].id,
- new_status_id: statuses[1].id,
- author: false,
- assignee: false)
+ type_id: type.id,
+ old_status_id: statuses[0].id,
+ new_status_id: statuses[1].id,
+ author: false,
+ assignee: false)
end
it 'returns the statuses relation' do
diff --git a/spec/models/user_deletion_spec.rb b/spec/models/user_deletion_spec.rb
index 7722ed5f90..d5d7d1e304 100644
--- a/spec/models/user_deletion_spec.rb
+++ b/spec/models/user_deletion_spec.rb
@@ -35,20 +35,20 @@ describe User, 'deletion', type: :model do
let(:member) { project.members.first }
let(:role) { member.roles.first }
let(:status) { FactoryBot.create(:status) }
- let(:issue) {
+ let(:issue) do
FactoryBot.create(:work_package, type: project.types.first,
- author: user,
- project: project,
- status: status,
- assigned_to: user)
- }
- let(:issue2) {
+ author: user,
+ project: project,
+ status: status,
+ assigned_to: user)
+ end
+ let(:issue2) do
FactoryBot.create(:work_package, type: project.types.first,
- author: user2,
- project: project,
- status: status,
- assigned_to: user2)
- }
+ author: user2,
+ project: project,
+ status: status,
+ assigned_to: user2)
+ end
let(:substitute_user) { DeletedUser.first }
@@ -179,25 +179,25 @@ describe User, 'deletion', type: :model do
end
describe 'WHEN the user has an issue created and assigned' do
- let(:associated_instance) {
+ let(:associated_instance) do
FactoryBot.build(:work_package, type: project.types.first,
- project: project,
- status: status)
- }
+ project: project,
+ status: status)
+ end
let(:associated_class) { WorkPackage }
- let(:associations) { [:author, :assigned_to, :responsible] }
+ let(:associations) { %i[author assigned_to responsible] }
it_should_behave_like 'created journalized associated object'
end
describe 'WHEN the user has an issue updated and assigned' do
- let(:associated_instance) {
+ let(:associated_instance) do
FactoryBot.build(:work_package, type: project.types.first,
- project: project,
- status: status)
- }
+ project: project,
+ status: status)
+ end
let(:associated_class) { WorkPackage }
- let(:associations) { [:author, :assigned_to, :responsible] }
+ let(:associations) { %i[author assigned_to responsible] }
before do
allow(User).to receive(:current).and_return user2
@@ -286,12 +286,12 @@ describe User, 'deletion', type: :model do
end
describe 'WHEN the user has created a time entry' do
- let(:associated_instance) {
+ let(:associated_instance) do
FactoryBot.build(:time_entry, project: project,
- work_package: issue,
- hours: 2,
- activity: FactoryBot.create(:time_entry_activity))
- }
+ work_package: issue,
+ hours: 2,
+ activity: FactoryBot.create(:time_entry_activity))
+ end
let(:associated_class) { TimeEntry }
let(:associations) { [:user] }
@@ -299,12 +299,12 @@ describe User, 'deletion', type: :model do
end
describe 'WHEN the user has worked on time_entry' do
- let(:associated_instance) {
+ let(:associated_instance) do
FactoryBot.build(:time_entry, project: project,
- work_package: issue,
- hours: 2,
- activity: FactoryBot.create(:time_entry_activity))
- }
+ work_package: issue,
+ hours: 2,
+ activity: FactoryBot.create(:time_entry_activity))
+ end
let(:associated_class) { TimeEntry }
let(:associations) { [:user] }
@@ -314,10 +314,10 @@ describe User, 'deletion', type: :model do
describe 'WHEN the user has commented' do
let(:news) { FactoryBot.create(:news, author: user) }
- let(:associated_instance) {
+ let(:associated_instance) do
Comment.new(commented: news,
comments: 'lorem')
- }
+ end
let(:associated_class) { Comment }
let(:associations) { [:author] }
@@ -342,10 +342,10 @@ describe User, 'deletion', type: :model do
describe 'WHEN the user is watching something' do
let(:watched) { FactoryBot.create(:work_package, project: project) }
- let(:watch) {
+ let(:watch) do
Watcher.new(user: user,
watchable: watched)
- }
+ end
before do
watch.save!
@@ -357,9 +357,9 @@ describe User, 'deletion', type: :model do
end
describe 'WHEN the user has a token created' do
- let(:token) {
+ let(:token) do
Token::RSS.new(user: user, value: 'loremipsum')
- }
+ end
before do
token.save!
@@ -395,8 +395,8 @@ describe User, 'deletion', type: :model do
with_virtual_subversion_repository do
let(:associated_instance) do
FactoryBot.build(:changeset,
- repository_id: repository.id,
- committer: user.login)
+ repository_id: repository.id,
+ committer: user.login)
end
let(:associated_class) { Changeset }
@@ -410,8 +410,8 @@ describe User, 'deletion', type: :model do
with_virtual_subversion_repository do
let(:associated_instance) do
FactoryBot.build(:changeset,
- repository_id: repository.id,
- committer: user2.login)
+ repository_id: repository.id,
+ committer: user2.login)
end
end
@@ -447,10 +447,10 @@ describe User, 'deletion', type: :model do
end
describe 'WHEN the user is assigned an issue category' do
- let(:category) {
+ let(:category) do
FactoryBot.build(:category, assigned_to: user,
- project: project)
- }
+ project: project)
+ end
before do
category.save!
diff --git a/spec/models/user_password_spec.rb b/spec/models/user_password_spec.rb
index 1a54e638a9..8cea9681eb 100644
--- a/spec/models/user_password_spec.rb
+++ b/spec/models/user_password_spec.rb
@@ -61,13 +61,13 @@ describe UserPassword, type: :model do
end
describe '#rehash_as_active' do
- let(:password) {
+ let(:password) do
pass = FactoryBot.build(:legacy_sha1_password, user: user, plain_password: 'adminAdmin!')
expect(pass).to receive(:salt_and_hash_password!).and_return nil
pass.save!
pass
- }
+ end
before do
password
@@ -76,9 +76,9 @@ describe UserPassword, type: :model do
it 'rehashed the password when correct' do
expect(user.current_password).to be_a(UserPassword::SHA1)
- expect {
+ expect do
password.matches_plaintext?('adminAdmin!')
- }.to_not change { user.passwords.count }
+ end.to_not change { user.passwords.count }
expect(user.current_password).to be_a(UserPassword::Bcrypt)
expect(user.current_password.hashed_password).to start_with '$2a$'
diff --git a/spec/models/user_passwords/sha1_spec.rb b/spec/models/user_passwords/sha1_spec.rb
index 57b0231fb5..99a57fd74c 100644
--- a/spec/models/user_passwords/sha1_spec.rb
+++ b/spec/models/user_passwords/sha1_spec.rb
@@ -29,13 +29,13 @@
require 'spec_helper'
describe UserPassword::SHA1, type: :model do
- let(:legacy_password) {
+ let(:legacy_password) do
pass = FactoryBot.build(:legacy_sha1_password, plain_password: 'adminAdmin!')
expect(pass).to receive(:salt_and_hash_password!).and_return nil
pass.save!
pass
- }
+ end
describe '#matches_plaintext?' do
it 'still matches for existing passwords' do
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 0e6d1baffd..9e5dd2dd47 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -92,7 +92,6 @@ describe User, type: :model do
end
end
-
describe 'a user with and overly long firstname (> 256 chars)' do
it 'is invalid' do
user.firstname = 'a' * 257
@@ -109,7 +108,6 @@ describe User, type: :model do
end
end
-
describe 'login whitespace' do
before do
user.login = login
@@ -337,7 +335,10 @@ describe User, type: :model do
end
it { expect(@u.valid?).to be_falsey }
- it { expect(@u.errors[:password]).to include I18n.t('activerecord.errors.messages.too_short', count: Setting.password_min_length.to_i) }
+ it {
+ expect(@u.errors[:password]).to include I18n.t('activerecord.errors.messages.too_short',
+ count: Setting.password_min_length.to_i)
+ }
end
describe '#random_password' do
@@ -445,7 +446,9 @@ describe User, type: :model do
end
describe '.default_admin_account_deleted_or_changed?' do
- let(:default_admin) { FactoryBot.build(:user, login: 'admin', password: 'admin', password_confirmation: 'admin', admin: true) }
+ let(:default_admin) do
+ FactoryBot.build(:user, login: 'admin', password: 'admin', password_confirmation: 'admin', admin: true)
+ end
before do
Setting.password_min_length = 5
diff --git a/spec/models/users/allowed_scope_spec.rb b/spec/models/users/allowed_scope_spec.rb
index 87d2aac70a..44177ab349 100644
--- a/spec/models/users/allowed_scope_spec.rb
+++ b/spec/models/users/allowed_scope_spec.rb
@@ -38,7 +38,7 @@ describe User, 'allowed scope' do
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role])
+ roles: [role])
end
let(:action) { :view_work_packages }
diff --git a/spec/models/users/allowed_to_spec.rb b/spec/models/users/allowed_to_spec.rb
index 40cb83da52..b43286b09f 100644
--- a/spec/models/users/allowed_to_spec.rb
+++ b/spec/models/users/allowed_to_spec.rb
@@ -36,16 +36,16 @@ describe User, 'allowed_to?' do
let(:role) { FactoryBot.build(:role) }
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
- let(:member) {
+ let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role],
- principal: user)
- }
- let(:member2) {
+ roles: [role],
+ principal: user)
+ end
+ let(:member2) do
FactoryBot.build(:member, project: project2,
- roles: [role2],
- principal: user)
- }
+ roles: [role2],
+ principal: user)
+ end
let(:global_permission) { OpenProject::AccessControl.permissions.find { |p| p.global? } }
let(:global_role) { FactoryBot.build(:global_role, permissions: [global_permission.name]) }
let(:global_member) do
@@ -413,7 +413,6 @@ describe User, 'allowed_to?' do
context "w/o the user being member in a project
w/ the user having the global role
w/ the global role having the necessary permission" do
-
before do
project.save!
@@ -576,7 +575,6 @@ describe User, 'allowed_to?' do
context "w/o the user being member in a project
w/ the user having a global role
w/o the global role having the necessary permission" do
-
before do
global_role.permissions = []
global_role.save!
@@ -592,7 +590,6 @@ describe User, 'allowed_to?' do
context "w/o the user being member in a project
w/o the user having the global role
w/ the global role having the necessary permission" do
-
before do
global_role.save!
end
@@ -655,9 +652,9 @@ describe User, 'allowed_to?' do
context 'w/ preloaded permissions' do
it_behaves_like 'w/ inquiring for project' do
- let(:final_setup_step) {
+ let(:final_setup_step) do
user.preload_projects_allowed_to(permission)
- }
+ end
end
end
end
diff --git a/spec/models/version_spec.rb b/spec/models/version_spec.rb
index 3c7e81d185..e5f886aee5 100644
--- a/spec/models/version_spec.rb
+++ b/spec/models/version_spec.rb
@@ -45,7 +45,7 @@ describe Version, type: :model do
let(:other_project) { FactoryBot.build(:project) }
it 'returns only the version for the same project' do
- expect(version.to_s_for_project(version.project)).to eq("#{version.name}")
+ expect(version.to_s_for_project(version.project)).to eq(version.name.to_s)
end
it 'returns the project name and the version name for a different project' do
diff --git a/spec/models/watcher_notification_mailer_spec.rb b/spec/models/watcher_notification_mailer_spec.rb
index 094fb88ef2..d44de1cb81 100644
--- a/spec/models/watcher_notification_mailer_spec.rb
+++ b/spec/models/watcher_notification_mailer_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -41,38 +42,38 @@ shared_examples 'WatcherNotificationMailer' do |watcher_notification_job|
end
describe 'watcher setup' do
- let(:work_package) {
+ let(:work_package) do
work_package = FactoryBot.build_stubbed(:work_package)
journal = FactoryBot.build_stubbed(:work_package_journal)
allow(work_package).to receive(:journals).and_return([journal])
work_package
- }
+ end
let(:watcher_changer) do
FactoryBot.build_stubbed(:user,
- mail_notification: watching_setting,
- preference: user_pref)
+ mail_notification: watching_setting,
+ preference: user_pref)
end
let(:watching_setting) { 'all' }
let(:self_notified) { true }
- let(:watching_user) {
+ let(:watching_user) do
FactoryBot.build_stubbed(:user,
- mail_notification: watching_setting,
- preference: user_pref)
- }
- let(:user_pref) {
+ mail_notification: watching_setting,
+ preference: user_pref)
+ end
+ let(:user_pref) do
pref = FactoryBot.build_stubbed(:user_preference)
allow(pref).to receive(:self_notified?).and_return(self_notified)
pref
- }
+ end
let(:watcher) do
FactoryBot.build_stubbed(:watcher, user: watching_user,
- watchable: work_package)
+ watchable: work_package)
end
shared_examples_for 'notifies the added watcher for' do |setting|
diff --git a/spec/models/wiki_content_spec.rb b/spec/models/wiki_content_spec.rb
index 9daefe4dd5..180c8c0763 100644
--- a/spec/models/wiki_content_spec.rb
+++ b/spec/models/wiki_content_spec.rb
@@ -66,15 +66,16 @@ describe WikiContent, type: :model do
describe '#save (create)' do
let(:content) { FactoryBot.build(:wiki_content, page: page) }
- it 'sends mails to the wiki`s watchers and project all watchers', with_settings: { notified_events: ['wiki_content_added'] } do
+ it 'sends mails to the wiki`s watchers and project all watchers',
+ with_settings: { notified_events: ['wiki_content_added'] } do
wiki_watcher
project_watcher
- expect {
+ expect do
perform_enqueued_jobs do
content.save!
end
- }
+ end
.to change { ActionMailer::Base.deliveries.size }
.by(2)
end
@@ -89,11 +90,11 @@ describe WikiContent, type: :model do
content.text = 'My new content'
- expect {
+ expect do
perform_enqueued_jobs do
content.save!
end
- }
+ end
.to change { ActionMailer::Base.deliveries.size }
.by(3)
end
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index c6e9816dc5..c3a19818ff 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -70,7 +70,9 @@ describe WikiPage, type: :model do
describe '#nearest_main_item' do
let(:child_page) { FactoryBot.create(:wiki_page, parent: wiki_page, wiki: wiki) }
- let!(:child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: child_page.slug, parent: wiki_page.menu_item) }
+ let!(:child_page_wiki_menu_item) do
+ FactoryBot.create(:wiki_menu_item, wiki: wiki, name: child_page.slug, parent: wiki_page.menu_item)
+ end
let(:grand_child_page) { FactoryBot.create(:wiki_page, parent: child_page, wiki: wiki) }
let!(:grand_child_page_wiki_menu_item) { FactoryBot.create(:wiki_menu_item, wiki: wiki, name: grand_child_page.slug) }
diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb
index d2b3e88cd4..ec516a49ab 100644
--- a/spec/models/wiki_spec.rb
+++ b/spec/models/wiki_spec.rb
@@ -29,7 +29,6 @@
require 'spec_helper'
describe Wiki, type: :model do
-
describe 'creation' do
let(:project) { FactoryBot.create(:project, disable_modules: 'wiki') }
let(:start_page) { 'The wiki start page' }
diff --git a/spec/models/work_package/aggregate_ancestors_spec.rb b/spec/models/work_package/aggregate_ancestors_spec.rb
index 78e8e87d22..4189053120 100644
--- a/spec/models/work_package/aggregate_ancestors_spec.rb
+++ b/spec/models/work_package/aggregate_ancestors_spec.rb
@@ -35,38 +35,38 @@ describe WorkPackage::Ancestors, type: :model do
let!(:root_work_package) do
FactoryBot.create :work_package,
- project: project
+ project: project
end
let!(:intermediate) do
FactoryBot.create :work_package,
- parent: root_work_package,
- project: project
+ parent: root_work_package,
+ project: project
end
let!(:intermediate_project2) do
FactoryBot.create :work_package,
- parent: root_work_package,
- project: project2
+ parent: root_work_package,
+ project: project2
end
let!(:leaf) do
FactoryBot.create :work_package,
- parent: intermediate,
- project: project
+ parent: intermediate,
+ project: project
end
let!(:leaf_project2) do
FactoryBot.create :work_package,
- parent: intermediate_project2,
- project: project
+ parent: intermediate_project2,
+ project: project
end
let(:view_role) do
FactoryBot.build(:role,
- permissions: [:view_work_packages])
+ permissions: [:view_work_packages])
end
let(:none_role) do
FactoryBot.build(:role,
- permissions: [])
+ permissions: [])
end
let(:leaf_ids) { [leaf.id, leaf_project2.id] }
@@ -82,9 +82,9 @@ describe WorkPackage::Ancestors, type: :model do
context 'with permission in the first project' do
before do
FactoryBot.create :member,
- user: user,
- project: project,
- roles: [view_role]
+ user: user,
+ project: project,
+ roles: [view_role]
end
describe 'fetching from db' do
@@ -120,9 +120,9 @@ describe WorkPackage::Ancestors, type: :model do
context 'and permission in second project' do
before do
FactoryBot.create :member,
- user: user,
- project: project2,
- roles: [view_role]
+ user: user,
+ project: project2,
+ roles: [view_role]
end
describe 'leaf ids' do
@@ -142,9 +142,9 @@ describe WorkPackage::Ancestors, type: :model do
context 'no permissions' do
before do
FactoryBot.create :member,
- user: user,
- project: project,
- roles: [none_role]
+ user: user,
+ project: project,
+ roles: [none_role]
end
describe 'leaf ids' do
diff --git a/spec/models/work_package/ask_before_destruction_spec.rb b/spec/models/work_package/ask_before_destruction_spec.rb
index e034380c36..368c82b78c 100644
--- a/spec/models/work_package/ask_before_destruction_spec.rb
+++ b/spec/models/work_package/ask_before_destruction_spec.rb
@@ -31,11 +31,11 @@ require 'spec_helper'
describe WorkPackage, type: :model do
let(:work_package) do
FactoryBot.create(:work_package, project: project,
- status: status)
+ status: status)
end
let(:work_package2) do
FactoryBot.create(:work_package, project: project2,
- status: status)
+ status: status)
end
let(:user) { FactoryBot.create(:user) }
diff --git a/spec/models/work_package/openproject_notifications_spec.rb b/spec/models/work_package/openproject_notifications_spec.rb
index 19fde2c2f7..65492fd83d 100644
--- a/spec/models/work_package/openproject_notifications_spec.rb
+++ b/spec/models/work_package/openproject_notifications_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/models/work_package/work_package_action_mailer_spec.rb b/spec/models/work_package/work_package_action_mailer_spec.rb
index dc27a104c9..800b7c6396 100644
--- a/spec/models/work_package/work_package_action_mailer_spec.rb
+++ b/spec/models/work_package/work_package_action_mailer_spec.rb
@@ -70,7 +70,11 @@ describe WorkPackage, type: :model do
ActionMailer::Base.deliveries.clear
work_package.subject = 'A different subject update'
- work_package.save! rescue nil
+ begin
+ work_package.save!
+ rescue StandardError
+ nil
+ end
end
it { is_expected.to eq(0) }
diff --git a/spec/models/work_package/work_package_acts_as_searchable_spec.rb b/spec/models/work_package/work_package_acts_as_searchable_spec.rb
index a7ed140a12..6460e0f85c 100644
--- a/spec/models/work_package/work_package_acts_as_searchable_spec.rb
+++ b/spec/models/work_package/work_package_acts_as_searchable_spec.rb
@@ -32,15 +32,15 @@ describe WorkPackage, 'acts_as_searchable', type: :model do
include BecomeMember
let(:wp_subject) { 'the quick brown fox jumps over the lazy dog' }
- let(:project) {
+ let(:project) do
FactoryBot.create(:project,
- public: false)
- }
- let(:work_package) {
+ public: false)
+ end
+ let(:work_package) do
FactoryBot.create(:work_package,
- subject: wp_subject,
- project: project)
- }
+ subject: wp_subject,
+ project: project)
+ end
let(:user) { FactoryBot.create(:user) }
describe '#search' do
diff --git a/spec/models/work_package/work_package_acts_as_watchable_spec.rb b/spec/models/work_package/work_package_acts_as_watchable_spec.rb
index 9360dc6e18..fdc4a81b37 100644
--- a/spec/models/work_package/work_package_acts_as_watchable_spec.rb
+++ b/spec/models/work_package/work_package_acts_as_watchable_spec.rb
@@ -32,10 +32,10 @@ require 'support/shared/acts_as_watchable'
describe WorkPackage, type: :model do
let(:project) { FactoryBot.create(:project) }
- let(:work_package) {
+ let(:work_package) do
FactoryBot.create(:work_package,
- project: project)
- }
+ project: project)
+ end
it_behaves_like 'acts_as_watchable included' do
let(:model_instance) { FactoryBot.create(:work_package) }
diff --git a/spec/models/work_package/work_package_custom_actions_spec.rb b/spec/models/work_package/work_package_custom_actions_spec.rb
index 4b8fd6bd71..0530ced664 100644
--- a/spec/models/work_package/work_package_custom_actions_spec.rb
+++ b/spec/models/work_package/work_package_custom_actions_spec.rb
@@ -33,15 +33,15 @@ require 'spec_helper'
describe WorkPackage, 'custom_actions', type: :model do
let(:work_package) do
FactoryBot.build_stubbed(:stubbed_work_package,
- project: project)
+ project: project)
end
let(:project) { FactoryBot.create(:project) }
let(:status) { FactoryBot.create(:status) }
let(:other_status) { FactoryBot.create(:status) }
let(:user) do
FactoryBot.create(:user,
- member_in_project: work_package.project,
- member_through_role: role)
+ member_in_project: work_package.project,
+ member_through_role: role)
end
let(:role) do
FactoryBot.create(:role)
diff --git a/spec/models/work_package/work_package_notifications_spec.rb b/spec/models/work_package/work_package_notifications_spec.rb
index 19d4887942..5ffe79137f 100644
--- a/spec/models/work_package/work_package_notifications_spec.rb
+++ b/spec/models/work_package/work_package_notifications_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/models/work_package/work_package_scheduling_spec.rb b/spec/models/work_package/work_package_scheduling_spec.rb
index 34981f1a54..0624759ea6 100644
--- a/spec/models/work_package/work_package_scheduling_spec.rb
+++ b/spec/models/work_package/work_package_scheduling_spec.rb
@@ -32,7 +32,7 @@ describe WorkPackage, type: :model do
describe '#overdue' do
let(:work_package) do
FactoryBot.create(:work_package,
- due_date: due_date)
+ due_date: due_date)
end
shared_examples_for 'overdue' do
@@ -75,7 +75,7 @@ describe WorkPackage, type: :model do
let(:due_date) { 1.day.ago.to_date }
let(:status) do
FactoryBot.create(:status,
- is_closed: true)
+ is_closed: true)
end
before do
@@ -89,9 +89,9 @@ describe WorkPackage, type: :model do
describe '#behind_schedule?' do
let(:work_package) do
FactoryBot.create(:work_package,
- start_date: start_date,
- due_date: due_date,
- done_ratio: done_ratio)
+ start_date: start_date,
+ due_date: due_date,
+ done_ratio: done_ratio)
end
shared_examples_for 'behind schedule' do
diff --git a/spec/models/work_package/work_package_visibility_spec.rb b/spec/models/work_package/work_package_visibility_spec.rb
index edaed6a5b9..a6e8c9c66e 100644
--- a/spec/models/work_package/work_package_visibility_spec.rb
+++ b/spec/models/work_package/work_package_visibility_spec.rb
@@ -63,9 +63,9 @@ describe 'WorkPackage-Visibility', type: :model do
it 'is visible for members of the project, with the view_work_packages permissison' do
FactoryBot.create(:member,
- user: user,
- project: private_project,
- role_ids: [view_work_packages.id])
+ user: user,
+ project: private_project,
+ role_ids: [view_work_packages.id])
expect(WorkPackage.visible(user)).to match_array [subject]
end
@@ -74,10 +74,10 @@ describe 'WorkPackage-Visibility', type: :model do
subject
FactoryBot.create(:member,
- user: user,
- project: private_project,
- role_ids: [view_work_packages.id,
- view_work_packages_role2.id])
+ user: user,
+ project: private_project,
+ role_ids: [view_work_packages.id,
+ view_work_packages_role2.id])
expect(WorkPackage.visible(user).pluck(:id)).to match_array [subject.id]
end
@@ -89,9 +89,9 @@ describe 'WorkPackage-Visibility', type: :model do
it 'is not visible for members of the project, without the view_work_packages permissison' do
no_permission = FactoryBot.create(:role, permissions: [:no_permission])
FactoryBot.create(:member,
- user: user,
- project: private_project,
- role_ids: [no_permission.id])
+ user: user,
+ project: private_project,
+ role_ids: [no_permission.id])
expect(WorkPackage.visible(user)).to match_array []
end
diff --git a/spec/models/work_package_spec.rb b/spec/models/work_package_spec.rb
index aaafdff685..92dcd8d501 100644
--- a/spec/models/work_package_spec.rb
+++ b/spec/models/work_package_spec.rb
@@ -130,7 +130,7 @@ describe WorkPackage, type: :model do
subject do
FactoryBot.create(:work_package,
- assigned_to: group).assigned_to
+ assigned_to: group).assigned_to
end
it { is_expected.to eq(group) }
@@ -142,8 +142,8 @@ describe WorkPackage, type: :model do
let(:user_2) { FactoryBot.create(:user, member_in_project: project) }
let(:category) do
FactoryBot.create(:category,
- project: project,
- assigned_to: user_2)
+ project: project,
+ assigned_to: user_2)
end
before do
diff --git a/spec/models/work_packages/scopes/for_scheduling_spec.rb b/spec/models/work_packages/scopes/for_scheduling_spec.rb
index c228924b71..be9a21f455 100644
--- a/spec/models/work_packages/scopes/for_scheduling_spec.rb
+++ b/spec/models/work_packages/scopes/for_scheduling_spec.rb
@@ -103,7 +103,7 @@ describe WorkPackages::Scopes::ForScheduling, 'allowed scope' do
end
let(:existing_work_packages) { [] }
- subject { }
+ subject {}
describe '.for_scheduling' do
it 'is a AR scope' do
diff --git a/spec/models/workflow_spec.rb b/spec/models/workflow_spec.rb
index f6831a637c..5b0855cd9f 100644
--- a/spec/models/workflow_spec.rb
+++ b/spec/models/workflow_spec.rb
@@ -39,7 +39,7 @@ describe Workflow, type: :model do
let(:type_target) { FactoryBot.create(:type) }
shared_examples_for 'copied workflow' do
- before do Workflow.copy(type, role, type_target, role_target) end
+ before { Workflow.copy(type, role, type_target, role_target) }
subject { Workflow.order(Arel.sql('id DESC')).first }
@@ -57,37 +57,37 @@ describe Workflow, type: :model do
end
describe 'workflow w/o author or assignee' do
- let!(:workflow_src) {
+ let!(:workflow_src) do
FactoryBot.create(:workflow,
- old_status: status_0,
- new_status: status_1,
- type_id: type.id,
- role: role)
- }
+ old_status: status_0,
+ new_status: status_1,
+ type_id: type.id,
+ role: role)
+ end
it_behaves_like 'copied workflow'
end
describe 'workflow with author' do
- let!(:workflow_src) {
+ let!(:workflow_src) do
FactoryBot.create(:workflow,
- old_status: status_0,
- new_status: status_1,
- type_id: type.id,
- role: role,
- author: true)
- }
+ old_status: status_0,
+ new_status: status_1,
+ type_id: type.id,
+ role: role,
+ author: true)
+ end
it_behaves_like 'copied workflow'
end
describe 'workflow with assignee' do
- let!(:workflow_src) {
+ let!(:workflow_src) do
FactoryBot.create(:workflow,
- old_status: status_0,
- new_status: status_1,
- type_id: type.id,
- role: role,
- assignee: true)
- }
+ old_status: status_0,
+ new_status: status_1,
+ type_id: type.id,
+ role: role,
+ assignee: true)
+ end
it_behaves_like 'copied workflow'
end
end
diff --git a/spec/permissions/copy_projects_spec.rb b/spec/permissions/copy_projects_spec.rb
index 3f777c9dc9..16d24bfe6d 100644
--- a/spec/permissions/copy_projects_spec.rb
+++ b/spec/permissions/copy_projects_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/permission_specs', __FILE__)
+require File.expand_path('../support/permission_specs', __dir__)
describe CopyProjectsController, 'copy_projects permission', type: :controller do
include PermissionSpecs
diff --git a/spec/permissions/export_work_packages_spec.rb b/spec/permissions/export_work_packages_spec.rb
index a7edadadc2..4d4d4a0ab0 100644
--- a/spec/permissions/export_work_packages_spec.rb
+++ b/spec/permissions/export_work_packages_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/permission_specs', __FILE__)
+require File.expand_path('../support/permission_specs', __dir__)
describe WorkPackagesController, 'export_work_packages permission', type: :controller do
include PermissionSpecs
diff --git a/spec/permissions/manage_forums_spec.rb b/spec/permissions/manage_forums_spec.rb
index 29b9e92351..873e13d468 100644
--- a/spec/permissions/manage_forums_spec.rb
+++ b/spec/permissions/manage_forums_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/permission_specs', __FILE__)
+require File.expand_path('../support/permission_specs', __dir__)
describe ForumsController, 'manage_forums permission', type: :controller do
include PermissionSpecs
diff --git a/spec/permissions/manage_repositories_spec.rb b/spec/permissions/manage_repositories_spec.rb
index 39ff46ff1f..4588c30999 100644
--- a/spec/permissions/manage_repositories_spec.rb
+++ b/spec/permissions/manage_repositories_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/permission_specs', __FILE__)
+require File.expand_path('../support/permission_specs', __dir__)
describe RepositoriesController, 'manage_repository permission', type: :controller do
include PermissionSpecs
diff --git a/spec/permissions/view_work_packages_spec.rb b/spec/permissions/view_work_packages_spec.rb
index 00a21e3f28..f11a6bdcc7 100644
--- a/spec/permissions/view_work_packages_spec.rb
+++ b/spec/permissions/view_work_packages_spec.rb
@@ -27,7 +27,7 @@
#++
require 'spec_helper'
-require File.expand_path('../../support/permission_specs', __FILE__)
+require File.expand_path('../support/permission_specs', __dir__)
describe WorkPackagesController, 'view_work_packages permission', type: :controller do
include PermissionSpecs
diff --git a/spec/policies/query_policy_spec.rb b/spec/policies/query_policy_spec.rb
index 74ab307639..3f21c86661 100644
--- a/spec/policies/query_policy_spec.rb
+++ b/spec/policies/query_policy_spec.rb
@@ -43,7 +43,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'viewing queries' do |global|
- context "#{ global ? 'in global context' : 'in project context' }" do
+ context (global ? 'in global context' : 'in project context').to_s do
let(:other_user) { FactoryBot.build_stubbed(:user) }
if global
let(:project) { nil }
@@ -58,9 +58,9 @@ describe QueryPolicy, type: :controller do
context 'query belongs to a different user' do
let(:query) do
FactoryBot.build_stubbed(:query,
- project: project,
- user: user,
- is_public: false)
+ project: project,
+ user: user,
+ is_public: false)
end
it 'is true if the query is private and the owner views it' do
@@ -76,7 +76,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'action on persisted' do |action, global|
- context "for #{action} #{ global ? 'in global context' : 'in project context' }" do
+ context "for #{action} #{global ? 'in global context' : 'in project context'}" do
if global
let(:project) { nil }
end
@@ -93,7 +93,7 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the save_query permission in the project ' +
- 'AND the query is not persisted' do
+ 'AND the query is not persisted' do
allow(user).to receive(:allowed_to?).with(:save_queries,
project,
global: project.nil?)
@@ -104,7 +104,7 @@ describe QueryPolicy, type: :controller do
end
it 'is true if the user has the save_query permission in the project ' +
- 'AND it is his query' do
+ 'AND it is his query' do
allow(user).to receive(:allowed_to?).with(:save_queries,
project,
global: project.nil?)
@@ -115,7 +115,7 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the save_query permission in the project ' +
- 'AND it is not his query' do
+ 'AND it is not his query' do
allow(user).to receive(:allowed_to?).with(:save_queries,
project,
global: project.nil?)
@@ -127,7 +127,7 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user lacks the save_query permission in the project ' +
- 'AND it is his query' do
+ 'AND it is his query' do
allow(user).to receive(:allowed_to?).with(:save_queries,
project,
global: project.nil?)
@@ -139,8 +139,8 @@ describe QueryPolicy, type: :controller do
end
it 'is true if the user has the manage_public_query permission in the project ' +
- 'AND it is anothers query ' +
- 'AND the query is public' do
+ 'AND it is anothers query ' +
+ 'AND the query is public' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -152,8 +152,8 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user lacks the manage_public_query permission in the project ' +
- 'AND it is anothers query ' +
- 'AND the query is public' do
+ 'AND it is anothers query ' +
+ 'AND the query is public' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -165,8 +165,8 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the manage_public_query permission in the project ' +
- 'AND it is anothers query ' +
- 'AND the query is not public' do
+ 'AND it is anothers query ' +
+ 'AND the query is not public' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -180,7 +180,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'action on unpersisted' do |action, global|
- context "for #{action} #{ global ? 'in global context' : 'in project context' }" do
+ context "for #{action} #{global ? 'in global context' : 'in project context'}" do
if global
let(:project) { nil }
end
@@ -206,7 +206,7 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the save_query permission in the project ' +
- 'AND the query is persisted' do
+ 'AND the query is persisted' do
allow(user).to receive(:allowed_to?).with(:save_queries,
project,
global: global)
@@ -220,7 +220,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'publicize' do |global|
- context "#{ global ? 'in global context' : 'in project context' }" do
+ context (global ? 'in global context' : 'in project context').to_s do
if global
let(:project) { nil }
end
@@ -232,7 +232,7 @@ describe QueryPolicy, type: :controller do
end
it 'is true if the user has the manage_public_query permission in the project ' +
- 'AND it is his query' do
+ 'AND it is his query' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -242,8 +242,8 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the manage_public_query permission in the project ' +
- 'AND the query is not public ' +
- 'AND it is not his query' do
+ 'AND the query is not public ' +
+ 'AND it is not his query' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -257,7 +257,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'depublicize' do |global|
- context "#{ global ? 'in global context' : 'in project context' }" do
+ context (global ? 'in global context' : 'in project context').to_s do
if global
let(:project) { nil }
end
@@ -269,8 +269,8 @@ describe QueryPolicy, type: :controller do
end
it 'is true if the user has the manage_public_query permission in the project ' +
- 'AND the query belongs to another user' +
- 'AND the query is public' do
+ 'AND the query belongs to another user' +
+ 'AND the query is public' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -283,7 +283,7 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the manage_public_query permission in the project ' +
- 'AND the query is not public' do
+ 'AND the query is not public' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -296,7 +296,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'star' do |global|
- context "#{ global ? 'in global context' : 'in project context' }" do
+ context (global ? 'in global context' : 'in project context').to_s do
if global
let(:project) { nil }
end
@@ -310,7 +310,7 @@ describe QueryPolicy, type: :controller do
end
shared_examples 'update ordered_work_packages' do |global|
- context "#{ global ? 'in global context' : 'in project context' }" do
+ context (global ? 'in global context' : 'in project context').to_s do
if global
let(:project) { nil }
end
@@ -351,9 +351,8 @@ describe QueryPolicy, type: :controller do
expect(subject.allowed?(query, :reorder_work_packages)).to be_truthy
end
-
it 'is true if the user has the manage_public_query permission in the project ' +
- 'AND it is a public query' do
+ 'AND it is a public query' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
@@ -364,8 +363,8 @@ describe QueryPolicy, type: :controller do
end
it 'is false if the user has the manage_public_query permission in the project ' +
- 'AND the query is not public ' +
- 'AND it is not his query' do
+ 'AND the query is not public ' +
+ 'AND it is not his query' do
allow(user).to receive(:allowed_to?).with(:manage_public_queries,
project,
global: project.nil?)
diff --git a/spec/policies/redirect_policy_spec.rb b/spec/policies/redirect_policy_spec.rb
index 9859981c97..e3bb9b2390 100644
--- a/spec/policies/redirect_policy_spec.rb
+++ b/spec/policies/redirect_policy_spec.rb
@@ -34,14 +34,14 @@ describe RedirectPolicy, type: :controller do
let(:return_escaped) { true }
let(:default) { 'http://test.foo/default' }
- let(:policy) {
+ let(:policy) do
described_class.new(
back_url,
default: default,
hostname: host,
return_escaped: return_escaped
)
- }
+ end
let(:subject) { policy.redirect_url }
shared_examples 'redirects to default' do |url|
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 6f9f93196c..756d8f2205 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -26,13 +26,12 @@
# See docs/COPYRIGHT.rdoc for more details.
ENV['RAILS_ENV'] ||= 'test'
-require File.expand_path('../../config/environment', __FILE__)
+require File.expand_path('../config/environment', __dir__)
require 'factory_bot_rails'
require 'rspec/rails'
require 'shoulda/matchers'
require 'test_prof/recipes/rspec/before_all'
-
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
diff --git a/spec/requests/api/v3/activities_by_work_package_resource_spec.rb b/spec/requests/api/v3/activities_by_work_package_resource_spec.rb
index cd74cd7e3e..986d127b17 100644
--- a/spec/requests/api/v3/activities_by_work_package_resource_spec.rb
+++ b/spec/requests/api/v3/activities_by_work_package_resource_spec.rb
@@ -69,7 +69,7 @@ describe API::V3::Activities::ActivitiesByWorkPackageAPI, type: :request do
shared_context 'create activity' do
before do
- header "Content-Type", "application/json"
+ header "Content-Type", "application/json"
post api_v3_paths.work_package_activities(work_package.id),
{ comment: { raw: comment } }.to_json
end
diff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
index b44f070c0e..e6ef3af91e 100644
--- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
+++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
@@ -61,7 +61,7 @@ shared_examples 'it supports direct uploads' do
expect(subject.status).to eq(404)
end
end
-
+
context 'with remote AWS storage', with_direct_uploads: true do
before do
request!
diff --git a/spec/requests/api/v3/attachments_spec.rb b/spec/requests/api/v3/attachments_spec.rb
index a0956d3c48..aa3135a29b 100644
--- a/spec/requests/api/v3/attachments_spec.rb
+++ b/spec/requests/api/v3/attachments_spec.rb
@@ -69,7 +69,9 @@ describe API::V3::Attachments::AttachmentsAPI, type: :request do
describe 'GET /uploaded' do
let(:digest) { "" }
- let(:attachment) { FactoryBot.create :attachment, digest: digest, author: current_user, container: nil, container_type: nil, downloads: -1 }
+ let(:attachment) do
+ FactoryBot.create :attachment, digest: digest, author: current_user, container: nil, container_type: nil, downloads: -1
+ end
before do
get "/api/v3/attachments/#{attachment.id}/uploaded"
diff --git a/spec/requests/api/v3/authentication_spec.rb b/spec/requests/api/v3/authentication_spec.rb
index e876cc63ac..41e4cb9bae 100644
--- a/spec/requests/api/v3/authentication_spec.rb
+++ b/spec/requests/api/v3/authentication_spec.rb
@@ -35,9 +35,9 @@ describe API::V3, type: :request do
let(:response_401) do
{
- '_type' => 'Error',
+ '_type' => 'Error',
'errorIdentifier' => 'urn:openproject-org:api:v3:errors:Unauthenticated',
- 'message' => expected_message
+ 'message' => expected_message
}
end
@@ -128,7 +128,6 @@ describe API::V3, type: :request do
expect(last_response.headers['Content-Type']).to eq 'application/hal+json; charset=utf-8'
end
-
it 'should return the WWW-Authenticate header' do
expect(last_response.header['WWW-Authenticate'])
.to include 'Basic realm="OpenProject API"'
diff --git a/spec/requests/api/v3/cors_header_spec.rb b/spec/requests/api/v3/cors_header_spec.rb
index 08c69dff1d..c720b75215 100644
--- a/spec/requests/api/v3/cors_header_spec.rb
+++ b/spec/requests/api/v3/cors_header_spec.rb
@@ -38,10 +38,8 @@ describe 'API v3 CORS headers',
context 'with setting enabled',
with_settings: { apiv3_cors_enabled: true } do
-
context 'with allowed origin set to specific values',
with_settings: { apiv3_cors_origins: %w[https://foo.example.com bla.test] } do
-
it 'outputs CORS headers', :aggregate_failures do
options '/api/v3',
nil,
diff --git a/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb b/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb
index 917db6d4ca..da153d92d8 100644
--- a/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb
+++ b/spec/requests/api/v3/custom_actions/custom_actions_api_spec.rb
@@ -34,18 +34,18 @@ describe 'API::V3::CustomActions::CustomActionsAPI', type: :request do
let(:role) do
FactoryBot.create(:role,
- permissions: %i[edit_work_packages view_work_packages])
+ permissions: %i[edit_work_packages view_work_packages])
end
let(:project) { FactoryBot.create(:project) }
let(:work_package) do
FactoryBot.create(:work_package,
- project: project,
- assigned_to: user)
+ project: project,
+ assigned_to: user)
end
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let(:action) do
FactoryBot.create(:custom_action, actions: [CustomActions::Actions::AssignedTo.new(nil)])
diff --git a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
index 1a9c6fd48b..b149085026 100644
--- a/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
+++ b/spec/requests/api/v3/custom_options/custom_options_resource_spec.rb
@@ -35,8 +35,8 @@ describe 'API v3 Custom Options resource' do
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let(:project) { FactoryBot.create(:project) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
@@ -50,7 +50,7 @@ describe 'API v3 Custom Options resource' do
end
let(:custom_option) do
FactoryBot.create(:custom_option,
- custom_field: custom_field)
+ custom_field: custom_field)
end
subject(:response) { last_response }
diff --git a/spec/requests/api/v3/groups/group_resource_spec.rb b/spec/requests/api/v3/groups/group_resource_spec.rb
index d45818f99b..a1c0c17e2d 100644
--- a/spec/requests/api/v3/groups/group_resource_spec.rb
+++ b/spec/requests/api/v3/groups/group_resource_spec.rb
@@ -36,16 +36,16 @@ describe 'API v3 Group resource', type: :request, content_type: :json do
let(:project) { FactoryBot.create(:project) }
let(:group) do
FactoryBot.create(:group,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let(:group_project) { project }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
let(:permissions) { [:view_members] }
let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
subject(:response) { last_response }
diff --git a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb
index 38efc7349e..62b105b512 100644
--- a/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb
+++ b/spec/requests/api/v3/help_texts/help_texts_resource_spec.rb
@@ -37,8 +37,8 @@ describe 'API v3 Help texts resource' do
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let!(:help_texts) do
diff --git a/spec/requests/api/v3/membership_resources_spec.rb b/spec/requests/api/v3/membership_resources_spec.rb
index 68032773fb..cba14147c8 100644
--- a/spec/requests/api/v3/membership_resources_spec.rb
+++ b/spec/requests/api/v3/membership_resources_spec.rb
@@ -675,7 +675,7 @@ describe 'API v3 memberships resource', type: :request, content_type: :json do
.to match_array [another_role]
# Assigning a new role also updates the member
- expect(other_member.updated_at > other_member_updated_at )
+ expect(other_member.updated_at > other_member_updated_at)
.to be_truthy
end
diff --git a/spec/requests/api/v3/priority_resource_spec.rb b/spec/requests/api/v3/priority_resource_spec.rb
index 4cc688e537..60ab3ad94e 100644
--- a/spec/requests/api/v3/priority_resource_spec.rb
+++ b/spec/requests/api/v3/priority_resource_spec.rb
@@ -37,8 +37,8 @@ describe 'API v3 Priority resource' do
let(:project) { FactoryBot.create(:project, public: false) }
let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let!(:priorities) { FactoryBot.create_list(:priority, 2) }
diff --git a/spec/requests/api/v3/projects/version_resource_spec.rb b/spec/requests/api/v3/projects/version_resource_spec.rb
index 30f4ca1c0a..a92fa34805 100644
--- a/spec/requests/api/v3/projects/version_resource_spec.rb
+++ b/spec/requests/api/v3/projects/version_resource_spec.rb
@@ -35,8 +35,8 @@ describe "API v3 project's versions resource" do
let(:current_user) do
user = FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
allow(User).to receive(:current).and_return user
diff --git a/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb b/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb
index e66de513f7..7f43820a94 100644
--- a/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb
+++ b/spec/requests/api/v3/queries/columns/query_columns_resource_spec.rb
@@ -41,8 +41,8 @@ describe 'API v3 Query Column resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/create_form_api_spec.rb b/spec/requests/api/v3/queries/create_form_api_spec.rb
index 07b8827deb..65d2d7b685 100644
--- a/spec/requests/api/v3/queries/create_form_api_spec.rb
+++ b/spec/requests/api/v3/queries/create_form_api_spec.rb
@@ -190,10 +190,10 @@ describe "POST /api/v3/queries/form", type: :request do
context 'with relation columns allowed by the enterprise token' do
it 'has the static, custom field and relation columns' do
expected_columns = static_columns_json +
- custom_field_columns_json +
- relation_to_type_columns_json +
- relation_of_type_columns_json +
- non_project_type_relation_column_json
+ custom_field_columns_json +
+ relation_to_type_columns_json +
+ relation_of_type_columns_json +
+ non_project_type_relation_column_json
actual_columns = form.dig('_embedded',
'schema',
@@ -216,7 +216,7 @@ describe "POST /api/v3/queries/form", type: :request do
it 'has the static and custom field' do
expected_columns = static_columns_json +
- custom_field_columns_json
+ custom_field_columns_json
actual_columns = form.dig('_embedded',
'schema',
@@ -283,9 +283,9 @@ describe "POST /api/v3/queries/form", type: :request do
context 'with relation columns allowed by the enterprise token' do
it 'has the static, custom field and relation columns' do
expected_columns = static_columns_json +
- custom_field_columns_json +
- relation_to_type_columns_json +
- relation_of_type_columns_json
+ custom_field_columns_json +
+ relation_to_type_columns_json +
+ relation_of_type_columns_json
actual_columns = form.dig('_embedded',
'schema',
@@ -309,7 +309,7 @@ describe "POST /api/v3/queries/form", type: :request do
it 'has the static and custom field' do
expected_columns = static_columns_json +
- custom_field_columns_json
+ custom_field_columns_json
actual_columns = form.dig('_embedded',
'schema',
@@ -580,15 +580,14 @@ describe "POST /api/v3/queries/form", type: :request do
let!(:type) { FactoryBot.create(:type, custom_fields: [custom_field]) }
let!(:project) { FactoryBot.create(:project, types: [type], work_package_custom_fields: [custom_field]) }
-
- let(:path_with_cf) {
+ let(:path_with_cf) do
uri = Addressable::URI.parse(path)
uri.query = {
filters: [{ "customField#{custom_field.id}": { "operator": "=", "values": ["ABC"] } }]
}.to_query
uri.to_s
- }
+ end
let(:parameters) do
{
diff --git a/spec/requests/api/v3/queries/create_query_spec.rb b/spec/requests/api/v3/queries/create_query_spec.rb
index f393fb94e8..2ef9a0ca62 100644
--- a/spec/requests/api/v3/queries/create_query_spec.rb
+++ b/spec/requests/api/v3/queries/create_query_spec.rb
@@ -118,7 +118,7 @@ describe "POST /api/v3/queries", type: :request do
expect(query).to be_present
expect(query.group_by_column.name).to eq :assigned_to
expect(query.sort_criteria).to eq [["id", "desc"], ["assigned_to", "asc"]]
- expect(query.columns.map(&:name)).to eq [:id, :subject, :status, :assigned_to]
+ expect(query.columns.map(&:name)).to eq %i[id subject status assigned_to]
expect(query.user).to eq user
expect(query.project).to eq project
diff --git a/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb b/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb
index 9276422e95..967d7aeb13 100644
--- a/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb
+++ b/spec/requests/api/v3/queries/filters/query_filters_resource_spec.rb
@@ -41,8 +41,8 @@ describe 'API v3 Query Filter resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb b/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb
index 84649a70f4..5fe61ae976 100644
--- a/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb
+++ b/spec/requests/api/v3/queries/group_bys/query_group_bys_resource_spec.rb
@@ -41,8 +41,8 @@ describe 'API v3 Query Group By resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb b/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb
index 15ff6938eb..16b5fcbfbc 100644
--- a/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb
+++ b/spec/requests/api/v3/queries/operators/query_operators_resource_spec.rb
@@ -41,8 +41,8 @@ describe 'API v3 Query Operator resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/order/query_order_api_spec.rb b/spec/requests/api/v3/queries/order/query_order_api_spec.rb
index 3d14d3d027..916a6b5763 100644
--- a/spec/requests/api/v3/queries/order/query_order_api_spec.rb
+++ b/spec/requests/api/v3/queries/order/query_order_api_spec.rb
@@ -56,7 +56,7 @@ describe "/api/v3/queries/:id/order", type: :request do
expect(last_response.status).to eq 200
expect(body).to be_a Hash
- expect(body).to eq( { wp1.id => 0, wp2.id => 8192 }.stringify_keys )
+ expect(body).to eq({ wp1.id => 0, wp2.id => 8192 }.stringify_keys)
end
end
diff --git a/spec/requests/api/v3/queries/query_resource_spec.rb b/spec/requests/api/v3/queries/query_resource_spec.rb
index 047c2235ff..39377ce65e 100644
--- a/spec/requests/api/v3/queries/query_resource_spec.rb
+++ b/spec/requests/api/v3/queries/query_resource_spec.rb
@@ -232,7 +232,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
describe '#delete queries/:id' do
let(:path) { api_v3_paths.query query.id }
- let(:permissions) { [:view_work_packages, :manage_public_queries] }
+ let(:permissions) { %i[view_work_packages manage_public_queries] }
before do
delete path
@@ -308,7 +308,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
describe 'public queries' do
context 'user with permission to manage public queries' do
- let(:permissions) { [:view_work_packages, :manage_public_queries] }
+ let(:permissions) { %i[view_work_packages manage_public_queries] }
context 'when starring an unstarred query' do
it 'should respond with 200' do
@@ -350,7 +350,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
describe 'private queries' do
context 'user with permission to save queries' do
let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) }
- let(:permissions) { [:view_work_packages, :save_queries] }
+ let(:permissions) { %i[view_work_packages save_queries] }
context 'starring his own query' do
it 'should respond with 200' do
@@ -386,7 +386,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
let(:query) { FactoryBot.create(:public_query, project: project) }
context 'user with permission to manage public queries' do
- let(:permissions) { [:view_work_packages, :manage_public_queries] }
+ let(:permissions) { %i[view_work_packages manage_public_queries] }
context 'when unstarring a starred query' do
before(:each) do
@@ -443,7 +443,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
describe 'private queries' do
context 'user with permission to save queries' do
let(:query) { FactoryBot.create(:private_query, project: project, user: current_user) }
- let(:permissions) { [:view_work_packages, :save_queries] }
+ let(:permissions) { %i[view_work_packages save_queries] }
before(:each) do
patch unstar_path
end
diff --git a/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb b/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb
index 231802c062..f444482d6b 100644
--- a/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb
+++ b/spec/requests/api/v3/queries/schemas/query_filter_instance_schema_resource_spec.rb
@@ -44,8 +44,8 @@ describe 'API v3 Query Filter Schema resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
@@ -76,8 +76,8 @@ describe 'API v3 Query Filter Schema resource', type: :request do
end
describe '#get queries/filter_instance_schemas' do
- [:global,
- :project].each do |current_path|
+ %i[global
+ project].each do |current_path|
context current_path do
let(:path) { send "#{current_path}_path".to_sym }
diff --git a/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb b/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb
index 48343e2f70..ae8720ca7a 100644
--- a/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb
+++ b/spec/requests/api/v3/queries/schemas/query_schema_resource_spec.rb
@@ -38,8 +38,8 @@ describe 'API v3 Query Schema resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb b/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb
index fb9432b937..008c20a580 100644
--- a/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb
+++ b/spec/requests/api/v3/queries/sort_bys/query_sort_bys_resource_spec.rb
@@ -42,8 +42,8 @@ describe 'API v3 Query Sort Bys resource', type: :request do
let(:permissions) { [:view_work_packages] }
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
before do
diff --git a/spec/requests/api/v3/queries/update_query_spec.rb b/spec/requests/api/v3/queries/update_query_spec.rb
index ada6a2f4b9..6a90d14991 100644
--- a/spec/requests/api/v3/queries/update_query_spec.rb
+++ b/spec/requests/api/v3/queries/update_query_spec.rb
@@ -134,7 +134,7 @@ describe "PATCH /api/v3/queries/:id", type: :request do
expect(query.group_by_column.name).to eq :assigned_to
expect(query.sort_criteria).to eq [["id", "desc"], ["assigned_to", "asc"]]
- expect(query.columns.map(&:name)).to eq [:id, :subject, :status, :assigned_to]
+ expect(query.columns.map(&:name)).to eq %i[id subject status assigned_to]
expect(query.project).to eq project
expect(query.is_public).to eq true
expect(query.display_sums).to eq false
diff --git a/spec/requests/api/v3/rack_deflater_spec.rb b/spec/requests/api/v3/rack_deflater_spec.rb
index 8b70c10f5e..85397a041d 100644
--- a/spec/requests/api/v3/rack_deflater_spec.rb
+++ b/spec/requests/api/v3/rack_deflater_spec.rb
@@ -43,7 +43,7 @@ describe Rack::Deflater, type: :request do
etag = last_response.headers['Etag']
content_length = last_response.headers['Content-Length'].to_i
- header "Accept-Encoding", "gzip"
+ header "Accept-Encoding", "gzip"
get api_v3_paths.configuration
expect(last_response.headers['Etag']).to eql etag
diff --git a/spec/requests/api/v3/render_resource_spec.rb b/spec/requests/api/v3/render_resource_spec.rb
index 3d58d1741f..6afea6d914 100644
--- a/spec/requests/api/v3/render_resource_spec.rb
+++ b/spec/requests/api/v3/render_resource_spec.rb
@@ -80,11 +80,11 @@ describe 'API v3 Render resource', type: :request do
let(:params) { "Hello World! Have a look at ##{work_package.id}" }
let(:id) { work_package.id }
let(:href) { "/work_packages/#{id}" }
- let(:text) {
+ let(:text) do
'Hello World! Have a look at ##{id}
"
- }
+ end
context 'with work package context' do
let(:context) { api_v3_paths.work_package work_package.id }
@@ -103,9 +103,9 @@ describe 'API v3 Render resource', type: :request do
describe 'invalid' do
context 'content type' do
let(:content_type) { 'application/json' }
- let(:params) {
+ let(:params) do
{ 'text' => "Hello World! Have a look at ##{work_package.id}" }.to_json
- }
+ end
it_behaves_like 'unsupported content type',
I18n.t('api_v3.errors.invalid_content_type',
diff --git a/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb b/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb
index 951ec64ac8..96f797e2a5 100644
--- a/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb
+++ b/spec/requests/api/v3/repositories/revisions_by_work_package_resource_spec.rb
@@ -34,14 +34,14 @@ describe 'API v3 Revisions by work package resource', type: :request do
include API::V3::Utilities::PathHelper
include FileHelpers
- let(:current_user) {
+ let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
- }
+ member_in_project: project,
+ member_through_role: role)
+ end
let(:project) { FactoryBot.create(:project, public: false) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
- let(:permissions) { [:view_work_packages, :view_changesets] }
+ let(:permissions) { %i[view_work_packages view_changesets] }
let(:repository) { FactoryBot.create(:repository_subversion, project: project) }
let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) }
let(:revisions) { [] }
@@ -56,7 +56,7 @@ describe 'API v3 Revisions by work package resource', type: :request do
let(:get_path) { api_v3_paths.work_package_revisions work_package.id }
before do
- revisions.each do |rev| rev.save! end
+ revisions.each { |rev| rev.save! }
get get_path
end
@@ -66,15 +66,13 @@ describe 'API v3 Revisions by work package resource', type: :request do
it_behaves_like 'API V3 collection response', 0, 0, 'Revision'
-
context 'with existing revisions' do
- let(:revisions) {
+ let(:revisions) do
FactoryBot.build_list(:changeset,
- 5,
- comments: "This commit references ##{work_package.id}",
- repository: repository
- )
- }
+ 5,
+ comments: "This commit references ##{work_package.id}",
+ repository: repository)
+ end
it_behaves_like 'API V3 collection response', 5, 5, 'Revision'
@@ -96,20 +94,19 @@ describe 'API v3 Revisions by work package resource', type: :request do
describe 'revisions linked from another project' do
let(:subproject) { FactoryBot.create(:project, parent: project) }
let(:repository) { FactoryBot.create(:repository_subversion, project: subproject) }
- let!(:revisions) {
+ let!(:revisions) do
FactoryBot.build_list(:changeset,
- 2,
- comments: "This commit references ##{work_package.id}",
- repository: repository
- )
- }
+ 2,
+ comments: "This commit references ##{work_package.id}",
+ repository: repository)
+ end
context 'with permissions in subproject' do
- let(:current_user) {
+ let(:current_user) do
FactoryBot.create(:user,
- member_in_projects: [project, subproject],
- member_through_role: role)
- }
+ member_in_projects: [project, subproject],
+ member_through_role: role)
+ end
it_behaves_like 'API V3 collection response', 2, 2, 'Revision'
end
diff --git a/spec/requests/api/v3/repositories/revisions_resource_spec.rb b/spec/requests/api/v3/repositories/revisions_resource_spec.rb
index 7e315e6c8d..1ffffb38de 100644
--- a/spec/requests/api/v3/repositories/revisions_resource_spec.rb
+++ b/spec/requests/api/v3/repositories/revisions_resource_spec.rb
@@ -34,26 +34,25 @@ describe 'API v3 Revisions resource', type: :request do
include Capybara::RSpecMatchers
include API::V3::Utilities::PathHelper
- let(:revision) {
+ let(:revision) do
FactoryBot.create(:changeset,
- repository: repository,
- comments: 'Some commit message',
- committer: 'foo bar '
- )
- }
- let(:repository) {
+ repository: repository,
+ comments: 'Some commit message',
+ committer: 'foo bar ')
+ end
+ let(:repository) do
FactoryBot.create(:repository_subversion, project: project)
- }
- let(:project) {
+ end
+ let(:project) do
FactoryBot.create(:project, identifier: 'test_project', public: false)
- }
- let(:role) {
+ end
+ let(:role) do
FactoryBot.create(:role,
- permissions: [:view_changesets])
- }
- let(:current_user) {
+ permissions: [:view_changesets])
+ end
+ let(:current_user) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
- }
+ end
let(:unauthorized_user) { FactoryBot.create(:user) }
diff --git a/spec/requests/api/v3/root_resource_spec.rb b/spec/requests/api/v3/root_resource_spec.rb
index a82a581970..4b6113f30f 100644
--- a/spec/requests/api/v3/root_resource_spec.rb
+++ b/spec/requests/api/v3/root_resource_spec.rb
@@ -33,9 +33,9 @@ describe 'API v3 Root resource' do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
- let(:current_user) {
+ let(:current_user) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
- }
+ end
let(:role) { FactoryBot.create(:role, permissions: []) }
let(:project) { FactoryBot.create(:project, public: false) }
diff --git a/spec/requests/api/v3/support/api_v3_collection_response.rb b/spec/requests/api/v3/support/api_v3_collection_response.rb
index 8f830ea4cf..143debd7c5 100644
--- a/spec/requests/api/v3/support/api_v3_collection_response.rb
+++ b/spec/requests/api/v3/support/api_v3_collection_response.rb
@@ -51,7 +51,6 @@ shared_examples_for 'API V3 collection response' do |total, count, type|
it 'returns a collection successfully' do
aggregate_failures do
-
expect(last_response.status).to eql(200)
expect(subject).to be_json_eql('Collection'.to_json).at_path('_type')
expect(subject).to be_json_eql(count_number.to_json).at_path('count')
diff --git a/spec/requests/api/v3/support/response_examples.rb b/spec/requests/api/v3/support/response_examples.rb
index 217ad4f6cd..eb2a0dbde6 100644
--- a/spec/requests/api/v3/support/response_examples.rb
+++ b/spec/requests/api/v3/support/response_examples.rb
@@ -29,9 +29,9 @@
require 'spec_helper'
shared_examples_for 'error response' do |code, id, provided_message = nil|
- let(:expected_message) {
+ let(:expected_message) do
provided_message || message
- }
+ end
it 'has the expected status code' do
expect(last_response.status).to eq(code)
@@ -52,7 +52,7 @@ shared_examples_for 'error response' do |code, id, provided_message = nil|
it { expect(subject['message']).to include(expected_message) }
it 'includes punctuation' do
- expect(subject['message']).to match(/(\.|\?|\!)\z/)
+ expect(subject['message']).to match(/(\.|\?|!)\z/)
end
end
end
@@ -210,8 +210,10 @@ shared_examples_for 'multiple errors of the same type with messages' do
end
before do
- raise "Need to have 'message' defined to state\
- which message is expected".squish unless defined?(message)
+ unless defined?(message)
+ raise "Need to have 'message' defined to state\
+ which message is expected".squish
+ end
end
it { expect(actual_messages).to match_array(Array(message)) }
diff --git a/spec/requests/api/v3/types/type_resource_spec.rb b/spec/requests/api/v3/types/type_resource_spec.rb
index 9c9616b6c0..b02540f117 100644
--- a/spec/requests/api/v3/types/type_resource_spec.rb
+++ b/spec/requests/api/v3/types/type_resource_spec.rb
@@ -37,8 +37,8 @@ describe 'API v3 Type resource' do
let(:project) { FactoryBot.create(:project, no_types: true, public: false) }
let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let!(:types) { FactoryBot.create_list(:type, 4) }
diff --git a/spec/requests/api/v3/types/types_by_project_resource_spec.rb b/spec/requests/api/v3/types/types_by_project_resource_spec.rb
index 679c224b7d..1d63c516b7 100644
--- a/spec/requests/api/v3/types/types_by_project_resource_spec.rb
+++ b/spec/requests/api/v3/types/types_by_project_resource_spec.rb
@@ -38,8 +38,8 @@ describe '/api/v3/projects/:id/types' do
let(:requested_project) { project }
let(:current_user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let!(:irrelevant_types) { FactoryBot.create_list(:type, 4) }
diff --git a/spec/requests/api/v3/user/create_user_common_examples.rb b/spec/requests/api/v3/user/create_user_common_examples.rb
index 87b7ff9125..9403287010 100644
--- a/spec/requests/api/v3/user/create_user_common_examples.rb
+++ b/spec/requests/api/v3/user/create_user_common_examples.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -79,12 +80,12 @@ shared_examples 'create user request flow' do
describe 'invited status' do
let(:status) { 'invited' }
- let(:invitation_request) {
+ let(:invitation_request) do
{
status: status,
email: 'foo@example.org'
}
- }
+ end
describe 'invitation successful' do
before do
@@ -152,4 +153,4 @@ shared_examples 'create user request flow' do
.to include 'Status is not a valid status for new users.'
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/requests/api/v3/user/create_user_resource_spec.rb b/spec/requests/api/v3/user/create_user_resource_spec.rb
index 1e80be778f..6d5338edaa 100644
--- a/spec/requests/api/v3/user/create_user_resource_spec.rb
+++ b/spec/requests/api/v3/user/create_user_resource_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -34,7 +35,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do
include API::V3::Utilities::PathHelper
let(:path) { api_v3_paths.users }
- let(:parameters) {
+ let(:parameters) do
{
status: 'active',
login: 'myusername',
@@ -43,7 +44,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do
email: 'foobar@example.org',
language: 'de'
}
- }
+ end
before do
login_as(current_user)
@@ -129,7 +130,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do
end
describe 'active status' do
- let(:parameters) {
+ let(:parameters) do
{
status: 'active',
login: 'myusername',
@@ -138,7 +139,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do
email: 'foobar@example.org',
language: 'de'
}
- }
+ end
context 'with identity_url' do
let(:identity_url) { 'google:3289272389298' }
diff --git a/spec/requests/api/v3/user/update_user_resource_spec.rb b/spec/requests/api/v3/user/update_user_resource_spec.rb
index 2a65f33845..7ef94ac5a0 100644
--- a/spec/requests/api/v3/user/update_user_resource_spec.rb
+++ b/spec/requests/api/v3/user/update_user_resource_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -42,7 +43,7 @@ describe ::API::V3::Users::UsersAPI, type: :request do
end
def send_request
- header "Content-Type", "application/json"
+ header "Content-Type", "application/json"
patch path, parameters.to_json
end
@@ -124,7 +125,6 @@ describe ::API::V3::Users::UsersAPI, type: :request do
expect(last_response.status).to eql(404)
end
end
-
end
describe 'user with global add_user permission' do
diff --git a/spec/requests/api/v3/user/user_resource_spec.rb b/spec/requests/api/v3/user/user_resource_spec.rb
index 98a40a4902..65a2f40eb4 100644
--- a/spec/requests/api/v3/user/user_resource_spec.rb
+++ b/spec/requests/api/v3/user/user_resource_spec.rb
@@ -94,12 +94,12 @@ describe 'API v3 User resource',
context 'on filtering for name' do
let(:get_path) do
- filter = [{'name' => {
+ filter = [{ 'name' => {
'operator' => '~',
'values' => [user.name]
- }}]
+ } }]
- "#{api_v3_paths.users}?#{{filters: filter.to_json}.to_query}"
+ "#{api_v3_paths.users}?#{{ filters: filter.to_json }.to_query}"
end
it 'contains the filtered user in the response' do
@@ -123,7 +123,7 @@ describe 'API v3 User resource',
let(:get_path) do
sort = [['name', 'desc']]
- "#{api_v3_paths.users}?#{{sortBy: sort.to_json}.to_query}"
+ "#{api_v3_paths.users}?#{{ sortBy: sort.to_json }.to_query}"
end
it 'contains the first user as the first element' do
@@ -141,12 +141,12 @@ describe 'API v3 User resource',
context 'on an invalid filter' do
let(:get_path) do
- filter = [{'name' => {
+ filter = [{ 'name' => {
'operator' => 'a',
'values' => [user.name]
- }}]
+ } }]
- "#{api_v3_paths.users}?#{{filters: filter.to_json}.to_query}"
+ "#{api_v3_paths.users}?#{{ filters: filter.to_json }.to_query}"
end
it 'returns an error' do
diff --git a/spec/requests/api/v3/user/userlock_resource_spec.rb b/spec/requests/api/v3/user/userlock_resource_spec.rb
index a495850562..f30c3e40bd 100644
--- a/spec/requests/api/v3/user/userlock_resource_spec.rb
+++ b/spec/requests/api/v3/user/userlock_resource_spec.rb
@@ -63,9 +63,9 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do
end
context 'user account is incompatible' do
- let(:user) {
+ let(:user) do
FactoryBot.create(:user, status: User.statuses[:registered])
- }
+ end
it 'should fail for invalid transitions' do
expect(subject.status).to eq(400)
end
@@ -110,9 +110,9 @@ describe 'API v3 UserLock resource', type: :request, content_type: :json do
end
context 'user account is incompatible' do
- let(:user) {
+ let(:user) do
FactoryBot.create(:user, status: User.statuses[:registered])
- }
+ end
it 'should fail for invalid transitions' do
expect(subject.status).to eq(400)
end
diff --git a/spec/requests/api/v3/versions/available_projects_resource_spec.rb b/spec/requests/api/v3/versions/available_projects_resource_spec.rb
index ed008c0810..1b2b5bcca3 100644
--- a/spec/requests/api/v3/versions/available_projects_resource_spec.rb
+++ b/spec/requests/api/v3/versions/available_projects_resource_spec.rb
@@ -59,7 +59,7 @@ describe 'API v3 members available projects resource', type: :request do
user: current_user)
end
end
- #let(:membered_project) do
+ # let(:membered_project) do
# FactoryBot.create(:project).tap do |p|
# FactoryBot.create(:member,
# roles: [FactoryBot.create(:role, permissions: permissions)],
@@ -71,7 +71,7 @@ describe 'API v3 members available projects resource', type: :request do
# project: p,
# user: other_user)
# end
- #end
+ # end
let(:unauthorized_project) do
FactoryBot.create(:public_project)
end
diff --git a/spec/requests/api/v3/versions/project_resource_spec.rb b/spec/requests/api/v3/versions/project_resource_spec.rb
index e32f54aeea..9f1c8932a0 100644
--- a/spec/requests/api/v3/versions/project_resource_spec.rb
+++ b/spec/requests/api/v3/versions/project_resource_spec.rb
@@ -61,13 +61,13 @@ describe "API v3 version's projects resource" do
# this is to be included
FactoryBot.create(:member, user: current_user,
- project: project2,
- roles: [role])
+ project: project2,
+ roles: [role])
# this is to be included as the user is a member of the project, the
# lack of permissions is irrelevant.
FactoryBot.create(:member, user: current_user,
- project: project3,
- roles: [role_without_permissions])
+ project: project3,
+ roles: [role_without_permissions])
# project4 should NOT be included
project4
diff --git a/spec/requests/api/v3/watcher_resource_spec.rb b/spec/requests/api/v3/watcher_resource_spec.rb
index 6d7dee0fd6..d96ff764ca 100644
--- a/spec/requests/api/v3/watcher_resource_spec.rb
+++ b/spec/requests/api/v3/watcher_resource_spec.rb
@@ -242,7 +242,7 @@ describe 'API v3 Watcher resource', type: :request, content_type: :json do
let(:permissions) { %i[add_work_package_watchers view_work_packages] }
let(:available_watchers_path) { api_v3_paths.available_watchers work_package.id }
let(:returned_user_ids) do
- JSON.parse(subject.body)['_embedded']['elements'].map {|user| user['id'] }
+ JSON.parse(subject.body)['_embedded']['elements'].map { |user| user['id'] }
end
before do
diff --git a/spec/requests/api/v3/work_package_resource_spec.rb b/spec/requests/api/v3/work_package_resource_spec.rb
index d0dca06ff6..f022b1b0fe 100644
--- a/spec/requests/api/v3/work_package_resource_spec.rb
+++ b/spec/requests/api/v3/work_package_resource_spec.rb
@@ -324,7 +324,6 @@ describe 'API v3 Work package resource',
FactoryBot.create(:work_package,
project_id: project.id,
description: 'lorem ipsum').tap do |wp|
-
FactoryBot.create(:relation, relates: 1, from: wp, to: directly_related_wp)
FactoryBot.create(:relation, relates: 1, from: directly_related_wp, to: transitively_related_wp)
end
@@ -652,7 +651,7 @@ describe 'API v3 Work package resource',
context 'valid type changing custom fields' do
let(:custom_field) { FactoryBot.create(:work_package_custom_field) }
- let(:custom_field_parameter) { { :"customField#{custom_field.id}" => true } }
+ let(:custom_field_parameter) { { "customField#{custom_field.id}": true } }
let(:params) { valid_params.merge(type_parameter).merge(custom_field_parameter) }
before do
@@ -731,7 +730,7 @@ describe 'API v3 Work package resource',
context 'with a custom field defined on the target project' do
let(:custom_field) { FactoryBot.create(:work_package_custom_field) }
- let(:custom_field_parameter) { { :"customField#{custom_field.id}" => true } }
+ let(:custom_field_parameter) { { "customField#{custom_field.id}": true } }
let(:params) { valid_params.merge(project_parameter).merge(custom_field_parameter) }
before do
@@ -796,7 +795,7 @@ describe 'API v3 Work package resource',
describe 'valid' do
shared_examples_for 'valid user assignment' do
- let(:title) { "#{assigned_user.name}".to_json }
+ let(:title) { assigned_user.name.to_s.to_json }
it { expect(response.status).to eq(200) }
diff --git a/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb b/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb
index d66f877680..85cbd8d581 100644
--- a/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb
+++ b/spec/requests/api/v3/work_packages/available_projects_on_edit_api_spec.rb
@@ -33,8 +33,8 @@ describe 'API::V3::WorkPackages::AvailableProjectsOnEditAPI', type: :request do
include API::V3::Utilities::PathHelper
let(:edit_role) do
- FactoryBot.create(:role, permissions: [:edit_work_packages,
- :view_work_packages])
+ FactoryBot.create(:role, permissions: %i[edit_work_packages
+ view_work_packages])
end
let(:move_role) do
FactoryBot.create(:role, permissions: [:move_work_packages])
@@ -44,13 +44,13 @@ describe 'API::V3::WorkPackages::AvailableProjectsOnEditAPI', type: :request do
let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:user) do
user = FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: edit_role)
+ member_in_project: project,
+ member_through_role: edit_role)
FactoryBot.create(:member,
- user: user,
- project: target_project,
- roles: [move_role])
+ user: user,
+ project: target_project,
+ roles: [move_role])
user
end
diff --git a/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb b/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb
index a18d7338e1..863a3e536b 100644
--- a/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb
+++ b/spec/requests/api/v3/work_packages/available_relation_candidates_spec.rb
@@ -83,7 +83,6 @@ describe ::API::V3::Relations::RelationRepresenter, type: :request do
context "without cross project relations",
with_settings: { cross_project_work_package_relations: false } do
-
describe "relation candidates for wp_1 (in hierarchy)" do
it "should return an empty list" do # as relations to ancestors or descendents is not allowed
expect(result["count"]).to eq 0
@@ -117,7 +116,6 @@ describe ::API::V3::Relations::RelationRepresenter, type: :request do
context "with cross project relations",
with_settings: { cross_project_work_package_relations: true } do
-
describe "relation candidates for wp_1 (in hierarchy)" do
let(:href) { "/api/v3/work_packages/#{wp_1.id}/available_relation_candidates?query=WP" }
diff --git a/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb b/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb
index b588755adc..0ad23b007d 100644
--- a/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/create_project_form_resource_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb b/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb
index fc83d99d2b..529b69a808 100644
--- a/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/work_packages_by_project_resource_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -290,7 +291,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do
end
describe '#post' do
- let(:permissions) { [:add_work_packages, :view_project] }
+ let(:permissions) { %i[add_work_packages view_project] }
let(:status) { FactoryBot.build(:status, is_default: true) }
let(:priority) { FactoryBot.build(:priority, is_default: true) }
let(:parameters) do
@@ -314,7 +315,7 @@ describe API::V3::WorkPackages::WorkPackagesByProjectAPI, type: :request do
end
context 'notifications' do
- let(:permissions) { [:add_work_packages, :view_project, :view_work_packages] }
+ let(:permissions) { %i[add_work_packages view_project view_work_packages] }
it 'sends a mail by default' do
expect(DeliverWorkPackageNotificationJob).to have_been_enqueued
diff --git a/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb b/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb
index 3022d927ff..28cc6be278 100644
--- a/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb
+++ b/spec/requests/api/v3/work_packages/work_packages_schemas_resource_spec.rb
@@ -142,7 +142,7 @@ describe API::V3::WorkPackages::Schema::WorkPackageSchemasAPI, type: :request do
end
it 'should set a weak ETag' do
- expect(last_response.headers['ETag']).to match(/W\/\"\w+\"/)
+ expect(last_response.headers['ETag']).to match(/W\/"\w+"/)
end
it 'caches the response' do
diff --git a/spec/requests/auth/token_based_access_spec.rb b/spec/requests/auth/token_based_access_spec.rb
index 6515514325..2426ac6b9a 100644
--- a/spec/requests/auth/token_based_access_spec.rb
+++ b/spec/requests/auth/token_based_access_spec.rb
@@ -48,7 +48,7 @@ describe 'Token based access', type: :rails_request, with_settings: { login_requ
# access is possible with a token
get "/work_packages/#{work_package.id}.atom?key=#{rss_key}"
expect(response.body)
- .to include("OpenProject - #{work_package.to_s} ")
+ .to include("OpenProject - #{work_package} ")
# but for the next request, the user is not logged in
get "/work_packages/#{work_package.id}"
diff --git a/spec/requests/oauth/client_credentials_flow_spec.rb b/spec/requests/oauth/client_credentials_flow_spec.rb
index 30fd91de74..e8b4126ea7 100644
--- a/spec/requests/oauth/client_credentials_flow_spec.rb
+++ b/spec/requests/oauth/client_credentials_flow_spec.rb
@@ -35,7 +35,7 @@ describe 'OAuth client credentials flow', type: :request do
let!(:application) { FactoryBot.create(:oauth_application, client_credentials_user_id: user_id, name: 'Cool API app!') }
let(:client_secret) { application.plaintext_secret }
- let(:access_token) {
+ let(:access_token) do
response = post '/oauth/token',
grant_type: 'client_credentials',
scope: 'api_v3',
@@ -45,7 +45,7 @@ describe 'OAuth client credentials flow', type: :request do
expect(response).to be_successful
body = JSON.parse(response.body)
body['access_token']
- }
+ end
subject do
# Perform request with it
diff --git a/spec/routing/enterprise_routing_spec.rb b/spec/routing/enterprise_routing_spec.rb
index 3020824f69..97f634b219 100644
--- a/spec/routing/enterprise_routing_spec.rb
+++ b/spec/routing/enterprise_routing_spec.rb
@@ -33,7 +33,7 @@ describe EnterprisesController, type: :routing do
it 'should connect GET /admin/enterprise to enterprises#show' do
allow(OpenProject::Configuration).to receive(:ee_manager_visible?).and_return(true)
expect(get('/admin/enterprise')).to route_to(controller: 'enterprises',
- action: 'show')
+ action: 'show')
end
end
@@ -44,7 +44,7 @@ describe EnterprisesController, type: :routing do
# Think of cloud solutions for instance.
allow(OpenProject::Configuration).to receive(:ee_manager_visible?).and_return(false)
expect(get('/admin/enterprise')).not_to route_to(controller: 'enterprises',
- action: 'show')
+ action: 'show')
end
end
end
diff --git a/spec/routing/project_settings_routing_spec.rb b/spec/routing/project_settings_routing_spec.rb
index 5d0674122f..50671babcd 100644
--- a/spec/routing/project_settings_routing_spec.rb
+++ b/spec/routing/project_settings_routing_spec.rb
@@ -32,50 +32,50 @@ describe ProjectSettingsController, type: :routing do
describe 'show' do
it do
expect(get('/projects/123/settings/generic')).to route_to(
- controller: 'project_settings/generic', action: 'show', id: '123'
- )
+ controller: 'project_settings/generic', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/modules')).to route_to(
- controller: 'project_settings/modules', action: 'show', id: '123'
- )
+ controller: 'project_settings/modules', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/custom_fields')).to route_to(
- controller: 'project_settings/custom_fields', action: 'show', id: '123'
- )
+ controller: 'project_settings/custom_fields', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/versions')).to route_to(
- controller: 'project_settings/versions', action: 'show', id: '123'
- )
+ controller: 'project_settings/versions', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/categories')).to route_to(
- controller: 'project_settings/categories', action: 'show', id: '123'
- )
+ controller: 'project_settings/categories', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/repository')).to route_to(
- controller: 'project_settings/repository', action: 'show', id: '123'
- )
+ controller: 'project_settings/repository', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/activities')).to route_to(
- controller: 'project_settings/activities', action: 'show', id: '123'
- )
+ controller: 'project_settings/activities', action: 'show', id: '123'
+ )
end
it do
expect(get('/projects/123/settings/types')).to route_to(
- controller: 'project_settings/types', action: 'show', id: '123'
- )
+ controller: 'project_settings/types', action: 'show', id: '123'
+ )
end
end
diff --git a/spec/routing/status_routing_spec.rb b/spec/routing/status_routing_spec.rb
index c0d94005c5..391505250a 100644
--- a/spec/routing/status_routing_spec.rb
+++ b/spec/routing/status_routing_spec.rb
@@ -53,7 +53,8 @@ describe StatusesController, type: :routing do
it do
expect(post('/statuses/update_work_package_done_ratio')).to route_to(
controller: 'statuses',
- action: 'update_work_package_done_ratio')
+ action: 'update_work_package_done_ratio'
+ )
end
end
end
diff --git a/spec/routing/work_packages_spec.rb b/spec/routing/work_packages_spec.rb
index 30658f8dc3..d3b2120330 100644
--- a/spec/routing/work_packages_spec.rb
+++ b/spec/routing/work_packages_spec.rb
@@ -91,7 +91,6 @@ describe WorkPackagesController, type: :routing do
id: '1')
end
-
it 'should connect GET /work_packages/:work_package_id/moves/new to work_packages/moves#new' do
expect(get('/work_packages/1/move/new')).to route_to(controller: 'work_packages/moves',
action: 'new',
diff --git a/spec/security/active_support_to_json_spec.rb b/spec/security/active_support_to_json_spec.rb
index 5b8a9c17d5..0626d84dca 100644
--- a/spec/security/active_support_to_json_spec.rb
+++ b/spec/security/active_support_to_json_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/seeders/setting_seeder_spec.rb b/spec/seeders/setting_seeder_spec.rb
index a02b6d9d58..cb536e5ec9 100644
--- a/spec/seeders/setting_seeder_spec.rb
+++ b/spec/seeders/setting_seeder_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/add_work_package_note_service_spec.rb b/spec/services/add_work_package_note_service_spec.rb
index 0d5720db48..49955eea4d 100644
--- a/spec/services/add_work_package_note_service_spec.rb
+++ b/spec/services/add_work_package_note_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/api/v3/parse_query_params_service_spec.rb b/spec/services/api/v3/parse_query_params_service_spec.rb
index 45d5541add..3636672aa6 100644
--- a/spec/services/api/v3/parse_query_params_service_spec.rb
+++ b/spec/services/api/v3/parse_query_params_service_spec.rb
@@ -150,7 +150,7 @@ describe ::API::V3::ParseQueryParamsService,
context 'with display_representation' do
it_behaves_like 'transforms' do
let(:params) { { displayRepresentation: 'cards' } }
- let(:expected) { { display_representation:'cards' } }
+ let(:expected) { { display_representation: 'cards' } }
end
end
diff --git a/spec/services/api/v3/update_query_from_v3_params_service_spec.rb b/spec/services/api/v3/update_query_from_v3_params_service_spec.rb
index e4a7c4b4d4..0041f924b0 100644
--- a/spec/services/api/v3/update_query_from_v3_params_service_spec.rb
+++ b/spec/services/api/v3/update_query_from_v3_params_service_spec.rb
@@ -30,7 +30,6 @@ require 'spec_helper'
describe ::API::V3::UpdateQueryFromV3ParamsService,
type: :model do
-
let(:user) { FactoryBot.build_stubbed(:user) }
let(:query) { FactoryBot.build_stubbed(:query) }
diff --git a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
index 6f7659febf..6410e1fb6a 100644
--- a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
+++ b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb
@@ -41,7 +41,6 @@ describe ::API::V3::WorkPackageCollectionFromQueryService,
allow(query)
.to receive(:manually_sorted?)
.and_return(query_manually_sorted)
-
end
end
let(:query_manually_sorted) { false }
@@ -86,7 +85,6 @@ describe ::API::V3::WorkPackageCollectionFromQueryService,
:per_page,
:embed_schemas,
:current_user) do
-
def initialize(work_packages,
self_link:,
query:,
@@ -117,7 +115,6 @@ describe ::API::V3::WorkPackageCollectionFromQueryService,
:query,
:sums,
:current_user) do
-
def initialize(group,
count,
query:,
diff --git a/spec/services/attachments/create_service_spec.rb b/spec/services/attachments/create_service_spec.rb
index adb1e188c1..bebda3ca5b 100644
--- a/spec/services/attachments/create_service_spec.rb
+++ b/spec/services/attachments/create_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/services/authentication/omniauth_service_spec.rb b/spec/services/authentication/omniauth_service_spec.rb
index 9daa455312..4c959dacff 100644
--- a/spec/services/authentication/omniauth_service_spec.rb
+++ b/spec/services/authentication/omniauth_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -37,8 +38,7 @@ describe Authentication::OmniauthService do
info: { name: 'foo',
email: 'foo@bar.com',
first_name: 'foo',
- last_name: 'bar'
- }
+ last_name: 'bar' }
)
end
let(:controller) { double('Controller', session: session_stub) }
@@ -111,7 +111,6 @@ describe Authentication::OmniauthService do
context 'without remapping allowed',
with_settings: { oauth_allow_remapping_of_existing_users?: false } do
-
it 'does not look for the user by login' do
# Regular find
expect(User)
diff --git a/spec/services/authorization/query_transformation_spec.rb b/spec/services/authorization/query_transformation_spec.rb
index 2174e0b26b..6f9e5714f0 100644
--- a/spec/services/authorization/query_transformation_spec.rb
+++ b/spec/services/authorization/query_transformation_spec.rb
@@ -33,7 +33,7 @@ describe Authorization::QueryTransformation do
let(:name) { 'name' }
let(:after) { 'after' }
let(:before) { 'before' }
- let(:block) { -> (*args) { args } }
+ let(:block) { ->(*args) { args } }
let(:instance) do
described_class.new on,
diff --git a/spec/services/authorization/query_transformations_spec.rb b/spec/services/authorization/query_transformations_spec.rb
index 13a1670a00..6ca7d8fd7c 100644
--- a/spec/services/authorization/query_transformations_spec.rb
+++ b/spec/services/authorization/query_transformations_spec.rb
@@ -141,13 +141,13 @@ describe Authorization::QueryTransformations do
args
end
- expected_order = [:transformation1, :transformation2]
+ expected_order = %i[transformation1 transformation2]
- expect {
+ expect do
instance.register(:on, :transformation2, before: [:transformation1]) do |*args|
args.join(', ')
end
- }.to raise_error "Cannot sort #{expected_order} into the list of transformations"
+ end.to raise_error "Cannot sort #{expected_order} into the list of transformations"
end
end
end
diff --git a/spec/services/authorization/user_allowed_query_spec.rb b/spec/services/authorization/user_allowed_query_spec.rb
index 2bd345f37b..492fec23ce 100644
--- a/spec/services/authorization/user_allowed_query_spec.rb
+++ b/spec/services/authorization/user_allowed_query_spec.rb
@@ -40,7 +40,7 @@ describe Authorization::UserAllowedQuery do
let(:non_member_role) { FactoryBot.build(:non_member) }
let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role])
+ roles: [role])
end
let(:action) { :view_work_packages }
diff --git a/spec/services/authorization/user_global_roles_query_spec.rb b/spec/services/authorization/user_global_roles_query_spec.rb
index 3a0aecff20..5ac358bfd6 100644
--- a/spec/services/authorization/user_global_roles_query_spec.rb
+++ b/spec/services/authorization/user_global_roles_query_spec.rb
@@ -38,16 +38,16 @@ describe Authorization::UserGlobalRolesQuery do
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
let(:non_member) { FactoryBot.build(:non_member) }
- let(:member) {
+ let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role],
- principal: user)
- }
- let(:member2) {
+ roles: [role],
+ principal: user)
+ end
+ let(:member2) do
FactoryBot.build(:member, project: project2,
- roles: [role2],
- principal: user)
- }
+ roles: [role2],
+ principal: user)
+ end
let(:global_permission) { OpenProject::AccessControl.permissions.find { |p| p.global? } }
let(:global_role) do
FactoryBot.build(:global_role,
diff --git a/spec/services/authorization/user_project_roles_query_spec.rb b/spec/services/authorization/user_project_roles_query_spec.rb
index d9bc2756de..0048582daf 100644
--- a/spec/services/authorization/user_project_roles_query_spec.rb
+++ b/spec/services/authorization/user_project_roles_query_spec.rb
@@ -38,16 +38,16 @@ describe Authorization::UserProjectRolesQuery do
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
let(:non_member) { FactoryBot.build(:non_member) }
- let(:member) {
+ let(:member) do
FactoryBot.build(:member, project: project,
- roles: [role],
- principal: user)
- }
- let(:member2) {
+ roles: [role],
+ principal: user)
+ end
+ let(:member2) do
FactoryBot.build(:member, project: project2,
- roles: [role2],
- principal: user)
- }
+ roles: [role2],
+ principal: user)
+ end
describe '.query' do
before do
diff --git a/spec/services/base/base_callable_spec.rb b/spec/services/base/base_callable_spec.rb
index 9792d783e0..8ecca257bb 100644
--- a/spec/services/base/base_callable_spec.rb
+++ b/spec/services/base/base_callable_spec.rb
@@ -31,7 +31,7 @@ require 'spec_helper'
describe ::BaseServices::BaseCallable, type: :model do
let(:test_service) do
Class.new(::BaseServices::BaseCallable) do
- def perform(params)
+ def perform(_params)
state.test = 'foo'
ServiceResult.new(success: true, result: 'something')
end
@@ -44,7 +44,7 @@ describe ::BaseServices::BaseCallable, type: :model do
let(:test_service2) do
Class.new(::BaseServices::BaseCallable) do
- def perform(params)
+ def perform(_params)
state.test2 = 'foo'
ServiceResult.new(success: true, result: 'something')
end
diff --git a/spec/services/create_type_service_spec.rb b/spec/services/create_type_service_spec.rb
index ac2ead11ed..250f9a6d20 100644
--- a/spec/services/create_type_service_spec.rb
+++ b/spec/services/create_type_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/custom_actions/update_work_package_service_spec.rb b/spec/services/custom_actions/update_work_package_service_spec.rb
index 8cc5afe0c9..c7ddfcb674 100644
--- a/spec/services/custom_actions/update_work_package_service_spec.rb
+++ b/spec/services/custom_actions/update_work_package_service_spec.rb
@@ -205,7 +205,7 @@ describe CustomActions::UpdateWorkPackageService do
allow(contract)
.to receive(:errors)
- .and_return(:base => ['invalid'])
+ .and_return(base: ['invalid'])
work_package.lock_version = 200
diff --git a/spec/services/custom_fields/create_service_spec.rb b/spec/services/custom_fields/create_service_spec.rb
index 9b62b50986..23a7d8165a 100644
--- a/spec/services/custom_fields/create_service_spec.rb
+++ b/spec/services/custom_fields/create_service_spec.rb
@@ -31,10 +31,8 @@
require 'spec_helper'
require 'services/base_services/behaves_like_create_service'
-
describe CustomFields::CreateService, type: :model do
it_behaves_like 'BaseServices create service' do
-
context 'when creating a project cf' do
let(:model_instance) { FactoryBot.build_stubbed :project_custom_field }
diff --git a/spec/services/messages/create_service_spec.rb b/spec/services/messages/create_service_spec.rb
index c5b06442cd..a64345c942 100644
--- a/spec/services/messages/create_service_spec.rb
+++ b/spec/services/messages/create_service_spec.rb
@@ -31,7 +31,6 @@
require 'spec_helper'
require 'services/base_services/behaves_like_create_service'
-
describe Messages::CreateService, type: :model do
it_behaves_like 'BaseServices create service'
end
diff --git a/spec/services/notifications/journal_notification_service_spec.rb b/spec/services/notifications/journal_notification_service_spec.rb
index a11732973c..02b0ba9e43 100644
--- a/spec/services/notifications/journal_notification_service_spec.rb
+++ b/spec/services/notifications/journal_notification_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/notifications/journal_wp_mail_service_spec.rb b/spec/services/notifications/journal_wp_mail_service_spec.rb
index 1de94681d3..aea18c8f78 100644
--- a/spec/services/notifications/journal_wp_mail_service_spec.rb
+++ b/spec/services/notifications/journal_wp_mail_service_spec.rb
@@ -69,7 +69,9 @@ describe Notifications::JournalWpMailService do
work_package.journals.last
end
let(:send_mails) { true }
- let(:notification_setting) { %w(work_package_added work_package_updated work_package_note_added status_updated work_package_priority_updated) }
+ let(:notification_setting) do
+ %w(work_package_added work_package_updated work_package_note_added status_updated work_package_priority_updated)
+ end
def call
described_class.call(journal, send_mails)
diff --git a/spec/services/parse_schema_filter_params_service_spec.rb b/spec/services/parse_schema_filter_params_service_spec.rb
index f81560f3d3..d2cfefee4e 100644
--- a/spec/services/parse_schema_filter_params_service_spec.rb
+++ b/spec/services/parse_schema_filter_params_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/services/projects/copy_service_integration_spec.rb b/spec/services/projects/copy_service_integration_spec.rb
index 9aa5d67664..cff0afd26b 100644
--- a/spec/services/projects/copy_service_integration_spec.rb
+++ b/spec/services/projects/copy_service_integration_spec.rb
@@ -34,7 +34,9 @@ describe Projects::CopyService, 'integration', type: :model do
shared_let(:status_locked) { FactoryBot.create :status, is_readonly: true }
shared_let(:source) { FactoryBot.create :project, enabled_module_names: %w[wiki work_package_tracking] }
shared_let(:source_wp) { FactoryBot.create :work_package, project: source, subject: 'source wp' }
- shared_let(:source_wp_locked) { FactoryBot.create :work_package, project: source, subject: 'source wp locked', status: status_locked }
+ shared_let(:source_wp_locked) do
+ FactoryBot.create :work_package, project: source, subject: 'source wp locked', status: status_locked
+ end
shared_let(:source_query) { FactoryBot.create :query, project: source, name: 'My query' }
shared_let(:source_category) { FactoryBot.create :category, project: source, name: 'Stock management' }
shared_let(:source_version) { FactoryBot.create :version, project: source, name: 'Version A' }
@@ -187,8 +189,9 @@ describe Projects::CopyService, 'integration', type: :model do
let!(:user) { FactoryBot.create :user }
let!(:another_role) { FactoryBot.create(:role) }
- let!(:group) { FactoryBot.create :group, members: [user]
- }
+ let!(:group) do
+ FactoryBot.create :group, members: [user]
+ end
it 'will copy them as well' do
source.add_member! group, another_role
diff --git a/spec/services/projects/set_attributes_service_spec.rb b/spec/services/projects/set_attributes_service_spec.rb
index 432533625b..cb0dfe14af 100644
--- a/spec/services/projects/set_attributes_service_spec.rb
+++ b/spec/services/projects/set_attributes_service_spec.rb
@@ -102,7 +102,7 @@ describe Projects::SetAttributesService, type: :model do
end
context 'identifier default value' do
- context 'with a default identifier configured', with_settings: {sequential_project_identifiers: true} do
+ context 'with a default identifier configured', with_settings: { sequential_project_identifiers: true } do
context 'with an identifier provided' do
let(:call_attributes) do
{
@@ -128,7 +128,7 @@ describe Projects::SetAttributesService, type: :model do
end
end
- context 'without a default identifier configured', with_settings: {sequential_project_identifiers: false} do
+ context 'without a default identifier configured', with_settings: { sequential_project_identifiers: false } do
context 'with an identifier provided' do
let(:call_attributes) do
{
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 14342e24c3..68a2b0a39e 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -34,7 +34,7 @@ require 'services/base_services/behaves_like_update_service'
describe Projects::UpdateService, type: :model do
it_behaves_like 'BaseServices update service' do
let!(:model_instance) do
- FactoryBot.build_stubbed(:project, status: project_status).tap do |p|
+ FactoryBot.build_stubbed(:project, status: project_status).tap do |_p|
project_status.clear_changes_information
end
end
diff --git a/spec/services/queries/update_from_params_service_spec.rb b/spec/services/queries/update_from_params_service_spec.rb
index 48d52dbcad..80081dbaa6 100644
--- a/spec/services/queries/update_from_params_service_spec.rb
+++ b/spec/services/queries/update_from_params_service_spec.rb
@@ -69,7 +69,7 @@ describe UpdateQueryFromParamsService,
expect(query.group_by).to eql('status')
expect(query.show_hierarchies).to eql(true)
- expect(subject).not_to be_success
+ expect(subject).not_to be_success
end
end
end
diff --git a/spec/services/queries/update_service_spec.rb b/spec/services/queries/update_service_spec.rb
index eca2bf69c2..78a813e241 100644
--- a/spec/services/queries/update_service_spec.rb
+++ b/spec/services/queries/update_service_spec.rb
@@ -65,8 +65,8 @@ describe Queries::UpdateService do
before do
# violating the validations
violating_menu_item = FactoryBot.build(:query_menu_item,
- name: menu_item.name,
- navigatable_id: menu_item.navigatable_id)
+ name: menu_item.name,
+ navigatable_id: menu_item.navigatable_id)
violating_menu_item.save(validate: false)
diff --git a/spec/services/scm/checkout_instructions_service_spec.rb b/spec/services/scm/checkout_instructions_service_spec.rb
index f6ccc7f85a..790c23d00b 100644
--- a/spec/services/scm/checkout_instructions_service_spec.rb
+++ b/spec/services/scm/checkout_instructions_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -33,24 +34,23 @@ describe SCM::CheckoutInstructionsService do
let(:project) { FactoryBot.build(:project) }
let(:url) { 'file:///tmp/some/svn/repo' }
- let(:repository) {
+ let(:repository) do
FactoryBot.build(:repository_subversion,
- url: url,
- project: project)
- }
+ url: url,
+ project: project)
+ end
let(:base_url) { 'http://example.org/svn/' }
let(:path) { nil }
let(:text) { 'foo' }
- let(:checkout_hash) {
+ let(:checkout_hash) do
{
'git' => { 'enabled' => '0' },
'subversion' => { 'enabled' => '1',
'text' => text,
- 'base_url' => base_url
- }
+ 'base_url' => base_url }
}
- }
+ end
subject(:service) { SCM::CheckoutInstructionsService.new(repository, user: user, path: path) }
diff --git a/spec/services/scm/create_managed_repository_service_spec.rb b/spec/services/scm/create_managed_repository_service_spec.rb
index bd660c3800..ad20415c64 100644
--- a/spec/services/scm/create_managed_repository_service_spec.rb
+++ b/spec/services/scm/create_managed_repository_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -55,11 +56,11 @@ describe SCM::CreateManagedRepositoryService do
context 'with managed repository' do
# Must not .create a managed repository, or it will call this service itself!
- let(:repository) {
+ let(:repository) do
repo = Repository::Subversion.new(scm_type: :managed)
repo.project = project
repo
- }
+ end
context 'but no managed config' do
it 'does not create a filesystem repository' do
@@ -71,14 +72,14 @@ describe SCM::CreateManagedRepositoryService do
context 'with managed local config' do
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
subversion: { manages: File.join(tmpdir, 'svn') },
git: { manages: File.join(tmpdir, 'git') }
}
- }
+ end
- let(:repository) {
+ let(:repository) do
repo = Repository::Subversion.new(scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
@@ -87,7 +88,7 @@ describe SCM::CreateManagedRepositoryService do
allow(repo).to receive(:create_managed_repository)
repo.save!
repo
- }
+ end
before do
allow_any_instance_of(SCM::CreateLocalRepositoryJob)
@@ -144,18 +145,18 @@ describe SCM::CreateManagedRepositoryService do
context 'with managed remote config', webmock: true do
let(:url) { 'http://myreposerver.example.com/api/' }
- let(:config) {
+ let(:config) do
{
subversion: { manages: url }
}
- }
+ end
- let(:repository) {
+ let(:repository) do
repo = FactoryBot.build(:repository_subversion, scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
repo
- }
+ end
it 'detects the remote config' do
expect(repository.class.managed_remote.to_s).to eq(url)
@@ -200,11 +201,11 @@ describe SCM::CreateManagedRepositoryService do
context 'with https' do
let(:url) { 'https://myreposerver.example.com/api/' }
- let(:config) {
+ let(:config) do
{
subversion: { manages: url, insecure: insecure }
}
- }
+ end
let(:instance) { SCM::CreateRemoteRepositoryJob.new }
let(:job_call) { instance.perform(repository) }
diff --git a/spec/services/scm/delete_managed_repository_service_spec.rb b/spec/services/scm/delete_managed_repository_service_spec.rb
index a76ebf1bb7..033bc28a5f 100644
--- a/spec/services/scm/delete_managed_repository_service_spec.rb
+++ b/spec/services/scm/delete_managed_repository_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -65,14 +66,14 @@ describe SCM::DeleteManagedRepositoryService do
context 'with managed repository and managed config' do
include_context 'with tmpdir'
- let(:config) {
+ let(:config) do
{
subversion: { manages: File.join(tmpdir, 'svn') },
git: { manages: File.join(tmpdir, 'git') }
}
- }
+ end
- let(:repository) {
+ let(:repository) do
repo = Repository::Subversion.new(scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
@@ -80,7 +81,7 @@ describe SCM::DeleteManagedRepositoryService do
repo.save!
perform_enqueued_jobs
repo
- }
+ end
it 'deletes the repository' do
expect(File.directory?(repository.root_url)).to be true
@@ -99,9 +100,9 @@ describe SCM::DeleteManagedRepositoryService do
context 'and parent project' do
let(:parent) { FactoryBot.create(:project) }
let(:project) { FactoryBot.create(:project, parent: parent) }
- let(:repo_path) {
+ let(:repo_path) do
Pathname.new(File.join(tmpdir, 'svn', project.identifier))
- }
+ end
it 'does not delete anything but the repository itself' do
expect(service.call).to be true
@@ -118,23 +119,23 @@ describe SCM::DeleteManagedRepositoryService do
context 'with managed remote config', webmock: true do
let(:url) { 'http://myreposerver.example.com/api/' }
- let(:config) {
+ let(:config) do
{
subversion: { manages: url }
}
- }
+ end
- let(:repository) {
+ let(:repository) do
repo = Repository::Subversion.new(scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
repo
- }
+ end
context 'with a valid remote' do
before do
- stub_request(:post, url).to_return(status: 200, body: {}.to_json )
+ stub_request(:post, url).to_return(status: 200, body: {}.to_json)
end
it 'calls the callback' do
@@ -161,7 +162,6 @@ describe SCM::DeleteManagedRepositoryService do
.to receive(:perform_now)
.and_call_original
-
expect(service.call).to be false
expect(service.localized_rejected_reason)
diff --git a/spec/services/scm/repository_factory_service_spec.rb b/spec/services/scm/repository_factory_service_spec.rb
index 6a7abf89d5..a098f019d9 100644
--- a/spec/services/scm/repository_factory_service_spec.rb
+++ b/spec/services/scm/repository_factory_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -52,9 +53,9 @@ describe SCM::RepositoryFactoryService do
end
context 'with valid vendor' do
- let(:params_hash) {
+ let(:params_hash) do
{ scm_vendor: 'subversion' }
- }
+ end
it 'should allow temporary build repository' do
expect(service.build_temporary).to be true
@@ -70,9 +71,9 @@ describe SCM::RepositoryFactoryService do
end
context 'with invalid vendor' do
- let(:params_hash) {
+ let(:params_hash) do
{ scm_vendor: 'not_subversion', scm_type: 'foo' }
- }
+ end
it 'should not allow to temporary build repository' do
expect { service.build_temporary }.not_to raise_error
@@ -90,9 +91,9 @@ describe SCM::RepositoryFactoryService do
end
context 'with vendor and type' do
- let(:params_hash) {
+ let(:params_hash) do
{ scm_vendor: 'subversion', scm_type: 'existing' }
- }
+ end
it 'should not allow to persist a repository without URL' do
expect(service.build_and_save).not_to be true
@@ -103,12 +104,12 @@ describe SCM::RepositoryFactoryService do
end
context 'with invalid hash' do
- let(:params_hash) {
+ let(:params_hash) do
{
scm_vendor: 'subversion', scm_type: 'existing',
repository: { url: '/tmp/foo.svn' }
}
- }
+ end
it 'should not allow to persist a repository URL' do
expect(service.build_and_save).not_to be true
@@ -119,12 +120,12 @@ describe SCM::RepositoryFactoryService do
end
context 'with valid hash' do
- let(:params_hash) {
+ let(:params_hash) do
{
scm_vendor: 'subversion', scm_type: 'existing',
repository: { url: 'file:///tmp/foo.svn' }
}
- }
+ end
it 'should allow to persist a repository without URL' do
expect(service.build_and_save).to be true
diff --git a/spec/services/service_result_spec.rb b/spec/services/service_result_spec.rb
index 67e801d4d0..7775103d25 100644
--- a/spec/services/service_result_spec.rb
+++ b/spec/services/service_result_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/shared_type_service.rb b/spec/services/shared_type_service.rb
index 4a812f8006..793f174e5d 100644
--- a/spec/services/shared_type_service.rb
+++ b/spec/services/shared_type_service.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/update_projects_types_service.rb b/spec/services/update_projects_types_service.rb
index 5702601d33..9b645f5277 100644
--- a/spec/services/update_projects_types_service.rb
+++ b/spec/services/update_projects_types_service.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/services/update_query_from_params_service_spec.rb b/spec/services/update_query_from_params_service_spec.rb
index b9cd494d09..827ab75208 100644
--- a/spec/services/update_query_from_params_service_spec.rb
+++ b/spec/services/update_query_from_params_service_spec.rb
@@ -30,7 +30,6 @@ require 'spec_helper'
describe UpdateQueryFromParamsService,
type: :model do
-
let(:user) { FactoryBot.build_stubbed(:user) }
let(:query) { FactoryBot.build_stubbed(:query) }
@@ -140,7 +139,7 @@ describe UpdateQueryFromParamsService,
context 'default highlighting mode', with_ee: %i[conditional_highlighting] do
let(:params) do
- { }
+ {}
end
it 'sets the highlighting_mode' do
diff --git a/spec/services/update_type_service_spec.rb b/spec/services/update_type_service_spec.rb
index 460a5d443d..99aa9e41a9 100644
--- a/spec/services/update_type_service_spec.rb
+++ b/spec/services/update_type_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/services/update_user_email_settings_service_spec.rb b/spec/services/update_user_email_settings_service_spec.rb
index 70b108f6c5..33ae46b8e7 100644
--- a/spec/services/update_user_email_settings_service_spec.rb
+++ b/spec/services/update_user_email_settings_service_spec.rb
@@ -86,9 +86,9 @@ describe UpdateUserEmailSettingsService, type: :model do
it 'set the notified_project_ids on successful saving and mail_notifications is "selected"' do
allow(user).to receive(:mail_notification).and_return 'selected'
- expect(user).to receive(:notified_project_ids=).with([1,2,3])
+ expect(user).to receive(:notified_project_ids=).with([1, 2, 3])
- service.call(notified_project_ids: [1,2,3])
+ service.call(notified_project_ids: [1, 2, 3])
end
end
end
diff --git a/spec/services/users/create_user_service_spec.rb b/spec/services/users/create_user_service_spec.rb
index cc20f6d8fd..1d3d137ad7 100644
--- a/spec/services/users/create_user_service_spec.rb
+++ b/spec/services/users/create_user_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -47,7 +48,7 @@ describe Users::CreateService do
it 'will call not call UserInvitation' do
expect(::UserInvitation).not_to receive(:invite_user!)
expect(subject).not_to be_success
- expect(subject.errors.details[:mail]).to eq [{error: :blank}]
+ expect(subject.errors.details[:mail]).to eq [{ error: :blank }]
end
end
end
diff --git a/spec/services/users/delete_service_spec.rb b/spec/services/users/delete_service_spec.rb
index 5020d65cb7..7eb1d4374c 100644
--- a/spec/services/users/delete_service_spec.rb
+++ b/spec/services/users/delete_service_spec.rb
@@ -52,7 +52,6 @@ describe ::Users::DeleteService, type: :model do
end
end
-
context 'if deletion by admins allowed', with_settings: { users_deletable_by_admins: true } do
context 'with admin user' do
let(:actor) { FactoryBot.build_stubbed(:admin) }
diff --git a/spec/services/users/login_service_spec.rb b/spec/services/users/login_service_spec.rb
index ae661d34ff..dbfb2707df 100644
--- a/spec/services/users/login_service_spec.rb
+++ b/spec/services/users/login_service_spec.rb
@@ -32,7 +32,7 @@ describe ::Users::LoginService, type: :model do
let(:input_user) { FactoryBot.build_stubbed(:user) }
let(:controller) { double('ApplicationController') }
let(:session) { {} }
- let(:flash) { ActionDispatch::Flash::FlashHash.new() }
+ let(:flash) { ActionDispatch::Flash::FlashHash.new }
let(:instance) { described_class.new(controller: controller) }
diff --git a/spec/services/users/register_user_service_spec.rb b/spec/services/users/register_user_service_spec.rb
index f587912562..430e939f77 100644
--- a/spec/services/users/register_user_service_spec.rb
+++ b/spec/services/users/register_user_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
@@ -94,7 +95,7 @@ describe Users::RegisterUserService do
end
it 'does not return an error for all cases except disabled' do
- with_all_registration_options(except: :disabled) do |type|
+ with_all_registration_options(except: :disabled) do |_type|
user = User.new
instance = described_class.new(user)
@@ -263,6 +264,5 @@ describe Users::RegisterUserService do
end
describe '#with_saved_user_result' do
-
end
end
diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb
index e38cb148e3..4bde00cc68 100644
--- a/spec/services/users/update_service_spec.rb
+++ b/spec/services/users/update_service_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2020 the OpenProject GmbH
diff --git a/spec/services/work_packages/copy_service_integration_spec.rb b/spec/services/work_packages/copy_service_integration_spec.rb
index a0d41c46db..bfa8c2a510 100644
--- a/spec/services/work_packages/copy_service_integration_spec.rb
+++ b/spec/services/work_packages/copy_service_integration_spec.rb
@@ -141,9 +141,9 @@ describe WorkPackages::CopyService, 'integration', type: :model do
let(:custom_field) do
FactoryBot.create(
:work_package_custom_field,
- field_format: 'text',
- is_required: true,
- is_for_all: false
+ field_format: 'text',
+ is_required: true,
+ is_for_all: false
)
end
let(:target_custom_fields) { [custom_field] }
diff --git a/spec/services/work_packages/set_schedule_service_spec.rb b/spec/services/work_packages/set_schedule_service_spec.rb
index 4972153e61..8d7dcfc49d 100644
--- a/spec/services/work_packages/set_schedule_service_spec.rb
+++ b/spec/services/work_packages/set_schedule_service_spec.rb
@@ -176,10 +176,10 @@ describe WorkPackages::SetScheduleService do
it 'returns only the original and the changed work packages' do
expected_to_change = if defined?(unchanged)
- expected.keys - unchanged
- else
- expected.keys
- end
+ expected.keys - unchanged
+ else
+ expected.keys
+ end
expected_to_change << work_package
diff --git a/spec/services/work_packages/update_ancestors_service_spec.rb b/spec/services/work_packages/update_ancestors_service_spec.rb
index c0934fb43d..41070ad50d 100644
--- a/spec/services/work_packages/update_ancestors_service_spec.rb
+++ b/spec/services/work_packages/update_ancestors_service_spec.rb
@@ -195,7 +195,7 @@ describe WorkPackages::UpdateAncestorsService, type: :model, with_mail: false do
end
let!(:parent) do
FactoryBot.create :work_package,
- parent: grandparent
+ parent: grandparent
end
let!(:sibling) do
FactoryBot.create :work_package,
@@ -207,7 +207,7 @@ describe WorkPackages::UpdateAncestorsService, type: :model, with_mail: false do
let!(:work_package) do
FactoryBot.create :work_package,
- parent: parent
+ parent: parent
end
subject do
diff --git a/spec/services/workflows/bulk_update_service_integration_spec.rb b/spec/services/workflows/bulk_update_service_integration_spec.rb
index 54c8007cc0..a164277b7c 100644
--- a/spec/services/workflows/bulk_update_service_integration_spec.rb
+++ b/spec/services/workflows/bulk_update_service_integration_spec.rb
@@ -84,7 +84,7 @@ describe Workflows::BulkUpdateService, 'integration', type: :model do
let(:params) do
{
status4.id => { status5.id => ['always'] },
- status3.id => { status1.id => ['author'], status2.id => ['assignee'], status4.id => %w(author assignee)}
+ status3.id => { status1.id => ['author'], status2.id => ['assignee'], status4.id => %w(author assignee) }
}
end
diff --git a/spec/support/angular.rb b/spec/support/angular.rb
index 0c67b14c0e..d4bc55165d 100644
--- a/spec/support/angular.rb
+++ b/spec/support/angular.rb
@@ -31,4 +31,3 @@
def expect_angular_frontend_initialized
expect(page).to have_selector('.__ng2-bootstrap-has-run', wait: 20)
end
-
diff --git a/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb b/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
index 2372233d68..5b4ff1ec14 100644
--- a/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
+++ b/spec/support/api/v3/work_packages/work_package_representer_eager_loading.rb
@@ -31,7 +31,7 @@
shared_context 'eager loaded work package representer' do
before do
allow(::API::V3::WorkPackages::WorkPackageEagerLoadingWrapper)
- .to receive(:wrap_one) do |work_package, user|
+ .to receive(:wrap_one) do |work_package, _user|
allow(work_package)
.to receive(:cache_checksum)
.and_return(srand)
diff --git a/spec/support/browsers/chrome.rb b/spec/support/browsers/chrome.rb
index ee3c985b3b..e491de8ae4 100644
--- a/spec/support/browsers/chrome.rb
+++ b/spec/support/browsers/chrome.rb
@@ -97,6 +97,6 @@ register_chrome 'en', name: :chrome_billy do |options, capabilities|
end
# Register Revit add in
-register_chrome 'en', name: :chrome_revit_add_in do |options, capabilities|
+register_chrome 'en', name: :chrome_revit_add_in do |options, _capabilities|
options.add_argument("user-agent='foo bar Revit'")
end
diff --git a/spec/support/browsers/firefox.rb b/spec/support/browsers/firefox.rb
index d4b4d01302..dce2ac47af 100644
--- a/spec/support/browsers/firefox.rb
+++ b/spec/support/browsers/firefox.rb
@@ -42,23 +42,23 @@ def register_firefox(language, name: :"firefox_#{language}")
options.args << "--headless"
end
- if ENV['SELENIUM_GRID_URL']
- driver = Capybara::Selenium::Driver.new(
- app,
- browser: :remote,
- url: ENV['SELENIUM_GRID_URL'],
- desired_capabilities: capabilities,
- options: options
- )
- else
- driver = Capybara::Selenium::Driver.new(
- app,
- browser: :firefox,
- desired_capabilities: capabilities,
- options: options,
- http_client: client
- )
- end
+ driver = if ENV['SELENIUM_GRID_URL']
+ Capybara::Selenium::Driver.new(
+ app,
+ browser: :remote,
+ url: ENV['SELENIUM_GRID_URL'],
+ desired_capabilities: capabilities,
+ options: options
+ )
+ else
+ Capybara::Selenium::Driver.new(
+ app,
+ browser: :firefox,
+ desired_capabilities: capabilities,
+ options: options,
+ http_client: client
+ )
+ end
Capybara::Screenshot.register_driver(name) do |driver, path|
driver.browser.save_screenshot(path)
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index c7a0be6c27..30099df9b3 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -5,7 +5,7 @@ require 'capybara-screenshot/rspec'
require 'rack_session_access/capybara'
require 'action_dispatch'
-RSpec.configure do |config|
+RSpec.configure do |_config|
Capybara.default_max_wait_time = 4
Capybara.javascript_driver = :chrome_en
diff --git a/spec/support/clear_notification_subscriptions.rb b/spec/support/clear_notification_subscriptions.rb
index d29970b151..7b5fa09e63 100644
--- a/spec/support/clear_notification_subscriptions.rb
+++ b/spec/support/clear_notification_subscriptions.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -28,7 +29,7 @@
#++
RSpec.configure do |config|
- config.after(:each) do |example|
+ config.after(:each) do |_example|
OpenProject::Notifications.subscriptions.clear
end
end
diff --git a/spec/support/components/admin/type_configuration_form.rb b/spec/support/components/admin/type_configuration_form.rb
index 1c008c9a6f..699b637eb6 100644
--- a/spec/support/components/admin/type_configuration_form.rb
+++ b/spec/support/components/admin/type_configuration_form.rb
@@ -211,10 +211,10 @@ module Components
end
def expect_no_attribute(attribute, group)
- expect(find_group(group)).not_to have_selector("#{attribute_selector(attribute)}")
+ expect(find_group(group)).not_to have_selector(attribute_selector(attribute).to_s)
end
- def expect_group(label, translation, *attributes)
+ def expect_group(_label, translation, *attributes)
expect(find_group(translation)).to have_selector(".group-edit-handler", text: translation.upcase)
within find_group(translation) do
diff --git a/spec/support/components/attachments/attachments.rb b/spec/support/components/attachments/attachments.rb
index debfd575e5..94931650d9 100644
--- a/spec/support/components/attachments/attachments.rb
+++ b/spec/support/components/attachments/attachments.rb
@@ -28,7 +28,7 @@ module Components
end
def js_drop_files
- @js_file ||= File.read(File.expand_path('../attachments_input.js', __FILE__))
+ @js_file ||= File.read(File.expand_path('attachments_input.js', __dir__))
end
end
end
diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rb
index e3cd3ea71f..892af4aa5d 100644
--- a/spec/support/components/datepicker/datepicker.rb
+++ b/spec/support/components/datepicker/datepicker.rb
@@ -28,12 +28,12 @@ module Components
current_month = Date::MONTHNAMES.index(container.first('.cur-month').text)
if current_month < month
- while (current_month < month) do
+ while current_month < month
container.find('.flatpickr-next-month').click
current_month = Date::MONTHNAMES.index(container.first('.cur-month').text)
end
elsif current_month > month
- while (current_month > month) do
+ while current_month > month
container.find('.flatpickr-prev-month').click
current_month = Date::MONTHNAMES.index(container.first('.cur-month').text)
end
@@ -54,8 +54,8 @@ module Components
container
.first('.flatpickr-days .flatpickr-day:not(.nextMonthDay):not(.prevMonthDay)',
- text: value,
- exact_text: true)
+ text: value,
+ exact_text: true)
.click
end
diff --git a/spec/support/components/global_search.rb b/spec/support/components/global_search.rb
index aa618d2109..04fc928beb 100644
--- a/spec/support/components/global_search.rb
+++ b/spec/support/components/global_search.rb
@@ -67,17 +67,17 @@ module Components
def expect_work_package_marked(wp)
expect(page)
- .to have_selector('.ng-option-marked', text: "#{wp.subject}", wait: 10)
+ .to have_selector('.ng-option-marked', text: wp.subject.to_s, wait: 10)
end
def expect_work_package_option(wp)
expect(page)
- .to have_selector('.global-search--option', text: "#{wp.subject}", wait: 10)
+ .to have_selector('.global-search--option', text: wp.subject.to_s, wait: 10)
end
def expect_no_work_package_option(wp)
expect(page)
- .to have_no_selector('.global-search--option', text: "#{wp.subject}")
+ .to have_no_selector('.global-search--option', text: wp.subject.to_s)
end
def click_work_package(wp)
@@ -85,7 +85,7 @@ module Components
end
def find_work_package(wp)
- find_option "#{wp.subject}"
+ find_option wp.subject.to_s
end
def find_option(text)
diff --git a/spec/support/components/grids/grid_area.rb b/spec/support/components/grids/grid_area.rb
index 160e6fef22..e40b8a349a 100644
--- a/spec/support/components/grids/grid_area.rb
+++ b/spec/support/components/grids/grid_area.rb
@@ -67,7 +67,6 @@ module Components
['grid-column-start', startColumn * 2],
['grid-row-end', endRow * 2 - 1],
['grid-column-end', endColumn * 2 - 1]].each do |style, expected|
-
actual = area.native.style(style)
expect(actual)
diff --git a/spec/support/components/table_pagination.rb b/spec/support/components/table_pagination.rb
index 6f93f09282..03e00a589d 100644
--- a/spec/support/components/table_pagination.rb
+++ b/spec/support/components/table_pagination.rb
@@ -47,10 +47,8 @@ module Components
protected
- def within_pagination
- within('.pagination') do
- yield
- end
+ def within_pagination(&block)
+ within('.pagination', &block)
end
end
end
diff --git a/spec/support/components/work_packages/columns.rb b/spec/support/components/work_packages/columns.rb
index c54b66c88b..fcb4a9867a 100644
--- a/spec/support/components/work_packages/columns.rb
+++ b/spec/support/components/work_packages/columns.rb
@@ -143,10 +143,8 @@ module Components
private
- def within_modal
- page.within('.wp-table--configuration-modal') do
- yield
- end
+ def within_modal(&block)
+ page.within('.wp-table--configuration-modal', &block)
end
def modal_open?
diff --git a/spec/support/components/work_packages/destroy_modal.rb b/spec/support/components/work_packages/destroy_modal.rb
index 0e6404b7d9..6296d873f3 100644
--- a/spec/support/components/work_packages/destroy_modal.rb
+++ b/spec/support/components/work_packages/destroy_modal.rb
@@ -42,7 +42,8 @@ module Components
wp = wps.first
expect(page).to have_selector('strong', text: "#{wp.type.name} ##{wp.id} #{wp.subject}")
else
- expect(page).to have_selector('.danger-zone--warning', text: 'Are you sure you want to delete the following work packages ?')
+ expect(page).to have_selector('.danger-zone--warning',
+ text: 'Are you sure you want to delete the following work packages ?')
wps.each do |wp|
expect(page).to have_selector('li', text: "##{wp.id} #{wp.subject}")
end
diff --git a/spec/support/components/work_packages/display_representation.rb b/spec/support/components/work_packages/display_representation.rb
index f955ce1e31..f4e7e391ff 100644
--- a/spec/support/components/work_packages/display_representation.rb
+++ b/spec/support/components/work_packages/display_representation.rb
@@ -42,7 +42,7 @@ module Components
def switch_to_list_layout
expect_button 'Table'
select_view 'Table'
- end
+ end
def switch_to_gantt_layout
expect_button 'Gantt'
@@ -68,10 +68,8 @@ module Components
end
end
- def within_view_context_menu
- page.within('#wp-view-context-menu') do
- yield
- end
+ def within_view_context_menu(&block)
+ page.within('#wp-view-context-menu', &block)
end
end
end
diff --git a/spec/support/components/work_packages/group_by.rb b/spec/support/components/work_packages/group_by.rb
index 6dce98deea..b4506044ed 100644
--- a/spec/support/components/work_packages/group_by.rb
+++ b/spec/support/components/work_packages/group_by.rb
@@ -68,10 +68,8 @@ module Components
page.find(".generic-table--sort-header ##{name.downcase}").click
end
- def within_column_context_menu
- page.within('#column-context-menu') do
- yield
- end
+ def within_column_context_menu(&block)
+ page.within('#column-context-menu', &block)
end
end
end
diff --git a/spec/support/components/work_packages/query_title.rb b/spec/support/components/work_packages/query_title.rb
index 3ff241657e..b434d2f848 100644
--- a/spec/support/components/work_packages/query_title.rb
+++ b/spec/support/components/work_packages/query_title.rb
@@ -32,7 +32,6 @@ module Components
include Capybara::DSL
include RSpec::Matchers
-
def expect_changed
expect(page).to have_selector '.editable-toolbar-title--save'
expect(page).to have_selector '.editable-toolbar-title--input.-changed'
diff --git a/spec/support/components/work_packages/relations.rb b/spec/support/components/work_packages/relations.rb
index 093678822b..76c5b5df66 100644
--- a/spec/support/components/work_packages/relations.rb
+++ b/spec/support/components/work_packages/relations.rb
@@ -174,6 +174,7 @@ module Components
def openChildrenAutocompleter
retry_block do
next if page.has_selector?('.wp-relations--children .ng-input input')
+
SeleniumHubWaiter.wait
find('.wp-inline-create--reference-link', text: I18n.t('js.relation_buttons.add_existing_child')).click
diff --git a/spec/support/components/work_packages/sort_by.rb b/spec/support/components/work_packages/sort_by.rb
index 58611c2e47..f14805b031 100644
--- a/spec/support/components/work_packages/sort_by.rb
+++ b/spec/support/components/work_packages/sort_by.rb
@@ -44,14 +44,13 @@ module Components
end
end
- def update_criteria(first, second=nil, third=nil)
+ def update_criteria(first, second = nil, third = nil)
open_modal
SeleniumHubWaiter.wait
[first, second, third]
.compact
.each_with_index do |entry, i|
-
column, direction = entry
update_nth_criteria(i, column, descending: descending?(direction))
end
@@ -59,14 +58,13 @@ module Components
apply_changes
end
- def expect_criteria(first, second=nil, third=nil)
+ def expect_criteria(first, second = nil, third = nil)
open_modal
SeleniumHubWaiter.wait
[first, second, third]
.compact
.each_with_index do |entry, i|
-
column, direction = entry
page.within(".modal-sorting-row-#{i}") do
expect(page).to have_selector("#modal-sorting-attribute-#{i} option", text: column)
@@ -121,10 +119,8 @@ module Components
page.find(".generic-table--sort-header ##{id}").click
end
- def within_column_context_menu
- page.within('#column-context-menu') do
- yield
- end
+ def within_column_context_menu(&block)
+ page.within('#column-context-menu', &block)
end
end
end
diff --git a/spec/support/components/work_packages/table_configuration/graph_general.rb b/spec/support/components/work_packages/table_configuration/graph_general.rb
index 86249bd36d..7d713b5b5b 100644
--- a/spec/support/components/work_packages/table_configuration/graph_general.rb
+++ b/spec/support/components/work_packages/table_configuration/graph_general.rb
@@ -67,10 +67,8 @@ module Components
private
- def within_modal
- page.within('.wp-table--configuration-modal') do
- yield
- end
+ def within_modal(&block)
+ page.within('.wp-table--configuration-modal', &block)
end
end
end
diff --git a/spec/support/components/work_packages/table_configuration/highlighting.rb b/spec/support/components/work_packages/table_configuration/highlighting.rb
index d24f333cca..76e08510da 100644
--- a/spec/support/components/work_packages/table_configuration/highlighting.rb
+++ b/spec/support/components/work_packages/table_configuration/highlighting.rb
@@ -93,10 +93,8 @@ module Components
private
- def within_modal
- page.within('.wp-table--configuration-modal') do
- yield
- end
+ def within_modal(&block)
+ page.within('.wp-table--configuration-modal', &block)
end
def modal_open?
diff --git a/spec/support/components/work_packages/tabs_counter.rb b/spec/support/components/work_packages/tabs_counter.rb
index 2b93a159b8..b2ba82601b 100644
--- a/spec/support/components/work_packages/tabs_counter.rb
+++ b/spec/support/components/work_packages/tabs_counter.rb
@@ -15,7 +15,7 @@ module Components
# Check value of counter for the given tab
def expect_counter(tab, content)
- expect(tab).to have_selector('.wp-tabs-count', text: "#{content}")
+ expect(tab).to have_selector('.wp-tabs-count', text: content.to_s)
end
# Counter should not be displayed, if there are no relations or watchers
diff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rb
index ac329ece3f..20a4e864cb 100644
--- a/spec/support/components/wysiwyg/wysiwyg_editor.rb
+++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb
@@ -71,7 +71,7 @@ module Components
##
# Create an image fixture with the optional caption
def drag_attachment(image_fixture, caption = 'Some caption')
- in_editor do |container, editable|
+ in_editor do |_container, editable|
sleep 0.5
editable.base.send_keys(:enter, 'some text', :enter, :enter)
@@ -81,7 +81,6 @@ module Components
expect(page)
.to have_selector('figure img[src^="/api/v3/attachments/"]', count: images.length + 1, wait: 10)
-
expect(page).not_to have_selector('notification-upload-progress')
sleep 0.5
@@ -112,7 +111,7 @@ module Components
def refocus
editor_element.first('*').click
- rescue => e
+ rescue StandardError => e
warn "Failed to refocus on first editor element #{e}"
end
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
index 446583bb8f..0c08beeec0 100644
--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -1,5 +1,4 @@
RSpec.configure do |config|
-
# Since Rails 5.1., we can force the application server and capybara to share the same connection,
# which results in database_cleaner no longer being necessary.
# This will only work with a server that works in single mode (e.g., Puma)
diff --git a/spec/support/download_list.rb b/spec/support/download_list.rb
index 0df23523b3..c52b7d0026 100644
--- a/spec/support/download_list.rb
+++ b/spec/support/download_list.rb
@@ -3,7 +3,7 @@ class DownloadList
ENV.fetch("CAPYBARA_DOWNLOADED_FILE_DIR", Rails.root.join('tmp/test/downloads'))
).join(
ENV.fetch('TEST_ENV_NUMBER', '1')
- ).tap {|f| p ["DownloadList::SHARED_PATH", f.to_s] ; f.mkpath }
+ ).tap { |f| p ["DownloadList::SHARED_PATH", f.to_s]; f.mkpath }
def initialize
@history = []
@@ -16,7 +16,7 @@ class DownloadList
page.visit("about:downloads")
# give some time for page to load
sleep 0.5
- download_name = page.evaluate_script("document.querySelector('downloads-manager').shadowRoot.querySelector('#downloadsList downloads-item').shadowRoot.querySelector('div#content #file-link')").text()
+ download_name = page.evaluate_script("document.querySelector('downloads-manager').shadowRoot.querySelector('#downloadsList downloads-item').shadowRoot.querySelector('div#content #file-link')").text
if download_name && !@history.include?(download_name)
Timeout.timeout(Capybara.default_max_wait_time) do
sleep 0.1 until SHARED_PATH.join(download_name).exist?
@@ -26,7 +26,7 @@ class DownloadList
end
else
sleep 0.5
- @latest = Dir.glob(SHARED_PATH.join("*").to_s).max_by {|f| File.mtime(f) }
+ @latest = Dir.glob(SHARED_PATH.join("*").to_s).max_by { |f| File.mtime(f) }
@history << @latest
end
self
@@ -34,11 +34,13 @@ class DownloadList
def latest_download
return nil if @latest.nil?
+
SHARED_PATH.join(@latest)
end
def latest_downloaded_content
return nil if @latest.nil?
+
SHARED_PATH.join(@latest).read
end
diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rb
index bc7c9e804d..787ffa6753 100644
--- a/spec/support/edit_fields/date_edit_field.rb
+++ b/spec/support/edit_fields/date_edit_field.rb
@@ -1,8 +1,7 @@
require_relative './edit_field'
class DateEditField < EditField
- attr_accessor :milestone
- attr_accessor :is_table
+ attr_accessor :milestone, :is_table
def initialize(context,
property_name,
diff --git a/spec/support/edit_fields/edit_field.rb b/spec/support/edit_fields/edit_field.rb
index 23ed285b3a..f635328626 100644
--- a/spec/support/edit_fields/edit_field.rb
+++ b/spec/support/edit_fields/edit_field.rb
@@ -146,7 +146,7 @@ class EditField
##
# Set or select the given value.
# For fields of type select, will check for an option with that value.
- def unset_value(content, multi=false)
+ def unset_value(content, multi = false)
scroll_to_element(input_element)
if field_type.end_with?('-autocompleter')
diff --git a/spec/support/edit_fields/text_area_field.rb b/spec/support/edit_fields/text_area_field.rb
index 51ea62ef07..5516c57312 100644
--- a/spec/support/edit_fields/text_area_field.rb
+++ b/spec/support/edit_fields/text_area_field.rb
@@ -1,7 +1,6 @@
require_relative './edit_field'
class TextAreaField < EditField
-
def input_selector
'textarea'
end
@@ -39,7 +38,8 @@ class TextAreaField < EditField
end
def control_link(action = :save)
- raise 'Invalid link' unless [:save, :cancel].include?(action)
+ raise 'Invalid link' unless %i[save cancel].include?(action)
+
".inplace-edit--control--#{action}"
end
end
diff --git a/spec/support/edit_fields/text_editor_field.rb b/spec/support/edit_fields/text_editor_field.rb
index e5e72508de..94e905367b 100644
--- a/spec/support/edit_fields/text_editor_field.rb
+++ b/spec/support/edit_fields/text_editor_field.rb
@@ -62,7 +62,8 @@ class TextEditorField < EditField
end
def control_link(action = :save)
- raise 'Invalid link' unless [:save, :cancel].include?(action)
+ raise 'Invalid link' unless %i[save cancel].include?(action)
+
".inplace-edit--control--#{action}"
end
end
diff --git a/spec/support/edit_fields/work_package_status_field.rb b/spec/support/edit_fields/work_package_status_field.rb
index bd4c81c8a8..43136210de 100644
--- a/spec/support/edit_fields/work_package_status_field.rb
+++ b/spec/support/edit_fields/work_package_status_field.rb
@@ -11,7 +11,7 @@ class WorkPackageStatusField < EditField
end
def input_element
- page.find "#{input_selector}"
+ page.find input_selector.to_s
end
def display_element
@@ -47,7 +47,7 @@ class WorkPackageStatusField < EditField
def expect_active!
expect(page).to have_selector(input_selector, wait: 10),
- "Expected context menu for status."
+ "Expected context menu for status."
end
def expect_inactive!
diff --git a/spec/support/flash.rb b/spec/support/flash.rb
index 1b7b26f145..dacb7c3384 100644
--- a/spec/support/flash.rb
+++ b/spec/support/flash.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/identical_ext.rb b/spec/support/identical_ext.rb
index e71dfcdb3a..30adbd769a 100644
--- a/spec/support/identical_ext.rb
+++ b/spec/support/identical_ext.rb
@@ -45,8 +45,9 @@ end
Hash.class_eval do
def identical?(o)
return false unless self.class === o
+
(o.keys + keys).uniq.all? do |key|
- (o[key].identical?(self[key]))
+ o[key].identical?(self[key])
end
end
end
@@ -54,6 +55,7 @@ end
Array.class_eval do
def identical?(o)
return false unless self.class === o
+
all? do |ea|
(o.any? { |other_each| other_each.identical?(ea) })
end
diff --git a/spec/support/local_storage_cleanup.rb b/spec/support/local_storage_cleanup.rb
index 480ed5dbbe..1f6dd4f285 100644
--- a/spec/support/local_storage_cleanup.rb
+++ b/spec/support/local_storage_cleanup.rb
@@ -28,6 +28,8 @@
RSpec.configure do |config|
config.after(:each, js: true) do
- Capybara.current_session.driver.execute_script('window.localStorage.clear()') rescue nil
+ Capybara.current_session.driver.execute_script('window.localStorage.clear()')
+ rescue StandardError
+ nil
end
end
diff --git a/spec/support/matchers/be_boolean.rb b/spec/support/matchers/be_boolean.rb
index 6074c11b7f..c52ea87e0e 100644
--- a/spec/support/matchers/be_boolean.rb
+++ b/spec/support/matchers/be_boolean.rb
@@ -2,4 +2,4 @@ RSpec::Matchers.define :be_boolean do
match do |value|
[true, false].include? value
end
-end
\ No newline at end of file
+end
diff --git a/spec/support/matchers/be_html_eql.rb b/spec/support/matchers/be_html_eql.rb
index e48ae518e6..11030ee588 100644
--- a/spec/support/matchers/be_html_eql.rb
+++ b/spec/support/matchers/be_html_eql.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/matchers/has_conditional_selector.rb b/spec/support/matchers/has_conditional_selector.rb
index 0e4a384337..5708d91c3e 100644
--- a/spec/support/matchers/has_conditional_selector.rb
+++ b/spec/support/matchers/has_conditional_selector.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/matchers/has_focus_on.rb b/spec/support/matchers/has_focus_on.rb
index 42a45f1065..f30490439f 100644
--- a/spec/support/matchers/has_focus_on.rb
+++ b/spec/support/matchers/has_focus_on.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/matchers/raise_if_found.rb b/spec/support/matchers/raise_if_found.rb
index 822b2c66d6..04c2b49525 100644
--- a/spec/support/matchers/raise_if_found.rb
+++ b/spec/support/matchers/raise_if_found.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/noop_contract.rb b/spec/support/noop_contract.rb
index c4a83d50c3..6893b9a2e1 100644
--- a/spec/support/noop_contract.rb
+++ b/spec/support/noop_contract.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -28,8 +29,7 @@
#++
class NoopContract
- def initialize(*_)
- end
+ def initialize(*_); end
def validate
true
diff --git a/spec/support/onboarding_helper.rb b/spec/support/onboarding_helper.rb
index c4cf572170..ea8b4f8683 100644
--- a/spec/support/onboarding_helper.rb
+++ b/spec/support/onboarding_helper.rb
@@ -29,13 +29,13 @@
require 'spec_helper'
module OnboardingHelper
- def step_through_onboarding_wp_tour project, wp
+ def step_through_onboarding_wp_tour(project, wp)
expect(page).not_to have_selector('.loading-indicator')
- expect(page).to have_text 'This is the Work package list'
+ expect(page).to have_text 'This is the Work package list'
next_button.click
expect(page).to have_current_path project_work_package_path(project, wp.id, 'activity')
- expect(page).to have_text 'Within the Work package details you find all relevant information'
+ expect(page).to have_text 'Within the Work package details you find all relevant information'
next_button.click
expect(page).to have_text 'With the arrow you can navigate back to the work package list.'
diff --git a/spec/support/pages/admin/custom_actions/index.rb b/spec/support/pages/admin/custom_actions/index.rb
index 62589f82b0..9c65492d43 100644
--- a/spec/support/pages/admin/custom_actions/index.rb
+++ b/spec/support/pages/admin/custom_actions/index.rb
@@ -96,19 +96,15 @@ module Pages
private
- def within_row_of(name)
+ def within_row_of(name, &block)
within 'table' do
- within find('tr', text: name) do
- yield
- end
+ within find('tr', text: name), &block
end
end
- def within_buttons_of(name)
+ def within_buttons_of(name, &block)
within_row_of(name) do
- within find('.buttons') do
- yield
- end
+ within find('.buttons'), &block
end
end
end
diff --git a/spec/support/pages/admin/users/edit.rb b/spec/support/pages/admin/users/edit.rb
index ac9b086f52..7950e39232 100644
--- a/spec/support/pages/admin/users/edit.rb
+++ b/spec/support/pages/admin/users/edit.rb
@@ -67,11 +67,9 @@ module Pages
page.within("#member-#{membership.id}-roles-form") do
page.all('.form--check-box').each do |f|
- begin
- f.set false
- rescue Selenium::WebDriver::Error::InvalidElementStateError
- # Happens if an element is disabled
- end
+ f.set false
+ rescue Selenium::WebDriver::Error::InvalidElementStateError
+ # Happens if an element is disabled
end
Array(roles).each { |role| page.check role }
page.find('.user-memberships--edit-submit-button').click
diff --git a/spec/support/pages/admin/users/index.rb b/spec/support/pages/admin/users/index.rb
index 9dbefff164..83e5980549 100644
--- a/spec/support/pages/admin/users/index.rb
+++ b/spec/support/pages/admin/users/index.rb
@@ -107,11 +107,9 @@ module Pages
private
- def within_user_row(user)
+ def within_user_row(user, &block)
row = find('tr.user', text: user.login)
- within row do
- yield
- end
+ within row, &block
end
end
end
diff --git a/spec/support/pages/form_filler.rb b/spec/support/pages/form_filler.rb
index 837e8e938d..aac6354a94 100644
--- a/spec/support/pages/form_filler.rb
+++ b/spec/support/pages/form_filler.rb
@@ -65,7 +65,7 @@ module Pages
end
##
- # Checks (or unchecks) a check box.
+ # Checks (or unchecks) a check box.
def set_checked!(field, key)
if fields.include? key
checked = fields[field]
diff --git a/spec/support/pages/messages/show.rb b/spec/support/pages/messages/show.rb
index 6871cccfbb..8a7f9d93fd 100644
--- a/spec/support/pages/messages/show.rb
+++ b/spec/support/pages/messages/show.rb
@@ -60,7 +60,7 @@ module Pages::Messages
Message.last
end
- def quote(quoted_message: nil, subject: nil, content:)
+ def quote(content:, quoted_message: nil, subject: nil)
if quoted_message
within "#message-#{quoted_message.id} .contextual" do
click_on 'Quote'
diff --git a/spec/support/pages/page.rb b/spec/support/pages/page.rb
index 915edc2354..1c50fdeac2 100644
--- a/spec/support/pages/page.rb
+++ b/spec/support/pages/page.rb
@@ -85,7 +85,7 @@ module Pages
expect(current_path).to eql expected_path
end
- def expect_notification(type: :success, message:)
+ def expect_notification(message:, type: :success)
if notification_type == :angular
expect(page).to have_selector(".notification-box.-#{type}", text: message, wait: 20)
elsif type == :error
@@ -97,7 +97,7 @@ module Pages
end
end
- def expect_and_dismiss_notification(type: :success, message:)
+ def expect_and_dismiss_notification(message:, type: :success)
expect_notification(type: type, message: message)
dismiss_notification!
expect_no_notification(type: type, message: message)
diff --git a/spec/support/pages/projects/index.rb b/spec/support/pages/projects/index.rb
index 22f086a3d6..d2e136f7af 100644
--- a/spec/support/pages/projects/index.rb
+++ b/spec/support/pages/projects/index.rb
@@ -65,7 +65,7 @@ module Pages
set_toggle_filter(values)
when 'created_at'
set_created_at_filter(human_operator, values)
- when /cf_[\d]+/
+ when /cf_\d+/
set_custom_field_filter(selected_filter, human_operator, values)
end
end
diff --git a/spec/support/pages/projects/settings.rb b/spec/support/pages/projects/settings.rb
index 60af46c63d..d8064e9054 100644
--- a/spec/support/pages/projects/settings.rb
+++ b/spec/support/pages/projects/settings.rb
@@ -44,7 +44,7 @@ module Pages
end
# only notice is used as opposed to notification-box
- def expect_notification(type: :notice, message:)
+ def expect_notification(message:, type: :notice)
expect(page).to have_selector(".flash.#{type}", text: message, wait: 10)
end
diff --git a/spec/support/pages/work_packages/embedded_work_packages_table.rb b/spec/support/pages/work_packages/embedded_work_packages_table.rb
index 12d37a541c..60631f8214 100644
--- a/spec/support/pages/work_packages/embedded_work_packages_table.rb
+++ b/spec/support/pages/work_packages/embedded_work_packages_table.rb
@@ -28,7 +28,7 @@
require 'support/pages/page'
require 'support/pages/work_packages/work_packages_table'
-require 'support/components/ng_select_autocomplete_helpers.rb'
+require 'support/components/ng_select_autocomplete_helpers'
module Pages
class EmbeddedWorkPackagesTable < WorkPackagesTable
diff --git a/spec/support/pages/work_packages/work_packages_table.rb b/spec/support/pages/work_packages/work_packages_table.rb
index a8706d0984..633cd26c51 100644
--- a/spec/support/pages/work_packages/work_packages_table.rb
+++ b/spec/support/pages/work_packages/work_packages_table.rb
@@ -61,7 +61,7 @@ module Pages
within(table_container) do
attr_value_hash.each do |column, value|
expect(page).to have_selector(
- ".wp-row-#{work_package.id} td.#{column.to_s}", text: value.to_s, wait: 20
+ ".wp-row-#{work_package.id} td.#{column}", text: value.to_s, wait: 20
)
end
end
@@ -294,6 +294,7 @@ module Pages
filter_container = label_field.find(:xpath, '..')
raise 'Missing ID on Filter (Angular not ready?)' if filter_container['id'].nil?
+
filter_container['id'].gsub('filter_', '')
end
end
diff --git a/spec/support/pages/work_packages/work_packages_timeline.rb b/spec/support/pages/work_packages/work_packages_timeline.rb
index 2a8f946719..ab4bb2594e 100644
--- a/spec/support/pages/work_packages/work_packages_timeline.rb
+++ b/spec/support/pages/work_packages/work_packages_timeline.rb
@@ -94,7 +94,7 @@ module Pages
end
def timeline_row(wp_id)
- ::Components::Timelines::TimelineRow.new page.find(timeline_row_selector(wp_id))
+ ::Components::Timelines::TimelineRow.new page.find(timeline_row_selector(wp_id))
end
def zoom_in_button
diff --git a/spec/support/permission_specs.rb b/spec/support/permission_specs.rb
index 0a844107e6..27fdad6bb9 100644
--- a/spec/support/permission_specs.rb
+++ b/spec/support/permission_specs.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -27,7 +28,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require File.expand_path('../shared/become_member', __FILE__)
+require File.expand_path('shared/become_member', __dir__)
module PermissionSpecs
def self.included(base)
diff --git a/spec/support/puffing_billy_proxy.rb b/spec/support/puffing_billy_proxy.rb
index 2892abbcba..65ca140f3d 100644
--- a/spec/support/puffing_billy_proxy.rb
+++ b/spec/support/puffing_billy_proxy.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -40,7 +41,6 @@ require 'billy/capybara/rspec'
require 'table_print' # Add this dependency to your gemfile
-
##
# Patch `puffing-billy`'s proxy so that it doesn't try to stop
# eventmachine's reactor if it's not running.
@@ -48,9 +48,8 @@ require 'table_print' # Add this dependency to your gemfile
module BillyProxyPatch
def stop
return unless EM.reactor_running?
-
rescue Errno::ECONNRESET => e
- STDERR.puts "Got error while shutting down Billy proxy"
+ warn "Got error while shutting down Billy proxy"
end
end
diff --git a/spec/support/repository_helpers.rb b/spec/support/repository_helpers.rb
index bfd6779841..11e0ecf348 100644
--- a/spec/support/repository_helpers.rb
+++ b/spec/support/repository_helpers.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -38,14 +39,11 @@ def with_filesystem_repository(vendor, command = nil, &block)
repo_dir = Dir.mktmpdir("#{vendor}_repository")
fixture = File.join(Rails.root, "spec/fixtures/repositories/#{vendor}_repository.tar.gz")
-
['tar', command].compact.each do |cmd|
- begin
- # Avoid `which`, as it's not POSIX
- Open3.capture2e(cmd, '--version')
- rescue Errno::ENOENT
- skip "#{cmd} was not found in PATH. Skipping local repository specs"
- end
+ # Avoid `which`, as it's not POSIX
+ Open3.capture2e(cmd, '--version')
+ rescue Errno::ENOENT
+ skip "#{cmd} was not found in PATH. Skipping local repository specs"
end
after(:all) do
diff --git a/spec/support/request_with_header.rb b/spec/support/request_with_header.rb
index cdcfd02691..d696b7528e 100644
--- a/spec/support/request_with_header.rb
+++ b/spec/support/request_with_header.rb
@@ -7,10 +7,7 @@ RSpec.configure do |c|
end
end
- c.before(:each, type: :request, content_type: :json) do |ex|
+ c.before(:each, type: :request, content_type: :json) do |_ex|
header('Content-Type', 'application/json')
end
end
-
-
-
diff --git a/spec/support/roles.rb b/spec/support/roles.rb
index 146be660d2..f1f3cdf565 100644
--- a/spec/support/roles.rb
+++ b/spec/support/roles.rb
@@ -26,7 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-#
shared_context 'with non-member permissions from non_member_permissions' do
around do |example|
non_member = Role.non_member
diff --git a/spec/support/rspec_cleanup.rb b/spec/support/rspec_cleanup.rb
index f50793f879..03a751fca2 100644
--- a/spec/support/rspec_cleanup.rb
+++ b/spec/support/rspec_cleanup.rb
@@ -19,6 +19,7 @@ RSpec.configure do |config|
config.append_after(:suite) do
[User, Project, WorkPackage].each do |cls|
next if cls.count == 0
+
raise <<-EOS
Your specs left a #{cls} in the DB
Did you use before(:all) instead of before
diff --git a/spec/support/rspec_retry.rb b/spec/support/rspec_retry.rb
index 0d61f13bff..b7b680762c 100644
--- a/spec/support/rspec_retry.rb
+++ b/spec/support/rspec_retry.rb
@@ -42,7 +42,7 @@ def retry_block(args: {}, screenshot: false, &block)
end
log_errors = Proc.new do |exception, try, elapsed_time, next_interval|
- $stderr.puts <<-EOS.strip_heredoc
+ warn <<-EOS.strip_heredoc
#{exception.class}: '#{exception.message}'
#{try} tries in #{elapsed_time} seconds and #{next_interval} seconds until the next try.
EOS
@@ -51,7 +51,7 @@ def retry_block(args: {}, screenshot: false, &block)
begin
Capybara::Screenshot.screenshot_and_save_page
rescue StandardError => e
- $stderr.puts "Failed to take screenshot in retry_block: #{e} #{e.message}"
+ warn "Failed to take screenshot in retry_block: #{e} #{e.message}"
end
end
end
diff --git a/spec/support/scm/countable_repository.rb b/spec/support/scm/countable_repository.rb
index 71b0c9d06a..23a44c70e7 100644
--- a/spec/support/scm/countable_repository.rb
+++ b/spec/support/scm/countable_repository.rb
@@ -72,7 +72,7 @@ shared_examples_for 'is a countable repository' do
it 'falls back to using ruby when du is unavailable' do
expect(::Open3).to receive(:capture3).with('du', any_args)
- .and_raise(SystemCallError.new 'foo')
+ .and_raise(SystemCallError.new('foo'))
expect(repository.scm).to receive(:count_storage_fallback).and_return(12345)
expect(repository.scm.count_repository!).to eq(12345)
diff --git a/spec/support/scm/relocate_repository.rb b/spec/support/scm/relocate_repository.rb
index 6b987aa66e..b7ced5c201 100644
--- a/spec/support/scm/relocate_repository.rb
+++ b/spec/support/scm/relocate_repository.rb
@@ -3,17 +3,17 @@ shared_examples_for 'repository can be relocated' do |vendor|
::SCM::RelocateRepositoryJob.perform_now repository
end
let(:project) { FactoryBot.build :project }
- let(:repository) {
+ let(:repository) do
repo = FactoryBot.build("repository_#{vendor}".to_sym,
- project: project,
- scm_type: :managed)
+ project: project,
+ scm_type: :managed)
repo.configure(:managed, nil)
repo.save!
perform_enqueued_jobs
repo
- }
+ end
before do
allow(Repository).to receive(:find).and_return(repository)
@@ -47,14 +47,14 @@ shared_examples_for 'repository can be relocated' do |vendor|
let(:url) { 'http://myreposerver.example.com/api/' }
let(:config) { { manages: url } }
- let(:repository) {
+ let(:repository) do
stub_request(:post, url)
.to_return(status: 200,
body: { success: true, url: 'file:///foo/bar', path: '/tmp/foo/bar' }.to_json)
FactoryBot.create("repository_#{vendor}".to_sym,
- project: project,
- scm_type: :managed)
- }
+ project: project,
+ scm_type: :managed)
+ end
before do
stub_request(:post, url)
diff --git a/spec/support/selector_helpers.rb b/spec/support/selector_helpers.rb
index 1df496ae60..a8f253b3ea 100644
--- a/spec/support/selector_helpers.rb
+++ b/spec/support/selector_helpers.rb
@@ -26,7 +26,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-
module SelectorHelpers
module_function
diff --git a/spec/support/shared/acts_as_attachable.rb b/spec/support/shared/acts_as_attachable.rb
index 5662bb4382..b15a4ee43b 100644
--- a/spec/support/shared/acts_as_attachable.rb
+++ b/spec/support/shared/acts_as_attachable.rb
@@ -134,7 +134,8 @@ shared_examples_for 'acts_as_attachable included' do
expect(attachment2.reload.container).to eql model_instance
if described_class.journaled?
- expect(model_instance.journals.last.attachable_journals.map(&:attachment_id)).to match_array [attachment1.id, attachment2.id]
+ expect(model_instance.journals.last.attachable_journals.map(&:attachment_id)).to match_array [attachment1.id,
+ attachment2.id]
end
end
end
diff --git a/spec/support/shared/become_member.rb b/spec/support/shared/become_member.rb
index f3e175f631..517308ac35 100644
--- a/spec/support/shared/become_member.rb
+++ b/spec/support/shared/become_member.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/shared/forms_html.rb b/spec/support/shared/forms_html.rb
index f0d2f6a285..5c5b0707a0 100644
--- a/spec/support/shared/forms_html.rb
+++ b/spec/support/shared/forms_html.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/shared/permissions.rb b/spec/support/shared/permissions.rb
index 01868c2851..87074c54db 100644
--- a/spec/support/shared/permissions.rb
+++ b/spec/support/shared/permissions.rb
@@ -29,7 +29,7 @@
module PermissionSpecHelpers
def spec_permissions(test_denied = true)
describe 'w/ valid auth' do
- before do allow(User).to receive(:current).and_return valid_user end
+ before { allow(User).to receive(:current).and_return valid_user }
it 'grants access' do
fetch
@@ -53,16 +53,16 @@ module PermissionSpecHelpers
end
end
- describe 'w/o valid auth' do
- before do allow(User).to receive(:current).and_return invalid_user end
+ if test_denied
+ describe 'w/o valid auth' do
+ before { allow(User).to receive(:current).and_return invalid_user }
- it 'denies access' do
- fetch
+ it 'denies access' do
+ fetch
- if invalid_user.logged?
- expect(response.response_code).to eq(403)
- else
- if controller.send(:api_request?)
+ if invalid_user.logged?
+ expect(response.response_code).to eq(403)
+ elsif controller.send(:api_request?)
expect(response.response_code).to eq(401)
else
expect(response).to be_redirect
@@ -70,7 +70,7 @@ module PermissionSpecHelpers
end
end
end
- end if test_denied
+ end
end
end
diff --git a/spec/support/shared/with_config.rb b/spec/support/shared/with_config.rb
index ee371630ba..bcfb916657 100644
--- a/spec/support/shared/with_config.rb
+++ b/spec/support/shared/with_config.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/shared/with_direct_uploads.rb b/spec/support/shared/with_direct_uploads.rb
index 28d4bc2600..280e3a99d2 100644
--- a/spec/support/shared/with_direct_uploads.rb
+++ b/spec/support/shared/with_direct_uploads.rb
@@ -98,7 +98,7 @@ class WithDirectUploads
proxy.stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'options').and_return(
headers: {
'Access-Control-Allow-Methods' => 'POST',
- 'Access-Control-Allow-Origin' => '*'
+ 'Access-Control-Allow-Origin' => '*'
},
code: 200
)
@@ -113,7 +113,7 @@ class WithDirectUploads
def stub_with_redirect
proxy
.stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'post')
- .and_return(Proc.new { |params, headers, body, url, method|
+ .and_return(Proc.new do |_params, _headers, body, _url, _method|
key = body.scan(/key"\s*([^\s]+)\s/m).flatten.first
redirect_url = body.scan(/success_action_redirect"\s*(http[^\s]+)\s/m).flatten.first
ok = body =~ /X-Amz-Signature/ # check that the expected post to AWS was made with the form fields
@@ -123,24 +123,24 @@ class WithDirectUploads
headers: {
'Location' => ok ? redirect_url + '?key=' + CGI.escape(key) : nil,
'Access-Control-Allow-Methods' => 'POST',
- 'Access-Control-Allow-Origin' => '*'
+ 'Access-Control-Allow-Origin' => '*'
}
}
- })
+ end)
end
def stub_with_status
proxy
.stub("https://" + OpenProject::Configuration.remote_storage_upload_host + ":443/", method: 'post')
- .and_return(Proc.new { |params, headers, body, url, method|
+ .and_return(Proc.new do |_params, _headers, body, _url, _method|
{
- code: (body =~ /X-Amz-Signature/) ? 201 : 403, # check that the expected post to AWS was made with the form fields
+ code: body =~ /X-Amz-Signature/ ? 201 : 403, # check that the expected post to AWS was made with the form fields
headers: {
'Access-Control-Allow-Methods' => 'POST',
- 'Access-Control-Allow-Origin' => '*'
+ 'Access-Control-Allow-Origin' => '*'
}
}
- })
+ end)
end
def stub_uploader
diff --git a/spec/support/shared/with_ee.rb b/spec/support/shared/with_ee.rb
index 829093523c..66980abb82 100644
--- a/spec/support/shared/with_ee.rb
+++ b/spec/support/shared/with_ee.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/shared/with_settings.rb b/spec/support/shared/with_settings.rb
index 2bdb8ed739..05d65b38f6 100644
--- a/spec/support/shared/with_settings.rb
+++ b/spec/support/shared/with_settings.rb
@@ -53,7 +53,7 @@ RSpec.configure do |config|
raise "#{k} is not a valid setting" unless Setting.respond_to?(name)
- expect(name).not_to start_with("localized_"), ->() do
+ expect(name).not_to start_with("localized_"), -> do
base = name[10..-1]
"Don't use `#{name}` in `with_settings`. Do this: `with_settings: { #{base}: { \"en\" => \"#{v}\" } }`"
diff --git a/spec/support/tempdir.rb b/spec/support/tempdir.rb
index 0ce41f65f0..61ba41932c 100644
--- a/spec/support/tempdir.rb
+++ b/spec/support/tempdir.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb
index 576bdeda8e..61edfb8805 100644
--- a/spec/support/webmock.rb
+++ b/spec/support/webmock.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -37,17 +38,15 @@ RSpec.configure do |config|
end
config.around(:example, webmock: true) do |example|
- begin
- # When we enable webmock, no connections other than stubbed ones are allowed.
- # We will exempt local connections from this block, since selenium etc.
- # uses localhost to communicate with the browser.
- # Leaving this off will randomly fail some specs with WebMock::NetConnectNotAllowedError
- WebMock.disable_net_connect!(allow_localhost: true, allow: ["selenium-hub", Capybara.server_host])
- WebMock.enable!
- example.run
- ensure
- WebMock.allow_net_connect!
- WebMock.disable!
- end
+ # When we enable webmock, no connections other than stubbed ones are allowed.
+ # We will exempt local connections from this block, since selenium etc.
+ # uses localhost to communicate with the browser.
+ # Leaving this off will randomly fail some specs with WebMock::NetConnectNotAllowedError
+ WebMock.disable_net_connect!(allow_localhost: true, allow: ["selenium-hub", Capybara.server_host])
+ WebMock.enable!
+ example.run
+ ensure
+ WebMock.allow_net_connect!
+ WebMock.disable!
end
end
diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rb
index 6816feba6a..3e2cb5102c 100644
--- a/spec/views/layouts/base.html.erb_spec.rb
+++ b/spec/views/layouts/base.html.erb_spec.rb
@@ -90,8 +90,7 @@ describe 'layouts/base', type: :view do
end
context 'with omni_auth_direct_login enabled',
- with_config: { omniauth_direct_login_provider: 'some_provider' } do
-
+ with_config: { omniauth_direct_login_provider: 'some_provider' } do
it 'shows just a sign-in link, no menu' do
expect(rendered).to have_selector "a[href='/login']"
expect(rendered).not_to have_selector 'div#nav-login-content'
diff --git a/spec/views/users/edit.html.erb_spec.rb b/spec/views/users/edit.html.erb_spec.rb
index 0fe3443b87..7a60b1f94c 100644
--- a/spec/views/users/edit.html.erb_spec.rb
+++ b/spec/views/users/edit.html.erb_spec.rb
@@ -41,7 +41,7 @@ describe 'users/edit', type: :view do
context 'authentication provider' do
let(:user) do
FactoryBot.build :user, id: 1, # id is required to create route to edit
- identity_url: 'test_provider:veryuniqueid'
+ identity_url: 'test_provider:veryuniqueid'
end
before do
diff --git a/spec/views/users/index.html.erb_spec.rb b/spec/views/users/index.html.erb_spec.rb
index 31946b5844..79fdfa0d1a 100644
--- a/spec/views/users/index.html.erb_spec.rb
+++ b/spec/views/users/index.html.erb_spec.rb
@@ -56,7 +56,7 @@ describe 'users/index', type: :view do
context "with an Enterprise token" do
before do
- allow(OpenProject::Enterprise).to receive(:token).and_return(Struct.new(:restrictions).new({active_user_count: 5}))
+ allow(OpenProject::Enterprise).to receive(:token).and_return(Struct.new(:restrictions).new({ active_user_count: 5 }))
end
it "shows the current number of active and allowed users" do
diff --git a/spec/views/work_package/auto_complete/index_spec.rb b/spec/views/work_package/auto_complete/index_spec.rb
index 202f69cdb9..e51da0275c 100644
--- a/spec/views/work_package/auto_complete/index_spec.rb
+++ b/spec/views/work_package/auto_complete/index_spec.rb
@@ -29,10 +29,10 @@
require 'spec_helper'
describe 'work_packages/auto_completes/index.html.erb', type: :view do
- let(:work_package) {
+ let(:work_package) do
FactoryBot.build(:work_package,
- subject: '')
- }
+ subject: '')
+ end
it 'escapes work package subject in auto-completion' do
assign :work_packages, [work_package]
diff --git a/spec/workers/application_job_spec.rb b/spec/workers/application_job_spec.rb
index 86abca766d..8e28ab5a2d 100644
--- a/spec/workers/application_job_spec.rb
+++ b/spec/workers/application_job_spec.rb
@@ -41,7 +41,7 @@ describe ApplicationJob do
describe 'resets request store' do
it 'resets request store on each perform' do
- job = JobMock.new(->() do
+ job = JobMock.new(-> do
expect(RequestStore[:test_value]).to be_nil
RequestStore[:test_value] = 42
end)
diff --git a/spec/workers/attachments/finish_direct_upload_job_integration_spec.rb b/spec/workers/attachments/finish_direct_upload_job_integration_spec.rb
index 6e6ed6b0d6..dc83bfc03c 100644
--- a/spec/workers/attachments/finish_direct_upload_job_integration_spec.rb
+++ b/spec/workers/attachments/finish_direct_upload_job_integration_spec.rb
@@ -110,4 +110,4 @@ describe Attachments::FinishDirectUploadJob, 'integration', type: :job do
it_behaves_like 'turning pending attachment into a standard attachment'
it_behaves_like "adding a journal to the attachment in the name of the attachment's author"
end
-end
\ No newline at end of file
+end
diff --git a/spec/workers/copy_project_job_spec.rb b/spec/workers/copy_project_job_spec.rb
index d24825e4f5..7161608dea 100644
--- a/spec/workers/copy_project_job_spec.rb
+++ b/spec/workers/copy_project_job_spec.rb
@@ -32,7 +32,7 @@ describe CopyProjectJob, type: :model do
let(:project) { FactoryBot.create(:project, public: false) }
let(:user) { FactoryBot.create(:user) }
let(:role) { FactoryBot.create(:role, permissions: [:copy_projects]) }
- let(:params) { {name: 'Copy', identifier: 'copy'} }
+ let(:params) { { name: 'Copy', identifier: 'copy' } }
let(:maildouble) { double('Mail::Message', deliver: true) }
before do
@@ -57,10 +57,9 @@ describe CopyProjectJob, type: :model do
end
copy_job.perform user_id: user_de.id,
- source_project_id: source_project.id,
- target_project_params: {},
- associations_to_copy: []
-
+ source_project_id: source_project.id,
+ target_project_params: {},
+ associations_to_copy: []
end
end
@@ -88,8 +87,10 @@ describe CopyProjectJob, type: :model do
CopyProjectJob.new(job_args).tap(&:perform_now)
end
- let(:params) { {name: 'Copy', identifier: 'copy', type_ids: [type.id], work_package_custom_field_ids: [custom_field.id]} }
- let(:expected_error_message) { "#{WorkPackage.model_name.human} '#{work_package.type.name} ##{work_package.id}: #{work_package.subject}': #{custom_field.name} #{I18n.t('errors.messages.blank')}." }
+ let(:params) { { name: 'Copy', identifier: 'copy', type_ids: [type.id], work_package_custom_field_ids: [custom_field.id] } }
+ let(:expected_error_message) do
+ "#{WorkPackage.model_name.human} '#{work_package.type.name} ##{work_package.id}: #{work_package.subject}': #{custom_field.name} #{I18n.t('errors.messages.blank')}."
+ end
before do
source_project.work_package_custom_fields << custom_field
@@ -162,7 +163,7 @@ describe CopyProjectJob, type: :model do
end
end
- let(:params) { {name: 'Copy', identifier: 'copy'} }
+ let(:params) { { name: 'Copy', identifier: 'copy' } }
before do
allow(User).to receive(:current).and_return(admin)
diff --git a/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb b/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb
index 03d28fbfc8..806fccfc7f 100644
--- a/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb
+++ b/spec/workers/mail_notification_jobs/deliver_watcher_notification_job_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb b/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb
index 4465f32d19..9da5e3c841 100644
--- a/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb
+++ b/spec/workers/mail_notification_jobs/deliver_work_package_notification_job_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -32,15 +33,15 @@ require 'spec_helper'
describe DeliverWorkPackageNotificationJob, type: :model do
let(:project) { FactoryBot.create(:project) }
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
- let(:recipient) {
+ let(:recipient) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
- }
+ end
let(:author) { FactoryBot.create(:user) }
- let(:work_package) {
+ let(:work_package) do
FactoryBot.create(:work_package,
- project: project,
- author: author)
- }
+ project: project,
+ author: author)
+ end
let(:journal) { work_package.journals.first }
let(:instance) { described_class.new }
subject { instance.perform(journal.id, recipient.id, author.id) }
diff --git a/spec/workers/scm/create_local_repository_job_spec.rb b/spec/workers/scm/create_local_repository_job_spec.rb
index 795e945896..6e2238665a 100644
--- a/spec/workers/scm/create_local_repository_job_spec.rb
+++ b/spec/workers/scm/create_local_repository_job_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -49,16 +50,16 @@ describe SCM::CreateLocalRepositoryJob do
include_context 'with tmpdir'
let(:project) { FactoryBot.build(:project) }
- let(:repository) {
+ let(:repository) do
repo = Repository::Subversion.new(scm_type: :managed)
repo.project = project
repo.configure(:managed, nil)
repo
- }
+ end
- let(:config) {
+ let(:config) do
{ subversion: { mode: mode, manages: tmpdir } }
- }
+ end
shared_examples 'creates a directory with mode' do |expected|
it 'creates the directory' do
@@ -71,7 +72,7 @@ describe SCM::CreateLocalRepositoryJob do
end
context 'with mode set' do
- let(:mode) { 0770 }
+ let(:mode) { 0o770 }
it 'uses the correct mode' do
expect(instance).to receive(:create).with(mode)
@@ -84,7 +85,7 @@ describe SCM::CreateLocalRepositoryJob do
context 'with string mode' do
let(:mode) { '0770' }
it 'uses the correct mode' do
- expect(instance).to receive(:create).with(0770)
+ expect(instance).to receive(:create).with(0o770)
subject
end
@@ -94,7 +95,7 @@ describe SCM::CreateLocalRepositoryJob do
context 'with no mode set' do
let(:mode) { nil }
it 'uses the default mode' do
- expect(instance).to receive(:create).with(0700)
+ expect(instance).to receive(:create).with(0o700)
subject
end
diff --git a/spec/workers/work_packages/exports/export_job_spec.rb b/spec/workers/work_packages/exports/export_job_spec.rb
index e1937bf276..e9ae9a9a51 100644
--- a/spec/workers/work_packages/exports/export_job_spec.rb
+++ b/spec/workers/work_packages/exports/export_job_spec.rb
@@ -100,7 +100,7 @@ describe WorkPackages::Exports::ExportJob do
describe 'query passing' do
context 'passing in group_by through attributes' do
- let(:query_attributes) { { group_by: 'assigned_to' }}
+ let(:query_attributes) { { group_by: 'assigned_to' } }
let(:mime_type) { :pdf }
it 'updates the query from attributes' do
diff --git a/spec_legacy/fixtures/files/060719210727_source.rb b/spec_legacy/fixtures/files/060719210727_source.rb
index 53f651bbaa..c27ad5d18c 100644
--- a/spec_legacy/fixtures/files/060719210727_source.rb
+++ b/spec_legacy/fixtures/files/060719210727_source.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/functional/application_controller_spec.rb b/spec_legacy/functional/application_controller_spec.rb
index 4edbc8ae5f..8926311e28 100644
--- a/spec_legacy/functional/application_controller_spec.rb
+++ b/spec_legacy/functional/application_controller_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/functional/sys_controller_spec.rb b/spec_legacy/functional/sys_controller_spec.rb
index 051372a6f3..1ba8318824 100644
--- a/spec_legacy/functional/sys_controller_spec.rb
+++ b/spec_legacy/functional/sys_controller_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -39,7 +40,6 @@ describe SysController, type: :controller do
describe 'when enabled',
with_settings: { sys_api_enabled?: true } do
-
it 'should projects with repository enabled' do
get :projects
assert_response :success
diff --git a/spec_legacy/functional/user_mailer_spec.rb b/spec_legacy/functional/user_mailer_spec.rb
index 93a3a7c89b..a61791de95 100644
--- a/spec_legacy/functional/user_mailer_spec.rb
+++ b/spec_legacy/functional/user_mailer_spec.rb
@@ -223,7 +223,7 @@ describe UserMailer, type: :mailer do
end
it 'should message posted message id' do
- user = FactoryBot.create(:user)
+ user = FactoryBot.create(:user)
FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false })
message = FactoryBot.create(:message)
UserMailer.message_posted(user, message, user).deliver_now
@@ -238,7 +238,7 @@ describe UserMailer, type: :mailer do
end
it 'should reply posted message id' do
- user = FactoryBot.create(:user)
+ user = FactoryBot.create(:user)
FactoryBot.create(:user_preference, user: user, others: { no_self_notified: false })
parent = FactoryBot.create(:message)
message = FactoryBot.create(:message, parent: parent)
@@ -249,7 +249,8 @@ describe UserMailer, type: :mailer do
assert_match mail.references, UserMailer.generate_message_id(parent, user)
assert_select_email do
# link to the reply
- assert_select 'a[href=?]', "#{Setting.protocol}://#{Setting.host_name}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", text: message.subject
+ assert_select 'a[href=?]',
+ "#{Setting.protocol}://#{Setting.host_name}/topics/#{message.root.id}?r=#{message.id}#message-#{message.id}", text: message.subject
end
end
@@ -357,7 +358,7 @@ describe UserMailer, type: :mailer do
context 'layout',
with_settings: {
- available_languages: [:en, :de],
+ available_languages: %i[en de],
emails_header: {
"de" => 'deutscher header'
}
@@ -386,30 +387,30 @@ describe UserMailer, type: :mailer do
project.save
related_issue = FactoryBot.create(:work_package,
- subject: 'My related Ticket',
- type: type,
- project: project)
+ subject: 'My related Ticket',
+ type: type,
+ project: project)
issue = FactoryBot.create(:work_package,
- subject: 'My awesome Ticket',
- type: type,
- project: project,
- description: 'nothing here yet')
+ subject: 'My awesome Ticket',
+ type: type,
+ project: project,
+ description: 'nothing here yet')
# now change the issue, to get a nice journal
issue.description = "This is related to issue ##{related_issue.id}\n"
repository = FactoryBot.create(:repository_subversion,
- project: project)
+ project: project)
changeset = FactoryBot.create :changeset,
- repository: repository,
- comments: 'This commit fixes #1, #2 and references #1 and #3'
+ repository: repository,
+ comments: 'This commit fixes #1, #2 and references #1 and #3'
issue.description += " A reference to a changeset r#{changeset.revision}\n" if changeset
attachment = FactoryBot.build(:attachment,
- author: issue.author)
+ author: issue.author)
issue.attachments << attachment
diff --git a/spec_legacy/functional/wiki_controller_spec.rb b/spec_legacy/functional/wiki_controller_spec.rb
index ce6e277e17..05dc4bff25 100644
--- a/spec_legacy/functional/wiki_controller_spec.rb
+++ b/spec_legacy/functional/wiki_controller_spec.rb
@@ -88,11 +88,11 @@ describe WikiController, type: :controller do
it 'should create page' do
session[:user_id] = 2
post :create, params: { project_id: 1,
- id: 'New page',
- content: { comments: 'Created the page',
- text: "h1. New page\n\nThis is a new page",
- page: { title: 'New page',
- parent_id: '' } } }
+ id: 'New page',
+ content: { comments: 'Created the page',
+ text: "h1. New page\n\nThis is a new page",
+ page: { title: 'New page',
+ parent_id: '' } } }
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'new-page'
page = wiki.find_page('New page')
assert !page.new_record?
@@ -127,17 +127,17 @@ describe WikiController, type: :controller do
it 'should history' do
FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: 'h1. CookBook documentation')
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: 'h1. CookBook documentation')
FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: "h1. CookBook documentation\nSome updated [[documentation]] here...")
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: "h1. CookBook documentation\nSome updated [[documentation]] here...")
get :history, params: { project_id: 1, id: 'CookBook documentation' }
assert_response :success
@@ -149,9 +149,9 @@ describe WikiController, type: :controller do
it 'should history with one version' do
FactoryBot.create :wiki_content_journal,
- journable_id: 2,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: "h1. Another page\n\n\nthis is a link to ticket: #2")
+ journable_id: 2,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: "h1. Another page\n\n\nthis is a link to ticket: #2")
get :history, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_template 'history'
@@ -162,32 +162,33 @@ describe WikiController, type: :controller do
it 'should diff' do
journal_from = FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: 'h1. CookBook documentation')
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: 'h1. CookBook documentation')
journal_to = FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
- get :diff, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version }
+ get :diff,
+ params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version }
assert_response :success
assert_template 'diff'
assert_select 'ins', attributes: { class: 'diffins' },
- content: /updated/
+ content: /updated/
end
it 'should annotate' do
FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: 'h1. CookBook documentation')
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: 'h1. CookBook documentation')
journal_to = FactoryBot.create :wiki_content_journal,
- journable_id: 1,
- data: FactoryBot.build(:journal_wiki_content_journal,
- text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...")
+ journable_id: 1,
+ data: FactoryBot.build(:journal_wiki_content_journal,
+ text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...")
- get :annotate, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version }
+ get :annotate, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version }
assert_response :success
assert_template 'annotate'
# Line 1
@@ -291,14 +292,14 @@ describe WikiController, type: :controller do
assert_equal pages.first.content.updated_at, pages.first.updated_at
assert_select 'ul', attributes: { class: 'pages-hierarchy' },
- child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/CookBook%20documentation' },
- content: 'CookBook documentation' },
- child: { tag: 'ul',
- child: { tag: 'li',
- child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Page%20with%20an%20inline%20image' },
- content: 'Page with an inline image' } } } },
- child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Another%20page' },
- content: 'Another page' } }
+ child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/CookBook%20documentation' },
+ content: 'CookBook documentation' },
+ child: { tag: 'ul',
+ child: { tag: 'li',
+ child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Page%20with%20an%20inline%20image' },
+ content: 'Page with an inline image' } } } },
+ child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Another%20page' },
+ content: 'Another page' } }
end
it 'should index should include atom link' do
diff --git a/spec_legacy/legacy_spec_helper.rb b/spec_legacy/legacy_spec_helper.rb
index 552c21613d..1fd3857133 100644
--- a/spec_legacy/legacy_spec_helper.rb
+++ b/spec_legacy/legacy_spec_helper.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -29,7 +30,7 @@
ENV['RAILS_ENV'] = 'test'
-require File.expand_path('../../config/environment', __FILE__)
+require File.expand_path('../config/environment', __dir__)
require 'fileutils'
require 'rspec/mocks'
diff --git a/spec_legacy/support/legacy_assertions.rb b/spec_legacy/support/legacy_assertions.rb
index 0f6e3861f6..9f268f2be6 100644
--- a/spec_legacy/support/legacy_assertions.rb
+++ b/spec_legacy/support/legacy_assertions.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -47,12 +48,13 @@ module LegacyAssertionsAndHelpers
def initialize_attachments
Attachment.all.each do |a|
if a.file.filename.nil?
- begin # existing file under `spec/fixtures/files`
+ # existing file under `spec/fixtures/files`
+ begin
a.file = uploaded_test_file a.disk_filename, a.attributes['content_type'],
original_filename: a.attributes['filename']
- rescue # imaginary file: create it on-the-fly
+ rescue StandardError # imaginary file: create it on-the-fly
a.file = LegacyFileHelpers.mock_uploaded_file name: a.attributes['filename'],
- content_type: a.attributes['content_type']
+ content_type: a.attributes['content_type']
end
a.save!
@@ -84,7 +86,7 @@ module LegacyAssertionsAndHelpers
def with_settings(options, &_block)
saved_settings = options.keys.inject({}) { |h, k| h[k] = Setting[k].dup; h }
- options.each do |k, v| Setting[k] = v end
+ options.each { |k, v| Setting[k] = v }
yield
ensure
saved_settings.each { |k, v| Setting[k] = v }
@@ -132,15 +134,15 @@ module LegacyAssertionsAndHelpers
return false if !!ENV['CI']
@test_ldap = Net::LDAP.new(host: '127.0.0.1', port: 389)
- return @test_ldap.bind
+ @test_ldap.bind
rescue Exception => e
# LDAP is not listening
- return nil
+ nil
end
# Returns the path to the test +vendor+ repository
def repository_path(vendor)
- File.join(Rails.root.to_s.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
+ File.join(Rails.root.to_s.gsub(%r{config/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
end
# Returns the url of the subversion test repository
@@ -371,10 +373,9 @@ module LegacyAssertionsAndHelpers
#
# @param [String] url Request
def should_respond_with_content_type_based_on_url(url)
- case
- when url.match(/xml/i)
+ if url.match(/xml/i)
should_respond_with_content_type 'application/xml'
- when url.match(/json/i)
+ elsif url.match(/json/i)
should_respond_with_content_type 'application/json'
else
raise "Unknown content type for should_respond_with_content_type_based_on_url: #{url}"
@@ -388,10 +389,9 @@ module LegacyAssertionsAndHelpers
#
# @param [String] url Request
def should_be_a_valid_response_string_based_on_url(url)
- case
- when url.match(/xml/i)
+ if url.match(/xml/i)
should_be_a_valid_xml_string
- when url.match(/json/i)
+ elsif url.match(/json/i)
should_be_a_valid_json_string
else
raise "Unknown content type for should_be_a_valid_response_based_on_url: #{url}"
diff --git a/spec_legacy/unit/category_spec.rb b/spec_legacy/unit/category_spec.rb
index 92549865c7..f9435200c9 100644
--- a/spec_legacy/unit/category_spec.rb
+++ b/spec_legacy/unit/category_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/comment_spec.rb b/spec_legacy/unit/comment_spec.rb
index f4220b1940..c649717b86 100644
--- a/spec_legacy/unit/comment_spec.rb
+++ b/spec_legacy/unit/comment_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/custom_value_spec.rb b/spec_legacy/unit/custom_value_spec.rb
index 08bb0af153..0dfef0ba3f 100644
--- a/spec_legacy/unit/custom_value_spec.rb
+++ b/spec_legacy/unit/custom_value_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -123,9 +124,9 @@ describe CustomValue, type: :model do
user = FactoryBot.create :user
custom_field = FactoryBot.create :user_custom_field, field_format: 'string'
custom_value = FactoryBot.create :principal_custom_value,
- custom_field: custom_field,
- customized: user,
- value: '01 23 45 67 89'
+ custom_field: custom_field,
+ customized: user,
+ value: '01 23 45 67 89'
user.reload
assert !user.custom_values.empty?
diff --git a/spec_legacy/unit/enumeration_spec.rb b/spec_legacy/unit/enumeration_spec.rb
index afd321ad13..13d12603a4 100644
--- a/spec_legacy/unit/enumeration_spec.rb
+++ b/spec_legacy/unit/enumeration_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/helpers/sort_helper_spec.rb b/spec_legacy/unit/helpers/sort_helper_spec.rb
index 6f882a626c..6bf7446f75 100644
--- a/spec_legacy/unit/helpers/sort_helper_spec.rb
+++ b/spec_legacy/unit/helpers/sort_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/lib/redmine/hook_spec.rb b/spec_legacy/unit/lib/redmine/hook_spec.rb
index a3da0d070f..b689c7a575 100644
--- a/spec_legacy/unit/lib/redmine/hook_spec.rb
+++ b/spec_legacy/unit/lib/redmine/hook_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/lib/redmine/i18n_spec.rb b/spec_legacy/unit/lib/redmine/i18n_spec.rb
index e1c0752ac3..8092f7b9c2 100644
--- a/spec_legacy/unit/lib/redmine/i18n_spec.rb
+++ b/spec_legacy/unit/lib/redmine/i18n_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -40,13 +41,13 @@ describe Redmine::I18n do
Setting.date_format = ''
valid_languages.each do |lang|
set_language_if_valid lang
- expect {
+ expect do
format_date(Date.today)
format_time(Time.now)
format_time(Time.now, false)
refute_equal 'default', ::I18n.l(Date.today, format: :default), "date.formats.default missing in #{lang}"
refute_equal 'time', ::I18n.l(Time.now, format: :time), "time.formats.time missing in #{lang}"
- }.not_to raise_error
+ end.not_to raise_error
assert I18n.t('date.day_names').is_a?(Array)
assert_equal 7, I18n.t('date.day_names').size
@@ -102,9 +103,9 @@ describe Redmine::I18n do
it 'should number to human size for each language' do
valid_languages.each do |lang|
set_language_if_valid lang
- expect {
+ expect do
number_to_human_size(1024 * 1024 * 4)
- }.not_to raise_error
+ end.not_to raise_error
end
end
diff --git a/spec_legacy/unit/lib/redmine/menu_manager/mapper_spec.rb b/spec_legacy/unit/lib/redmine/menu_manager/mapper_spec.rb
index bbd1a7eee6..743387e718 100644
--- a/spec_legacy/unit/lib/redmine/menu_manager/mapper_spec.rb
+++ b/spec_legacy/unit/lib/redmine/menu_manager/mapper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -29,7 +30,6 @@
require 'legacy_spec_helper'
describe Redmine::MenuManager::Mapper do
-
it 'should push onto root' do
menu_mapper = Redmine::MenuManager::Mapper.new(:test_menu, {})
menu_mapper.push :test_overview, { controller: 'projects', action: 'show' }, {}
@@ -175,12 +175,12 @@ describe Redmine::MenuManager::Mapper do
menu.push :help, OpenProject::Static::Links.help_link, last: true
end
- expect {
+ expect do
Redmine::MenuManager.map :test_menu do |menu|
menu.delete(:administration)
menu.delete(:help)
menu.push :test_overview, { controller: 'projects', action: 'show' }, {}
end
- }.not_to raise_error
+ end.not_to raise_error
end
end
diff --git a/spec_legacy/unit/lib/redmine/menu_manager/menu_helper_spec.rb b/spec_legacy/unit/lib/redmine/menu_manager/menu_helper_spec.rb
index 2d21dbc925..deaac6b14a 100644
--- a/spec_legacy/unit/lib/redmine/menu_manager/menu_helper_spec.rb
+++ b/spec_legacy/unit/lib/redmine/menu_manager/menu_helper_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -96,17 +97,17 @@ describe Redmine::MenuManager::MenuHelper, type: :helper do
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
{ controller: 'work_packages', action: 'index' },
-
- children: Proc.new {|_p|
+ children: Proc.new do |_p|
children = []
3.times do |time|
children << Redmine::MenuManager::MenuItem.new("test_child_#{time}",
- { controller: 'work_packages', action: 'index' },
+ {
+ controller: 'work_packages', action: 'index'
+ },
{})
end
children
- }
- )
+ end)
@response.body = render_menu_node(parent_node, Project.find(1))
html_node = Nokogiri::HTML(@response.body)
@@ -125,27 +126,27 @@ describe Redmine::MenuManager::MenuHelper, type: :helper do
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
{ controller: 'work_packages', action: 'index' },
-
- children: Proc.new {|_p|
+ children: Proc.new do |_p|
children = []
3.times do |time|
- children << Redmine::MenuManager::MenuItem.new("test_child_#{time}", { controller: 'work_packages', action: 'index' }, {})
+ children << Redmine::MenuManager::MenuItem.new("test_child_#{time}",
+ { controller: 'work_packages', action: 'index' }, {})
end
children
- }
- )
+ end)
parent_node << Redmine::MenuManager::MenuItem.new(:child_node,
{ controller: 'work_packages', action: 'index' },
-
- children: Proc.new {|_p|
+ children: Proc.new do |_p|
children = []
6.times do |time|
- children << Redmine::MenuManager::MenuItem.new("test_dynamic_child_#{time}", { controller: 'work_packages', action: 'index' }, {})
+ children << Redmine::MenuManager::MenuItem.new(
+ "test_dynamic_child_#{time}", { controller: 'work_packages',
+ action: 'index' }, {}
+ )
end
children
- }
- )
+ end)
@response.body = render_menu_node(parent_node, Project.find(1))
@@ -172,9 +173,10 @@ describe Redmine::MenuManager::MenuHelper, type: :helper do
it 'should render menu node with children without an array' do
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
{ controller: 'work_packages', action: 'index' },
-
- children: Proc.new { |_p| Redmine::MenuManager::MenuItem.new('test_child', { controller: 'work_packages', action: 'index' }, {}) },
- )
+ children: Proc.new do |_p|
+ Redmine::MenuManager::MenuItem.new('test_child',
+ { controller: 'work_packages', action: 'index' }, {})
+ end)
assert_raises Redmine::MenuManager::MenuError, ':children must be an array of MenuItems' do
@response.body = render_menu_node(parent_node, Project.find(1))
@@ -184,9 +186,7 @@ describe Redmine::MenuManager::MenuHelper, type: :helper do
it 'should render menu node with incorrect children' do
parent_node = Redmine::MenuManager::MenuItem.new(:parent_node,
{ controller: 'work_packages', action: 'index' },
-
- children: Proc.new { |_p| ['a string'] }
- )
+ children: Proc.new { |_p| ['a string'] })
assert_raises Redmine::MenuManager::MenuError, ':children must be an array of MenuItems' do
@response.body = render_menu_node(parent_node, Project.find(1))
diff --git a/spec_legacy/unit/lib/redmine/menu_manager/menu_item_spec.rb b/spec_legacy/unit/lib/redmine/menu_manager/menu_item_spec.rb
index 75b67ff5f8..f45057e516 100644
--- a/spec_legacy/unit/lib/redmine/menu_manager/menu_item_spec.rb
+++ b/spec_legacy/unit/lib/redmine/menu_manager/menu_item_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -40,8 +41,8 @@ describe Redmine::MenuManager::MenuItem do
Redmine::MenuManager.map :test_menu do |menu|
menu.push(:parent, '/test', {})
- menu.push(:child_menu, '/test', parent: :parent)
- menu.push(:child2_menu, '/test', parent: :parent)
+ menu.push(:child_menu, '/test', parent: :parent)
+ menu.push(:child2_menu, '/test', parent: :parent)
end
# context new menu item
@@ -70,47 +71,36 @@ describe Redmine::MenuManager::MenuItem do
it 'should new menu item should require a proc to use for the if condition' do
assert_raises ArgumentError do
Redmine::MenuManager::MenuItem.new(:test_error, '/test',
-
- if: ['not_a_proc']
- )
+ if: ['not_a_proc'])
end
assert Redmine::MenuManager::MenuItem.new(:test_good_if, '/test',
-
- if: Proc.new {}
- )
+ if: Proc.new {})
end
it 'should new menu item should allow a hash for extra html options' do
assert_raises ArgumentError do
Redmine::MenuManager::MenuItem.new(:test_error, '/test',
-
- html: ['not_a_hash']
- )
+ html: ['not_a_hash'])
end
assert Redmine::MenuManager::MenuItem.new(:test_good_html, '/test',
- html: { data: 'foo' }
- )
+ html: { data: 'foo' })
end
it 'should new menu item should require a proc to use the children option' do
assert_raises ArgumentError do
Redmine::MenuManager::MenuItem.new(:test_error, '/test',
-
- children: ['not_a_proc']
- )
+ children: ['not_a_proc'])
end
assert Redmine::MenuManager::MenuItem.new(:test_good_children, '/test',
-
- children: Proc.new {}
- )
+ children: Proc.new {})
end
it 'should new should not allow setting the parent item to the current item' do
assert_raises ArgumentError do
- Redmine::MenuManager::MenuItem.new(:test_error, '/test', parent: :test_error)
+ Redmine::MenuManager::MenuItem.new(:test_error, '/test', parent: :test_error)
end
end
diff --git a/spec_legacy/unit/lib/redmine/mime_type_spec.rb b/spec_legacy/unit/lib/redmine/mime_type_spec.rb
index b3c9289184..60659c18eb 100644
--- a/spec_legacy/unit/lib/redmine/mime_type_spec.rb
+++ b/spec_legacy/unit/lib/redmine/mime_type_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -32,8 +33,7 @@ describe Redmine::MimeType do
it 'should of' do
to_test = { 'test.unk' => nil,
'test.txt' => 'text/plain',
- 'test.c' => 'text/x-c',
- }
+ 'test.c' => 'text/x-c' }
to_test.each do |name, expected|
assert_equal expected, Redmine::MimeType.of(name)
end
@@ -42,8 +42,7 @@ describe Redmine::MimeType do
it 'should css class of' do
to_test = { 'test.unk' => nil,
'test.txt' => 'text-plain',
- 'test.c' => 'text-x-c',
- }
+ 'test.c' => 'text-x-c' }
to_test.each do |name, expected|
assert_equal expected, Redmine::MimeType.css_class_of(name)
end
@@ -52,8 +51,7 @@ describe Redmine::MimeType do
it 'should main mimetype of' do
to_test = { 'test.unk' => nil,
'test.txt' => 'text',
- 'test.c' => 'text',
- }
+ 'test.c' => 'text' }
to_test.each do |name, expected|
assert_equal expected, Redmine::MimeType.main_mimetype_of(name)
end
@@ -62,8 +60,7 @@ describe Redmine::MimeType do
it 'should is type' do
to_test = { ['text', 'test.unk'] => false,
['text', 'test.txt'] => true,
- ['text', 'test.c'] => true,
- }
+ ['text', 'test.c'] => true }
to_test.each do |args, expected|
assert_equal expected, Redmine::MimeType.is_type?(*args)
end
diff --git a/spec_legacy/unit/lib/redmine/notifiable_spec.rb b/spec_legacy/unit/lib/redmine/notifiable_spec.rb
index 6880749659..4a040c0c0c 100644
--- a/spec_legacy/unit/lib/redmine/notifiable_spec.rb
+++ b/spec_legacy/unit/lib/redmine/notifiable_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -32,7 +33,8 @@ describe Redmine::Notifiable do
it 'should all' do
assert_equal 11, Redmine::Notifiable.all.length
- %w(work_package_added work_package_updated work_package_note_added status_updated work_package_priority_updated news_added news_comment_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
+ %w(work_package_added work_package_updated work_package_note_added status_updated work_package_priority_updated news_added
+ news_comment_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable|
assert Redmine::Notifiable.all.map(&:name).include?(notifiable), "missing #{notifiable}"
end
end
diff --git a/spec_legacy/unit/lib/redmine/unified_diff_spec.rb b/spec_legacy/unit/lib/redmine/unified_diff_spec.rb
index 00a692b76f..bcc8cee09e 100644
--- a/spec_legacy/unit/lib/redmine/unified_diff_spec.rb
+++ b/spec_legacy/unit/lib/redmine/unified_diff_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -27,7 +28,7 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
-require 'legacy_spec_helper'
+require_relative '../../../legacy_spec_helper'
describe Redmine::UnifiedDiff do
it 'should subversion diff' do
@@ -99,58 +100,58 @@ describe Redmine::UnifiedDiff do
end
it 'should line starting with dashes' do
- diff = Redmine::UnifiedDiff.new(<<-DIFF
---- old.txt Wed Nov 11 14:24:58 2009
-+++ new.txt Wed Nov 11 14:25:02 2009
-@@ -1,8 +1,4 @@
--Lines that starts with dashes:
--
--------------------------
---- file.c
--------------------------
-+A line that starts with dashes:
+ diff = Redmine::UnifiedDiff.new(<<~DIFF
+ --- old.txt Wed Nov 11 14:24:58 2009
+ +++ new.txt Wed Nov 11 14:25:02 2009
+ @@ -1,8 +1,4 @@
+ -Lines that starts with dashes:
+ -
+ -------------------------
+ --- file.c
+ -------------------------
+ +A line that starts with dashes:
- and removed.
+ and removed.
-@@ -23,4 +19,4 @@
+ @@ -23,4 +19,4 @@
--Another chunk of change
-+Another chunk of changes
+ -Another chunk of change
+ +Another chunk of changes
-DIFF
+ DIFF
)
assert_equal 1, diff.size
end
it 'should one line new files' do
- diff = Redmine::UnifiedDiff.new(<<-DIFF
-diff -r 000000000000 -r ea98b14f75f0 README1
---- /dev/null
-+++ b/README1
-@@ -0,0 +1,1 @@
-+test1
-diff -r 000000000000 -r ea98b14f75f0 README2
---- /dev/null
-+++ b/README2
-@@ -0,0 +1,1 @@
-+test2
-diff -r 000000000000 -r ea98b14f75f0 README3
---- /dev/null
-+++ b/README3
-@@ -0,0 +1,3 @@
-+test4
-+test5
-+test6
-diff -r 000000000000 -r ea98b14f75f0 README4
---- /dev/null
-+++ b/README4
-@@ -0,0 +1,3 @@
-+test4
-+test5
-+test6
-DIFF
+ diff = Redmine::UnifiedDiff.new(<<~DIFF
+ diff -r 000000000000 -r ea98b14f75f0 README1
+ --- /dev/null
+ +++ b/README1
+ @@ -0,0 +1,1 @@
+ +test1
+ diff -r 000000000000 -r ea98b14f75f0 README2
+ --- /dev/null
+ +++ b/README2
+ @@ -0,0 +1,1 @@
+ +test2
+ diff -r 000000000000 -r ea98b14f75f0 README3
+ --- /dev/null
+ +++ b/README3
+ @@ -0,0 +1,3 @@
+ +test4
+ +test5
+ +test6
+ diff -r 000000000000 -r ea98b14f75f0 README4
+ --- /dev/null
+ +++ b/README4
+ @@ -0,0 +1,3 @@
+ +test4
+ +test5
+ +test6
+ DIFF
)
assert_equal 4, diff.size
end
diff --git a/spec_legacy/unit/lib/redmine_spec.rb b/spec_legacy/unit/lib/redmine_spec.rb
index 200d408ed4..b26b9fcda3 100644
--- a/spec_legacy/unit/lib/redmine_spec.rb
+++ b/spec_legacy/unit/lib/redmine_spec.rb
@@ -36,7 +36,8 @@ module RedmineMenuTestHelper
end
def assert_menu_contains_item_named(menu_name, item_name)
- assert Redmine::MenuManager.items(menu_name).map(&:name).include?(item_name.to_sym), "Menu did not have an item named #{item_name}"
+ assert Redmine::MenuManager.items(menu_name).map(&:name).include?(item_name.to_sym),
+ "Menu did not have an item named #{item_name}"
end
# Helpers
diff --git a/spec_legacy/unit/mail_handler_spec.rb b/spec_legacy/unit/mail_handler_spec.rb
index 6799f2a235..a98f3b20d6 100644
--- a/spec_legacy/unit/mail_handler_spec.rb
+++ b/spec_legacy/unit/mail_handler_spec.rb
@@ -373,7 +373,9 @@ describe MailHandler, type: :model do
it 'should email with long subject line' do
issue = submit_email('ticket_with_long_subject.eml')
assert issue.is_a?(WorkPackage)
- assert_equal issue.subject, 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[0, 255]
+ assert_equal issue.subject,
+ 'New ticket on a given project with a very long subject line which exceeds 255 chars and should not be ignored but chopped off. And if the subject line is still not long enough, we just add more text. And more text. Wow, this is really annoying. Especially, if you have nothing to say...'[
+0, 255]
end
it 'should new user from attributes should return valid user' do
@@ -383,8 +385,12 @@ describe MailHandler, type: :model do
['jsmith@example.net', 'John'] => ['jsmith@example.net', 'John', '-'],
['jsmith@example.net', 'John Smith'] => ['jsmith@example.net', 'John', 'Smith'],
['jsmith@example.net', 'John Paul Smith'] => ['jsmith@example.net', 'John', 'Paul Smith'],
- ['jsmith@example.net', 'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength Smith'] => ['jsmith@example.net', 'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength', 'Smith'],
- ['jsmith@example.net', 'John AVeryLongLastnameThatNoLongerExceedsTheMaximumLength'] => ['jsmith@example.net', 'John', 'AVeryLongLastnameThatNoLongerExceedsTheMaximumLength']
+ ['jsmith@example.net',
+ 'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength Smith'] => ['jsmith@example.net',
+ 'AVeryLongFirstnameThatNoLongerExceedsTheMaximumLength', 'Smith'],
+ ['jsmith@example.net',
+ 'John AVeryLongLastnameThatNoLongerExceedsTheMaximumLength'] => ['jsmith@example.net', 'John',
+ 'AVeryLongLastnameThatNoLongerExceedsTheMaximumLength']
}
to_test.each do |attrs, expected|
diff --git a/spec_legacy/unit/member_spec.rb b/spec_legacy/unit/member_spec.rb
index 5d4c678682..2c6ddda738 100644
--- a/spec_legacy/unit/member_spec.rb
+++ b/spec_legacy/unit/member_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -42,8 +43,8 @@ describe Member, type: :model do
it 'should create' do
member = Member.new.tap do |m|
m.attributes = { project_id: @project.id,
- user_id: FactoryBot.create(:user).id,
- role_ids: [@role.id] }
+ user_id: FactoryBot.create(:user).id,
+ role_ids: [@role.id] }
end
assert member.save
member.reload
@@ -98,7 +99,7 @@ describe Member, type: :model do
Watcher.create!(watchable: FactoryBot.create(:wiki, project: @private_project), user: @watcher_user)
@private_project.reload # to access @private_project.wiki
Watcher.create!(watchable: FactoryBot.create(:wiki_page, wiki: @private_project.wiki), user: @watcher_user)
- @private_role = FactoryBot.create :role, permissions: [:view_wiki_pages, :view_work_packages]
+ @private_role = FactoryBot.create :role, permissions: %i[view_wiki_pages view_work_packages]
@private_project.public = false
@private_project.save
@@ -108,8 +109,8 @@ describe Member, type: :model do
before do
(@member = Member.new.tap do |m|
m.attributes = { project_id: @private_project.id,
- user_id: @watcher_user.id,
- role_ids: [@private_role.id, FactoryBot.create(:role).id] }
+ user_id: @watcher_user.id,
+ role_ids: [@private_role.id, FactoryBot.create(:role).id] }
end).save!
end
@@ -138,8 +139,8 @@ describe Member, type: :model do
@group = FactoryBot.create :group, members: @watcher_user
@member = (Member.new.tap do |m|
m.attributes = { project_id: @private_project.id,
- user_id: @group.id,
- role_ids: [@private_role.id, FactoryBot.create(:role).id] }
+ user_id: @group.id,
+ role_ids: [@private_role.id, FactoryBot.create(:role).id] }
end)
@group.members << @member
diff --git a/spec_legacy/unit/project_spec.rb b/spec_legacy/unit/project_spec.rb
index 073d41424e..fc68361482 100644
--- a/spec_legacy/unit/project_spec.rb
+++ b/spec_legacy/unit/project_spec.rb
@@ -135,7 +135,7 @@ describe Project, type: :model do
it 'should descendants' do
d = Project.find(1).descendants.pluck(:id)
- assert_equal [3,4,5,6], d.sort
+ assert_equal [3, 4, 5, 6], d.sort
end
it 'should users by role' do
diff --git a/spec_legacy/unit/search_spec.rb b/spec_legacy/unit/search_spec.rb
index 39a9d4c638..5773e7e2de 100644
--- a/spec_legacy/unit/search_spec.rb
+++ b/spec_legacy/unit/search_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/time_entry_activity_spec.rb b/spec_legacy/unit/time_entry_activity_spec.rb
index 2ab6fb3bc4..3e0f32d7e2 100644
--- a/spec_legacy/unit/time_entry_activity_spec.rb
+++ b/spec_legacy/unit/time_entry_activity_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/user_preference_spec.rb b/spec_legacy/unit/user_preference_spec.rb
index 07f9bb6845..f535d4d7a4 100644
--- a/spec_legacy/unit/user_preference_spec.rb
+++ b/spec_legacy/unit/user_preference_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/user_spec.rb b/spec_legacy/unit/user_spec.rb
index 33b4563fb9..f69af09b5a 100644
--- a/spec_legacy/unit/user_spec.rb
+++ b/spec_legacy/unit/user_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -155,7 +156,8 @@ describe User, type: :model do
end
it 'should select the exact matching user first' do
- case_sensitive_user = FactoryBot.create(:user, login: 'changed', password: 'adminADMIN!', password_confirmation: 'adminADMIN!')
+ case_sensitive_user = FactoryBot.create(:user, login: 'changed', password: 'adminADMIN!',
+ password_confirmation: 'adminADMIN!')
# bypass validations to make it appear like existing data
case_sensitive_user.update_attribute(:login, 'ADMIN')
diff --git a/spec_legacy/unit/version_spec.rb b/spec_legacy/unit/version_spec.rb
index aa82d3bf69..addcb1c44b 100644
--- a/spec_legacy/unit/version_spec.rb
+++ b/spec_legacy/unit/version_spec.rb
@@ -118,7 +118,7 @@ describe Version, type: :model do
add_work_package(v, done_ratio: 20)
add_work_package(v, status: Status.where(is_closed: true).first)
assert_progress_equal (0.0 + 20.0 + 100.0) / 3, v.completed_percent
- assert_progress_equal (100.0) / 3, v.closed_percent
+ assert_progress_equal 100.0 / 3, v.closed_percent
end
it 'should progress should consider estimated hours to weigth issues' do
diff --git a/spec_legacy/unit/wiki_content_spec.rb b/spec_legacy/unit/wiki_content_spec.rb
index 2270e54fa3..b8afd9ebe8 100644
--- a/spec_legacy/unit/wiki_content_spec.rb
+++ b/spec_legacy/unit/wiki_content_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/wiki_page_spec.rb b/spec_legacy/unit/wiki_page_spec.rb
index 1b59435fde..cb809d7db2 100644
--- a/spec_legacy/unit/wiki_page_spec.rb
+++ b/spec_legacy/unit/wiki_page_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/wiki_redirect_spec.rb b/spec_legacy/unit/wiki_redirect_spec.rb
index 548c2384b3..531508be4a 100644
--- a/spec_legacy/unit/wiki_redirect_spec.rb
+++ b/spec_legacy/unit/wiki_redirect_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
diff --git a/spec_legacy/unit/wiki_spec.rb b/spec_legacy/unit/wiki_spec.rb
index 8fbd27ab5c..594cabc58d 100644
--- a/spec_legacy/unit/wiki_spec.rb
+++ b/spec_legacy/unit/wiki_spec.rb
@@ -1,4 +1,5 @@
#-- encoding: UTF-8
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
@@ -26,7 +27,8 @@
#
# See docs/COPYRIGHT.rdoc for more details.
#++
-require 'legacy_spec_helper'
+
+require_relative '../legacy_spec_helper'
describe Wiki, type: :model do
fixtures :all