Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read-only Bans API #345

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alex-j-butler
Copy link

Exposes user bans through the read-only API.

Fixes #344

@coveralls
Copy link

coveralls commented Jan 21, 2018

Coverage Status

Coverage increased (+0.02%) to 95.164% when pulling 016911e on alex-j-butler:ozfort-bans-api into db7502a on ozfortress:master.

@BenjaminSchaaf
Copy link
Collaborator

In order to reduce traffic for the use case of #344, I would prefer to have a relationship on users called active_bans and have the /users/:id API return those. Though I'm also not against keeping what you've already written.

@@ -0,0 +1,5 @@
module JsonHelpers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this, use response.parsed_body. It automagically decodes the json.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did try to use response.parsed_body but it ended up parsing the response as a string, even with as: :json (get :bans, params: { id: user.id }, as: :json). I just created this helper instead 🤷‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for the other API requests.

@@ -0,0 +1,43 @@
require 'rails_helper'

describe API::V1::UsersController do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea, completely missed this. The API is tested with request tests, eg. spec/requests/api/v1/users_spec.rb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants