Output active blocks list
This commit is contained in:
parent
9ec7e8c888
commit
f6572e3712
7 changed files with 37 additions and 14 deletions
|
@ -7,7 +7,10 @@ module Api
|
|||
|
||||
before_action :set_request_formats
|
||||
|
||||
def show; end
|
||||
def show
|
||||
@user_blocks = current_user.blocks.active.order(:id => :desc)
|
||||
@skip_reason = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
json.user_block do
|
||||
json.id user_block.id
|
||||
json.created_at user_block.created_at.xmlschema
|
||||
json.updated_at user_block.updated_at.xmlschema
|
||||
|
@ -9,5 +8,4 @@ json.user_block do
|
|||
json.creator :uid => user_block.creator_id, :user => user_block.creator.display_name
|
||||
json.revoker :uid => user_block.revoker_id, :user => user_block.revoker.display_name if user_block.revoker
|
||||
|
||||
json.reason user_block.reason
|
||||
end
|
||||
json.reason user_block.reason unless @skip_reason
|
||||
|
|
|
@ -10,5 +10,6 @@ xml.user_block(attrs) do
|
|||
xml.user :uid => user_block.user_id, :user => user_block.user.display_name
|
||||
xml.creator :uid => user_block.creator_id, :user => user_block.creator.display_name
|
||||
xml.revoker :uid => user_block.revoker_id, :user => user_block.revoker.display_name if user_block.revoker
|
||||
xml.reason user_block.reason
|
||||
|
||||
xml.reason user_block.reason unless @skip_reason
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
json.partial! "api/root_attributes"
|
||||
|
||||
json.user_blocks do
|
||||
json.array! @user_blocks, :partial => "api/user_blocks/user_block", :as => :user_block
|
||||
end
|
5
app/views/api/user_blocks/active_lists/show.xml.builder
Normal file
5
app/views/api/user_blocks/active_lists/show.xml.builder
Normal file
|
@ -0,0 +1,5 @@
|
|||
xml.instruct!
|
||||
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << (render(:partial => "api/user_blocks/user_block", :collection => @user_blocks) || "")
|
||||
end
|
|
@ -1,3 +1,5 @@
|
|||
json.partial! "api/root_attributes"
|
||||
|
||||
json.user_block do
|
||||
json.partial! @user_block
|
||||
end
|
||||
|
|
|
@ -50,6 +50,10 @@ module Api
|
|||
|
||||
get api_user_blocks_active_list_path, :headers => user_auth_header
|
||||
assert_response :success
|
||||
assert_dom "user_block", :count => 2 do |dom_blocks|
|
||||
assert_dom dom_blocks[0], "> @id", block1.id.to_s
|
||||
assert_dom dom_blocks[1], "> @id", block0.id.to_s
|
||||
end
|
||||
end
|
||||
|
||||
def test_show_json
|
||||
|
@ -63,6 +67,11 @@ module Api
|
|||
|
||||
get api_user_blocks_active_list_path(:format => "json"), :headers => user_auth_header
|
||||
assert_response :success
|
||||
js = ActiveSupport::JSON.decode(@response.body)
|
||||
assert_not_nil js
|
||||
assert_equal 2, js["user_blocks"].count
|
||||
assert_equal block1.id, js["user_blocks"][0]["id"]
|
||||
assert_equal block0.id, js["user_blocks"][1]["id"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue