Skip to content

Commit fe0fb9f

Browse files
committed
Exercise option name labels test
Originally this did test that if single keyword arguments is recognized as label values not options since label values are required arguments. It works fine when two label values and keyword arguments are passed, but if users are unsure whether we can use a label with the same name as an option at the same time, I'll add an extra test.
1 parent 2fe1ca0 commit fe0fb9f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

activerecord/test/cases/enum_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,13 +907,19 @@ def self.name; "Book"; end
907907
klass = Class.new(ActiveRecord::Base) do
908908
self.table_name = "books"
909909
enum :status, default: 0, scopes: 1, prefix: 2, suffix: 3
910+
enum :last_read, { default: 0, scopes: 1, prefix: 2, suffix: 3 }, prefix: "p", suffix: true
910911
end
911912

912913
book = klass.new
913914
assert_predicate book, :default?
914915
assert_not_predicate book, :scopes?
915916
assert_not_predicate book, :prefix?
916917
assert_not_predicate book, :suffix?
918+
919+
assert_predicate book, :p_default_last_read?
920+
assert_not_predicate book, :p_scopes_last_read?
921+
assert_not_predicate book, :p_prefix_last_read?
922+
assert_not_predicate book, :p_suffix_last_read?
917923
end
918924

919925
test "scopes are named like methods" do

0 commit comments

Comments
 (0)