|
|
|
@ -16,10 +16,11 @@ describe Carto::Api::TagsController do
|
|
|
|
|
before(:each) do
|
|
|
|
|
@mapaza = FactoryGirl.create(:carto_visualization, type: Carto::Visualization::TYPE_DERIVED,
|
|
|
|
|
user: @carto_user1, name: "mapaza",
|
|
|
|
|
tags: ["owned-tag", "map"])
|
|
|
|
|
tags: ["owned-tag"])
|
|
|
|
|
|
|
|
|
|
table = create_random_table(@user2)
|
|
|
|
|
shared_visualization = table.table_visualization
|
|
|
|
|
shared_visualization.name = "shared_table"
|
|
|
|
|
shared_visualization.tags = ["shared-tag"]
|
|
|
|
|
shared_visualization.save
|
|
|
|
|
shared_entity = CartoDB::SharedEntity.new(
|
|
|
|
@ -69,24 +70,40 @@ describe Carto::Api::TagsController do
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
login_as(@user1, scope: @user1.username)
|
|
|
|
|
get_json search_preview_url(q: "mapaza", types: "derived"), @headers do |response|
|
|
|
|
|
get_json search_preview_url(q: "mapaz", types: "derived"), @headers do |response|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
|
expect(response.body[:result]).to eq expected_result
|
|
|
|
|
expect(response.body[:total_count]).to eq 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns a 200 response with matching maps and tags' do
|
|
|
|
|
it 'returns a 200 response with matching maps, tables and tags' do
|
|
|
|
|
expected_result = [
|
|
|
|
|
{ type: "tag", name: "map", url: "http://#{@base_url}:53716/dashboard/search/tag/map" },
|
|
|
|
|
{ type: "tag", name: "owned-tag", url: "http://#{@base_url}:53716/dashboard/search/tag/owned-tag" },
|
|
|
|
|
{ type: "tag", name: "shared-tag", url: "http://#{@base_url}:53716/dashboard/search/tag/shared-tag" },
|
|
|
|
|
{ type: "table", name: "shared_table", url: "http://#{@base_url}:53716/tables/shared_table" },
|
|
|
|
|
{ type: "derived", name: "mapaza", url: "http://#{@base_url}:53716/viz/#{@mapaza.id}/map" }
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
login_as(@user1, scope: @user1.username)
|
|
|
|
|
get_json search_preview_url(q: "map", types: "derived,tag"), @headers do |response|
|
|
|
|
|
get_json search_preview_url(q: "tag", types: "derived,table,tag"), @headers do |response|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
|
expect(response.body[:result]).to eq expected_result
|
|
|
|
|
expect(response.body[:total_count]).to eq 2
|
|
|
|
|
expect(response.body[:total_count]).to eq 4
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'allows to limit total results' do
|
|
|
|
|
expected_result = [
|
|
|
|
|
{ type: "tag", name: "owned-tag", url: "http://#{@base_url}:53716/dashboard/search/tag/owned-tag" },
|
|
|
|
|
{ type: "tag", name: "shared-tag", url: "http://#{@base_url}:53716/dashboard/search/tag/shared-tag" }
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
login_as(@user1, scope: @user1.username)
|
|
|
|
|
get_json search_preview_url(q: "tag", types: "derived,table,tag", limit: 2), @headers do |response|
|
|
|
|
|
expect(response.status).to eq(200)
|
|
|
|
|
expect(response.body[:result]).to eq expected_result
|
|
|
|
|
expect(response.body[:total_count]).to eq 4
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|