提交 cf91b96b 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #30073 from yalab/fixture_binary_helper

Add `binary` helper method to fixtures.
* Add `binary` fixture helper method.
*Atsushi Yoshida*
* When using `Relation#or`, extract the common conditions and put them before the OR condition.
*Maxime Handfield Lapointe*
......
......@@ -1065,6 +1065,10 @@ def self.create_subclass
def get_binding
binding()
end
def binary(path)
%(!!binary "#{Base64.strict_encode64(File.read(path))}")
end
end
end
end
......@@ -132,7 +132,7 @@ def test_no_args_returns_all
def test_no_args_record_returns_all_without_array
all_binaries = binaries
assert_kind_of(Array, all_binaries)
assert_equal 1, binaries.length
assert_equal 2, binaries.length
end
def test_nil_raises
......@@ -313,6 +313,7 @@ def test_binary_in_fixtures
data.force_encoding("ASCII-8BIT")
data.freeze
assert_equal data, @flowers.data
assert_equal data, @binary_helper.data
end
def test_serialized_fixtures
......
......@@ -131,3 +131,7 @@ flowers:
SgCUASgCUASgCUASgAC74PbXOTvE5/En7jpSoLE8/wBn7uPJjKyj46T9D/NT
pKsXyQzxNpdNP0/akB5484WkMKh4RfXG4UafNmH7b0UxWMrb7Nxg6rl9Z/Im
w+vWq0iscQwxQroiUIvkKsRZQBKAJQBKAJQB/9k=
binary_helper:
id: 2
data: <%= binary(ASSETS_ROOT + "/flowers.jpg") %>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册