From 593ab38f86682d9b095123421ee518d28acb44f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Wed, 3 Aug 2022 12:31:59 +0100 Subject: [PATCH] Avoid collision between id and user_id --- app/controllers/users_controller.rb | 10 +++++++--- spec/features/user_spec.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 08de83dbb..7f6b2db35 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -30,9 +30,13 @@ class UsersController < ApplicationController def show; end - def dpo; end + def dpo + pp params + end - def key_contact; end + def key_contact + pp params + end def edit redirect_to user_path(@user) unless @user.active? @@ -168,7 +172,7 @@ private end def find_resource - @user = User.find_by(id: params[:id]) || User.find_by(id: params[:user_id]) || current_user + @user = User.find_by(id: params[:user_id]) || User.find_by(id: params[:id]) || current_user end def authenticate_scope! diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index f3c0b7c01..3dc6b0cf8 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -340,7 +340,7 @@ RSpec.describe "User Features" do context "when editing someone elses account details" do let!(:user) { FactoryBot.create(:user, :data_coordinator, last_sign_in_at: Time.zone.now) } - let!(:other_user) { FactoryBot.create(:user, name: "Other name", is_dpo: true, organisation: user.organisation) } + let!(:other_user) { FactoryBot.create(:user, name: "Other name", is_dpo: false, organisation: user.organisation) } before do visit("/logs")