if sell_price.to_s.length > 10
self.errors.add :sell_price, "数値が大き過ぎます。"
end
- if sell_price.blank? || sell_price == 0
+ if sell_price.blank? || sell_price.to_i == 0
self.errors.add :sell_price, "を入力して下さい"
+ elsif sell_price.to_i < 0
+ self.errors.add :sell_price, "は0以上の数字を入力して下さい"
end
end
+# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ProductStyle do
@product_style.should be_valid
@product_style.sell_price = 10000000000
@product_style.should_not be_valid
+ #マイナス
+ @product_style.sell_price = -1
+ @product_style.should_not be_valid
end
it "規格" do
#規格1が無い状態で規格 2を登録出来ません