Commit d97e87ff by Rocky Duan

api for getting all tags

parent 9f5e409f
......@@ -41,6 +41,10 @@ post '/api/v1/:commentable_id/threads' do |commentable_id|
thread.to_hash.to_json
end
get '/api/v1/threads/tags' do
CommentThread.tags.to_json
end
get '/api/v1/threads/:thread_id' do |thread_id|
thread.to_hash(recursive: params["recursive"]).to_json
end
......
......@@ -119,4 +119,18 @@ describe "app" do
end
end
end
describe "GET /api/v1/threads/tags" do
it "get all tags used in threads" do
thread1 = CommentThread.all.to_a.first
thread2 = CommentThread.all.to_a.last
thread1.tags = "a, b, c"
thread1.save
thread2.tags = "d, e, f"
thread2.save
get "/api/v1/threads/tags"
last_response.should be_ok
tags = parse last_response.body
tags.length.should == 6
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment