OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Pass correct nil
Oliver Günther74fa859e5f60
diff --git a/.rubocop.yml b/.rubocop.ymlindex d245164e264..addb52904d6 100644--- a/.rubocop.yml+++ b/.rubocop.yml@@ -208,6 +208,8 @@ Rails/DynamicFindBy:- 'spec/features/**/*.rb'- 'spec/support/**/*.rb'- 'modules/*/spec/features/**/*.rb'+ Whitelist:+ - find_by_login# We have config.active_record.belongs_to_required_by_default = false ,# which means, we do have to declare presence validators on belongs_to relations.diff --git a/modules/auth_plugins/spec/views/base.html.erb_spec.rb b/modules/auth_plugins/spec/views/base.html.erb_spec.rbindex dff8b94e056..a7e45ad22b4 100644--- a/modules/auth_plugins/spec/views/base.html.erb_spec.rb+++ b/modules/auth_plugins/spec/views/base.html.erb_spec.rb@@ -36,9 +36,8 @@ RSpec.describe "layouts/base" dobefore dowithout_partial_double_verification do- allow(view).to receive(:current_menu_item).and_return("overview")allow(view).to receive(:default_breadcrumb)- allow(view).to receive(:current_user).and_return anonymous+ allow(view).to receive_messages(current_menu_item: "overview", current_user: anonymous)endallow(OpenProject::Plugins::AuthPlugin).to receive(:providers).and_return([provider])enddiff --git a/modules/costs/spec/lib/api/v3/costs_api_user_permission_check_spec.rb b/modules/costs/spec/lib/api/v3/costs_api_user_permission_check_spec.rbindex 5d5a4477d2f..988264b0d6b 100644--- a/modules/costs/spec/lib/api/v3/costs_api_user_permission_check_spec.rb+++ b/modules/costs/spec/lib/api/v3/costs_api_user_permission_check_spec.rb@@ -53,8 +53,7 @@ RSpec.describe API::V3::CostsApiUserPermissionCheck dobefore dowithout_partial_double_verification do- allow(subject).to receive(:current_user).and_return(user)- allow(subject).to receive(:represented).and_return(work_package)+ allow(subject).to receive_messages(current_user: user, represented: work_package) # rubocop:disable RSpec/SubjectStubendmock_permissions_for(user) do |mock|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.rbindex 4a5387222d7..e0477e4de28 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@@ -12,7 +12,7 @@ RSpec.describe TwoFactorAuthentication::AuthenticationController, with_settings:session[:stage_secrets] = { two_factor_authentication: "asdf" }without_partial_double_verification do- allow_any_instance_of(User).to receive(:any_active_memberships?).and_return(true)+ allow_any_instance_of(User).to receive(:any_active_memberships?).and_return(true) # rubocop:disable RSpec/AnyInstanceendenddiff --git a/spec/controllers/concerns/omniauth_login_spec.rb b/spec/controllers/concerns/omniauth_login_spec.rbindex 44710cc06ad..e2bd9744abd 100644--- a/spec/controllers/concerns/omniauth_login_spec.rb+++ b/spec/controllers/concerns/omniauth_login_spec.rb@@ -29,8 +29,8 @@require "spec_helper"# Concern is included into AccountController and depends on methods available there-RSpec.describe AccountController, :skip_2fa_stage do- let(:omniauth_strategy) { double("Google Strategy", name: "google") }+RSpec.describe AccountController, :skip_2fa_stage do # rubocop:disable RSpec/SpecFilePathFormat+ let(:omniauth_strategy) { double("Google Strategy", name: "google") } # rubocop:disable RSpec/VerifiedDoubleslet(:omniauth_hash) doOmniAuth::AuthHash.new(provider: "google",@@ -52,9 +52,9 @@ RSpec.describe AccountController, :skip_2fa_stage doUser.current = nilend- 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+ describe "GET #omniauth_login", with_settings: { self_registration: Setting::SelfRegistration.automatic } do+ context "with on-the-fly registration" do+ context "when providing all required fields" dobefore dorequest.env["omniauth.origin"] = "https://example.net/some_back_url"post :omniauth_login, params: { provider: :google }@@ -118,7 +118,7 @@ RSpec.describe AccountController, :skip_2fa_stage do)end- context "available" do+ describe "available" doit "merges the strategy mapping" doallow(omniauth_strategy).to receive(:omniauth_hash_to_user_attributes) do |auth|raw_info = auth[:extra][:raw_info]@@ -129,18 +129,18 @@ RSpec.describe AccountController, :skip_2fa_stage do}end- expect(omniauth_strategy).to receive(:omniauth_hash_to_user_attributes)-post :omniauth_login, params: { provider: :google }user = User.find_by_login("[email protected]")expect(user).to be_an_instance_of(User)expect(user.firstname).to eql("foo")expect(user.lastname).to eql("bar")++ expect(omniauth_strategy).to have_received(:omniauth_hash_to_user_attributes)endend- context "unavailable" do+ describe "unavailable" doit "keeps the default mapping" dopost :omniauth_login, params: { provider: :google }@@ -152,7 +152,7 @@ RSpec.describe AccountController, :skip_2fa_stage doendend- context "not providing all required fields" do+ context "when not providing all required fields" dolet(:omniauth_hash) doOmniAuth::AuthHash.new(provider: "google",@@ -169,7 +169,7 @@ RSpec.describe AccountController, :skip_2fa_stage doendit "registers user via post" do- expect(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |user, auth_hash|+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |user, auth_hash|new_user = User.find_by_login("[email protected]")expect(user).to eq new_userexpect(auth_hash).to include(omniauth_hash)@@ -177,7 +177,7 @@ RSpec.describe AccountController, :skip_2fa_stage doauth_source_registration = omniauth_hash.merge(omniauth: true,- timestamp: Time.new+ timestamp: Time.zone.now)session[:auth_source_registration] = auth_source_registrationpost :register,@@ -198,11 +198,11 @@ RSpec.describe AccountController, :skip_2fa_stage doexpect(user.identity_url).to eql("google:123545")end- context "after a timeout expired" do+ context "when after a timeout expired" dobefore dosession[:auth_source_registration] = omniauth_hash.merge(omniauth: true,- timestamp: Time.new - 42.days+ timestamp: 42.days.ago)end@@ -220,21 +220,6 @@ RSpec.describe AccountController, :skip_2fa_stage doexpect(flash[:error]).to eq(I18n.t(:error_omniauth_registration_timed_out))expect(User.find_by_login("[email protected]")).to be_nilend-- it "does not register the user when providing all the missing fields" do- post :register,- params: {- user: {- firstname: "Foo",- # lastname intentionally not provided- mail: "[email protected]"- }- }-- expect(response).to redirect_to signin_path- expect(flash[:error]).to eq(I18n.t(:error_omniauth_registration_timed_out))- expect(User.find_by_login("[email protected]")).to be_nil- endendend@@ -390,8 +375,8 @@ RSpec.describe AccountController, :skip_2fa_stage doOpenProject::OmniAuth::Authorization.callbacks.clearend- it "works" do- expect(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |u, auth|+ it "logs in the user" do+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |u, auth|expect(u).to eq userexpect(auth).to eq omniauth_hashend@@ -407,22 +392,26 @@ RSpec.describe AccountController, :skip_2fa_stage doendit "is rejected against google" do- expect(OpenProject::OmniAuth::Authorization).not_to receive(:after_login!).with(user, any_args)+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!)post :omniauth_login, params: { provider: :google }expect(response).to redirect_to signin_pathexpect(flash[:error]).to eq "I only want to see [email protected] here."++ expect(OpenProject::OmniAuth::Authorization).not_to have_received(:after_login!).with(user, any_args)endit "is rejected against any other provider too" do- expect(OpenProject::OmniAuth::Authorization).not_to receive(:after_login!).with(user, any_args)+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!)omniauth_hash.provider = "any other"post :omniauth_login, params: { provider: :google }expect(response).to redirect_to signin_pathexpect(flash[:error]).to eq "I only want to see [email protected] here."++ expect(OpenProject::OmniAuth::Authorization).not_to have_received(:after_login!).with(user, any_args)endend@@ -434,16 +423,18 @@ RSpec.describe AccountController, :skip_2fa_stage doendit "is rejected against google" do- expect(OpenProject::OmniAuth::Authorization).not_to receive(:after_login!).with(user, any_args)+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!)post :omniauth_login, params: { provider: :google }expect(response).to redirect_to signin_pathexpect(flash[:error]).to eq "Go away foo!"++ expect(OpenProject::OmniAuth::Authorization).not_to have_received(:after_login!).with(user, any_args)endit "is approved against any other provider" do- expect(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |u|+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!) do |u|new_user = User.find_by identity_url: "some other:123545"expect(u).to eq new_user@@ -461,7 +452,7 @@ RSpec.describe AccountController, :skip_2fa_stage do# ... and to confirm that, here's what happens when the authorization failsit "is rejected against any other provider with the wrong email" do- expect(OpenProject::OmniAuth::Authorization).not_to receive(:after_login!).with(user, any_args)+ allow(OpenProject::OmniAuth::Authorization).to receive(:after_login!)omniauth_hash.provider = "yet another"config.global_email = "[email protected]"@@ -470,6 +461,7 @@ RSpec.describe AccountController, :skip_2fa_stage doexpect(response).to redirect_to signin_pathexpect(flash[:error]).to eq "I only want to see [email protected] here."+ expect(OpenProject::OmniAuth::Authorization).not_to have_received(:after_login!).with(user, any_args)endendend@@ -541,7 +533,7 @@ RSpec.describe AccountController, :skip_2fa_stage doendit "does not sign in the user" do- expect(controller.send(:current_user).logged?).to be_falsey+ expect(controller.send(:current_user)).not_to be_loggedendit "does not set registration information in the session" do@@ -556,8 +548,10 @@ RSpec.describe AccountController, :skip_2fa_stage doendit "logs a warn message" do- expect(Rails.logger).to receive(:warn).with("invalid_credentials")+ allow(Rails.logger).to receive(:warn)post :omniauth_failure, params: { message: "invalid_credentials" }++ expect(Rails.logger).to have_received(:warn).with("invalid_credentials")endendenddiff --git a/spec/lib/acts_as_list/acts_as_list_patch_spec.rb b/spec/lib/acts_as_list/acts_as_list_patch_spec.rbindex 635ec04fccb..f7409075211 100644--- a/spec/lib/acts_as_list/acts_as_list_patch_spec.rb+++ b/spec/lib/acts_as_list/acts_as_list_patch_spec.rb@@ -28,50 +28,65 @@require "spec_helper"-RSpec.describe "Models acting as list (acts_as_list)" do+RSpec.describe "Models acting as list (acts_as_list)" do # rubocop:disable RSpec/DescribeClassit "includes the patch" doexpect(ActiveRecord::Acts::List::InstanceMethods.included_modules).to include(OpenProject::Patches::ActsAsList)enddescribe "#move_to=" dolet(:includer) do- class ActsAsListPatchIncluder+ clazz = Class.new doinclude OpenProject::Patches::ActsAsList++ def move_to_top; end++ def move_to_bottom; end++ def move_higher; end++ def move_lower; endend- ActsAsListPatchIncluder.new+ clazz.new+ end++ before do+ allow(includer).to receive(:move_to_top)+ allow(includer).to receive(:move_to_bottom)+ allow(includer).to receive(:move_higher)+ allow(includer).to receive(:move_lower)endit "moves to top when wanting to move highest" do+ includer.move_to = "highest"+without_partial_double_verification do- expect(includer).to receive :move_to_top+ expect(includer).to have_received :move_to_topend-- includer.move_to = "highest"endit "moves to bottom when wanting to move lowest" do+ includer.move_to = "lowest"+without_partial_double_verification do- expect(includer).to receive :move_to_bottom+ expect(includer).to have_received :move_to_bottomend-- includer.move_to = "lowest"endit "moves higher when wanting to move higher" do+ includer.move_to = "higher"+without_partial_double_verification do- expect(includer).to receive :move_higher+ expect(includer).to have_received :move_higherend-- includer.move_to = "higher"endit "moves lower when wanting to move lower" do+ includer.move_to = "lower"+without_partial_double_verification do- expect(includer).to receive :move_lower+ expect(includer).to have_received :move_lowerend-- includer.move_to = "lower"endendenddiff --git a/spec/lib/api/v3/work_packages/work_package_at_timestamp_representer_rendering_spec.rb b/spec/lib/api/v3/work_packages/work_package_at_timestamp_representer_rendering_spec.rbindex 9d95eba9080..a567fbdbcb9 100644--- a/spec/lib/api/v3/work_packages/work_package_at_timestamp_representer_rendering_spec.rb+++ b/spec/lib/api/v3/work_packages/work_package_at_timestamp_representer_rendering_spec.rb@@ -89,11 +89,7 @@ RSpec.describe API::V3::WorkPackages::WorkPackageAtTimestampRepresenter, "render.with(:wrapped?).and_return(true)allow(wp)- .to receive(:available_custom_fields)- .and_return(available_custom_fields)- allow(wp)- .to receive(:custom_field_values)- .and_return([custom_value])+ .to receive_messages(available_custom_fields:, custom_field_values: [custom_value])endendlet(:timestamp) { Timestamp.new(1.day.ago) }@@ -109,23 +105,11 @@ RSpec.describe API::V3::WorkPackages::WorkPackageAtTimestampRepresenter, "render# Mimicking the eager loading wrapperwithout_partial_double_verification doallow(model)- .to receive(:timestamp)- .and_return(timestamp)- allow(model)- .to receive(:attributes_changed_to_baseline)- .and_return(attributes_changed_to_baseline)- allow(model)- .to receive(:exists_at_timestamp?)- .and_return(exists_at_timestamp)- allow(model)- .to receive(:with_query?)- .and_return(with_query)- allow(model)- .to receive(:matches_filters_at_timestamp?)- .and_return(matches_filters_at_timestamp)- allow(model)- .to receive(:exists_at_current_timestamp?)- .and_return(exists_at_current_timestamp)+ .to receive_messages(timestamp:, attributes_changed_to_baseline:,+ exists_at_timestamp?: exists_at_timestamp,+ with_query?: with_query,+ matches_filters_at_timestamp?: matches_filters_at_timestamp,+ exists_at_current_timestamp?: exists_at_current_timestamp)endendenddiff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rbindex ec7e65cce61..38e7ae1d4fd 100644--- a/spec/services/work_packages/set_attributes_service_spec.rb+++ b/spec/services/work_packages/set_attributes_service_spec.rb@@ -1583,20 +1583,18 @@ RSpec.describe WorkPackages::SetAttributesService,endbefore do- allow(new_project)- .to receive(:shared_versions)- .and_return(new_versions)- allow(new_project_categories)+ without_partial_double_verification do+ allow(new_project_categories).to receive(:find_by).with(name: category.name).and_return nil- allow(new_project)- .to receive(:types)- .and_return(new_types)- allow(new_types)- .to receive(:order)- .with(:position)- .and_return(new_types)+ allow(new_project)+ .to receive_messages(shared_versions: new_versions, types: new_types)+ allow(new_types)+ .to receive(:order)+ .with(:position)+ .and_return(new_types)+ endendshared_examples_for "updating the project" do@@ -1775,7 +1773,7 @@ RSpec.describe WorkPackages::SetAttributesService,subject { instance.call(call_attributes) }context "for non existing fields" do- let(:call_attributes) { { custom_field_891: "1" } } # rubocop:disable Naming/VariableNumber+ let(:call_attributes) { { custom_field_891: "1" } }before dosubjectdiff --git a/spec/support/shared/with_direct_uploads.rb b/spec/support/shared/with_direct_uploads.rbindex 1c192159274..05d86f913d7 100644--- a/spec/support/shared/with_direct_uploads.rb+++ b/spec/support/shared/with_direct_uploads.rb@@ -149,6 +149,7 @@ class WithDirectUploadscreds = config[:fog][:credentials]without_partial_double_verification do+ # rubocop:disable RSpec/AnyInstanceallow_any_instance_of(FogFileUploader).to receive(:fog_credentials).and_return credsallow_any_instance_of(FogFileUploader).to receive(:aws_access_key_id).and_return creds[:aws_access_key_id]@@ -158,6 +159,7 @@ class WithDirectUploadsallow_any_instance_of(FogFileUploader).to receive(:directory).and_return config[:fog][:directory]allow(OpenProject::Configuration).to receive(:direct_uploads?).and_return(true)+ # rubocop:enable RSpec/AnyInstanceendenddiff --git a/spec/support_spec/mocked_permission_helper_spec.rb b/spec/support_spec/mocked_permission_helper_spec.rbindex 5cf36015711..23422f86b5d 100644--- a/spec/support_spec/mocked_permission_helper_spec.rb+++ b/spec/support_spec/mocked_permission_helper_spec.rb@@ -185,7 +185,7 @@ RSpec.describe MockedPermissionHelper doendit "allows the project permission when querying with controller and action hash" do- expect(user).to be_allowed_in_project({ controller: "work_packages", action: "index", project_id: project.id })+ expect(user).to be_allowed_in_project({ controller: "work_packages", action: "index", project_id: project.id }, nil)expect(user).to be_allowed_in_any_project({ controller: "work_packages", action: "index" })enddiff --git a/spec/views/layouts/admin.html.erb_spec.rb b/spec/views/layouts/admin.html.erb_spec.rbindex d71a6dfa0a7..cd0aec85ecf 100644--- a/spec/views/layouts/admin.html.erb_spec.rb+++ b/spec/views/layouts/admin.html.erb_spec.rb@@ -36,13 +36,12 @@ RSpec.describe "layouts/admin" dobefore dowithout_partial_double_verification do- allow(view).to receive(:current_menu_item).and_return("overview")allow(view).to receive(:default_breadcrumb)- allow(view).to receive(:current_user).and_return adminparent_menu_item = Object.newallow(parent_menu_item).to receive(:name).and_return :root- allow(view).to receive(:admin_first_level_menu_entry).and_return parent_menu_item+ allow(view).to receive_messages(current_menu_item: "overview", current_user: admin,+ admin_first_level_menu_entry: parent_menu_item)allow(controller).to receive(:default_search_scope)allow(view).to receive(:render_to_string)diff --git a/spec/views/layouts/base.html.erb_spec.rb b/spec/views/layouts/base.html.erb_spec.rbindex 3b895a88847..1031875f376 100644--- a/spec/views/layouts/base.html.erb_spec.rb+++ b/spec/views/layouts/base.html.erb_spec.rb@@ -42,11 +42,10 @@ RSpec.describe "layouts/base" dobefore dowithout_partial_double_verification do- allow(view).to receive(:current_menu_item).and_return("overview")allow(view).to receive(:default_breadcrumb)allow(controller).to receive(:default_search_scope)allow(view).to receive(:render_to_string)- allow(view).to receive(:current_user).and_return current_user+ allow(view).to receive_messages(current_menu_item: "overview", current_user:)endallow(User).to receive(:current).and_return current_userdiff --git a/spec/views/users/index.html.erb_spec.rb b/spec/views/users/index.html.erb_spec.rbindex cbfb9d85eff..ac1dbdb7c2f 100644--- a/spec/views/users/index.html.erb_spec.rb+++ b/spec/views/users/index.html.erb_spec.rb@@ -40,9 +40,7 @@ RSpec.describe "users/index" doassign(:groups, Group.all)without_partial_double_verification do- allow(view).to receive(:current_user).and_return(admin)- allow(view).to receive(:controller_name).and_return("users")- allow(view).to receive(:action_name).and_return("index")+ allow(view).to receive_messages(current_user: admin, controller_name: "users", action_name: "index")endend