hydra_attribute 0.4.2 → 0.5.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.travis.yml +6 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/Rakefile +2 -7
- data/gemfiles/activerecord-3.2.gemfile +5 -0
- data/hydra_attribute.gemspec +6 -7
- data/lib/hydra_attribute.rb +17 -18
- data/lib/hydra_attribute/active_record.rb +34 -13
- data/lib/hydra_attribute/active_record/association_preloader.rb +47 -28
- data/lib/hydra_attribute/active_record/attribute_methods.rb +29 -140
- data/lib/hydra_attribute/active_record/mass_assignment_security.rb +39 -0
- data/lib/hydra_attribute/active_record/migration.rb +4 -4
- data/lib/hydra_attribute/active_record/relation.rb +6 -7
- data/lib/hydra_attribute/active_record/relation/query_methods.rb +28 -18
- data/lib/hydra_attribute/hydra_attribute.rb +12 -49
- data/lib/hydra_attribute/hydra_attribute_set.rb +67 -0
- data/lib/hydra_attribute/hydra_entity.rb +110 -0
- data/lib/hydra_attribute/hydra_entity_attribute_association.rb +155 -0
- data/lib/hydra_attribute/hydra_set.rb +24 -26
- data/lib/hydra_attribute/hydra_value.rb +210 -0
- data/lib/hydra_attribute/identity_map.rb +18 -0
- data/lib/hydra_attribute/middleware/identity_map.rb +15 -0
- data/lib/hydra_attribute/migrator.rb +24 -21
- data/lib/hydra_attribute/model.rb +47 -0
- data/lib/hydra_attribute/model/cacheable.rb +207 -0
- data/lib/hydra_attribute/model/dirty.rb +39 -0
- data/lib/hydra_attribute/model/has_many_through.rb +168 -0
- data/lib/hydra_attribute/model/identity_map.rb +59 -0
- data/lib/hydra_attribute/model/mediator.rb +89 -0
- data/lib/hydra_attribute/model/notifiable.rb +23 -0
- data/lib/hydra_attribute/model/persistence.rb +424 -0
- data/lib/hydra_attribute/model/validations.rb +40 -0
- data/lib/hydra_attribute/version.rb +1 -1
- data/spec/environments/mysql.rb +23 -0
- data/spec/environments/postgresql.rb +23 -0
- data/spec/environments/sqlite.rb +12 -0
- data/spec/fixtures/category.rb +8 -0
- data/spec/fixtures/product.rb +8 -0
- data/spec/fixtures/product_black_list.rb +13 -0
- data/spec/fixtures/product_white_list.rb +13 -0
- data/spec/hydra_attribute/active_record/attribute_methods_spec.rb +23 -28
- data/spec/hydra_attribute/active_record/mass_assignment_security_spec.rb +41 -0
- data/spec/hydra_attribute/active_record_spec.rb +577 -0
- data/spec/hydra_attribute/hydra_attribute_set_spec.rb +651 -0
- data/spec/hydra_attribute/hydra_attribute_spec.rb +208 -10
- data/spec/hydra_attribute/hydra_entity_attribute_association_spec.rb +216 -0
- data/spec/hydra_attribute/hydra_entity_spec.rb +71 -0
- data/spec/hydra_attribute/hydra_set_spec.rb +51 -10
- data/spec/hydra_attribute/hydra_value_spec.rb +286 -0
- data/spec/hydra_attribute/identity_map_spec.rb +47 -0
- data/spec/hydra_attribute/migrator_spec.rb +411 -0
- data/spec/hydra_attribute/model/cacheable_spec.rb +106 -0
- data/spec/hydra_attribute/model/has_many_through_spec.rb +132 -0
- data/spec/hydra_attribute/model/identity_map_spec.rb +39 -0
- data/spec/hydra_attribute/model/mediator_spec.rb +62 -0
- data/spec/hydra_attribute/model/persistence_spec.rb +550 -0
- data/spec/hydra_attribute/model_spec.rb +39 -0
- data/spec/hydra_attribute_spec.rb +36 -0
- data/spec/spec_helper.rb +10 -42
- metadata +76 -100
- data/Appraisals +0 -7
- data/cucumber.yml +0 -1
- data/features/entity/create.feature +0 -145
- data/features/entity/destroy.feature +0 -111
- data/features/entity/new.feature +0 -121
- data/features/entity/update.feature +0 -147
- data/features/hydra_attribute/create.feature +0 -30
- data/features/hydra_attribute/destroy.feature +0 -26
- data/features/hydra_attribute/update.feature +0 -36
- data/features/hydra_set/destroy.feature +0 -31
- data/features/migrations/create_and_drop.feature +0 -165
- data/features/migrations/migrate_and_rollback.feature +0 -211
- data/features/relation/query_methods/group.feature +0 -42
- data/features/relation/query_methods/order.feature +0 -67
- data/features/relation/query_methods/reorder.feature +0 -29
- data/features/relation/query_methods/reverse_order.feature +0 -29
- data/features/relation/query_methods/select.feature +0 -50
- data/features/relation/query_methods/where.feature +0 -115
- data/features/step_definitions/connections.rb +0 -65
- data/features/step_definitions/model_steps.rb +0 -136
- data/features/step_definitions/query_methods.rb +0 -48
- data/features/step_definitions/record_steps.rb +0 -93
- data/features/support/env.rb +0 -38
- data/features/support/world.rb +0 -61
- data/lib/hydra_attribute/active_record/association.rb +0 -113
- data/lib/hydra_attribute/active_record/reflection.rb +0 -16
- data/lib/hydra_attribute/association_builder.rb +0 -69
- data/lib/hydra_attribute/builder.rb +0 -37
- data/lib/hydra_attribute/entity_callbacks.rb +0 -26
- data/lib/hydra_attribute/hydra_attribute_methods.rb +0 -226
- data/lib/hydra_attribute/hydra_methods.rb +0 -528
- data/lib/hydra_attribute/hydra_set_methods.rb +0 -95
- data/lib/hydra_attribute/hydra_value_methods.rb +0 -21
- data/lib/hydra_attribute/memoizable.rb +0 -37
- data/spec/hydra_attribute/active_record/relation/query_methods_spec.rb +0 -31
- data/spec/hydra_attribute/hydra_attribute_methods_spec.rb +0 -458
- data/spec/hydra_attribute/hydra_methods_spec.rb +0 -456
- data/spec/hydra_attribute/hydra_set_methods_spec.rb +0 -203
- data/spec/hydra_attribute/memoizable_spec.rb +0 -95
@@ -1,111 +0,0 @@
|
|
1
|
-
Feature: destroy model
|
2
|
-
When destroy model
|
3
|
-
Then all associated values should be deleted too
|
4
|
-
|
5
|
-
Background: create hydra attributes
|
6
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
7
|
-
| name | backend_type | default_value | white_list |
|
8
|
-
| code | string | | [bool:t] |
|
9
|
-
| info | text | [str:] | [bool:t] |
|
10
|
-
| total | integer | 0 | [bool:t] |
|
11
|
-
| price | float | 0 | [bool:t] |
|
12
|
-
| active | boolean | 0 | [bool:t] |
|
13
|
-
| started | datetime | 2012-01-01 | [bool:t] |
|
14
|
-
|
15
|
-
Scenario: destroy model
|
16
|
-
Given create "Product" model with attributes as "hashes":
|
17
|
-
| code | info | total | price | active | started |
|
18
|
-
| 1 | a | 1 | 1.10 | 1 | 2012-01-01 |
|
19
|
-
| 2 | b | 2 | 1.20 | 1 | 2012-01-02 |
|
20
|
-
| 3 | c | 3 | 1.30 | 0 | 2012-01-03 |
|
21
|
-
|
22
|
-
Then table "hydra_string_products" should have 3 records:
|
23
|
-
| entity_id | hydra_attribute_id | value |
|
24
|
-
| 1 | [eval:Product.hydra_attribute('code').id] | 1 |
|
25
|
-
| 2 | [eval:Product.hydra_attribute('code').id] | 2 |
|
26
|
-
| 3 | [eval:Product.hydra_attribute('code').id] | 3 |
|
27
|
-
And table "hydra_text_products" should have 3 records:
|
28
|
-
| entity_id | hydra_attribute_id | value |
|
29
|
-
| 1 | [eval:Product.hydra_attribute('info').id] | a |
|
30
|
-
| 2 | [eval:Product.hydra_attribute('info').id] | b |
|
31
|
-
| 3 | [eval:Product.hydra_attribute('info').id] | c |
|
32
|
-
And table "hydra_integer_products" should have 3 records:
|
33
|
-
| entity_id | hydra_attribute_id | value |
|
34
|
-
| 1 | [eval:Product.hydra_attribute('total').id] | 1 |
|
35
|
-
| 2 | [eval:Product.hydra_attribute('total').id] | 2 |
|
36
|
-
| 3 | [eval:Product.hydra_attribute('total').id] | 3 |
|
37
|
-
And table "hydra_float_products" should have 3 records:
|
38
|
-
| entity_id | hydra_attribute_id | value |
|
39
|
-
| 1 | [eval:Product.hydra_attribute('price').id] | 1.10 |
|
40
|
-
| 2 | [eval:Product.hydra_attribute('price').id] | 1.20 |
|
41
|
-
| 3 | [eval:Product.hydra_attribute('price').id] | 1.30 |
|
42
|
-
And table "hydra_boolean_products" should have 3 records:
|
43
|
-
| entity_id | hydra_attribute_id | value |
|
44
|
-
| 1 | [eval:Product.hydra_attribute('active').id] | [bool:t] |
|
45
|
-
| 2 | [eval:Product.hydra_attribute('active').id] | [bool:t] |
|
46
|
-
| 3 | [eval:Product.hydra_attribute('active').id] | [bool:f] |
|
47
|
-
And table "hydra_datetime_products" should have 3 records:
|
48
|
-
| entity_id | hydra_attribute_id | value |
|
49
|
-
| 1 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-01] |
|
50
|
-
| 2 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-02] |
|
51
|
-
| 3 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-03] |
|
52
|
-
|
53
|
-
Given select first "Product" record
|
54
|
-
And destroy record
|
55
|
-
|
56
|
-
Then table "hydra_string_products" should have 2 records:
|
57
|
-
| entity_id | hydra_attribute_id | value |
|
58
|
-
| 2 | [eval:Product.hydra_attribute('code').id] | 2 |
|
59
|
-
| 3 | [eval:Product.hydra_attribute('code').id] | 3 |
|
60
|
-
And table "hydra_text_products" should have 2 records:
|
61
|
-
| entity_id | hydra_attribute_id | value |
|
62
|
-
| 2 | [eval:Product.hydra_attribute('info').id] | b |
|
63
|
-
| 3 | [eval:Product.hydra_attribute('info').id] | c |
|
64
|
-
And table "hydra_integer_products" should have 2 records:
|
65
|
-
| entity_id | hydra_attribute_id | value |
|
66
|
-
| 2 | [eval:Product.hydra_attribute('total').id] | 2 |
|
67
|
-
| 3 | [eval:Product.hydra_attribute('total').id] | 3 |
|
68
|
-
And table "hydra_float_products" should have 2 records:
|
69
|
-
| entity_id | hydra_attribute_id | value |
|
70
|
-
| 2 | [eval:Product.hydra_attribute('price').id] | 1.20 |
|
71
|
-
| 3 | [eval:Product.hydra_attribute('price').id] | 1.30 |
|
72
|
-
And table "hydra_boolean_products" should have 2 records:
|
73
|
-
| entity_id | hydra_attribute_id | value |
|
74
|
-
| 2 | [eval:Product.hydra_attribute('active').id] | [bool:t] |
|
75
|
-
| 3 | [eval:Product.hydra_attribute('active').id] | [bool:f] |
|
76
|
-
And table "hydra_datetime_products" should have 2 records:
|
77
|
-
| entity_id | hydra_attribute_id | value |
|
78
|
-
| 2 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-02] |
|
79
|
-
| 3 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-03] |
|
80
|
-
|
81
|
-
Given select first "Product" record
|
82
|
-
And destroy record
|
83
|
-
|
84
|
-
Then table "hydra_string_products" should have 1 record:
|
85
|
-
| entity_id | hydra_attribute_id | value |
|
86
|
-
| 3 | [eval:Product.hydra_attribute('code').id] | 3 |
|
87
|
-
And table "hydra_text_products" should have 1 record:
|
88
|
-
| entity_id | hydra_attribute_id | value |
|
89
|
-
| 3 | [eval:Product.hydra_attribute('info').id] | c |
|
90
|
-
And table "hydra_integer_products" should have 1 record:
|
91
|
-
| entity_id | hydra_attribute_id | value |
|
92
|
-
| 3 | [eval:Product.hydra_attribute('total').id] | 3 |
|
93
|
-
And table "hydra_float_products" should have 1 record:
|
94
|
-
| entity_id | hydra_attribute_id | value |
|
95
|
-
| 3 | [eval:Product.hydra_attribute('price').id] | 1.30 |
|
96
|
-
And table "hydra_boolean_products" should have 1 record:
|
97
|
-
| entity_id | hydra_attribute_id | value |
|
98
|
-
| 3 | [eval:Product.hydra_attribute('active').id] | [bool:f] |
|
99
|
-
And table "hydra_datetime_products" should have 1 record:
|
100
|
-
| entity_id | hydra_attribute_id | value |
|
101
|
-
| 3 | [eval:Product.hydra_attribute('started').id] | [date:2012-01-03] |
|
102
|
-
|
103
|
-
Given select first "Product" record
|
104
|
-
And destroy record
|
105
|
-
|
106
|
-
Then table "hydra_string_products" should have 0 records
|
107
|
-
And table "hydra_text_products" should have 0 records
|
108
|
-
And table "hydra_integer_products" should have 0 records
|
109
|
-
And table "hydra_float_products" should have 0 records
|
110
|
-
And table "hydra_boolean_products" should have 0 records
|
111
|
-
And table "hydra_datetime_products" should have 0 records
|
data/features/entity/new.feature
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
Feature: new entity
|
2
|
-
Given new entity should respond to hydra attributes which are saved in hydra_attributes table
|
3
|
-
|
4
|
-
When hydra attribute was created with white_list flag
|
5
|
-
Then it should be allowed through mass-assignment for new entity
|
6
|
-
|
7
|
-
When hydra_set_id was passed to the new entity
|
8
|
-
Then entity should respond only to hydra attributes which were added to this hydra set
|
9
|
-
And entity attribute list should include only attributes from hydra set
|
10
|
-
And HydraAttribute::MissingAttributeInHydraSetError error should be risen when we call attribute method and this attribute doesn't exist in hydra set
|
11
|
-
|
12
|
-
Scenario Outline: models should respond to hydra attributes
|
13
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
14
|
-
| name | backend_type | white_list |
|
15
|
-
| code | string | [bool:t] |
|
16
|
-
| price | float | [bool:f] |
|
17
|
-
Then model "<model>" <action> respond to "<attributes>"
|
18
|
-
|
19
|
-
Scenarios: hydra attributes
|
20
|
-
| model | action | attributes |
|
21
|
-
| Product | should | code |
|
22
|
-
| Product | should | code= |
|
23
|
-
| Product | should | code? |
|
24
|
-
| Product | should | code_before_type_cast |
|
25
|
-
| Product | should | code_changed? |
|
26
|
-
| Product | should | code_change |
|
27
|
-
| Product | should | code_will_change! |
|
28
|
-
| Product | should | code_was |
|
29
|
-
| Product | should | reset_code! |
|
30
|
-
| Product | should | price |
|
31
|
-
| Product | should | price= |
|
32
|
-
| Product | should | price? |
|
33
|
-
| Product | should | price_before_type_cast |
|
34
|
-
| Product | should | price_changed? |
|
35
|
-
| Product | should | price_change |
|
36
|
-
| Product | should | price_will_change! |
|
37
|
-
| Product | should | price_was |
|
38
|
-
| Product | should | reset_price! |
|
39
|
-
|
40
|
-
Scenario: model should have appropriate hydra attributes in white list
|
41
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
42
|
-
| name | backend_type | white_list |
|
43
|
-
| code | string | [bool:t] |
|
44
|
-
| price | float | [bool:f] |
|
45
|
-
# imitate initialization model class with already created hydra attributes
|
46
|
-
When redefine "Product" class to use hydra attributes
|
47
|
-
Then class "Product" should have "code" in white list
|
48
|
-
And class "Product" should not have "price" in white list
|
49
|
-
|
50
|
-
Scenario: set hydra_set_id to the new entity
|
51
|
-
Given create hydra sets for "Product" as "hashes":
|
52
|
-
| name |
|
53
|
-
| Default |
|
54
|
-
| General |
|
55
|
-
And create hydra attributes for "Product" with role "admin" as "hashes":
|
56
|
-
| name | backend_type | white_list |
|
57
|
-
| code | string | [bool:t] |
|
58
|
-
| title | string | [bool:t] |
|
59
|
-
| price | float | [bool:t] |
|
60
|
-
| total | integer | [bool:t] |
|
61
|
-
And add "Product" hydra attributes to hydra set:
|
62
|
-
| hydra attribute name | hydra set name |
|
63
|
-
| code | [array:Default] |
|
64
|
-
| title | [array:Default,General] |
|
65
|
-
| price | [array:General] |
|
66
|
-
|
67
|
-
When build "Product" model:
|
68
|
-
| hydra_set_id | [str:[eval:Product.hydra_sets.find_by_name('Default').id]] |
|
69
|
-
Then model should respond to "code title"
|
70
|
-
And model should not respond to "price total"
|
71
|
-
|
72
|
-
When build "Product" model:
|
73
|
-
| hydra_set_id | [str:[eval:Product.hydra_sets.find_by_name('General').id]] |
|
74
|
-
Then model should not respond to "code total"
|
75
|
-
And model should respond to "title price"
|
76
|
-
|
77
|
-
When build "Product" model
|
78
|
-
Then model should respond to "code title price total"
|
79
|
-
|
80
|
-
Scenario: attach and detach hydra set to the same entity
|
81
|
-
Given create hydra sets for "Product" as "hashes":
|
82
|
-
| name |
|
83
|
-
| Default |
|
84
|
-
| General |
|
85
|
-
And create hydra attributes for "Product" with role "admin" as "hashes":
|
86
|
-
| name | backend_type | white_list |
|
87
|
-
| title | string | [bool:t] |
|
88
|
-
| code | string | [bool:t] |
|
89
|
-
| total | integer | [bool:t] |
|
90
|
-
| price | float | [bool:t] |
|
91
|
-
And add "Product" hydra attributes to hydra set:
|
92
|
-
| hydra attribute name | hydra set name |
|
93
|
-
| title | [array:Default] |
|
94
|
-
| code | [array:Default,General] |
|
95
|
-
| total | [array:General] |
|
96
|
-
|
97
|
-
When build "Product" model
|
98
|
-
Then model should respond to "title code total price"
|
99
|
-
And model attributes should include "title code total price"
|
100
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should not be risen when methods "title code total price" are called
|
101
|
-
|
102
|
-
When set "hydra_set_id" to "[eval:Product.hydra_sets.find_by_name('Default').id]"
|
103
|
-
Then model should respond to "title code"
|
104
|
-
And model should not respond to "total price"
|
105
|
-
And model attributes should include "title code"
|
106
|
-
And model attributes should not include "total price"
|
107
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should be risen when methods "total price" are called
|
108
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should not be risen when methods "title code" are called
|
109
|
-
|
110
|
-
When set "hydra_set_id" to "[eval:Product.hydra_sets.find_by_name('General').id]"
|
111
|
-
Then model should respond to "code total"
|
112
|
-
And model should not respond to "title price"
|
113
|
-
And model attributes should include "code total"
|
114
|
-
And model attributes should not include "title price"
|
115
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should be risen when methods "title price" are called
|
116
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should not be risen when methods "code total" are called
|
117
|
-
|
118
|
-
When set "hydra_set_id" to "[nil:]"
|
119
|
-
Then model should respond to "title code total price"
|
120
|
-
And model attributes should include "title code total price"
|
121
|
-
And error "HydraAttribute::MissingAttributeInHydraSetError" should not be risen when methods "title code total price" are called
|
@@ -1,147 +0,0 @@
|
|
1
|
-
Feature: update hydra attributes
|
2
|
-
When update hydra attribute
|
3
|
-
Then updated_at for entity should be updated
|
4
|
-
|
5
|
-
When update hydra_set_id
|
6
|
-
Then entity should have hydra attributes from this hydra set
|
7
|
-
|
8
|
-
Background: create hydra attributes
|
9
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
10
|
-
| name | backend_type | default_value | white_list |
|
11
|
-
| code | string | ### | [bool:t] |
|
12
|
-
| title | string | | [bool:t] |
|
13
|
-
| info | text | | [bool:t] |
|
14
|
-
| total | integer | 1 | [bool:t] |
|
15
|
-
| price | float | | [bool:t] |
|
16
|
-
| launch | datetime | | [bool:t] |
|
17
|
-
And create "Product" model
|
18
|
-
|
19
|
-
Scenario Outline: update attributes
|
20
|
-
Given select last "Product" record
|
21
|
-
When assign attributes as "rows_hash":
|
22
|
-
| code | <set code> |
|
23
|
-
| title | <set title> |
|
24
|
-
| total | <set total> |
|
25
|
-
And save record
|
26
|
-
Then last created "Product" should have the following attributes:
|
27
|
-
| code | <code> |
|
28
|
-
| title | <title> |
|
29
|
-
| total | <total> |
|
30
|
-
|
31
|
-
Scenarios: attributes
|
32
|
-
| set code | set title | set total | code | title | total |
|
33
|
-
| a | b | [int:2] | a | b | [int:2] |
|
34
|
-
| [str:] | [str:] | [nil:] | [str:] | [str:] | [nil:] |
|
35
|
-
| | | 3 | ### | [nil:] | [int:3] |
|
36
|
-
|
37
|
-
Scenario: update the same model several times to test touch method
|
38
|
-
Given select first "Product" record
|
39
|
-
And save record
|
40
|
-
Then last created "Product" should have the following attributes:
|
41
|
-
| code | ### |
|
42
|
-
| title | [nil:] |
|
43
|
-
| total | [int:1] |
|
44
|
-
|
45
|
-
When assign attributes as "rows_hash":
|
46
|
-
| title | [str:] |
|
47
|
-
| total | [nil:] |
|
48
|
-
And save record
|
49
|
-
Then last created "Product" should have the following attributes:
|
50
|
-
| code | ### |
|
51
|
-
| title | [str:] |
|
52
|
-
| total | [nil:] |
|
53
|
-
|
54
|
-
When assign attributes as "rows_hash":
|
55
|
-
| code | a |
|
56
|
-
| total | 2 |
|
57
|
-
And save record
|
58
|
-
Then last created "Product" should have the following attributes:
|
59
|
-
| code | a |
|
60
|
-
| title | [str:] |
|
61
|
-
| total | [int:2] |
|
62
|
-
|
63
|
-
When assign attributes as "rows_hash":
|
64
|
-
| title | b |
|
65
|
-
And save record
|
66
|
-
Then last created "Product" should have the following attributes:
|
67
|
-
| code | a |
|
68
|
-
| title | b |
|
69
|
-
| total | [int:2] |
|
70
|
-
|
71
|
-
Scenario: touch entity when attribute is updated
|
72
|
-
Given select last "Product" record
|
73
|
-
And keep "updated_at" attribute
|
74
|
-
And save record
|
75
|
-
Then attribute "updated_at" should be the same
|
76
|
-
|
77
|
-
Given select last "Product" record
|
78
|
-
And keep "updated_at" attribute
|
79
|
-
When assign attributes as "rows_hash":
|
80
|
-
| code | ### |
|
81
|
-
| total | [int:1] |
|
82
|
-
And save record
|
83
|
-
Then attribute "updated_at" should be the same
|
84
|
-
|
85
|
-
Given select last "Product" record
|
86
|
-
And keep "updated_at" attribute
|
87
|
-
When assign attributes as "rows_hash":
|
88
|
-
| code | [nil:] |
|
89
|
-
And save record
|
90
|
-
Then attribute "updated_at" should not be the same
|
91
|
-
|
92
|
-
Given select last "Product" record
|
93
|
-
And keep "updated_at" attribute
|
94
|
-
When assign attributes as "rows_hash":
|
95
|
-
| code | [nil:] |
|
96
|
-
And save record
|
97
|
-
Then attribute "updated_at" should be the same
|
98
|
-
|
99
|
-
Given select last "Product" record
|
100
|
-
And keep "updated_at" attribute
|
101
|
-
When assign attributes as "rows_hash":
|
102
|
-
| total | [nil:] |
|
103
|
-
And save record
|
104
|
-
Then attribute "updated_at" should not be the same
|
105
|
-
|
106
|
-
Given select last "Product" record
|
107
|
-
And keep "updated_at" attribute
|
108
|
-
When assign attributes as "rows_hash":
|
109
|
-
| code | [str:] |
|
110
|
-
And save record
|
111
|
-
Then attribute "updated_at" should not be the same
|
112
|
-
|
113
|
-
Given select last "Product" record
|
114
|
-
And keep "updated_at" attribute
|
115
|
-
When assign attributes as "rows_hash":
|
116
|
-
| title | [str:] |
|
117
|
-
| total | [int:0] |
|
118
|
-
And save record
|
119
|
-
Then attribute "updated_at" should not be the same
|
120
|
-
|
121
|
-
Scenario: update hydra_set_id
|
122
|
-
Given create hydra sets for "Product" as "hashes":
|
123
|
-
| name |
|
124
|
-
| Default |
|
125
|
-
| General |
|
126
|
-
And add "Product" hydra attributes to hydra set:
|
127
|
-
| hydra attribute name | hydra set name |
|
128
|
-
| code | [array:Default] |
|
129
|
-
| title | [array:Default] |
|
130
|
-
| info | [array:Default,General] |
|
131
|
-
| total | [array:General] |
|
132
|
-
| price | [array:General] |
|
133
|
-
And create "Product" model
|
134
|
-
And find last "Product" model
|
135
|
-
|
136
|
-
When set "hydra_set_id" to "[eval:Product.hydra_sets.find_by_name('Default').id]"
|
137
|
-
And reload model
|
138
|
-
Then model attributes should include "code title info"
|
139
|
-
|
140
|
-
When set "hydra_set_id" to "[eval:Product.hydra_sets.find_by_name('General').id]"
|
141
|
-
And reload model
|
142
|
-
Then model attributes should include "info total price"
|
143
|
-
|
144
|
-
When set "hydra_set_id" to "[nil:]"
|
145
|
-
And reload model
|
146
|
-
Then model attributes should include "code title info total price launch"
|
147
|
-
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Feature: create hydra attributes
|
2
|
-
When new hydra attribute is created
|
3
|
-
Then entity should respond to it
|
4
|
-
|
5
|
-
Background: create hydra attributes
|
6
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
7
|
-
| name | backend_type | white_list |
|
8
|
-
| price | float | [bool:t] |
|
9
|
-
|
10
|
-
Scenario: create hydra attribute
|
11
|
-
# Important: when respond_to? is called the hydra attributes are being loaded for entity class
|
12
|
-
Then model "Product" should respond to "price"
|
13
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
14
|
-
| name | backend_type |
|
15
|
-
| title | string |
|
16
|
-
Then model "Product" should respond to "title"
|
17
|
-
|
18
|
-
Scenario: create attribute but don't add it to white list
|
19
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
20
|
-
| name | backend_type | white_list |
|
21
|
-
| code | string | |
|
22
|
-
| total | integer | [bool:f] |
|
23
|
-
Then class "Product" should not have "code" in white list
|
24
|
-
And class "Product" should not have "total" in white list
|
25
|
-
|
26
|
-
Scenario: create attribute and add it to white list
|
27
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
28
|
-
| name | backend_type | white_list |
|
29
|
-
| code | string | [bool:t] |
|
30
|
-
Then class "Product" should have "code" in white list
|
@@ -1,26 +0,0 @@
|
|
1
|
-
Feature: destroy hydra attributes
|
2
|
-
When destroy hydra attribute
|
3
|
-
Then model should not respond to this attribute any more
|
4
|
-
And all values for this attribute should be removed
|
5
|
-
|
6
|
-
Background: create hydra attributes
|
7
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
8
|
-
| name | backend_type | white_list |
|
9
|
-
| price | float | [bool:t] |
|
10
|
-
|
11
|
-
Scenario: entity should not respond to removed attribute
|
12
|
-
When destroy all "HydraAttribute::HydraAttribute" models with attributes as "rows_hash":
|
13
|
-
|name | price |
|
14
|
-
Then model "Product" should not respond to "price"
|
15
|
-
|
16
|
-
Scenario: remove all values from appropriate table
|
17
|
-
Given create "Product" model with attributes as "rows_hash":
|
18
|
-
| price | 10 |
|
19
|
-
When destroy all "HydraAttribute::HydraAttribute" models with attributes as "rows_hash":
|
20
|
-
|name | price |
|
21
|
-
Then total "HydraAttribute::HydraFloatProduct" records should be "0"
|
22
|
-
|
23
|
-
Scenario: remove attribute from white list
|
24
|
-
When destroy all "HydraAttribute::HydraAttribute" models with attributes as "rows_hash":
|
25
|
-
|name | price |
|
26
|
-
Then class "Product" should not have "price" in white list
|
@@ -1,36 +0,0 @@
|
|
1
|
-
Feature: update hydra attribute
|
2
|
-
When update hydra attribute data
|
3
|
-
Then model should be notified about this
|
4
|
-
|
5
|
-
Background: create hydra attributes
|
6
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
7
|
-
| name | backend_type | default_value | white_list |
|
8
|
-
| code | integer | 1 | [bool:t] |
|
9
|
-
|
10
|
-
Scenario: update default value
|
11
|
-
Given create "Product" model
|
12
|
-
And load and update attributes for "HydraAttribute::HydraAttribute" models with attributes as "rows_hash":
|
13
|
-
| default_value | 2 |
|
14
|
-
And create "Product" model
|
15
|
-
Then first created "Product" should have the following attributes:
|
16
|
-
| code | [int:1] |
|
17
|
-
And last created "Product" should have the following attributes:
|
18
|
-
| code | [int:2] |
|
19
|
-
|
20
|
-
Scenario: update white list attribute to true
|
21
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
22
|
-
| name | backend_type | white_list |
|
23
|
-
| title | string | [bool:f] |
|
24
|
-
And select last "HydraAttribute::HydraAttribute" record
|
25
|
-
When update attributes as "admin":
|
26
|
-
| white_list | [bool:t] |
|
27
|
-
Then class "Product" should have "title" in white list
|
28
|
-
|
29
|
-
Scenario: update white list attribute to false
|
30
|
-
Given create hydra attributes for "Product" with role "admin" as "hashes":
|
31
|
-
| name | backend_type | white_list |
|
32
|
-
| info | string | [bool:t] |
|
33
|
-
And select last "HydraAttribute::HydraAttribute" record
|
34
|
-
When update attributes as "admin":
|
35
|
-
| white_list | [bool:f] |
|
36
|
-
Then class "Product" should not have "info" in white list
|