Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Commit

Permalink
Avoiding use of non-existent or deprecated Hash method #index or #key
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed May 2, 2013
1 parent 28dc638 commit 41f2262
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/cupertino/provisioning_portal/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ def password
end

def team
# we're working with radio buttons instead of a drop down menu
teams = page.form_with(:name => 'saveTeamSelection').radiobuttons
# create a dictionary of team.value -> team name
formatted_teams = {}
teams.each do |team|
# we can't use team.label as this only returns the last label
# Apple use two labels with the same for="", we want the first
formatted_teams[team.value] = page.search("label[for=\"#{team.dom_id}\"]").first.text.strip
teams_by_name = {}
page.form_with(:name => 'saveTeamSelection').radiobuttons.each do |radio|
name = page.search("label[for=\"#{radio.dom_id}\"]").first.text.strip
teams_by_name[name] = radio.value
end
teamname = choose "Select a team:", *formatted_teams.values
@team ||= formatted_teams.key(teamname)

name = choose "Select a team:", *teams_by_name.keys
@team ||= teams_by_name[name]
end
end
end
Expand Down

0 comments on commit 41f2262

Please sign in to comment.