diff options
author | Yukio Mizuta <untidyhair@gmail.com> | 2018-05-25 17:43:28 -0700 |
---|---|---|
committer | Yukio Mizuta <untidyhair@gmail.com> | 2018-06-12 07:10:09 -0700 |
commit | e0bc5b4da1882a722975b920ec912d6229a8f92e (patch) | |
tree | 7233677e729df8ddf3e498b2a7899e76a962fe2e /activerecord/test/cases | |
parent | 2f76256127d35cfbfaadf162e4d8be2d0af4e453 (diff) | |
download | rails-e0bc5b4da1882a722975b920ec912d6229a8f92e.tar.gz rails-e0bc5b4da1882a722975b920ec912d6229a8f92e.tar.bz2 rails-e0bc5b4da1882a722975b920ec912d6229a8f92e.zip |
Update prefix and allow suffix options for store accessors
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/store_test.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb index 3bd480cfbd..4457cfbd37 100644 --- a/activerecord/test/cases/store_test.rb +++ b/activerecord/test/cases/store_test.rb @@ -214,4 +214,38 @@ class StoreTest < ActiveRecord::TestCase second_dump = YAML.dump(loaded) assert_equal @john, YAML.load(second_dump) end + + test "read store attributes through accessors with default suffix" do + @john.configs[:two_factor_auth] = true + assert_equal true, @john.two_factor_auth_configs + end + + test "write store attributes through accessors with default suffix" do + @john.two_factor_auth_configs = false + assert_equal false, @john.configs[:two_factor_auth] + end + + test "read store attributes through accessors with custom suffix" do + @john.configs[:login_retry] = 3 + assert_equal 3, @john.login_retry_config + end + + test "write store attributes through accessors with custom suffix" do + @john.login_retry_config = 5 + assert_equal 5, @john.configs[:login_retry] + end + + test "read accessor without pre/suffix in the same store as other pre/suffixed accessors still works" do + @john.configs[:secret_question] = "What is your high school?" + assert_equal "What is your high school?", @john.secret_question + end + + test "write accessor without pre/suffix in the same store as other pre/suffixed accessors still works" do + @john.secret_question = "What was the Rails version when you first worked on it?" + assert_equal "What was the Rails version when you first worked on it?", @john.configs[:secret_question] + end + + test "prefix/suffix do not affect stored attributes" do + assert_equal [:secret_question, :two_factor_auth, :login_retry], Admin::User.stored_attributes[:configs] + end end |