Skip to content

Commit

Permalink
API取得に関するテストを作成
Browse files Browse the repository at this point in the history
  • Loading branch information
garammasala29 committed Mar 3, 2022
1 parent 6ff86b1 commit a4008bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion db/fixtures/questions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ question<%= i %>:
description: ページャー確認用のテスト質問です。
user: hajime
practice: practice1
<% end %>
<% end %>
16 changes: 16 additions & 0 deletions test/integration/api/users/questions_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require 'test_helper'

class API::Users::QuestionsTest < ActionDispatch::IntegrationTest
test 'GET /api/users/253826460/questions.json' do
@user = users(:hajime)
get api_user_questions_path(@user.id, format: :json)
assert_response :unauthorized

token = create_token('hajime', 'testtest')
get api_user_questions_path(@user.id, format: :json),
headers: { 'Authorization' => "Bearer #{token}" }
assert_response :ok
end
end

0 comments on commit a4008bd

Please sign in to comment.