Skip to content

Commit 5d0afe7

Browse files
no6vjosevalim
authored andcommitted
prevent to run fixture accessor (e.g. test_foos for TestFoo model) as a test case [rails#2992 state:resolved]
Signed-off-by: Wijnand Wiersma <[email protected]> Signed-off-by: José Valim <[email protected]>
1 parent 9ef232a commit 5d0afe7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

activerecord/lib/active_record/fixtures.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ def setup_fixture_accessors(table_names = nil)
891891

892892
instances.size == 1 ? instances.first : instances
893893
end
894+
private table_name
894895
end
895896
end
896897

activerecord/test/cases/fixtures_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ def test_without_complete_instantiation
256256
def test_fixtures_from_root_yml_without_instantiation
257257
assert !defined?(@unknown), "@unknown is not defined"
258258
end
259+
260+
def test_visibility_of_accessor_method
261+
assert_equal false, respond_to?(:topics, false), "should be private method"
262+
assert_equal true, respond_to?(:topics, true), "confirm to respond surely"
263+
end
259264

260265
def test_accessor_methods
261266
assert_equal "The First Topic", topics(:first).title

0 commit comments

Comments
 (0)