Skip to content

Commit

Permalink
fix user account spec - users *can* now update their own profile via …
Browse files Browse the repository at this point in the history
…api due to previous change in #703
  • Loading branch information
andrew-1234 committed Feb 6, 2025
1 parent f188530 commit 7006a34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,11 @@ def to_tagging(user, is_guest)
end

def to_user(user, is_guest)
# admin only: :index, :edit, :update
# admin only: :index, :edit
# :edit and :update are the Admin interface for editing any user
# normal users edit their profile using devise/registrations#edit

# users can :update their own attributes on the user model via api
# users can only view their own:
can [:projects, :sites, :bookmarks, :audio_events, :audio_event_comments, :update], User, id: user.id

Expand Down
10 changes: 4 additions & 6 deletions spec/acceptance/user_accounts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,16 @@ def id_param
id_param
let(:id) { writer_id }
let(:raw_post) { { user: post_attributes }.to_json }
let(:authentication_token) { writer_token } # admin only, users edit using devise/registrations#edit
standard_request_options(:put, 'UPDATE (as writer, same user)', :forbidden,
{ expected_json_path: get_json_error_path(:permissions) })
let(:authentication_token) { writer_token }
standard_request_options(:put, 'UPDATE (as writer, same user)', :ok, { expected_json_path: 'data/user_name' })
end

put '/user_accounts/:id' do
id_param
let(:id) { reader_id }
let(:raw_post) { { user: post_attributes }.to_json }
let(:authentication_token) { reader_token } # admin only, users edit using devise/registrations#edit
standard_request_options(:put, 'UPDATE (as reader, same user)', :forbidden,
{ expected_json_path: get_json_error_path(:permissions) })
let(:authentication_token) { reader_token }
standard_request_options(:put, 'UPDATE (as reader, same user)', :ok, { expected_json_path: 'data/user_name' })
end

put '/user_accounts/:id' do
Expand Down

0 comments on commit 7006a34

Please sign in to comment.