Skip to content

Commit a06137e

Browse files
committed
Add test case
1 parent 909e0e7 commit a06137e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/controllers/api/v1/users.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class Users < Grape::API
188188
requires :id, type: Integer, desc: "User ID"
189189
requires :status, type: String, desc: "User/Agent status"
190190
end
191-
patch "/status/:id/:status", root: :users do
191+
patch "status/:id", root: :users do
192192
user = User.where(id: permitted_params[:id]).first
193193
user.update!(
194194
status: permitted_params[:status]

test/controllers/api/v1/users_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,12 @@ def app
212212
assert_equal "anon", object['login']
213213
assert_nil object['city']
214214
end
215+
216+
test "API users should be able to set status of users" do
217+
user = User.find(6)
218+
patch "/api/v1/users/status/#{user.id}.json?status=vacation", @default_params
219+
220+
object = JSON.parse(last_response.body)
221+
assert_equal "vacation", object['status']
222+
end
215223
end

0 commit comments

Comments
 (0)