提交 a23572cc 编写于 作者: R Rafael Mendonça França

Check by @v before converting the entry on expired?

We should convert when @v is defined not @value.

The test was calling value first that already converts the entry so we
are not catching this bug.
上级 e63670a4
......@@ -593,7 +593,7 @@ def value
# Check if the entry is expired. The +expires_in+ parameter can override
# the value set when the entry was created.
def expired?
convert_version_4beta1_entry! if defined?(@value)
convert_version_4beta1_entry! if defined?(@v)
@expires_in && @created_at + @expires_in <= Time.now.to_f
end
......
......@@ -1001,7 +1001,7 @@ def test_restoring_expired_version_4beta1_entries
version_4beta1_entry.instance_variable_set(:@v, "hello")
version_4beta1_entry.instance_variable_set(:@x, Time.now.to_i - 1)
entry = Marshal.load(Marshal.dump(version_4beta1_entry))
assert_equal "hello", entry.value
assert_equal true, entry.expired?
assert_equal "hello", entry.value
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册