Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't rely on fixed ids in contributions_spec #673

Merged
merged 1 commit into from
Sep 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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