Skip to content

Commit

Permalink
Don't show deleted team on add collaborator form
Browse files Browse the repository at this point in the history
  • Loading branch information
slorek committed Sep 15, 2020
1 parent c3a7869 commit b18073e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/collaborators_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def find_investigation_from_params
# rubocop:enable Naming/MemoizedInstanceVariableName

def teams_without_access
Team.where.not(id: team_ids_with_access).order(:name)
Team.not_deleted.where.not(id: team_ids_with_access).order(:name)
end

def team_ids_with_access
Expand Down
5 changes: 5 additions & 0 deletions spec/features/add_team_to_case_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:team) { create(:team, name: "Southampton Trading Standards", team_recipient_email: "enquiries@southampton.gov.uk") }
let(:user) { create(:user, :activated, team: create(:team, name: "Portsmouth Trading Standards"), name: "Bob Jones") }
let(:investigation) { create(:allegation, read_only_teams: read_only_team, creator: user) }
let!(:deleted_team) { create(:team, :deleted) }

before do
read_only_team.update!(name: "Birmingham Trading Standards")
Expand Down Expand Up @@ -46,6 +47,10 @@
expect(page).to have_selector("a", text: "Select the permission level the team should have")
expect(page).to have_selector("a", text: "Select whether you want to include a message")

# Check deleted teams are not listed
expect(page).to have_css("#team option[value=\"#{team.id}\"]")
expect(page).not_to have_css("#team option[value=\"#{deleted_team.id}\"]")

select "Southampton Trading Standards", from: "Choose team"
choose "Edit full case"
within_fieldset "Do you want to include instructions or more information?" do
Expand Down

0 comments on commit b18073e

Please sign in to comment.