Class: Webrat::FileField
- Defined in:
- lib/webrat/core/elements/field.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
Attributes inherited from Field
Attributes inherited from Element
Class Method Summary collapse
Instance Method Summary collapse
- #digest_value ⇒ Object
- #set(value, content_type = nil) ⇒ Object
- #test_uploaded_file ⇒ Object
- #to_query_string ⇒ Object
Methods inherited from Field
#disabled?, field_class, field_classes, #id, inherited, #initialize, #label_text, load, #raise_error_if_disabled, #unset, xpath_search_excluding_hidden
Methods inherited from Element
#initialize, #inspect, load, load_all, #path
Constructor Details
This class inherits a constructor from Webrat::Field
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
331 332 333 |
# File 'lib/webrat/core/elements/field.rb', line 331 def content_type @content_type end |
Class Method Details
.xpath_search ⇒ Object
327 328 329 |
# File 'lib/webrat/core/elements/field.rb', line 327 def self.xpath_search ".//input[@type = 'file']" end |
Instance Method Details
#digest_value ⇒ Object
339 340 341 |
# File 'lib/webrat/core/elements/field.rb', line 339 def digest_value @value ? Digest::MD5.hexdigest(self.object_id.to_s) : "" end |
#set(value, content_type = nil) ⇒ Object
333 334 335 336 337 |
# File 'lib/webrat/core/elements/field.rb', line 333 def set(value, content_type = nil) @original_value = @value @content_type ||= content_type super(value) end |
#test_uploaded_file ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/webrat/core/elements/field.rb', line 348 def test_uploaded_file return "" if @original_value.blank? case Webrat.configuration.mode when :rails if content_type ActionController::TestUploadedFile.new(@original_value, content_type) else ActionController::TestUploadedFile.new(@original_value) end when :rack, :merb Rack::Test::UploadedFile.new(@original_value, content_type) end end |
#to_query_string ⇒ Object
343 344 345 346 |
# File 'lib/webrat/core/elements/field.rb', line 343 def to_query_string @value.nil? ? set("") : set(digest_value) super end |