Test the boards API
This commit is contained in:
committed by
Stanko K.R.
parent
a81c681a8d
commit
d384971ea2
@@ -1,8 +1,12 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApiTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
@davids_bearer_token = bearer_token_env(identity_access_tokens(:davids_api_token).token)
|
||||
end
|
||||
|
||||
test "authenticate with valid access token" do
|
||||
get boards_path(format: :json), env: bearer_token_env(identity_access_tokens(:jasons_api_token).token)
|
||||
get boards_path(format: :json), env: @davids_bearer_token
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
@@ -11,6 +15,14 @@ class ApiTest < ActionDispatch::IntegrationTest
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
test "boards" do
|
||||
get boards_path(format: :json), env: @davids_bearer_token
|
||||
assert_equal users(:david).boards.count, @response.parsed_body.count
|
||||
|
||||
get board_path(boards(:writebook), format: :json), env: @jasons_bearer_token
|
||||
assert_equal boards(:writebook).name, @response.parsed_body["name"]
|
||||
end
|
||||
|
||||
private
|
||||
def bearer_token_env(token)
|
||||
{ "HTTP_AUTHORIZATION" => "Bearer #{token}" }
|
||||
|
||||
+6
@@ -3,3 +3,9 @@ jasons_api_token:
|
||||
token: 018cf1425682700098f24f0799e3fe20
|
||||
description: My Superscript
|
||||
permission: read
|
||||
|
||||
davids_api_token:
|
||||
identity: david
|
||||
token: x18cf1425682700098f24f0799e3fe20
|
||||
description: My Superscript
|
||||
permission: write
|
||||
|
||||
Reference in New Issue
Block a user