selected_time = true
end
+ if not year.blank? and year.to_i <= 0
+ return
+ end
+
+ if not month.blank? and (month.to_i < 1 or month.to_i > 12)
+ return
+ end
+
+ if not day.blank? and (day.to_i < 1 or day.to_i > 31)
+ return
+ end
+
now = DateTime.now
if selected_date
if year.blank?
end
end
+ describe "GET 'search' でエラーになるケース" do
+ before do
+ @minus_value_start = ["-2000", "3", "24"]
+ @minus_value_end = ["-1999", "3", "24"]
+ @old_value_start = ["1800", "3", "24"]
+ @old_value_end = ["1801", "3", "24"]
+ end
+
+ it "sale_start_atにマイナスの日付" do
+ search = {}
+ search.merge! array_to_time(@minus_value_start, 'sale_start_at_start')
+ search.merge! array_to_time(@minus_value_end, 'sale_start_at_end')
+ get "search", :search => search
+ end
+ it "sale_start_atに古すぎる日付" do
+ search = {}
+ search.merge! array_to_time(@old_value_start, 'sale_start_at_start')
+ search.merge! array_to_time(@old_value_end, 'sale_start_at_end')
+ get "search", :search => search
+ end
+
+ after do
+ response.should be_success
+ end
+
+ end
+
+
describe "GET 'new'" do
it "normal" do
get 'new'
search_form.month.should_not be_nil
search_form.month.should == Time.parse("2009-01-01 00:00:00")
end
+ it "データセット(検索用年月日) 空文字でも正常に対応できるか確認" do
+ search_form = SearchForm.new({"month(1i)"=>"2009", "month(2i)" => ""})
+ search_form.month.should_not be_nil
+ search_form.month.should == Time.parse("2009-01-01 00:00:00")
+ end
it "その他" do
TestForm.human_attribute_name("customer_id").should == "顧客コード"
TestForm.field_names.should == {"customer_id" => "顧客コード","customer_name" => "顧客名"}
}
end
+def array_to_time array, name
+ {
+ name+'(1i)' => array[0],
+ name+'(2i)' => array[1],
+ name+'(3i)' => array[2]
+ }
+end