File tree Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ def seed_people(names)
19
19
seed_project_technology ( project . id )
20
20
end
21
21
end
22
+
23
+ # Allow the default logged-in user to edit themselves
24
+ Person . find_by_name ( "Carl Albrecht Conf Admin" ) &.update ( auth_user_id : 1 )
22
25
end
23
26
24
27
def seed_association ( assoc_name , person_id )
Original file line number Diff line number Diff line change @@ -379,4 +379,29 @@ def add_language(language)
379
379
expect ( page ) . to have_no_content ( t ( "people.index.profile" ) )
380
380
end
381
381
end
382
+
383
+ describe 'Access control' do
384
+ before ( :each ) do
385
+ sign_in auth_users ( :user )
386
+ end
387
+
388
+ it 'logged in person can edit their own profile' do
389
+ ursula = people ( :user )
390
+ visit person_path ( ursula )
391
+
392
+ click_link ( 'Bearbeiten' , href : edit_person_path ( ursula ) )
393
+ fill_in 'person_title' , with : 'Expert at access control'
394
+ save_button = find_button ( "Person aktualisieren" )
395
+ save_button . click
396
+
397
+ expect ( page ) . to have_content ( 'Expert at access control' )
398
+ end
399
+
400
+ it 'logged in person should no be able to edit other profiles' do
401
+ longmax = people ( :longmax )
402
+ visit person_path ( longmax )
403
+
404
+ expect { click_link ( 'Bearbeiten' , href : edit_person_path ( longmax ) ) } . to raise_error ( "You are not authorized to access this page." )
405
+ end
406
+ end
382
407
end
Original file line number Diff line number Diff line change 4
4
email : user@skills.ch
5
5
is_admin : false
6
6
7
-
8
7
admin :
9
8
uid : 1234-5678-9012-3457
10
9
name : Andreas Admin
Original file line number Diff line number Diff line change @@ -182,4 +182,22 @@ maximillian:
182
182
Figma
183
183
display_competence_notes_in_cv : false
184
184
email : maximillian@example.com
185
- department : mid
185
+ department : mid
186
+
187
+ user :
188
+ birthdate : 1995-05-32 16:04:56
189
+ location : Belp
190
+ marital_status : <%= Person.marital_statuses[:single] %>
191
+ name : Ursula User
192
+ nationality : CH
193
+ roles : [ software-engineer ]
194
+ title : Just a user
195
+ competence_notes : |
196
+ Python
197
+ Go
198
+ Unity
199
+ company : firma
200
+ email : user@example.com
201
+ department : dev-one
202
+ shortname : UU
203
+ auth_user_id : 227792459
You can’t perform that action at this time.
0 commit comments