-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix call context when a preference default is a proc
Before v3.1, the proc given as the default value in a preference had its context bound to the initialized instance. That allowed, for example, referencing other preferences. From v3.1., the context is bound to the class. We are coming back to the behavior by calling the proc with `instance_exec` The test changed because initializing `preferences` with `default_preferences` cause an infinite loop. This is not a regression as it's the expected behavior on anterior versions but added some information on the comments. Change Preference Context: - `class A` is declared once in a `before(:all)` so the class WILL NOT be destroyed/recreate for each test - `@a = A.new` is in a `before(:each)` therefore the variable is initialized before the test start - The 4 examples from l.285 define the same preference `:secret` but the last one is the only using a default If the test run first: - `@a` is instantiated without `preference :secret` - `@a.preferences` looks like `{:color=>"green"}` - We define the `preference :secret` with a default - Calling `@a.get_preference(:secret)` will work because it will look for the default If the test doesn't run first: - `@a` is instantiated with a `preference :secret` without `:default` - `@a.preferences` looks like `{:color=>"green", :secret=>"rJ0s--jPH2d2iyyB9KseLU--HbYfXFtRB36+yj9L3fSDFA=="} ` (`:secret` value is `nil` but encrypted) - We override `preference :secret` with a default - `@a.get_preference(:secret)` returns `nil` as it's initialized and does not look for the default Setting `@a = A.new` after the override works because it'll be initialized with the new default To fix it we declared the class as anonymous and create them only when needed.
- v4.4.2
- v4.4.1
- v4.4.0
- v4.3.5
- v4.3.4
- v4.3.3
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.4.6
- v3.4.5
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- untagged-e2721ee559eefb5a7051
- untagged-c1cd44d417f3b08cfee7
- solidus_admin/v0.3.2
- solidus_admin/v0.3.1
- solidus_admin/v0.3.0
- solidus_admin/v0.2.0
- solidus_admin/v0.1.0
- solidus_admin/v0.0.2
- solidus_admin/v0.0.1
Showing
3 changed files
with
121 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters