require "test_helper" class OrganizationsControllerTest < ActionDispatch::IntegrationTest test "sport filter is a dropdown of values already in the project" do login_as users(:admin) create_campaign_org(name: "Futsal Test", email: "futsal@example.com", sport: "Calcio a 5") get organizations_path(project_code: "matchlivetv") assert_response :success assert_select "select[name=sport]" do assert_select "option[value='']", text: "Sport" assert_select "option[value=Calcio]", text: "Calcio" assert_select "option[value='Calcio a 5']", text: "Calcio a 5" end assert_select "input[name=sport]", count: 0 end test "sport filter keeps only organizations of that sport" do login_as users(:admin) create_campaign_org(name: "Futsal Test", email: "futsal@example.com", sport: "Calcio a 5") get organizations_path(project_code: "matchlivetv", sport: "Calcio a 5") assert_response :success assert_match(/Futsal Test/, response.body) assert_no_match(/ASD Test Calcio/, response.body) assert_select "select[name=sport] option[value='Calcio a 5'][selected]" end end