From d1311d2376472b7951e53f8dff9b3511d87e340a Mon Sep 17 00:00:00 2001 From: Noah Durbin <13364668+noahdurbin@users.noreply.github.com> Date: Thu, 12 Sep 2024 18:48:26 -0600 Subject: [PATCH] test: multiple tag filtering for top 5 links --- spec/requests/api/v1/links_request_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/requests/api/v1/links_request_spec.rb b/spec/requests/api/v1/links_request_spec.rb index 32309f3..b0def4c 100644 --- a/spec/requests/api/v1/links_request_spec.rb +++ b/spec/requests/api/v1/links_request_spec.rb @@ -204,8 +204,12 @@ @link6 = Link.create(original: 'https://example6.com', short: 'tur.link/pqr678', user: @user, click_count: 5) @link1.tags << @tag1 + @link1.tags << @tag2 + @link2.tags << @tag2 + @link3.tags << @tag1 + @link3.tags << @tag2 end it 'can return the top 5 links by click count' do @@ -229,6 +233,17 @@ expect(links[0][:attributes][:click_count]).to eq(100) expect(links.last[:attributes][:click_count]).to eq(50) end + + it 'can return the top 5 links filtered by multiple tags' do + get '/api/v1/top_links?tag=ruby,javascript' + + expect(response).to be_successful + links = JSON.parse(response.body, symbolize_names: true)[:data] + + expect(links.count).to eq(2) + expect(links[0][:attributes][:click_count]).to eq) + expect(links.last[:attributes][:click_count]).to eq(50) + end end describe 'PATCH /users/:user_id/links/:id/update_privacy' do