Skip to content

Commit

Permalink
Revert "Add #select_date for quickly filling out Rails-style date fie…
Browse files Browse the repository at this point in the history
…lds (Alex Lang)"

This reverts commit 9671c42.

Conflicts:

	History.txt
  • Loading branch information
brynary committed Oct 22, 2008
1 parent f831b49 commit d62d135
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 131 deletions.
1 change: 0 additions & 1 deletion History.txt
Expand Up @@ -12,7 +12,6 @@
* Minor enhancements

* Add Webrat.root method for cross-framework support (Krzysztof Zylawy)
* Add #select_date for quickly filling out Rails-style date fields (Alex Lang)
* Support selecting options by their values (Alex Lang)
* Support for clicking areas of an image map (Alex Lang)
* Add should_see and should_not_see for verifying HTML response bodys
Expand Down
6 changes: 4 additions & 2 deletions lib/webrat/core/form.rb
Expand Up @@ -17,12 +17,14 @@ def find_field(id_or_name_or_label, *field_types)
nil
end

def find_select_option(option_text, field_name_pattern = nil)
def find_select_option(option_text)
select_fields = fields_by_type([SelectField])
select_fields.select{|field| field_name_pattern.nil? || field.matches_name?(field_name_pattern) || field.matches_id?(field_name_pattern)}.each do |select_field|

select_fields.each do |select_field|
result = select_field.find_option(option_text)
return result if result
end

nil
end

Expand Down
16 changes: 0 additions & 16 deletions lib/webrat/core/scope.rb
Expand Up @@ -12,22 +12,6 @@ def initialize(session, html, selector = nil)
@selector = selector
end

def selects_date(date_string, options = {})
id_or_name = options[:from]
date = Date.parse date_string

year_option = find_select_option(date.year.to_s, /#{id_or_name.to_s}.*1i/)
month_option = find_select_option(date.month.to_s, /#{id_or_name.to_s}.*2i/)
day_option = find_select_option(date.day.to_s, /#{id_or_name.to_s}.*3i/)

flunk("Could not find date picker for #{date_string}") if year_option.nil? || month_option.nil? || day_option.nil?
year_option.choose
month_option.choose
day_option.choose
end

alias_method :select_date, :selects_date

# Verifies an input field or textarea exists on the current page, and stores a value for
# it which will be sent when the form is submitted.
#
Expand Down
1 change: 0 additions & 1 deletion lib/webrat/core/session.rb
Expand Up @@ -151,7 +151,6 @@ def formatted_error
def_delegators :current_scope, :uncheck, :unchecks
def_delegators :current_scope, :choose, :chooses
def_delegators :current_scope, :select, :selects
def_delegators :current_scope, :select_date, :selects_date
def_delegators :current_scope, :attach_file, :attaches_file
def_delegators :current_scope, :click_area, :clicks_area
def_delegators :current_scope, :click_link, :clicks_link
Expand Down
111 changes: 0 additions & 111 deletions spec/api/selects_date_spec.rb

This file was deleted.

0 comments on commit d62d135

Please sign in to comment.