require_relative 'spec_helper'

describe ActiveModel::Form do
  # DateTime params generated by e.g. https://github.com/zpaulovics/datetimepicker-rails
  let(:params) do
    { "form"=> {"created_at" => "2014-10-30", "whatever" => "yeah"} }
  end

  it "parses the Rails form helper datetime params" do
    class FormWithDateTime < ActiveModel::Form
      attribute :created_at, :date
      attribute :something_else, :string
      attribute :whatever, :string
    end

    form = FormWithDateTime.new(params['form'])
    form.created_at.must_equal(DateTime.new(2014, 10, 30, 0, 0))
    form.something_else.must_equal nil
    form.whatever.must_equal "yeah"
  end
end
