Merge remote-tracking branch 'upstream/pull/4240'
This commit is contained in:
commit
85b17a1f2a
8 changed files with 92 additions and 0 deletions
36
test/controllers/api/user_blocks_controller_test.rb
Normal file
36
test/controllers/api/user_blocks_controller_test.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
require "test_helper"
|
||||
|
||||
module Api
|
||||
class UserBlocksControllerTest < ActionDispatch::IntegrationTest
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user_blocks/1", :method => :get },
|
||||
{ :controller => "api/user_blocks", :action => "show", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user_blocks/1.json", :method => :get },
|
||||
{ :controller => "api/user_blocks", :action => "show", :id => "1", :format => "json" }
|
||||
)
|
||||
end
|
||||
|
||||
def test_show
|
||||
block = create(:user_block)
|
||||
|
||||
get api_user_block_path(:id => block)
|
||||
assert_response :success
|
||||
assert_select "user_block[id='#{block.id}']", 1
|
||||
|
||||
get api_user_block_path(:id => block, :format => "json")
|
||||
assert_response :success
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
assert_not_nil js
|
||||
assert_equal block.id, js["user_block"]["id"]
|
||||
end
|
||||
|
||||
def test_show_not_found
|
||||
get api_user_block_path(:id => 123)
|
||||
assert_response :not_found
|
||||
assert_equal "text/plain", @response.media_type
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue