Add active blocks list api endpoint with empty response

This commit is contained in:
Anton Khorev 2025-01-01 04:40:34 +03:00
parent f5af8befa9
commit 6d558003aa
4 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,43 @@
require "test_helper"
module Api
module UserBlocks
class ActiveListsControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
assert_routing(
{ :path => "/api/0.6/user/blocks/active", :method => :get },
{ :controller => "api/user_blocks/active_lists", :action => "show" }
)
assert_routing(
{ :path => "/api/0.6/user/blocks/active.json", :method => :get },
{ :controller => "api/user_blocks/active_lists", :action => "show", :format => "json" }
)
end
def test_show_no_auth_header
get api_user_blocks_active_list_path
assert_response :unauthorized
end
def test_show_no_permission
user = create(:user)
user_auth_header = bearer_authorization_header(user, :scopes => %w[])
get api_user_blocks_active_list_path, :headers => user_auth_header
assert_response :forbidden
end
def test_show_empty
user = create(:user)
user_auth_header = bearer_authorization_header(user, :scopes => %w[read_prefs])
create(:user_block, :expired, :user => user)
get api_user_blocks_active_list_path, :headers => user_auth_header
assert_response :success
assert_dom "user_block", :count => 0
end
end
end
end