Browse Source

Avoid collision between id and user_id

pull/787/head
Stéphane Meny 3 years ago
parent
commit
593ab38f86
No known key found for this signature in database
GPG Key ID: 9D0AFEA988527923
  1. 10
      app/controllers/users_controller.rb
  2. 2
      spec/features/user_spec.rb

10
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!

2
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")

Loading…
Cancel
Save