Skip to content

Commit

Permalink
test: multiple tag filtering for top 5 links
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdurbin committed Sep 13, 2024
1 parent 0ef11cf commit d1311d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions spec/requests/api/v1/links_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d1311d2

Please sign in to comment.