Skip to content

Commit 80a8eb9

Browse files
committed
Add tests
1 parent b03be7c commit 80a8eb9

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

spec/acceptance/decklists_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@
5050
end
5151
end
5252

53+
get '/api/v3/public/decklists?filter[exclude_card_id]=pennyshaver,stargate' do
54+
parameter :exclude_card_id, type: :string, required: true
55+
56+
example_request 'Filter - Get decklists excluding all supplied Card ids' do
57+
explanation <<~EXPLANATION
58+
The exclude_card_id filter can accept a single card_id or a comma-separated list of card ids.
59+
60+
If multiple card ids are supplied, the decklist must NOT contain any of the
61+
cards to be included in the results.
62+
EXPLANATION
63+
64+
expect(status).to eq 200
65+
end
66+
end
67+
5368
get '/api/v3/public/decklists?filter[faction_id]=:faction_id' do
5469
parameter :nsg_rules_team_verified, type: :boolean, required: true
5570

spec/resources/decklist_resource_reads_spec.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,40 @@
4242
expect(d.map(&:id)).to eq([decklist.id])
4343
end
4444
end
45+
46+
context 'with exclude_card_id' do
47+
let!(:corp_decklist) { Decklist.find('11111111-1111-1111-1111-111111111111') }
48+
let!(:runner_decklist) { Decklist.find('22222222-2222-2222-2222-222222222222') }
49+
50+
it 'excludes decklists with one specified card' do
51+
params[:filter] = { exclude_card_id: { eq: 'pennyshaver' } }
52+
53+
render
54+
decklist_ids = d.map(&:id)
55+
56+
expect(decklist_ids).to include(corp_decklist.id)
57+
expect(decklist_ids).not_to include(runner_decklist.id)
58+
end
59+
60+
it 'excludes decklists with multiple specified cards' do
61+
params[:filter] =
62+
{ exclude_card_id: { eq: 'pennyshaver,adonis_campaign' } }
63+
render
64+
decklist_ids = d.map(&:id)
65+
66+
expect(decklist_ids).not_to include(corp_decklist.id)
67+
expect(decklist_ids).not_to include(runner_decklist.id)
68+
end
69+
70+
it 'exludes no decklists when nonexistent card is specified' do
71+
params[:filter] = { exclude_card_id: { eq: 'nonexistent_card' } }
72+
render
73+
decklist_ids = d.map(&:id)
74+
75+
expect(decklist_ids).to include(corp_decklist.id)
76+
expect(decklist_ids).to include(runner_decklist.id)
77+
end
78+
end
4579
end
4680

4781
describe 'sideloading' do

0 commit comments

Comments
 (0)