api: refactor api attribute declarations.
Replace the `method_attributes` and `hidden_attributes` methods with
`api_attributes`. `api_attributes` can be used as a class macro:
# include only the given attributes.
api_attributes :id, :created_at, :creator_name, ...
# include all default attributes plus the `creator_name` method.
api_attributes including: [:creator_name]
or as an instance method:
def api_attributes
[:id, :created_at, :creator_name, ...]
end
By default, all attributes are included except for IP addresses and
tsvector columns.
This commit is contained in:
@@ -84,11 +84,10 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
should "render the current users's profile in json" do
|
||||
get_auth profile_path(format: :json), @user
|
||||
get_auth profile_path, @user, as: :json
|
||||
assert_response :success
|
||||
|
||||
json = as(@user) { @user.as_json(methods: @user.full_attributes + @user.method_attributes) }
|
||||
assert_equal(json, response.parsed_body)
|
||||
assert_equal(@user.upload_limit, response.parsed_body["upload_limit"])
|
||||
end
|
||||
|
||||
should "redirect anonymous users to the sign in page" do
|
||||
|
||||
Reference in New Issue
Block a user