Skip to content

Commit

Permalink
Merge pull request #673 from rubyforgood/drop-reliance-on-id-in-contr…
Browse files Browse the repository at this point in the history
…ibutions-spec

Don't rely on fixed ids in contributions_spec
  • Loading branch information
solebared authored Sep 5, 2020
2 parents aa67175 + 46387a6 commit e736cf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/tasks/db.rake
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ namespace :db do
task :import_custom_form_question_seeds => :environment do
require "#{Rails.root}/db/scripts/custom_form_question_seeds.rb"
end

end


9 changes: 6 additions & 3 deletions spec/requests/contributions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

it 'parses requests for a filtered list' do
categories = [
create(:category, id: 50, name: Faker::Lorem.word),
create(:category, id: 70, name: Faker::Lorem.word)
create(:category, name: Faker::Lorem.word),
create(:category, name: Faker::Lorem.word)
]
both_tags_listing = create(:listing, tag_list: categories.map(&:name))
expected_area = both_tags_listing.service_area
Expand All @@ -50,7 +50,10 @@
no_tags_correct_area_listing = create(:listing, service_area: expected_area)

# passing `as: json` to `get` does some surprising things to the request and its params that would break this test
get contributions_url, params: { 'Category[50]': 1, 'Category[70]': 1, "ServiceArea[#{expected_area.id}]": 1 }, headers: {'HTTP_ACCEPT' => 'application/json'}
get contributions_url, {
params: { "Category[#{categories[0].id}]": 1, "Category[#{categories[1].id}]": 1, "ServiceArea[#{expected_area.id}]": 1 },
headers: {'HTTP_ACCEPT' => 'application/json'}
}

expect(response.body).to match(/#{expected_area.name.to_json}/)

Expand Down

0 comments on commit e736cf9

Please sign in to comment.