Skip to content

Commit

Permalink
Add tests for /api/v1/accounts/:id/* 404 on deleted accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Nov 17, 2023
1 parent 2985e9d commit e059051
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,30 @@
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end
end

context 'when request account is permanently deleted' do
before do
account.mark_deleted!
account.deletion_request.destroy
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end

context 'when request account is pending deletion' do
before do
account.mark_deleted!
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,30 @@
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end
end

context 'when request account is permanently deleted' do
before do
account.mark_deleted!
account.deletion_request.destroy
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end

context 'when request account is pending deletion' do
before do
account.mark_deleted!
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end
end
end
25 changes: 25 additions & 0 deletions spec/controllers/api/v1/accounts/lists_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,30 @@
get :index, params: { account_id: account.id }
expect(response).to have_http_status(200)
end

context 'when request account is permanently deleted' do
before do
account.mark_deleted!
account.deletion_request.destroy
end

it 'returns http not found' do
get :index, params: { account_id: account.id }

expect(response).to have_http_status(404)
end
end

context 'when request account is pending deletion' do
before do
account.mark_deleted!
end

it 'returns http not found' do
get :index, params: { account_id: account.id }

expect(response).to have_http_status(404)
end
end
end
end
29 changes: 29 additions & 0 deletions spec/controllers/api/v1/accounts/statuses_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,34 @@
end
end
end

context 'when request account is permanently deleted' do
let(:account) { Fabricate(:account) }

before do
account.mark_deleted!
account.deletion_request.destroy
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end

context 'when request account is pending deletion' do
let(:account) { Fabricate(:account) }

before do
account.mark_deleted!
end

it 'returns http not found' do
get :index, params: { account_id: account.id, limit: 2 }

expect(response).to have_http_status(404)
end
end
end
end
25 changes: 25 additions & 0 deletions spec/requests/api/v1/accounts_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,31 @@
end
end

context 'when requesting a permanently deleted account' do
let(:other_account) { Fabricate(:account, deleted: true) }

before do
get "/api/v1/accounts/#{other_account.id}"
end

it 'returns http not found' do
expect(response).to have_http_status(404)
end
end

context 'when requesting an account pending deletion' do
let(:other_account) { Fabricate(:account) }

before do
other_account.mark_deleted!
get "/api/v1/accounts/#{other_account.id}"
end

it 'returns http not found' do
expect(response).to have_http_status(404)
end
end

context 'when logged in' do
subject do
get "/api/v1/accounts/#{account.id}", headers: headers
Expand Down

0 comments on commit e059051

Please sign in to comment.