|
1 | 1 | require File.expand_path('../../../test_helper', __FILE__) |
2 | 2 |
|
3 | | -# Tests for backward compatibility with 0.9.x API |
4 | | -class BackwardCompatibilityTest < ActiveSupport::TestCase |
5 | | - # Test find_by_key with old signature: find_by_key(id, context) |
6 | | - # New signature: find_by_key(key, options = {}) |
7 | | - def test_find_by_key_with_old_signature |
8 | | - # 0.9.x style: find_by_key(id, context) |
9 | | - # In 0.9.x, context was passed directly as second argument |
10 | | - # In 0.10+, context should be passed as options[:context] |
11 | | - # For backward compatibility, if second arg is a Hash without :context key, |
12 | | - # it should still work (context will be nil in resource) |
13 | | - context = { current_user: 'test_user' } |
14 | | - resource = PostResource.find_by_key(1, context) |
15 | | - |
16 | | - assert_not_nil resource |
17 | | - assert_equal 1, resource.id |
18 | | - end |
19 | | - |
20 | | - def test_find_by_key_with_new_signature |
21 | | - # 0.10+ style: find_by_key(key, options = {}) |
22 | | - context = { current_user: 'test_user' } |
23 | | - resource = PostResource.find_by_key(1, context: context) |
24 | | - |
25 | | - assert_not_nil resource |
26 | | - assert_equal 1, resource.id |
27 | | - end |
28 | | - |
29 | | - def test_find_by_key_without_context |
30 | | - # find_by_key without any context |
31 | | - resource = PostResource.find_by_key(1) |
32 | | - |
33 | | - assert_not_nil resource |
34 | | - assert_equal 1, resource.id |
35 | | - end |
36 | | -end |
37 | | - |
38 | 3 | # Tests for ResourceSetOperationResult backward compatibility |
39 | 4 | class ResourceSetOperationResultBackwardCompatibilityTest < ActiveSupport::TestCase |
40 | 5 | def setup |
|
0 commit comments