Skip to content

Commit

Permalink
feat: added test for making a link private
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdurbin committed Sep 12, 2024
1 parent 958ca69 commit 08cb456
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/requests/api/v1/links_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,16 @@
json_response = JSON.parse(response.body, symbolize_names: true)
expect(json_response[:error]).to eq('User or Link not found')
end

it 'returns an error if the update fails' do
allow_any_instance_of(Link).to receive(:update).and_return(false)

patch "/api/v1/users/#{user.id}/links/#{link.id}/update_privacy", params: { private: 'true' }

expect(response).to have_http_status(:unprocessable_entity)

json_response = JSON.parse(response.body, symbolize_names: true)
expect(json_response[:error]).to eq('Failed to update privacy setting')
end
end
end

0 comments on commit 08cb456

Please sign in to comment.