Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJonne Haß <me@jhass.eu>2020-02-11 12:27:46 +0300
committerJonne Haß <me@jhass.eu>2020-02-17 12:58:04 +0300
commit00df0b7bdae07c3e761ff3493aaa461c8c2e71dc (patch)
tree9ffc43e8e8c9e39b464f3000dc3e53b120a20b17 /spec
parent984b739eb46dfd58bb38f8367c4a817562d1bb69 (diff)
API: add new route to search for tags
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/api/search_controller_spec.rb50
1 files changed, 49 insertions, 1 deletions
diff --git a/spec/integration/api/search_controller_spec.rb b/spec/integration/api/search_controller_spec.rb
index 67e11ad8d..46524a32e 100644
--- a/spec/integration/api/search_controller_spec.rb
+++ b/spec/integration/api/search_controller_spec.rb
@@ -213,13 +213,61 @@ describe Api::V1::SearchController do
it "fails with bad credentials" do
get(
- "/api/v1/search/users",
+ "/api/v1/search/posts",
params: {tag: "tag1", access_token: invalid_token}
)
expect(response.status).to eq(401)
end
end
+ describe "tag_index" do
+ before do
+ FactoryGirl.create(:tag, name: "apipartyone")
+ FactoryGirl.create(:tag, name: "apipartytwo")
+ FactoryGirl.create(:tag, name: "apipartythree")
+ end
+
+ it "succeeds" do
+ get(
+ "/api/v1/search/tags",
+ params: {query: "apiparty", access_token: access_token_public_only_read_only}
+ )
+ expect(response.status).to eq(200)
+ tags = response_body_data(response)
+ expect(tags.size).to eq(3)
+
+ expect(tags.to_json).to match_json_schema(:api_v1_schema, fragment: "#/definitions/tags")
+ end
+
+ it "does a prefix search" do
+ get(
+ "/api/v1/search/tags",
+ params: {query: "apipartyt", access_token: access_token_public_only_read_only}
+ )
+ expect(response.status).to eq(200)
+ tags = response_body_data(response)
+ expect(tags.size).to eq(2)
+
+ expect(tags.to_json).to match_json_schema(:api_v1_schema, fragment: "#/definitions/tags")
+ end
+
+ it "fails with missing parameters" do
+ get(
+ "/api/v1/search/tags",
+ params: {access_token: access_token}
+ )
+ confirm_api_error(response, 422, "Search request could not be processed")
+ end
+
+ it "fails with bad credentials" do
+ get(
+ "/api/v1/search/tags",
+ params: {query: "apiparty", access_token: invalid_token}
+ )
+ expect(response.status).to eq(401)
+ end
+ end
+
def response_body_data(response)
JSON.parse(response.body)
end